[158] | 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 | |
---|
[166] | 19 | extern _ld_symbol_t seg_iob_base; |
---|
[158] | 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; |
---|
[160] | 27 | extern _ld_symbol_t seg_mapping_base; |
---|
[158] | 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 | |
---|
| 37 | unsigned int _strncmp(const char* s1, const char* s2, unsigned int n); |
---|
| 38 | |
---|
| 39 | void _dcache_buf_invalidate(const void *buffer, unsigned int size); |
---|
| 40 | |
---|
| 41 | void _itoa_dec(unsigned int val, char* buf); |
---|
| 42 | void _itoa_hex(unsigned int val, char* buf); |
---|
| 43 | |
---|
| 44 | unsigned int _get_epc(); |
---|
[166] | 45 | unsigned int _get_ptpr(); |
---|
[158] | 46 | unsigned int _get_bar(); |
---|
| 47 | unsigned int _get_cr(); |
---|
| 48 | |
---|
[165] | 49 | void _get_lock(unsigned int* lock); |
---|
| 50 | void _release_lock(unsigned int* lock); |
---|
| 51 | |
---|
[158] | 52 | mapping_cluster_t* _get_cluster_base( mapping_header_t* header ); |
---|
| 53 | mapping_pseg_t* _get_pseg_base( mapping_header_t* header ); |
---|
| 54 | mapping_vspace_t* _get_vspace_base( mapping_header_t* header ); |
---|
| 55 | mapping_vseg_t* _get_vseg_base( mapping_header_t* header ); |
---|
[160] | 56 | mapping_vobj_t* _get_vobj_base( mapping_header_t* header ); |
---|
[158] | 57 | mapping_task_t* _get_task_base( mapping_header_t* header ); |
---|
| 58 | |
---|
| 59 | |
---|
| 60 | /////////////////////////////////////////////////////////////////////////////////// |
---|
| 61 | // memcpy() function |
---|
| 62 | // This function is likely not called directly by the GIET, |
---|
| 63 | // but GCC can automatically issue call to it during compilation, |
---|
| 64 | // so we must provide it. |
---|
| 65 | // Code taken from MutekH. |
---|
| 66 | /////////////////////////////////////////////////////////////////////////////////// |
---|
| 67 | static inline void *memcpy(void *_dst, const void *_src, unsigned int size) |
---|
| 68 | { |
---|
| 69 | unsigned int *dst = _dst; |
---|
| 70 | const unsigned int *src = _src; |
---|
| 71 | |
---|
| 72 | /* if source and destination buffer are word-aligned, |
---|
| 73 | * then copy word-by-word */ |
---|
| 74 | if (!((unsigned int)dst & 3) && !((unsigned int)src & 3)) |
---|
| 75 | while (size > 3) { |
---|
| 76 | *dst++ = *src++; |
---|
| 77 | size -= 4; |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | unsigned char *cdst = (unsigned char*)dst; |
---|
| 81 | unsigned char *csrc = (unsigned char*)src; |
---|
| 82 | |
---|
| 83 | /* byte-by-byte copy */ |
---|
| 84 | while (size--) { |
---|
| 85 | *cdst++ = *csrc++; |
---|
| 86 | } |
---|
| 87 | return _dst; |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | #endif |
---|