[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> |
---|
[231] | 12 | #include <giet_config.h> |
---|
[238] | 13 | #include <ctx_handler.h> |
---|
[158] | 14 | |
---|
| 15 | /////////////////////////////////////////////////////////////////////////////////// |
---|
| 16 | // For retrieving base addresses defined in seg.ld file. |
---|
| 17 | /////////////////////////////////////////////////////////////////////////////////// |
---|
| 18 | |
---|
| 19 | typedef struct _ld_symbol_s _ld_symbol_t; |
---|
| 20 | |
---|
[166] | 21 | extern _ld_symbol_t seg_iob_base; |
---|
[218] | 22 | extern _ld_symbol_t seg_nic_base; |
---|
[158] | 23 | extern _ld_symbol_t seg_icu_base; |
---|
[253] | 24 | extern _ld_symbol_t seg_xcu_base; |
---|
[203] | 25 | extern _ld_symbol_t seg_tim_base; |
---|
[158] | 26 | extern _ld_symbol_t seg_tty_base; |
---|
| 27 | extern _ld_symbol_t seg_gcd_base; |
---|
| 28 | extern _ld_symbol_t seg_dma_base; |
---|
[203] | 29 | extern _ld_symbol_t seg_fbf_base; |
---|
[158] | 30 | extern _ld_symbol_t seg_ioc_base; |
---|
[249] | 31 | extern _ld_symbol_t seg_mmc_base; |
---|
[253] | 32 | extern _ld_symbol_t seg_cma_base; |
---|
[255] | 33 | extern _ld_symbol_t seg_sim_base; |
---|
[249] | 34 | |
---|
[253] | 35 | extern _ld_symbol_t vseg_cluster_increment; |
---|
| 36 | |
---|
[160] | 37 | extern _ld_symbol_t seg_mapping_base; |
---|
[158] | 38 | extern _ld_symbol_t seg_kernel_pt_base; |
---|
| 39 | |
---|
| 40 | /////////////////////////////////////////////////////////////////////////////////// |
---|
[228] | 41 | // Prototypes of common functions |
---|
[158] | 42 | /////////////////////////////////////////////////////////////////////////////////// |
---|
| 43 | |
---|
[238] | 44 | void _puts(char *string); |
---|
| 45 | void _putx(unsigned int val); |
---|
| 46 | void _putd(unsigned int val); |
---|
| 47 | void _putl(paddr_t val); |
---|
[158] | 48 | |
---|
[238] | 49 | unsigned int _strncmp(const char * s1, |
---|
| 50 | const char * s2, |
---|
| 51 | unsigned int n); |
---|
[158] | 52 | |
---|
[238] | 53 | void _dcache_buf_invalidate(const void * buffer, |
---|
| 54 | unsigned int size); |
---|
[158] | 55 | |
---|
[238] | 56 | void _dtlb_off(void); |
---|
| 57 | void _dtlb_on(void); |
---|
[158] | 58 | |
---|
[238] | 59 | void _it_mask(void); |
---|
| 60 | void _it_restore(void); |
---|
| 61 | void _it_disable(void); |
---|
| 62 | void _it_enable(void); |
---|
[165] | 63 | |
---|
[238] | 64 | unsigned int _get_epc(void); |
---|
| 65 | unsigned int _get_ptpr(void); |
---|
| 66 | unsigned int _get_bvar(void); |
---|
| 67 | unsigned int _get_cr(void); |
---|
[189] | 68 | |
---|
[238] | 69 | static_scheduler_t* _get_sched(void); |
---|
[199] | 70 | |
---|
[238] | 71 | unsigned int _get_context_slot( unsigned int slot ); |
---|
[199] | 72 | |
---|
[238] | 73 | void _set_context_slot( unsigned int slot, |
---|
| 74 | unsigned int value ); |
---|
[232] | 75 | |
---|
[238] | 76 | unsigned int _get_task_slot( unsigned int ltid, |
---|
| 77 | unsigned int slot ); |
---|
[232] | 78 | |
---|
[238] | 79 | void _set_task_slot( unsigned int ltid, |
---|
| 80 | unsigned int slot, |
---|
| 81 | unsigned int value ); |
---|
[199] | 82 | |
---|
[238] | 83 | void _get_lock(unsigned int * lock); |
---|
| 84 | void _release_lock(unsigned int * lock); |
---|
[199] | 85 | |
---|
[238] | 86 | mapping_cluster_t * _get_cluster_base(mapping_header_t* header); |
---|
| 87 | mapping_pseg_t * _get_pseg_base(mapping_header_t* header); |
---|
| 88 | mapping_vspace_t * _get_vspace_base(mapping_header_t* header); |
---|
| 89 | mapping_vseg_t * _get_vseg_base(mapping_header_t* header); |
---|
| 90 | mapping_vobj_t * _get_vobj_base(mapping_header_t* header); |
---|
| 91 | mapping_task_t * _get_task_base(mapping_header_t* header); |
---|
[189] | 92 | |
---|
| 93 | |
---|
[158] | 94 | /////////////////////////////////////////////////////////////////////////////////// |
---|
| 95 | // memcpy() function |
---|
| 96 | // This function is likely not called directly by the GIET, |
---|
| 97 | // but GCC can automatically issue call to it during compilation, |
---|
| 98 | // so we must provide it. |
---|
| 99 | // Code taken from MutekH. |
---|
| 100 | /////////////////////////////////////////////////////////////////////////////////// |
---|
[228] | 101 | static inline void * memcpy(void * _dst, const void * _src, unsigned int size) { |
---|
| 102 | unsigned int * dst = _dst; |
---|
| 103 | const unsigned int * src = _src; |
---|
[158] | 104 | |
---|
| 105 | /* if source and destination buffer are word-aligned, |
---|
| 106 | * then copy word-by-word */ |
---|
[228] | 107 | if (!((unsigned int) dst & 3) && !((unsigned int) src & 3)) { |
---|
[158] | 108 | while (size > 3) { |
---|
| 109 | *dst++ = *src++; |
---|
| 110 | size -= 4; |
---|
| 111 | } |
---|
[228] | 112 | } |
---|
[158] | 113 | |
---|
[228] | 114 | unsigned char * cdst = (unsigned char *) dst; |
---|
| 115 | unsigned char * csrc = (unsigned char *) src; |
---|
[158] | 116 | |
---|
| 117 | /* byte-by-byte copy */ |
---|
| 118 | while (size--) { |
---|
| 119 | *cdst++ = *csrc++; |
---|
| 120 | } |
---|
| 121 | return _dst; |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | #endif |
---|
[228] | 125 | |
---|
| 126 | // Local Variables: |
---|
| 127 | // tab-width: 4 |
---|
| 128 | // c-basic-offset: 4 |
---|
| 129 | // c-file-offsets:((innamespace . 0)(inline-open . 0)) |
---|
| 130 | // indent-tabs-mode: nil |
---|
| 131 | // End: |
---|
| 132 | // vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
---|
| 133 | |
---|