[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 | |
---|
[189] | 34 | void _puts(char *string); |
---|
| 35 | void _putw(unsigned int val); |
---|
| 36 | void _putd(unsigned int val); |
---|
[158] | 37 | |
---|
[189] | 38 | unsigned int _strncmp(const char* s1, const char* s2, unsigned int n); |
---|
[158] | 39 | |
---|
[189] | 40 | void _dcache_buf_invalidate(const void *buffer, unsigned int size); |
---|
[158] | 41 | |
---|
[189] | 42 | void _itoa_dec(unsigned int val, char* buf); |
---|
| 43 | void _itoa_hex(unsigned int val, char* buf); |
---|
[158] | 44 | |
---|
[189] | 45 | void _dtlb_off(void); |
---|
| 46 | void _dtlb_on(void); |
---|
[158] | 47 | |
---|
[189] | 48 | void _it_mask(void); |
---|
| 49 | void _it_enable(void); |
---|
[165] | 50 | |
---|
[189] | 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_current_context_slot(unsigned int index); |
---|
| 58 | unsigned int _get_interrupt_vector_entry(unsigned int index); |
---|
| 59 | unsigned int _get_current_task_id(void); |
---|
| 60 | unsigned int _get_tasks_number(void); |
---|
| 61 | |
---|
| 62 | void _set_current_task_id( unsigned int value); |
---|
| 63 | |
---|
| 64 | void _get_lock(unsigned int* lock); |
---|
| 65 | void _release_lock(unsigned int* lock); |
---|
| 66 | |
---|
[158] | 67 | mapping_cluster_t* _get_cluster_base( mapping_header_t* header ); |
---|
| 68 | mapping_pseg_t* _get_pseg_base( mapping_header_t* header ); |
---|
| 69 | mapping_vspace_t* _get_vspace_base( mapping_header_t* header ); |
---|
| 70 | mapping_vseg_t* _get_vseg_base( mapping_header_t* header ); |
---|
[160] | 71 | mapping_vobj_t* _get_vobj_base( mapping_header_t* header ); |
---|
[158] | 72 | mapping_task_t* _get_task_base( mapping_header_t* header ); |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | /////////////////////////////////////////////////////////////////////////////////// |
---|
| 76 | // memcpy() function |
---|
| 77 | // This function is likely not called directly by the GIET, |
---|
| 78 | // but GCC can automatically issue call to it during compilation, |
---|
| 79 | // so we must provide it. |
---|
| 80 | // Code taken from MutekH. |
---|
| 81 | /////////////////////////////////////////////////////////////////////////////////// |
---|
| 82 | static inline void *memcpy(void *_dst, const void *_src, unsigned int size) |
---|
| 83 | { |
---|
| 84 | unsigned int *dst = _dst; |
---|
| 85 | const unsigned int *src = _src; |
---|
| 86 | |
---|
| 87 | /* if source and destination buffer are word-aligned, |
---|
| 88 | * then copy word-by-word */ |
---|
| 89 | if (!((unsigned int)dst & 3) && !((unsigned int)src & 3)) |
---|
| 90 | while (size > 3) { |
---|
| 91 | *dst++ = *src++; |
---|
| 92 | size -= 4; |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | unsigned char *cdst = (unsigned char*)dst; |
---|
| 96 | unsigned char *csrc = (unsigned char*)src; |
---|
| 97 | |
---|
| 98 | /* byte-by-byte copy */ |
---|
| 99 | while (size--) { |
---|
| 100 | *cdst++ = *csrc++; |
---|
| 101 | } |
---|
| 102 | return _dst; |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | #endif |
---|