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

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

Introducing the giet_vm and some example applications

File size: 2.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_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_boot_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_task_t*     _get_task_base( mapping_header_t* header );
52
53
54///////////////////////////////////////////////////////////////////////////////////
55// memcpy() function
56// This function is likely not called directly by the GIET,
57// but GCC can automatically issue call to it during compilation,
58// so we must provide it.
59// Code taken from MutekH.
60///////////////////////////////////////////////////////////////////////////////////
61static inline void *memcpy(void *_dst, const void *_src, unsigned int size)
62{
63    unsigned int *dst = _dst;
64    const unsigned int *src = _src;
65
66    /* if source and destination buffer are word-aligned,
67     * then copy word-by-word */
68    if (!((unsigned int)dst & 3) && !((unsigned int)src & 3))
69        while (size > 3) {
70            *dst++ = *src++;
71            size -= 4;
72        }
73
74    unsigned char *cdst = (unsigned char*)dst;
75    unsigned char *csrc = (unsigned char*)src;
76
77    /* byte-by-byte copy */
78    while (size--) {
79        *cdst++ = *csrc++;
80    }
81    return _dst;
82}
83
84#endif
Note: See TracBrowser for help on using the repository browser.