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

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

Major evolution to support physical addresses larger than 32 bits.
The map.xml format has been modified: the vsegs associated to schedulers
are now explicitely defined and mapped in the page tables.

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