source: soft/giet_vm/sys/common.h @ 203

Last change on this file since 203 was 203, checked in by alain, 12 years ago

Introducing support for XICU

File size: 3.6 KB
Line 
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
17typedef struct _ld_symbol_s _ld_symbol_t;
18
19extern _ld_symbol_t seg_iob_base;
20extern _ld_symbol_t seg_icu_base;
21extern _ld_symbol_t seg_tim_base;
22extern _ld_symbol_t seg_tty_base;
23extern _ld_symbol_t seg_gcd_base;
24extern _ld_symbol_t seg_dma_base;
25extern _ld_symbol_t seg_fbf_base;
26extern _ld_symbol_t seg_ioc_base;
27extern _ld_symbol_t seg_mapping_base;
28extern _ld_symbol_t seg_kernel_pt_base;
29
30///////////////////////////////////////////////////////////////////////////////////
31//      Prototypes of common functions
32///////////////////////////////////////////////////////////////////////////////////
33
34void                            _puts(char *string);
35void                            _putw(unsigned int val);
36void                            _putd(unsigned int val);
37
38unsigned int            _strncmp( const char* s1, 
39                              const char* s2, 
40                              unsigned int n );
41
42void                            _dcache_buf_invalidate( const void *buffer, 
43                                            unsigned int size );
44
45void                            _dtlb_off(void);
46void                            _dtlb_on(void);
47
48void                            _it_mask(void);
49void                            _it_enable(void);
50
51unsigned int            _get_epc(void);
52unsigned int            _get_ptpr(void);
53unsigned int            _get_bvar(void);
54unsigned int            _get_cr(void);
55unsigned int            _get_sched(void);
56
57unsigned int            _get_context_slot( unsigned int task_id, 
58                                       unsigned int slot_id );
59
60void                            _set_context_slot( unsigned int task_id, 
61                                       unsigned int slot_id, 
62                                       unsigned int value );
63
64unsigned int            _get_interrupt_vector_entry(unsigned int index);
65
66unsigned int            _get_current_task_id( void );
67void                            _set_current_task_id( unsigned int value );
68
69unsigned int            _get_tasks_number(void);
70
71
72void                            _get_lock(unsigned int* lock);
73void                            _release_lock(unsigned int* lock);
74
75mapping_cluster_t*  _get_cluster_base( mapping_header_t* header );
76mapping_pseg_t*     _get_pseg_base( mapping_header_t* header );
77mapping_vspace_t*   _get_vspace_base( mapping_header_t* header );
78mapping_vseg_t*     _get_vseg_base( mapping_header_t* header );
79mapping_vobj_t*     _get_vobj_base( mapping_header_t* header );
80mapping_task_t*     _get_task_base( mapping_header_t* header );
81
82
83///////////////////////////////////////////////////////////////////////////////////
84// memcpy() function
85// This function is likely not called directly by the GIET,
86// but GCC can automatically issue call to it during compilation,
87// so we must provide it.
88// Code taken from MutekH.
89///////////////////////////////////////////////////////////////////////////////////
90static inline void *memcpy(void *_dst, const void *_src, unsigned int size)
91{
92    unsigned int *dst = _dst;
93    const unsigned int *src = _src;
94
95    /* if source and destination buffer are word-aligned,
96     * then copy word-by-word */
97    if (!((unsigned int)dst & 3) && !((unsigned int)src & 3))
98        while (size > 3) {
99            *dst++ = *src++;
100            size -= 4;
101        }
102
103    unsigned char *cdst = (unsigned char*)dst;
104    unsigned char *csrc = (unsigned char*)src;
105
106    /* byte-by-byte copy */
107    while (size--) {
108        *cdst++ = *csrc++;
109    }
110    return _dst;
111}
112
113#endif
Note: See TracBrowser for help on using the repository browser.