1 | /////////////////////////////////////////////////////////////////////////////////// |
---|
2 | // File : common.h |
---|
3 | // Date : 01/04/2012 |
---|
4 | // Author : alain greiner and joel porquet |
---|
5 | // Copyright (c) UPMC-LIP6 |
---|
6 | /////////////////////////////////////////////////////////////////////////////////// |
---|
7 | |
---|
8 | #ifndef _COMMON_H |
---|
9 | #define _COMMON_H |
---|
10 | |
---|
11 | #include <mapping_info.h> |
---|
12 | |
---|
13 | /////////////////////////////////////////////////////////////////////////////////// |
---|
14 | // For retrieving base addresses defined in seg.ld file. |
---|
15 | /////////////////////////////////////////////////////////////////////////////////// |
---|
16 | |
---|
17 | typedef struct _ld_symbol_s _ld_symbol_t; |
---|
18 | |
---|
19 | extern _ld_symbol_t seg_iob_base; |
---|
20 | extern _ld_symbol_t seg_icu_base; |
---|
21 | extern _ld_symbol_t seg_timer_base; |
---|
22 | extern _ld_symbol_t seg_tty_base; |
---|
23 | extern _ld_symbol_t seg_gcd_base; |
---|
24 | extern _ld_symbol_t seg_dma_base; |
---|
25 | extern _ld_symbol_t seg_fb_base; |
---|
26 | extern _ld_symbol_t seg_ioc_base; |
---|
27 | extern _ld_symbol_t seg_mapping_base; |
---|
28 | extern _ld_symbol_t seg_kernel_pt_base; |
---|
29 | |
---|
30 | /////////////////////////////////////////////////////////////////////////////////// |
---|
31 | // Prototypes of common functions |
---|
32 | /////////////////////////////////////////////////////////////////////////////////// |
---|
33 | |
---|
34 | void _puts(char *string); |
---|
35 | void _putw(unsigned int val); |
---|
36 | void _putd(unsigned int val); |
---|
37 | |
---|
38 | unsigned int _strncmp( const char* s1, |
---|
39 | const char* s2, |
---|
40 | unsigned int n ); |
---|
41 | |
---|
42 | void _dcache_buf_invalidate( const void *buffer, |
---|
43 | unsigned int size ); |
---|
44 | |
---|
45 | void _dtlb_off(void); |
---|
46 | void _dtlb_on(void); |
---|
47 | |
---|
48 | void _it_mask(void); |
---|
49 | void _it_enable(void); |
---|
50 | |
---|
51 | unsigned int _get_epc(void); |
---|
52 | unsigned int _get_ptpr(void); |
---|
53 | unsigned int _get_bvar(void); |
---|
54 | unsigned int _get_cr(void); |
---|
55 | unsigned int _get_sched(void); |
---|
56 | |
---|
57 | unsigned int _get_context_slot( unsigned int task_id, |
---|
58 | unsigned int slot_id ); |
---|
59 | |
---|
60 | void _set_context_slot( unsigned int task_id, |
---|
61 | unsigned int slot_id, |
---|
62 | unsigned int value ); |
---|
63 | |
---|
64 | unsigned int _get_interrupt_vector_entry(unsigned int index); |
---|
65 | |
---|
66 | unsigned int _get_current_task_id( void ); |
---|
67 | void _set_current_task_id( unsigned int value ); |
---|
68 | |
---|
69 | unsigned int _get_tasks_number(void); |
---|
70 | |
---|
71 | |
---|
72 | void _get_lock(unsigned int* lock); |
---|
73 | void _release_lock(unsigned int* lock); |
---|
74 | |
---|
75 | mapping_cluster_t* _get_cluster_base( mapping_header_t* header ); |
---|
76 | mapping_pseg_t* _get_pseg_base( mapping_header_t* header ); |
---|
77 | mapping_vspace_t* _get_vspace_base( mapping_header_t* header ); |
---|
78 | mapping_vseg_t* _get_vseg_base( mapping_header_t* header ); |
---|
79 | mapping_vobj_t* _get_vobj_base( mapping_header_t* header ); |
---|
80 | mapping_task_t* _get_task_base( mapping_header_t* header ); |
---|
81 | |
---|
82 | |
---|
83 | /////////////////////////////////////////////////////////////////////////////////// |
---|
84 | // memcpy() function |
---|
85 | // This function is likely not called directly by the GIET, |
---|
86 | // but GCC can automatically issue call to it during compilation, |
---|
87 | // so we must provide it. |
---|
88 | // Code taken from MutekH. |
---|
89 | /////////////////////////////////////////////////////////////////////////////////// |
---|
90 | static inline void *memcpy(void *_dst, const void *_src, unsigned int size) |
---|
91 | { |
---|
92 | unsigned int *dst = _dst; |
---|
93 | const unsigned int *src = _src; |
---|
94 | |
---|
95 | /* if source and destination buffer are word-aligned, |
---|
96 | * then copy word-by-word */ |
---|
97 | if (!((unsigned int)dst & 3) && !((unsigned int)src & 3)) |
---|
98 | while (size > 3) { |
---|
99 | *dst++ = *src++; |
---|
100 | size -= 4; |
---|
101 | } |
---|
102 | |
---|
103 | unsigned char *cdst = (unsigned char*)dst; |
---|
104 | unsigned char *csrc = (unsigned char*)src; |
---|
105 | |
---|
106 | /* byte-by-byte copy */ |
---|
107 | while (size--) { |
---|
108 | *cdst++ = *csrc++; |
---|
109 | } |
---|
110 | return _dst; |
---|
111 | } |
---|
112 | |
---|
113 | #endif |
---|