1 | /////////////////////////////////////////////////////////////////////////////// |
---|
2 | // File : sys_handler.h |
---|
3 | // Date : 01/04/2012 |
---|
4 | // Author : alain greiner |
---|
5 | // Copyright (c) UPMC-LIP6 |
---|
6 | /////////////////////////////////////////////////////////////////////////////// |
---|
7 | // The sys_handler.c and sys_handler.h files are part of the GIET-VM kernel. |
---|
8 | // It define the syscall_vector[] (at the end of this file), as well as the |
---|
9 | // associated syscall handlers. |
---|
10 | /////////////////////////////////////////////////////////////////////////////// |
---|
11 | |
---|
12 | #ifndef _SYS_HANDLER_H |
---|
13 | #define _SYS_HANDLER_H |
---|
14 | |
---|
15 | #include "giet_config.h" |
---|
16 | #include "kernel_locks.h" |
---|
17 | #include "stdio.h" |
---|
18 | |
---|
19 | /////////////////////////////////////////////////////////////////////////////// |
---|
20 | // Syscall Vector Table (indexed by syscall index) |
---|
21 | /////////////////////////////////////////////////////////////////////////////// |
---|
22 | |
---|
23 | extern const void * _syscall_vector[64]; |
---|
24 | |
---|
25 | /////////////////////////////////////////////////////////////////////////////// |
---|
26 | // This structure is used by the nic_chbuf_t and fbf_chbuf_t structures. |
---|
27 | // It describes a single buffer descriptor. The useful information is |
---|
28 | // contained in one single 64 bits word (desc field): |
---|
29 | // - the 48 LSB bits contain the buffer physical address |
---|
30 | // - the MSB bit 63 indicates the buffer state (empty if 0) |
---|
31 | // This descriptor must be aligned on a cache line (64 bytes) to simplify |
---|
32 | // the software L2/L3 cache coherence when the IO bridge is used. |
---|
33 | /////////////////////////////////////////////////////////////////////////////// |
---|
34 | |
---|
35 | typedef struct buffer_descriptor_s |
---|
36 | { |
---|
37 | unsigned long long desc; |
---|
38 | unsigned int padding[14]; |
---|
39 | } buffer_descriptor_t; |
---|
40 | |
---|
41 | /////////////////////////////////////////////////////////////////////////////// |
---|
42 | // This structure is used by the CMA component to move a stream |
---|
43 | // of images from two user buffers to the frame buffer in kernel space. |
---|
44 | // It contains two chbuf arrays: |
---|
45 | // - The SRC chbuf contains two buffers (buf0 & buf1), in user space. |
---|
46 | // - The DST cbuf contains one single buffer (fbf), that is the frame buffer. |
---|
47 | // - The length field define the buffer size (bytes) |
---|
48 | // This structure must be 64 bytes aligned. |
---|
49 | /////////////////////////////////////////////////////////////////////////////// |
---|
50 | |
---|
51 | typedef struct fbf_chbuf_s |
---|
52 | { |
---|
53 | buffer_descriptor_t buf0; // first user buffer descriptor |
---|
54 | buffer_descriptor_t buf1; // second user buffer descriptor |
---|
55 | buffer_descriptor_t fbf; // frame buffer descriptor |
---|
56 | unsigned int length; // buffer length (bytes) |
---|
57 | unsigned int padding[15]; // padding for 64 bytes alignment |
---|
58 | } fbf_chbuf_t; |
---|
59 | |
---|
60 | /////////////////////////////////////////////////////////////////////////////// |
---|
61 | // This structure is used by the CMA component to move a stream of containers |
---|
62 | // between the NIC chbuf containing 2 buffers, and a kernel chbuf |
---|
63 | // containing up to (X_SIZE * Y_SIZE) buffers (one buffer per cluster). |
---|
64 | // The same structure is used for both TX or RX transfers. |
---|
65 | // The number of distributed containers can be smaller than (X_SIZE * YSIZE). |
---|
66 | // The actual number of buffers used in the chbuf is defined by (xmax * ymax). |
---|
67 | // This structure must be 64 bytes aligned. |
---|
68 | /////////////////////////////////////////////////////////////////////////////// |
---|
69 | |
---|
70 | typedef struct nic_chbuf_s |
---|
71 | { |
---|
72 | buffer_descriptor_t buffer[X_SIZE*Y_SIZE]; // kernel chbuf |
---|
73 | unsigned int xmax; // nb clusters in a row |
---|
74 | unsigned int ymax; // nb clusters in a column |
---|
75 | } nic_chbuf_t; |
---|
76 | |
---|
77 | |
---|
78 | |
---|
79 | |
---|
80 | /////////////////////////////////////////////////////////////////////////////// |
---|
81 | // Coprocessors related syscall handlers |
---|
82 | /////////////////////////////////////////////////////////////////////////////// |
---|
83 | |
---|
84 | int _sys_coproc_alloc( unsigned int coproc_type, |
---|
85 | unsigned int* coproc_info, |
---|
86 | unsigned int* cluster_xy ); |
---|
87 | |
---|
88 | int _sys_coproc_release( unsigned int cluster_xy ); |
---|
89 | |
---|
90 | int _sys_coproc_channel_init( unsigned int cluster_xy, |
---|
91 | unsigned int channel, |
---|
92 | giet_coproc_channel_t* desc ); |
---|
93 | |
---|
94 | int _sys_coproc_channel_start( unsigned int cluster_xy, |
---|
95 | unsigned int channel ); |
---|
96 | |
---|
97 | int _sys_coproc_channel_stop( unsigned int cluster_xy, |
---|
98 | unsigned int channel ); |
---|
99 | |
---|
100 | int _sys_coproc_completed( unsigned int cluster_xy ); |
---|
101 | |
---|
102 | /////////////////////////////////////////////////////////////////////////////// |
---|
103 | // TTY related syscall handlers |
---|
104 | /////////////////////////////////////////////////////////////////////////////// |
---|
105 | |
---|
106 | int _sys_tty_alloc(); |
---|
107 | |
---|
108 | int _sys_tty_write( const char* buffer, |
---|
109 | unsigned int length, |
---|
110 | unsigned int channel ); |
---|
111 | |
---|
112 | int _sys_tty_read( char* buffer, |
---|
113 | unsigned int length, |
---|
114 | unsigned int channel ); |
---|
115 | |
---|
116 | int _sys_tty_get_lock( unsigned int channel, |
---|
117 | unsigned int * save_sr_ptr ); |
---|
118 | |
---|
119 | int _sys_tty_release_lock( unsigned int channel, |
---|
120 | unsigned int * save_sr_ptr ); |
---|
121 | |
---|
122 | int _sys_coproc_register_set( unsigned int cluster_xy, |
---|
123 | unsigned int reg_index, |
---|
124 | unsigned int value ); |
---|
125 | |
---|
126 | int _sys_coproc_register_get( unsigned int cluster_xy, |
---|
127 | unsigned int reg_index, |
---|
128 | unsigned int* buffer ); |
---|
129 | |
---|
130 | ////////////////////////////////////////////////////////////////////////////// |
---|
131 | // TIM related syscall handlers |
---|
132 | ////////////////////////////////////////////////////////////////////////////// |
---|
133 | |
---|
134 | int _sys_tim_alloc(); |
---|
135 | |
---|
136 | int _sys_tim_start( unsigned int period ); |
---|
137 | |
---|
138 | int _sys_tim_stop(); |
---|
139 | |
---|
140 | ////////////////////////////////////////////////////////////////////////////// |
---|
141 | // NIC related syscall handlers |
---|
142 | ////////////////////////////////////////////////////////////////////////////// |
---|
143 | |
---|
144 | int _sys_nic_alloc( unsigned int is_rx, |
---|
145 | unsigned int xmax, |
---|
146 | unsigned int ymax ); |
---|
147 | |
---|
148 | |
---|
149 | int _sys_nic_start( unsigned int is_rx, |
---|
150 | unsigned int channel ); |
---|
151 | |
---|
152 | int _sys_nic_move( unsigned int is_rx, |
---|
153 | unsigned int channel, |
---|
154 | void* buffer ); |
---|
155 | |
---|
156 | int _sys_nic_stop( unsigned int is_rx, |
---|
157 | unsigned int channel ); |
---|
158 | |
---|
159 | int _sys_nic_clear( unsigned int is_rx, |
---|
160 | unsigned int channel ); |
---|
161 | |
---|
162 | int _sys_nic_stats( unsigned int is_rx, |
---|
163 | unsigned int channel ); |
---|
164 | |
---|
165 | ////////////////////////////////////////////////////////////////////////////// |
---|
166 | // FBF related syscall handlers |
---|
167 | ////////////////////////////////////////////////////////////////////////////// |
---|
168 | |
---|
169 | int _sys_fbf_sync_write( unsigned int offset, |
---|
170 | void* buffer, |
---|
171 | unsigned int length ); |
---|
172 | |
---|
173 | int _sys_fbf_sync_read( unsigned int offset, |
---|
174 | void* buffer, |
---|
175 | unsigned int length ); |
---|
176 | |
---|
177 | int _sys_fbf_cma_alloc(); |
---|
178 | |
---|
179 | int _sys_fbf_cma_start( void* vbase0, |
---|
180 | void* vbase1, |
---|
181 | unsigned int length ); |
---|
182 | |
---|
183 | int _sys_fbf_cma_display( unsigned int buffer_index ); |
---|
184 | |
---|
185 | int _sys_fbf_cma_stop(); |
---|
186 | |
---|
187 | ////////////////////////////////////////////////////////////////////////////// |
---|
188 | // Miscelaneous syscall handlers |
---|
189 | ////////////////////////////////////////////////////////////////////////////// |
---|
190 | |
---|
191 | int _sys_ukn(); |
---|
192 | |
---|
193 | int _sys_proc_xyp( unsigned int* x, |
---|
194 | unsigned int* y, |
---|
195 | unsigned int* p ); |
---|
196 | |
---|
197 | int _sys_task_exit( char* string ); |
---|
198 | |
---|
199 | int _context_switch(); |
---|
200 | |
---|
201 | int _sys_local_task_id(); |
---|
202 | |
---|
203 | int _sys_global_task_id(); |
---|
204 | |
---|
205 | int _sys_thread_id(); |
---|
206 | |
---|
207 | int _sys_procs_number( unsigned int* x_size, |
---|
208 | unsigned int* y_size, |
---|
209 | unsigned int* nprocs ); |
---|
210 | |
---|
211 | int _sys_vseg_get_vbase( char* vspace_name, |
---|
212 | char* vseg_name, |
---|
213 | unsigned int* vbase ); |
---|
214 | |
---|
215 | int _sys_vseg_get_length( char* vspace_name, |
---|
216 | char* vseg_name, |
---|
217 | unsigned int* length ); |
---|
218 | |
---|
219 | int _sys_xy_from_ptr( void* ptr, |
---|
220 | unsigned int* x, |
---|
221 | unsigned int* y ); |
---|
222 | |
---|
223 | int _sys_heap_info( unsigned int* vaddr, |
---|
224 | unsigned int* length, |
---|
225 | unsigned int x, |
---|
226 | unsigned int y ); |
---|
227 | |
---|
228 | #endif |
---|
229 | |
---|
230 | // Local Variables: |
---|
231 | // tab-width: 4 |
---|
232 | // c-basic-offset: 4 |
---|
233 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
234 | // indent-tabs-mode: nil |
---|
235 | // End: |
---|
236 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
237 | |
---|