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

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

Introducing support for IOMMU

File size: 2.9 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_timer_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_fb_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);
36
37unsigned int _strncmp(const char* s1, const char* s2, unsigned int n);
38
39void _dcache_buf_invalidate(const void *buffer, unsigned int size);
40
41void _itoa_dec(unsigned int val, char* buf);
42void _itoa_hex(unsigned int val, char* buf);
43
44unsigned int _get_epc();
45unsigned int _get_ptpr();
46unsigned int _get_bar();
47unsigned int _get_cr();
48
49void _get_lock(unsigned int* lock);
50void _release_lock(unsigned int* lock);
51
52mapping_cluster_t*  _get_cluster_base( mapping_header_t* header );
53mapping_pseg_t*     _get_pseg_base( mapping_header_t* header );
54mapping_vspace_t*   _get_vspace_base( mapping_header_t* header );
55mapping_vseg_t*     _get_vseg_base( mapping_header_t* header );
56mapping_vobj_t*     _get_vobj_base( mapping_header_t* header );
57mapping_task_t*     _get_task_base( mapping_header_t* header );
58
59
60///////////////////////////////////////////////////////////////////////////////////
61// memcpy() function
62// This function is likely not called directly by the GIET,
63// but GCC can automatically issue call to it during compilation,
64// so we must provide it.
65// Code taken from MutekH.
66///////////////////////////////////////////////////////////////////////////////////
67static inline void *memcpy(void *_dst, const void *_src, unsigned int size)
68{
69    unsigned int *dst = _dst;
70    const unsigned int *src = _src;
71
72    /* if source and destination buffer are word-aligned,
73     * then copy word-by-word */
74    if (!((unsigned int)dst & 3) && !((unsigned int)src & 3))
75        while (size > 3) {
76            *dst++ = *src++;
77            size -= 4;
78        }
79
80    unsigned char *cdst = (unsigned char*)dst;
81    unsigned char *csrc = (unsigned char*)src;
82
83    /* byte-by-byte copy */
84    while (size--) {
85        *cdst++ = *csrc++;
86    }
87    return _dst;
88}
89
90#endif
Note: See TracBrowser for help on using the repository browser.