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

Last change on this file since 252 was 249, checked in by alain, 11 years ago

Various modifications to support IO Bridge,
and MEMC configuration interface.

File size: 4.2 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#include <giet_config.h>
13#include <ctx_handler.h>
14
15///////////////////////////////////////////////////////////////////////////////////
16// For retrieving base addresses defined in seg.ld file.
17///////////////////////////////////////////////////////////////////////////////////
18
19typedef struct _ld_symbol_s _ld_symbol_t;
20
21extern _ld_symbol_t seg_iob_base;
22extern _ld_symbol_t seg_nic_base;
23extern _ld_symbol_t seg_icu_base;
24extern _ld_symbol_t seg_tim_base;
25extern _ld_symbol_t seg_tty_base;
26extern _ld_symbol_t seg_gcd_base;
27extern _ld_symbol_t seg_dma_base;
28extern _ld_symbol_t seg_fbf_base;
29extern _ld_symbol_t seg_ioc_base;
30extern _ld_symbol_t seg_mmc_base;
31
32extern _ld_symbol_t seg_mapping_base;
33extern _ld_symbol_t seg_kernel_pt_base;
34
35///////////////////////////////////////////////////////////////////////////////////
36//     Prototypes of common functions
37///////////////////////////////////////////////////////////////////////////////////
38
39void                 _puts(char *string);
40void                 _putx(unsigned int val);
41void                 _putd(unsigned int val);
42void                 _putl(paddr_t val);
43
44unsigned int         _strncmp(const char * s1, 
45                              const char * s2, 
46                              unsigned int n);
47
48void                 _dcache_buf_invalidate(const void * buffer, 
49                                            unsigned int size);
50
51void                 _dtlb_off(void);
52void                 _dtlb_on(void);
53
54void                 _it_mask(void);
55void                 _it_restore(void);
56void                 _it_disable(void);
57void                 _it_enable(void);
58
59unsigned int         _get_epc(void);
60unsigned int         _get_ptpr(void);
61unsigned int         _get_bvar(void);
62unsigned int         _get_cr(void);
63
64static_scheduler_t*  _get_sched(void);
65
66unsigned int         _get_context_slot( unsigned int slot );
67
68void                 _set_context_slot( unsigned int slot,
69                                        unsigned int value );
70
71unsigned int         _get_task_slot( unsigned int ltid,
72                                     unsigned int slot );
73
74void                 _set_task_slot( unsigned int ltid,
75                                     unsigned int slot,
76                                     unsigned int value );
77
78void                 _get_lock(unsigned int * lock);
79void                 _release_lock(unsigned int * lock);
80
81mapping_cluster_t *  _get_cluster_base(mapping_header_t* header);
82mapping_pseg_t *     _get_pseg_base(mapping_header_t* header);
83mapping_vspace_t *   _get_vspace_base(mapping_header_t* header);
84mapping_vseg_t *     _get_vseg_base(mapping_header_t* header);
85mapping_vobj_t *     _get_vobj_base(mapping_header_t* header);
86mapping_task_t *     _get_task_base(mapping_header_t* header);
87
88
89///////////////////////////////////////////////////////////////////////////////////
90// memcpy() function
91// This function is likely not called directly by the GIET,
92// but GCC can automatically issue call to it during compilation,
93// so we must provide it.
94// Code taken from MutekH.
95///////////////////////////////////////////////////////////////////////////////////
96static inline void * memcpy(void * _dst, const void * _src, unsigned int size) {
97    unsigned int * dst = _dst;
98    const unsigned int * src = _src;
99
100    /* if source and destination buffer are word-aligned,
101     * then copy word-by-word */
102    if (!((unsigned int) dst & 3) && !((unsigned int) src & 3)) {
103        while (size > 3) {
104            *dst++ = *src++;
105            size -= 4;
106        }
107    }
108
109    unsigned char * cdst = (unsigned char *) dst;
110    unsigned char * csrc = (unsigned char *) src;
111
112    /* byte-by-byte copy */
113    while (size--) {
114        *cdst++ = *csrc++;
115    }
116    return _dst;
117}
118
119#endif
120
121// Local Variables:
122// tab-width: 4
123// c-basic-offset: 4
124// c-file-offsets:((innamespace . 0)(inline-open . 0))
125// indent-tabs-mode: nil
126// End:
127// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
128
Note: See TracBrowser for help on using the repository browser.