MOS Source Code
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2
3#pragma once
4
5#include <mos/mos_global.h>
6#include <stdbool.h>
7#include <stddef.h>
8
9typedef signed char s8;
10typedef signed short s16;
11typedef signed int s32;
12typedef signed long slong;
13typedef signed long long int s64;
14
15typedef unsigned char u8;
16typedef unsigned short u16;
17typedef unsigned int u32;
18typedef unsigned long ulong;
19typedef unsigned long long u64;
20
21typedef unsigned long ptr_t;
22typedef unsigned int ptr32_t;
23typedef unsigned long long ptr64_t;
24
25typedef signed long intn;
26typedef unsigned long uintn;
27
28// native integer type
29#define PTR_FMT "0x%16.16lx"
30#define PTR_VLFMT "0x%lx"
31
32#define PTR_RANGE "[" PTR_FMT " - " PTR_FMT "]"
33#define PTR_VLRANGE "[" PTR_VLFMT " - " PTR_VLFMT "]"
34#define PTR_RANGE64 "[0x%.16llx - 0x%.16llx]"
35
36// physical frame number
37typedef unsigned long long pfn_t;
38#define PFN_FMT "%llu"
39#define PFN_RANGE "[" PFN_FMT " - " PFN_FMT "]"
40#define PFNADDR_RANGE "[" PTR_FMT " - " PTR_FMT "] (PFN " PFN_FMT " - " PFN_FMT ")"
41
42#define PFNADDR(pfn, end) (((ptr_t) (pfn)) * MOS_PAGE_SIZE), ((((ptr_t) end) * MOS_PAGE_SIZE) - 1), (pfn), (end)
43
44MOS_STATIC_ASSERT(sizeof(void *) == 8, "pointer size check failed");
45MOS_STATIC_ASSERT(sizeof(ptr_t) == sizeof(void *), "ptr_t is not the same size as void *");
46
47typedef uintn reg_t; // native register type
48typedef u16 reg16_t; // 16-bit
49typedef u32 reg32_t; // 32-bit
50typedef u64 reg64_t; // 64-bit
51
52typedef union
53{
54 struct
55 {
56 bool b0 : 1;
57 bool b1 : 1;
58 bool b2 : 1;
59 bool b3 : 1;
60 bool b4 : 1;
61 bool b5 : 1;
62 bool b6 : 1;
63 bool msb : 1;
64 } __packed bits;
66} byte_t;
67
68MOS_STATIC_ASSERT(sizeof(byte_t) == 1, "byte_t is not 1 byte");
69
70typedef u32 id_t;
71typedef u32 uid_t;
72typedef u32 gid_t;
73
74typedef s32 pid_t;
75typedef s32 tid_t;
76
77typedef s32 fd_t;
78
79typedef signed long ssize_t;
80typedef ssize_t off_t;
81
82typedef long pte_content_t;
83
84#define new_named_opaque_type(base, name, type) \
85 typedef struct \
86 { \
87 base name; \
88 } type
89
90#define new_opaque_type(type, name) new_named_opaque_type(type, name, name##_t)
91#define new_opaque_ptr_type(name) new_named_opaque_type(ptr_t, ptr, name)
92
94
96
97#ifndef __cplusplus
98#define __atomic(type) _Atomic(type)
99typedef __atomic(size_t) atomic_t;
100#endif
#define __packed
Definition mos_global.h:29
#define MOS_STATIC_ASSERT
Definition mos_global.h:14
size_t hash
Definition types.h:93
uintn reg_t
Definition types.h:47
signed int s32
Definition types.h:11
unsigned int u32
Definition types.h:17
s32 futex_word_t
Definition types.h:95
signed char s8
Definition types.h:9
unsigned long long pfn_t
Definition types.h:37
ssize_t off_t
Definition types.h:80
unsigned long uintn
Definition types.h:26
signed long intn
Definition types.h:25
u32 uid_t
Definition types.h:71
s32 fd_t
Definition types.h:77
signed long long int s64
Definition types.h:13
signed short s16
Definition types.h:10
u16 reg16_t
Definition types.h:48
unsigned long ulong
Definition types.h:18
s32 tid_t
Definition types.h:75
u32 gid_t
Definition types.h:72
u32 reg32_t
Definition types.h:49
s32 pid_t
Definition types.h:74
unsigned short u16
Definition types.h:16
#define new_opaque_type(type, name)
Definition types.h:90
#define __atomic(type)
Definition types.h:98
u64 reg64_t
Definition types.h:50
unsigned int ptr32_t
Definition types.h:22
unsigned long ptr_t
Definition types.h:21
long pte_content_t
Definition types.h:82
unsigned long long u64
Definition types.h:19
signed long slong
Definition types.h:12
unsigned long long ptr64_t
Definition types.h:23
signed long ssize_t
Definition types.h:79
unsigned char u8
Definition types.h:15
u32 id_t
Definition types.h:70
std::atomic_size_t atomic_t
Definition types.hpp:11
Definition types.h:53
bool b1
Definition types.h:57
bool msb
Definition types.h:63
bool b5
Definition types.h:61
bool b3
Definition types.h:59
bool b2
Definition types.h:58
bool b4
Definition types.h:60
u8 byte
Definition types.h:65
bool b0
Definition types.h:56
bool b6
Definition types.h:62