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_nic_base; |
---|
21 | extern _ld_symbol_t seg_icu_base; |
---|
22 | extern _ld_symbol_t seg_tim_base; |
---|
23 | extern _ld_symbol_t seg_tty_base; |
---|
24 | extern _ld_symbol_t seg_gcd_base; |
---|
25 | extern _ld_symbol_t seg_dma_base; |
---|
26 | extern _ld_symbol_t seg_fbf_base; |
---|
27 | extern _ld_symbol_t seg_ioc_base; |
---|
28 | extern _ld_symbol_t seg_mapping_base; |
---|
29 | extern _ld_symbol_t seg_kernel_pt_base; |
---|
30 | |
---|
31 | /////////////////////////////////////////////////////////////////////////////////// |
---|
32 | // Prototypes of common functions |
---|
33 | /////////////////////////////////////////////////////////////////////////////////// |
---|
34 | |
---|
35 | void _puts(char *string); |
---|
36 | void _putx(unsigned int val); |
---|
37 | void _putd(unsigned int val); |
---|
38 | |
---|
39 | unsigned int _strncmp( const char* s1, |
---|
40 | const char* s2, |
---|
41 | unsigned int n ); |
---|
42 | |
---|
43 | void _dcache_buf_invalidate( const void *buffer, |
---|
44 | unsigned int size ); |
---|
45 | |
---|
46 | void _dtlb_off(void); |
---|
47 | void _dtlb_on(void); |
---|
48 | |
---|
49 | void _it_mask(void); |
---|
50 | void _it_enable(void); |
---|
51 | |
---|
52 | unsigned int _get_epc(void); |
---|
53 | unsigned int _get_ptpr(void); |
---|
54 | unsigned int _get_bvar(void); |
---|
55 | unsigned int _get_cr(void); |
---|
56 | unsigned int _get_sched(void); |
---|
57 | |
---|
58 | unsigned int _get_context_slot( unsigned int task_id, |
---|
59 | unsigned int slot_id ); |
---|
60 | |
---|
61 | void _set_context_slot( unsigned int task_id, |
---|
62 | unsigned int slot_id, |
---|
63 | unsigned int value ); |
---|
64 | |
---|
65 | unsigned int _get_interrupt_vector_entry(unsigned int index); |
---|
66 | |
---|
67 | unsigned int _get_current_task_id( void ); |
---|
68 | void _set_current_task_id( unsigned int value ); |
---|
69 | |
---|
70 | unsigned int _get_tasks_number(void); |
---|
71 | |
---|
72 | |
---|
73 | void _get_lock(unsigned int* lock); |
---|
74 | void _release_lock(unsigned int* lock); |
---|
75 | |
---|
76 | mapping_cluster_t* _get_cluster_base( mapping_header_t* header ); |
---|
77 | mapping_pseg_t* _get_pseg_base( mapping_header_t* header ); |
---|
78 | mapping_vspace_t* _get_vspace_base( mapping_header_t* header ); |
---|
79 | mapping_vseg_t* _get_vseg_base( mapping_header_t* header ); |
---|
80 | mapping_vobj_t* _get_vobj_base( mapping_header_t* header ); |
---|
81 | mapping_task_t* _get_task_base( mapping_header_t* header ); |
---|
82 | |
---|
83 | |
---|
84 | /////////////////////////////////////////////////////////////////////////////////// |
---|
85 | // memcpy() function |
---|
86 | // This function is likely not called directly by the GIET, |
---|
87 | // but GCC can automatically issue call to it during compilation, |
---|
88 | // so we must provide it. |
---|
89 | // Code taken from MutekH. |
---|
90 | /////////////////////////////////////////////////////////////////////////////////// |
---|
91 | static inline void *memcpy(void *_dst, const void *_src, unsigned int size) |
---|
92 | { |
---|
93 | unsigned int *dst = _dst; |
---|
94 | const unsigned int *src = _src; |
---|
95 | |
---|
96 | /* if source and destination buffer are word-aligned, |
---|
97 | * then copy word-by-word */ |
---|
98 | if (!((unsigned int)dst & 3) && !((unsigned int)src & 3)) |
---|
99 | while (size > 3) { |
---|
100 | *dst++ = *src++; |
---|
101 | size -= 4; |
---|
102 | } |
---|
103 | |
---|
104 | unsigned char *cdst = (unsigned char*)dst; |
---|
105 | unsigned char *csrc = (unsigned char*)src; |
---|
106 | |
---|
107 | /* byte-by-byte copy */ |
---|
108 | while (size--) { |
---|
109 | *cdst++ = *csrc++; |
---|
110 | } |
---|
111 | return _dst; |
---|
112 | } |
---|
113 | |
---|
114 | #endif |
---|