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

Last change on this file since 160 was 160, checked in by karaoui, 12 years ago

giet-vm new version

File size: 2.8 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_icu_base;
20extern _ld_symbol_t seg_timer_base;
21extern _ld_symbol_t seg_tty_base;
22extern _ld_symbol_t seg_gcd_base;
23extern _ld_symbol_t seg_dma_base;
24extern _ld_symbol_t seg_fb_base;
25extern _ld_symbol_t seg_ioc_base;
26extern _ld_symbol_t seg_mapping_base;
27extern _ld_symbol_t seg_kernel_pt_base;
28
29///////////////////////////////////////////////////////////////////////////////////
30//      Prototypes of common functions
31///////////////////////////////////////////////////////////////////////////////////
32
33void _puts(char *string);
34void _putw(unsigned int val);
35
36unsigned int _strncmp(const char* s1, const char* s2, unsigned int n);
37
38void _dcache_buf_invalidate(const void *buffer, unsigned int size);
39
40void _itoa_dec(unsigned int val, char* buf);
41void _itoa_hex(unsigned int val, char* buf);
42
43unsigned int _get_epc();
44unsigned int _get_bar();
45unsigned int _get_cr();
46
47mapping_cluster_t*  _get_cluster_base( mapping_header_t* header );
48mapping_pseg_t*     _get_pseg_base( mapping_header_t* header );
49mapping_vspace_t*   _get_vspace_base( mapping_header_t* header );
50mapping_vseg_t*     _get_vseg_base( mapping_header_t* header );
51mapping_vobj_t*     _get_vobj_base( mapping_header_t* header );
52mapping_task_t*     _get_task_base( mapping_header_t* header );
53
54
55///////////////////////////////////////////////////////////////////////////////////
56// memcpy() function
57// This function is likely not called directly by the GIET,
58// but GCC can automatically issue call to it during compilation,
59// so we must provide it.
60// Code taken from MutekH.
61///////////////////////////////////////////////////////////////////////////////////
62static inline void *memcpy(void *_dst, const void *_src, unsigned int size)
63{
64    unsigned int *dst = _dst;
65    const unsigned int *src = _src;
66
67    /* if source and destination buffer are word-aligned,
68     * then copy word-by-word */
69    if (!((unsigned int)dst & 3) && !((unsigned int)src & 3))
70        while (size > 3) {
71            *dst++ = *src++;
72            size -= 4;
73        }
74
75    unsigned char *cdst = (unsigned char*)dst;
76    unsigned char *csrc = (unsigned char*)src;
77
78    /* byte-by-byte copy */
79    while (size--) {
80        *cdst++ = *csrc++;
81    }
82    return _dst;
83}
84
85#endif
Note: See TracBrowser for help on using the repository browser.