source: trunk/hal/x86_64/hal_types.h @ 32

Last change on this file since 32 was 32, checked in by max@…, 5 years ago

Update. Retrieve and parse the multiboot info, and dump the mmap. Some
more sanity checks could probably be added.

File size: 7.2 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 <kernel_config.h>
28
29#ifndef NULL
30#define NULL (void*)        0
31#endif
32
33#define __packed        __attribute__((__packed__))
34#define __arraycount(a) (sizeof(a) / sizeof(*(a)))
35#define __in_kdata      __attribute__((section(".kdata")))
36
37/**************************************************************************
38 *                      Exact-width integer types. 
39 **************************************************************************/
40
41typedef   signed           char      int8_t;
42typedef unsigned           char     uint8_t;
43
44typedef   signed           short    int16_t;
45typedef unsigned           short   uint16_t;
46
47typedef          int                int32_t;
48typedef unsigned int               uint32_t;
49
50typedef   signed long long int      int64_t;
51typedef unsigned long long int     uint64_t;
52
53typedef uint64_t                     size_t;
54
55typedef uint64_t                    vaddr_t; // XXX
56
57/***************************************************************************
58 * Pthread related types
59 **************************************************************************/
60
61typedef uint32_t      pthread_t;               
62typedef uint32_t      pthread_mutexattr_t;
63typedef uint32_t      pthread_barrier_t;
64typedef uint32_t      pthread_barrierattr_t;
65typedef uint32_t      sem_t;
66typedef uint32_t      pthread_cond_t;
67typedef uint32_t      pthread_condattr_t;
68typedef uint32_t      pthread_rwlock_t;
69typedef uint32_t      pthread_rwlockattr_t;
70typedef uint32_t      pthread_key_t;
71
72/***************************************************************************
73 * Boolean type and macros
74 **************************************************************************/
75
76typedef uint32_t      bool_t;
77
78#define false         0
79#define true          1
80
81/***************************************************************************
82 * Kernel error type : signed
83 **************************************************************************/
84
85typedef int32_t       error_t;
86
87/***************************************************************************
88 * Time related type
89 **************************************************************************/
90
91typedef uint64_t      cycle_t;   // for cycle counters
92
93/***************************************************************************
94 * Global Process identifier type / fixed format
95 * 16 MSB = cluster XY identifier
96 * 16 LSB = local process index
97 **************************************************************************/
98
99typedef uint32_t      pid_t; 
100
101/***************************************************************************
102 * Local Process index 
103 **************************************************************************/
104
105typedef uint16_t      lpid_t;
106
107/***************************************************************************
108 * Thread  identifier type / fixed format
109 * 16 MSB = cluster XY identifier
110 * 16 LSB = local thread index
111 **************************************************************************/
112
113typedef uint32_t      trdid_t;
114
115/***************************************************************************
116 * Local Thread index
117 **************************************************************************/
118
119typedef uint16_t      ltid_t;
120
121/***************************************************************************
122 * User identifier type
123 **************************************************************************/
124
125typedef uint32_t      uid_t;
126
127/***************************************************************************
128 * CPU identifier types
129 **************************************************************************/
130
131typedef uint16_t      lid_t;    // local index in cluster
132typedef uint32_t      gid_t;    // global (hardware) identifier
133
134/***************************************************************************
135 * File Descriptor Index in File Descriptor Array
136 **************************************************************************/
137
138typedef uint32_t      fdid_t;
139
140/***************************************************************************
141 * This structure defines a single 32 bits integer alone in a cache line.
142 **************************************************************************/
143
144typedef struct cache_line_s
145{
146  union
147  {
148    uint32_t values[CONFIG_CACHE_LINE_SIZE>>2];
149    uint32_t value;
150  };
151}
152__attribute__((packed)) cacheline_t;
153
154/***************************************************************************
155 *  Address types and macros         !!!  hardware dependant  !!!
156 ***************************************************************************
157 * An extended pointer a 64 bits integer, structured in two fields :
158 * - cxy : cluster identifier.
159 * - ptr : pointer in the virtual space of a single cluster.
160 *
161 * In TSAR (MIPS32), the kernel virtual space has 4 Gbytes per cluster
162 * - the cxy field occupies bits[47:32]
163 * - the ptr field occupies bits[31:0]
164 ***************************************************************************
165 * A physical address is a 64 bits integer, structured in two fields :
166 * - cxy : cluster identifier.
167 * - lpa : local physical address inside cluster.
168 *
169 * In TSAR (MIPS32), the physical space has 4Gbytes per cluster.
170 * - the cxy field occupies bits[39:32]
171 * - the lpa field occupies bits[31:0]
172 **************************************************************************/
173
174typedef uint32_t               reg_t;         // core register
175
176typedef uint64_t               xptr_t;        // extended pointer
177
178typedef uint16_t               cxy_t;         // cluster identifier
179
180typedef uint64_t               paddr_t;       // global physical address
181
182typedef uint32_t               lpa_t;         // local physical address
183
184typedef uint64_t               intptr_t;      // local pointer stored as integer
185
186typedef uint32_t               ppn_t;         // Physical Page Number
187
188typedef uint32_t               vpn_t;         // Virtual Page number
189
190#define XPTR_NULL              0
191
192#define PTR_MASK               0x00000000FFFFFFFFULL
193
194#define GET_CXY(xp)            ((cxy_t)((xp) >> 32))
195
196#define GET_PTR(xp)            ((void*)(uint32_t)((xp) & PTR_MASK))
197
198#define XPTR(cxy,ptr)          (((uint64_t)(cxy) << 32) | (((uint32_t)(ptr)) & PTR_MASK))
199
200#define LPA_MASK               0x00000000FFFFFFFFULL
201
202#define CXY_FROM_PADDR(paddr)  ((cxy_t)((paddr) >> 32))
203
204#define LPA_FROM_PADDR(paddr)  (lpa_t)((paddr & LPA_MASK)
205
206#define PADDR(cxy,lpa)         (((uint64_t)(cxy) << 32) | (((uint64_t)(lpa)) & LPA_MASK))
207
208
209
210#endif  /* HAL_TYPES_H_ */
Note: See TracBrowser for help on using the repository browser.