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