Moved old bin2xdevcfg to revbin
[reconos.git] / lib / arch / arch_microblaze_linux.c
blob4ef4a246bcb8301dbc6472221ac5971c2a76a6b8
1 /*
2 * ____ _____
3 * ________ _________ ____ / __ \/ ___/
4 * / ___/ _ \/ ___/ __ \/ __ \/ / / /\__ \
5 * / / / __/ /__/ /_/ / / / / /_/ /___/ /
6 * /_/ \___/\___/\____/_/ /_/\____//____/
8 * ======================================================================
10 * title: Architecture specific code - Microblaze, Linux
12 * project: ReconOS
13 * author: Christoph RĂ¼thing, University of Paderborn
14 * description: Functions needed for ReconOS which are architecure
15 * specific and are implemented here.
17 * ======================================================================
21 #ifdef RECONOS_ARCH_microblaze
22 #ifdef RECONOS_OS_linux
24 #include "arch.h"
26 #include "../../linux/driver/include/reconos.h"
28 #include <stdio.h>
29 #include <unistd.h>
30 #include <fcntl.h>
31 #include <sys/ioctl.h>
32 #include "pthread.h"
34 #define PROC_CONTROL_DEV "/dev/reconos-proc-control"
35 #define OSIF_DEV "/dev/reconos-osif-%d"
38 /* == OSIF related functions ============================================ */
40 int reconos_osif_open(int num) {
41 char dev[25];
42 int fd;
44 if (num < 0)
45 return -1;
47 snprintf(dev, 25, OSIF_DEV, num);
48 fd = open(dev, O_RDWR);
49 if (fd < 0)
50 panic("[reconos_core] error while opening osif %d\n", num);
52 return fd;
55 uint32_t reconos_osif_read(int fd) {
56 uint32_t data;
57 int ret;
59 ret = read(fd, &data, sizeof(data));
60 if (ret < 0)
61 panic("[reconos-core] error reading from osif\n");
63 return data;
66 void reconos_osif_write(int fd, uint32_t data) {
67 int ret;
69 ret = write(fd, &data, sizeof(data));
70 if (ret < 0)
71 panic("[reconos-core] error writing to osif\n");
74 void reconos_osif_close(int fd) {
75 close(fd);
79 /* == Proc control related functions ==================================== */
81 int reconos_proc_control_open() {
82 int fd;
84 fd = open(PROC_CONTROL_DEV, O_RDWR);
85 if (fd < 0)
86 panic("[reconos_core] error while opening proc control\n");
88 return fd;
91 int reconos_proc_control_get_num_hwts(int fd) {
92 int data;
94 ioctl(fd, RECONOS_PROC_CONTROL_GET_NUM_HWTS, &data);
96 return data;
99 int reconos_proc_control_get_tlb_hits(int fd) {
100 int data;
102 ioctl(fd, RECONOS_PROC_CONTROL_GET_TLB_HITS, &data);
104 return data;
107 int reconos_proc_control_get_tlb_misses(int fd) {
108 int data;
110 ioctl(fd, RECONOS_PROC_CONTROL_GET_TLB_MISSES, &data);
112 return data;
115 uint32_t reconos_proc_control_get_fault_addr(int fd) {
116 uint32_t data;
118 ioctl(fd, RECONOS_PROC_CONTROL_GET_FAULT_ADDR, &data);
120 return data;
123 void reconos_proc_control_clear_page_fault(int fd) {
124 ioctl(fd, RECONOS_PROC_CONTROL_CLEAR_PAGE_FAULT, NULL);
127 void reconos_proc_control_set_pgd(int fd) {
128 ioctl(fd, RECONOS_PROC_CONTROL_SET_PGD_ADDR, NULL);
131 void reconos_proc_control_sys_reset(int fd) {
132 ioctl(fd, RECONOS_PROC_CONTROL_SYS_RESET, NULL);
135 void reconos_proc_control_hwt_reset(int fd, int num, int reset) {
136 if (reset)
137 ioctl(fd, RECONOS_PROC_CONTROL_SET_HWT_RESET, &num);
138 else
139 ioctl(fd, RECONOS_PROC_CONTROL_CLEAR_HWT_RESET, &num);
142 void reconos_proc_control_cache_flush(int fd) {
143 ioctl(fd, RECONOS_PROC_CONTROL_CACHE_FLUSH, NULL);
146 void reconos_proc_control_close(int fd) {
147 close(fd);
151 /* == Reconfiguration related functions ================================= */
153 int load_partial_bitstream(uint32_t *bitstream, unsigned int bitstream_length) {
154 panic("NOT IMPLEMENTED YET\n");
156 return 0;
160 /* == Initialization function =========================================== */
162 void reconos_drv_init() {
163 // nothing to do here
166 #endif
167 #endif