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

Last change on this file since 235 was 232, checked in by meunier, 11 years ago

Ajout du malloc dans le Giet.

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