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

Last change on this file since 257 was 255, checked in by meunier, 11 years ago
  • Added a syscall and some user functions to manipulate the Simulation Helper
  • Changed the the way the Vseg -> Pseg mapping is made during the boot to better utilize the address space (+ adaptation of the algorithm in memo)
  • Fixed a bug in boot_init (vobj_init): the vobj initialization could only be made for the first application (ptpr was not changed)
File size: 4.4 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_xcu_base;
25extern _ld_symbol_t seg_tim_base;
26extern _ld_symbol_t seg_tty_base;
27extern _ld_symbol_t seg_gcd_base;
28extern _ld_symbol_t seg_dma_base;
29extern _ld_symbol_t seg_fbf_base;
30extern _ld_symbol_t seg_ioc_base;
31extern _ld_symbol_t seg_mmc_base;
32extern _ld_symbol_t seg_cma_base;
33extern _ld_symbol_t seg_sim_base;
34
35extern _ld_symbol_t vseg_cluster_increment;
36
37extern _ld_symbol_t seg_mapping_base;
38extern _ld_symbol_t seg_kernel_pt_base;
39
40///////////////////////////////////////////////////////////////////////////////////
41//     Prototypes of common functions
42///////////////////////////////////////////////////////////////////////////////////
43
44void                 _puts(char *string);
45void                 _putx(unsigned int val);
46void                 _putd(unsigned int val);
47void                 _putl(paddr_t val);
48
49unsigned int         _strncmp(const char * s1, 
50                              const char * s2, 
51                              unsigned int n);
52
53void                 _dcache_buf_invalidate(const void * buffer, 
54                                            unsigned int size);
55
56void                 _dtlb_off(void);
57void                 _dtlb_on(void);
58
59void                 _it_mask(void);
60void                 _it_restore(void);
61void                 _it_disable(void);
62void                 _it_enable(void);
63
64unsigned int         _get_epc(void);
65unsigned int         _get_ptpr(void);
66unsigned int         _get_bvar(void);
67unsigned int         _get_cr(void);
68
69static_scheduler_t*  _get_sched(void);
70
71unsigned int         _get_context_slot( unsigned int slot );
72
73void                 _set_context_slot( unsigned int slot,
74                                        unsigned int value );
75
76unsigned int         _get_task_slot( unsigned int ltid,
77                                     unsigned int slot );
78
79void                 _set_task_slot( unsigned int ltid,
80                                     unsigned int slot,
81                                     unsigned int value );
82
83void                 _get_lock(unsigned int * lock);
84void                 _release_lock(unsigned int * lock);
85
86mapping_cluster_t *  _get_cluster_base(mapping_header_t* header);
87mapping_pseg_t *     _get_pseg_base(mapping_header_t* header);
88mapping_vspace_t *   _get_vspace_base(mapping_header_t* header);
89mapping_vseg_t *     _get_vseg_base(mapping_header_t* header);
90mapping_vobj_t *     _get_vobj_base(mapping_header_t* header);
91mapping_task_t *     _get_task_base(mapping_header_t* header);
92
93
94///////////////////////////////////////////////////////////////////////////////////
95// memcpy() function
96// This function is likely not called directly by the GIET,
97// but GCC can automatically issue call to it during compilation,
98// so we must provide it.
99// Code taken from MutekH.
100///////////////////////////////////////////////////////////////////////////////////
101static inline void * memcpy(void * _dst, const void * _src, unsigned int size) {
102    unsigned int * dst = _dst;
103    const unsigned int * src = _src;
104
105    /* if source and destination buffer are word-aligned,
106     * then copy word-by-word */
107    if (!((unsigned int) dst & 3) && !((unsigned int) src & 3)) {
108        while (size > 3) {
109            *dst++ = *src++;
110            size -= 4;
111        }
112    }
113
114    unsigned char * cdst = (unsigned char *) dst;
115    unsigned char * csrc = (unsigned char *) src;
116
117    /* byte-by-byte copy */
118    while (size--) {
119        *cdst++ = *csrc++;
120    }
121    return _dst;
122}
123
124#endif
125
126// Local Variables:
127// tab-width: 4
128// c-basic-offset: 4
129// c-file-offsets:((innamespace . 0)(inline-open . 0))
130// indent-tabs-mode: nil
131// End:
132// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
133
Note: See TracBrowser for help on using the repository browser.