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

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

Added support for memspaces and const.
Added an interrupt masking to the "giet_context_switch" syscall
Corrected two bugs in boot/boot_init.c (one minor and one regarding barriers initialization)
Reformatted the code in all files.

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