source: trunk/hal/tsar_mips32/hal_types.h @ 1

Last change on this file since 1 was 1, checked in by alain, 5 years ago

First import

File size: 7.0 KB
Line 
1/*
2 * hal_types.h - common kernel types for MIPS 32 bits
3 *
4 * Author  Alain Greiner (2016)
5 *
6 * Copyright (c) UPMC Sorbonne Universites
7 *
8 * This file is part of ALMOS-MKH.
9 *
10 * ALMOS-MKH is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; version 2.0 of the License.
13 *
14 * ALMOS-MKH is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24#ifndef HAL_TYPES_H_
25#define HAL_TYPES_H_
26
27#include <almos_config.h>
28
29#ifndef NULL
30#define NULL (void*)        0
31#endif
32
33/**************************************************************************
34 *                      Exact-width integer types. 
35 **************************************************************************/
36
37typedef   signed           char     int8_t;
38typedef unsigned           char    uint8_t;
39
40typedef   signed           int      int16_t;
41typedef unsigned           int     uint16_t;
42
43typedef   signed long      int      int32_t;
44typedef unsigned long      int     uint32_t;
45
46typedef   signed long long int      int64_t;
47typedef unsigned long long int     uint64_t;
48
49/***************************************************************************
50 * Pthread related types
51 **************************************************************************/
52
53typedef uint32_t      pthread_t;               
54typedef uint32_t      pthread_mutexattr_t;
55typedef uint32_t      pthread_barrier_t;
56typedef uint32_t      pthread_barrierattr_t;
57typedef uint32_t      sem_t;
58typedef uint32_t      pthread_cond_t;
59typedef uint32_t      pthread_condattr_t;
60typedef uint32_t      pthread_rwlock_t;
61typedef uint32_t      pthread_rwlockattr_t;
62typedef uint32_t      pthread_key_t;
63
64/***************************************************************************
65 * Boolean type and macros
66 **************************************************************************/
67
68typedef uint32_t      bool_t;
69
70#define false         0
71#define true          1
72
73/***************************************************************************
74 * Kernel error type : signed
75 **************************************************************************/
76
77typedef int32_t       error_t;
78
79/***************************************************************************
80 * Time related type
81 **************************************************************************/
82
83typedef uint64_t      clock_t;   // for cycle counters
84
85/***************************************************************************
86 * Global Process identifier type / fixed format
87 * 16 MSB = cluster XY identifier
88 * 16 LSB = local process index
89 **************************************************************************/
90
91typedef uint32_t      pid_t; 
92
93/***************************************************************************
94 * Local Process index 
95 **************************************************************************/
96
97typedef uint16_t      lpid_t;
98
99/***************************************************************************
100 * Thread  identifier type / fixed format
101 * 16 MSB = cluster XY identifier
102 * 16 LSB = local thread index
103 **************************************************************************/
104
105typedef uint32_t      trdid_t;
106
107/***************************************************************************
108 * Local Thread index
109 **************************************************************************/
110
111typedef uint16_t      ltid_t;
112
113/***************************************************************************
114 * User identifier type
115 **************************************************************************/
116
117typedef uint32_t      uid_t;
118
119/***************************************************************************
120 * CPU identifier types
121 **************************************************************************/
122
123typedef uint32_t      lid_t;   // local index in cluster
124typedef uint32_t      gid_t;   // global (hardware) identifier
125
126/***************************************************************************
127 * File Descriptor Index in File Descriptor Array
128 **************************************************************************/
129
130typedef uint32_t      fdid_t;
131
132/***************************************************************************
133 * This structure defines a single 32 bits integer alone in a cache line.
134 **************************************************************************/
135
136typedef struct cache_line_s
137{
138  union
139  {
140    uint32_t values[CONFIG_CACHE_LINE_SIZE>>2];
141    uint32_t value;
142  };
143}
144__attribute__((packed)) cacheline_t;
145
146#define CACHELINE_ALIGNED __attribute__((aligned(CONFIG_CACHE_LINE_SIZE)))
147
148/***************************************************************************
149 *  Address types and macros         !!!  hardware dependant  !!!
150 ***************************************************************************
151 * An extended pointer a 64 bits integer, structured in two fields :
152 * - cxy : cluster identifier.
153 * - ptr : pointer in the virtual space of a single cluster.
154 *
155 * In TSAR (MIPS32), the kernel virtual space has 4 Gbytes per cluster
156 * - the cxy field occupies bits[47:32]
157 * - the ptr field occupies bits[31:0]
158 ***************************************************************************
159 * A physical address is a 64 bits integer, structured in two fields :
160 * - cxy : cluster identifier.
161 * - lpa : local physical address inside cluster.
162 *
163 * In TSAR (MIPS32), the physical space has 4Gbytes per cluster.
164 * - the cxy field occupies bits[39:32]
165 * - the lpa field occupies bits[31:0]
166 **************************************************************************/
167
168typedef uint32_t               reg_t;         // core register
169
170typedef uint64_t               xptr_t;        // extended pointer
171
172typedef uint16_t               cxy_t;         // cluster identifier
173
174typedef uint64_t               paddr_t;       // global physical address
175
176typedef uint32_t               lpa_t;         // local physical address
177
178typedef uint32_t               intptr_t;      // local pointer stored as integer
179
180typedef uint32_t               ppn_t;         // Physical Page Number
181
182typedef uint32_t               vpn_t;         // Virtual Page number
183
184#define XPTR_NULL              0
185
186#define PTR_MASK               ((1ULL)<<31)
187
188#define GET_CXY(xp)            ((cxy_t)((xp) >> 32))
189
190#define GET_PTR(xp)            ((void*)(uint32_t)((xp) & PTR_MASK))
191
192#define XPTR(cxy,ptr)          (((uint64_t)(cxy) << 32) | (((uint32_t)(ptr)) & PTR_MASK))
193
194#define LPA_MASK               ((1ULL)<<31)
195
196#define CXY_FROM_PADDR(paddr)  ((cxy_t)((paddr) >> 32))
197
198#define LPA_FROM_PADDR(paddr)  (lpa_t)((paddr & LPA_MASK)
199
200#define PADDR(cxy,lpa)         (((uint64_t)(cxy) << 32) | (((uint64_t)(lpa)) & LPA_MASK))
201
202
203
204#endif  /* HAL_TYPES_H_ */
Note: See TracBrowser for help on using the repository browser.