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_icu_base; |
---|
20 | extern _ld_symbol_t seg_timer_base; |
---|
21 | extern _ld_symbol_t seg_tty_base; |
---|
22 | extern _ld_symbol_t seg_gcd_base; |
---|
23 | extern _ld_symbol_t seg_dma_base; |
---|
24 | extern _ld_symbol_t seg_fb_base; |
---|
25 | extern _ld_symbol_t seg_ioc_base; |
---|
26 | extern _ld_symbol_t seg_mapping_base; |
---|
27 | extern _ld_symbol_t seg_kernel_pt_base; |
---|
28 | |
---|
29 | /////////////////////////////////////////////////////////////////////////////////// |
---|
30 | // Prototypes of common functions |
---|
31 | /////////////////////////////////////////////////////////////////////////////////// |
---|
32 | |
---|
33 | void _puts(char *string); |
---|
34 | void _putw(unsigned int val); |
---|
35 | |
---|
36 | unsigned int _strncmp(const char* s1, const char* s2, unsigned int n); |
---|
37 | |
---|
38 | void _dcache_buf_invalidate(const void *buffer, unsigned int size); |
---|
39 | |
---|
40 | void _itoa_dec(unsigned int val, char* buf); |
---|
41 | void _itoa_hex(unsigned int val, char* buf); |
---|
42 | |
---|
43 | unsigned int _get_epc(); |
---|
44 | unsigned int _get_bar(); |
---|
45 | unsigned int _get_cr(); |
---|
46 | |
---|
47 | mapping_cluster_t* _get_cluster_base( mapping_header_t* header ); |
---|
48 | mapping_pseg_t* _get_pseg_base( mapping_header_t* header ); |
---|
49 | mapping_vspace_t* _get_vspace_base( mapping_header_t* header ); |
---|
50 | mapping_vseg_t* _get_vseg_base( mapping_header_t* header ); |
---|
51 | mapping_vobj_t* _get_vobj_base( mapping_header_t* header ); |
---|
52 | mapping_task_t* _get_task_base( mapping_header_t* header ); |
---|
53 | |
---|
54 | |
---|
55 | /////////////////////////////////////////////////////////////////////////////////// |
---|
56 | // memcpy() function |
---|
57 | // This function is likely not called directly by the GIET, |
---|
58 | // but GCC can automatically issue call to it during compilation, |
---|
59 | // so we must provide it. |
---|
60 | // Code taken from MutekH. |
---|
61 | /////////////////////////////////////////////////////////////////////////////////// |
---|
62 | static inline void *memcpy(void *_dst, const void *_src, unsigned int size) |
---|
63 | { |
---|
64 | unsigned int *dst = _dst; |
---|
65 | const unsigned int *src = _src; |
---|
66 | |
---|
67 | /* if source and destination buffer are word-aligned, |
---|
68 | * then copy word-by-word */ |
---|
69 | if (!((unsigned int)dst & 3) && !((unsigned int)src & 3)) |
---|
70 | while (size > 3) { |
---|
71 | *dst++ = *src++; |
---|
72 | size -= 4; |
---|
73 | } |
---|
74 | |
---|
75 | unsigned char *cdst = (unsigned char*)dst; |
---|
76 | unsigned char *csrc = (unsigned char*)src; |
---|
77 | |
---|
78 | /* byte-by-byte copy */ |
---|
79 | while (size--) { |
---|
80 | *cdst++ = *csrc++; |
---|
81 | } |
---|
82 | return _dst; |
---|
83 | } |
---|
84 | |
---|
85 | #endif |
---|