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

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

Introducing support for Network controller

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