source: soft/giet_vm/apps/numsplit/consumer.cpp @ 160

Last change on this file since 160 was 160, checked in by karaoui, 12 years ago

giet-vm new version

File size: 11.1 KB
Line 
1# 1 "consumer.c"
2# 1 "<built-in>"
3# 1 "<command-line>"
4# 1 "consumer.c"
5# 1 "consumer_proto.h" 1
6# 18 "consumer_proto.h"
7# 1 "numsplit_common.h" 1
8
9
10
11
12
13
14# 1 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/srl.h" 1
15# 10 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/srl.h"
16# 1 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_public_types.h" 1
17# 10 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_public_types.h"
18typedef unsigned long uint_t;
19typedef signed long sint_t;
20
21typedef unsigned char uint8_t;
22typedef signed char sint8_t;
23typedef signed short int int8_t;
24
25typedef unsigned short int uint16_t;
26typedef signed short int sint16_t;
27typedef signed short int int16_t;
28
29typedef unsigned int uint32_t;
30typedef signed int sint32_t;
31typedef signed int int32_t;
32
33typedef sint32_t error_t;
34typedef uint_t bool_t;
35
36typedef void *srl_buffer_t;
37# 11 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/srl.h" 2
38
39
40# 1 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_lock.h" 1
41# 23 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_lock.h"
42# 1 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_public_types.h" 1
43# 24 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_lock.h" 2
44# 1 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/stdio.h" 1
45# 11 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/stdio.h"
46# 1 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/xml/mapping_info.h" 1
47# 57 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/xml/mapping_info.h"
48enum
49{
50    ELF = 0,
51    PTAB,
52    PERI,
53    MWMR,
54    LOCK,
55    BUFFER,
56    BARRIER
57};
58
59
60
61typedef struct mapping_header_s
62{
63    unsigned int signature;
64 unsigned int clusters;
65 unsigned int psegs;
66    unsigned int ttys;
67 unsigned int globals;
68 unsigned int vspaces;
69 unsigned int vsegs;
70 unsigned int vobjs;
71 unsigned int tasks;
72    char name[32];
73} mapping_header_t;
74
75
76typedef struct mapping_cluster_s
77{
78    unsigned int procs;
79    unsigned int timers;
80    unsigned int dmas;
81} mapping_cluster_t;
82
83
84typedef struct mapping_pseg_s
85{
86    char name[32];
87 unsigned int base;
88 unsigned int length;
89    unsigned int next_free_page;
90} mapping_pseg_t;
91
92
93typedef struct mapping_vspace_s
94{
95    char name[32];
96    unsigned int funcs_offset;
97 unsigned int vsegs;
98 unsigned int vobjs;
99 unsigned int tasks;
100 unsigned int ttys;
101    unsigned int vseg_offset;
102    unsigned int vobj_offset;
103    unsigned int task_offset;
104} mapping_vspace_t;
105
106
107typedef struct mapping_vseg_s
108{
109 char name[32];
110 unsigned int vbase;
111 unsigned int pbase;
112 unsigned int length;
113 unsigned int psegid;
114 unsigned char mode;
115    unsigned char ident;
116 unsigned int vobjs;
117    unsigned int vobj_offset;
118    unsigned char reserved;
119} mapping_vseg_t;
120
121
122typedef struct mapping_task_s
123{
124 char name[32];
125 unsigned int clusterid;
126 unsigned int proclocid;
127    unsigned int vobjlocid;
128    unsigned int startid;
129    unsigned int ttylocid;
130} mapping_task_t;
131
132
133typedef struct mapping_vobj_s
134{
135    char name[32];
136    char binpath[64];
137 unsigned int type;
138 unsigned int length;
139 unsigned int align;
140 unsigned int vaddr;
141 unsigned int paddr;
142} mapping_vobj_t;
143# 12 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/stdio.h" 2
144
145
146unsigned int procid();
147unsigned int proctime();
148unsigned int procnumber();
149
150
151unsigned int tty_putc(char byte);
152unsigned int tty_puts(char *buf);
153unsigned int tty_putw(unsigned int val);
154unsigned int tty_getc(char *byte);
155unsigned int tty_getc_irq(char *byte);
156unsigned int tty_gets_irq(char *buf, unsigned int bufsize);
157unsigned int tty_getw_irq(unsigned int *val);
158unsigned int tty_printf(char *format,...);
159
160
161unsigned int timer_set_mode(unsigned int mode);
162unsigned int timer_set_period(unsigned int period);
163unsigned int timer_reset_irq();
164unsigned int timer_get_time(unsigned int *time);
165
166
167unsigned int gcd_set_opa(unsigned int val);
168unsigned int gcd_set_opb(unsigned int val);
169unsigned int gcd_start();
170unsigned int gcd_get_result(unsigned int *val);
171unsigned int gcd_get_status(unsigned int *val);
172
173
174unsigned int ioc_read(unsigned int lba, void *buffer, unsigned int count);
175unsigned int ioc_write(unsigned int lba, void *buffer, unsigned int count);
176unsigned int ioc_completed();
177
178
179unsigned int fb_sync_read(unsigned int offset, void *buffer, unsigned int length);
180unsigned int fb_sync_write(unsigned int offset, void *buffer, unsigned int length);
181unsigned int fb_read(unsigned int offset, void *buffer, unsigned int length);
182unsigned int fb_write(unsigned int offset, void *buffer, unsigned int length);
183unsigned int fb_completed();
184
185
186unsigned int barrier_init(unsigned int index, unsigned int count);
187unsigned int barrier_wait(unsigned int index);
188
189
190void exit();
191unsigned int rand();
192unsigned int ctx_switch();
193unsigned int vobj_get_vbase( char* vspace_name, char* vobj_name,
194                        unsigned int vobj_type, unsigned int* vobj_buffer);
195# 73 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/stdio.h"
196static inline void *memcpy(void *_dst, const void *_src, unsigned int size)
197{
198    unsigned int *dst = _dst;
199    const unsigned int *src = _src;
200
201
202
203    if (!((unsigned int)dst & 3) && !((unsigned int)src & 3))
204        while (size > 3) {
205            *dst++ = *src++;
206            size -= 4;
207        }
208
209    unsigned char *cdst = (unsigned char*)dst;
210    unsigned char *csrc = (unsigned char*)src;
211
212
213    while (size--) {
214        *cdst++ = *csrc++;
215    }
216    return _dst;
217}
218# 25 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_lock.h" 2
219
220typedef struct {
221 unsigned int lock;
222}srl_lock_t;
223# 37 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_lock.h"
224int srl_lock_lock( srl_lock_t lock );
225
226
227
228
229
230
231void srl_lock_unlock( srl_lock_t lock );
232# 53 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_lock.h"
233int srl_lock_try_lock( srl_lock_t lock );
234# 14 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/srl.h" 2
235# 1 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_mwmr.h" 1
236
237
238
239# 1 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/mwmr.h" 1
240# 17 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/mwmr.h"
241typedef struct mwmr_channel_s {
242    unsigned int ptr;
243    unsigned int ptw;
244    unsigned int sts;
245    unsigned int depth;
246    unsigned int lock;
247    unsigned int data[1019];
248} mwmr_channel_t;
249
250
251
252
253
254
255void mwmr_write( mwmr_channel_t* mwmr,
256                 unsigned int* buffer,
257                 unsigned int nwords );
258
259void mwmr_read( mwmr_channel_t* mwmr,
260                unsigned int* buffer,
261                unsigned int nwords );
262# 5 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_mwmr.h" 2
263# 15 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/srl.h" 2
264# 1 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_log.h" 1
265# 24 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_log.h"
266# 1 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/giet_config.h" 1
267# 25 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_log.h" 2
268# 1 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_hw_helpers.h" 1
269# 12 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_hw_helpers.h"
270typedef struct __ldscript_symbol_s __ldscript_symbol_t;
271# 56 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_hw_helpers.h"
272void srl_sleep_cycles( unsigned int time );
273# 66 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_hw_helpers.h"
274static inline unsigned int srl_cycle_count()
275{
276 return proctime();
277}
278
279
280
281
282
283static inline void srl_abort()
284{
285 asm volatile ("break 0");
286 while(1);
287}
288# 26 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_log.h" 2
289
290
291enum __srl_verbosity {
292    VERB_NONE,
293    VERB_TRACE,
294    VERB_DEBUG,
295    VERB_MAX,
296};
297
298
299void _srl_log(const char *);
300void _srl_log_printf(const char *, ...);
301# 16 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/srl.h" 2
302# 1 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_barrier.h" 1
303# 24 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_barrier.h"
304# 1 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_log.h" 1
305# 25 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_barrier.h" 2
306# 1 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_sched_wait.h" 1
307# 27 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_sched_wait.h"
308void srl_sched_wait_eq(void *addr, sint32_t val );
309void srl_sched_wait_ne(void *addr, sint32_t val );
310void srl_sched_wait_le(void *addr, sint32_t val );
311void srl_sched_wait_ge(void *addr, sint32_t val );
312void srl_sched_wait_lt(void *addr, sint32_t val );
313void srl_sched_wait_gt(void *addr, sint32_t val );
314
315
316
317
318void srl_sleep_cycles( unsigned int n );
319# 26 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_barrier.h" 2
320
321
322typedef struct srl_abstract_barrier_s
323{
324 unsigned int init_val;
325 unsigned int count;
326
327} srl_barrier_s;
328
329
330
331typedef srl_barrier_s *srl_barrier_t;
332
333void srl_barrier_wait( srl_barrier_t barrier );
334# 17 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/srl.h" 2
335# 1 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_memspace.h" 1
336# 13 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_memspace.h"
337typedef struct srl_memspace_s {
338 void *buffer;
339 uint32_t size;
340} srl_memspace_s;
341
342
343
344
345typedef struct srl_memspace_s *srl_memspace_t;
346# 18 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/srl.h" 2
347
348# 1 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/libsrl/srl_hw_helpers.h" 1
349# 20 "/users/cao/karaoui/soc/myplateform/caba_vgsb_almo_mmu_vloader/soft/libs/srl.h" 2
350# 8 "numsplit_common.h" 2
351# 19 "consumer_proto.h" 2
352# 2 "consumer.c" 2
353
354__attribute__((constructor))void consumer_func_cons_func ()
355{
356    mwmr_channel_t* input = ({ mwmr_channel_t* _mwmr; if( vobj_get_vbase( "APP_NAME" , "port", MWMR, (unsigned int*)&_mwmr ) ) { do { if (VERB_NONE <= VERB_TRACE) { tty_printf("\n[ERROR] in TASK task :\n"); } } while (0); do { if (VERB_NONE <= VERB_TRACE) { tty_printf("          undefined <port> channel: %d\n", _mwmr); } } while (0); do { if (VERB_TRACE <= VERB_TRACE) { tty_printf("*** &port = %x\n\n", (unsigned int)_mwmr); } } while (0); exit(); }else do { if (VERB_DEBUG <= VERB_TRACE) { tty_printf("%s:%d: arg of %s: %s\n", "consumer.c", 5, "APP_NAME", "port"); } } while (0); _mwmr;});
357    char buf[32];
358    mwmr_read(input, (unsigned *)buf, 8);
359    do { if (VERB_NONE <= VERB_TRACE) { tty_printf("Consumer : %s\n\n", buf); } } while (0);
360}
Note: See TracBrowser for help on using the repository browser.