1 | ///////////////////////////////////////////////////////////////-*-C-*- |
---|
2 | // |
---|
3 | // Copyright (c) 2006 Xilinx, Inc. All rights reserved. |
---|
4 | // |
---|
5 | // Xilinx, Inc. XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION |
---|
6 | // "AS IS" AS A COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR |
---|
7 | // INFORMATION AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, |
---|
8 | // APPLICATION OR STANDARD, XILINX IS MAKING NO REPRESENTATION THAT |
---|
9 | // THIS IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND |
---|
10 | // YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR |
---|
11 | // YOUR IMPLEMENTATION. XILINX EXPRESSLY DISCLAIMS ANY WARRANTY |
---|
12 | // WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE IMPLEMENTATION, |
---|
13 | // INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR REPRESENTATIONS THAT |
---|
14 | // THIS IMPLEMENTATION IS FREE FROM CLAIMS OF INFRINGEMENT, IMPLIED |
---|
15 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
---|
16 | // |
---|
17 | ////////////////////////////////////////////////////////////////////// |
---|
18 | |
---|
19 | #ifndef __XCOPE_H__ |
---|
20 | #define __XCOPE_H__ |
---|
21 | |
---|
22 | #include "xbasic_types.h" |
---|
23 | |
---|
24 | // Basic data types |
---|
25 | typedef char uint8_t; |
---|
26 | typedef Xuint16 uint16_t; |
---|
27 | typedef Xuint32 uint32_t; |
---|
28 | |
---|
29 | // Raw address and processing data types |
---|
30 | typedef unsigned xc_raw_addr_t; |
---|
31 | typedef unsigned xc_word_t; |
---|
32 | |
---|
33 | // Read-only address data type |
---|
34 | typedef xc_raw_addr_t xc_r_addr_t; |
---|
35 | // Write-only address data type |
---|
36 | typedef xc_raw_addr_t xc_w_addr_t; |
---|
37 | // Read-Write address data type |
---|
38 | typedef xc_raw_addr_t xc_addr_t; |
---|
39 | |
---|
40 | typedef uint32_t xc_status_t; |
---|
41 | // error codes between +1023 and -1024 are reserved for XCOPE use |
---|
42 | #define XC_SUCCESS 0 // non-negative values denote ok |
---|
43 | #define XC_FAILURE -1 // negative values denote error |
---|
44 | |
---|
45 | typedef struct { |
---|
46 | int n_bits; |
---|
47 | xc_word_t raw_bits[0]; |
---|
48 | } xc_bits_t; |
---|
49 | |
---|
50 | typedef struct { |
---|
51 | int bin_pt; |
---|
52 | uint32_t attr; |
---|
53 | xc_bits_t bits; |
---|
54 | } xc_fix_t; |
---|
55 | |
---|
56 | typedef uint16_t xc_id_t; |
---|
57 | |
---|
58 | typedef struct { |
---|
59 | xc_r_addr_t dout; |
---|
60 | uint32_t n_bits; |
---|
61 | uint32_t bin_pt; |
---|
62 | // uint32_t attr; |
---|
63 | } xc_from_reg_t; |
---|
64 | |
---|
65 | typedef struct { |
---|
66 | xc_addr_t din; |
---|
67 | uint32_t n_bits; |
---|
68 | uint32_t bin_pt; |
---|
69 | // uint32_t attr; |
---|
70 | } xc_to_reg_t; |
---|
71 | |
---|
72 | typedef struct { |
---|
73 | xc_r_addr_t dout; |
---|
74 | xc_r_addr_t percentfull; |
---|
75 | xc_r_addr_t empty; |
---|
76 | uint32_t n_bits; |
---|
77 | uint32_t bin_pt; |
---|
78 | // uint32_t attr; |
---|
79 | } xc_from_fifo_t; |
---|
80 | |
---|
81 | typedef struct { |
---|
82 | xc_w_addr_t din; |
---|
83 | xc_r_addr_t percentfull; |
---|
84 | xc_r_addr_t full; |
---|
85 | uint32_t n_bits; |
---|
86 | uint32_t bin_pt; |
---|
87 | // uint32_t attr; |
---|
88 | } xc_to_fifo_t; |
---|
89 | |
---|
90 | typedef struct { |
---|
91 | xc_addr_t addr; |
---|
92 | // xc_r_addr_t *grant; |
---|
93 | // xc_w_addr_t *req; |
---|
94 | uint32_t n_bits; |
---|
95 | uint32_t bin_pt; |
---|
96 | // uint32_t attr; |
---|
97 | } xc_shram_t; |
---|
98 | |
---|
99 | typedef struct { |
---|
100 | xc_from_reg_t *from_regs; |
---|
101 | xc_to_reg_t *to_regs; |
---|
102 | xc_from_fifo_t *from_fifos; |
---|
103 | xc_to_fifo_t *to_fifos; |
---|
104 | xc_shram_t *shrams; |
---|
105 | } xc_memmap_t; |
---|
106 | |
---|
107 | struct struct_xc_iface_t { |
---|
108 | uint32_t version; |
---|
109 | // function pointers to low-level drivers |
---|
110 | xc_status_t (*xc_create)(struct struct_xc_iface_t **, void *); |
---|
111 | xc_status_t (*xc_release)(struct struct_xc_iface_t **); |
---|
112 | xc_status_t (*xc_open)(struct struct_xc_iface_t *); |
---|
113 | xc_status_t (*xc_close)(struct struct_xc_iface_t *); |
---|
114 | xc_status_t (*xc_read)(struct struct_xc_iface_t *, xc_r_addr_t, uint32_t *); |
---|
115 | xc_status_t (*xc_write)(struct struct_xc_iface_t *, xc_w_addr_t, const uint32_t); |
---|
116 | xc_status_t (*xc_get_shmem)(struct struct_xc_iface_t *, const char *, void **); |
---|
117 | xc_from_reg_t *from_regs; |
---|
118 | xc_to_reg_t *to_regs; |
---|
119 | xc_from_fifo_t *from_fifos; |
---|
120 | xc_to_fifo_t *to_fifos; |
---|
121 | xc_shram_t *shrams; |
---|
122 | // optional device-specific data fields |
---|
123 | xc_word_t data[0]; |
---|
124 | }; |
---|
125 | |
---|
126 | typedef struct struct_xc_iface_t xc_iface_t; |
---|
127 | |
---|
128 | // XCOPE functions |
---|
129 | static inline xc_status_t xc_create(xc_iface_t** iface, void* config_table) { |
---|
130 | return ((xc_iface_t *) config_table)->xc_create(iface, config_table); |
---|
131 | } |
---|
132 | |
---|
133 | static inline xc_status_t xc_get_shmem(xc_iface_t* iface, const char* name, void** shmem) { |
---|
134 | return iface->xc_get_shmem(iface, name, shmem); |
---|
135 | } |
---|
136 | |
---|
137 | static inline xc_status_t xc_write(xc_iface_t* iface, xc_w_addr_t w_addr, const uint32_t data) { |
---|
138 | return iface->xc_write(iface, w_addr, data); |
---|
139 | } |
---|
140 | |
---|
141 | static inline xc_status_t xc_read(xc_iface_t* iface, xc_r_addr_t r_addr, uint32_t* data) { |
---|
142 | return iface->xc_read(iface, r_addr, data); |
---|
143 | } |
---|
144 | |
---|
145 | // XCOPE helper functions |
---|
146 | static inline xc_raw_addr_t xc_get_addr(xc_raw_addr_t addr, uint32_t offset) { |
---|
147 | return addr + sizeof(xc_raw_addr_t) * offset; |
---|
148 | } |
---|
149 | |
---|
150 | #endif |
---|