MOS Source Code
Loading...
Searching...
No Matches
platform_defs.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2
3#pragma once
4
5#include <mos/types.hpp>
6#include <mos_string.hpp>
7
8#define MOS_PLATFORM_PAGING_LEVELS 4
9
10#define MOS_PLATFORM_HAS_FDT 1
11
12#define PML2_HUGE_CAPABLE 1
13#define PML3_HUGE_CAPABLE 1
14#define PML4_HUGE_CAPABLE 1
15
16#define PML1_SHIFT 12
17#define PML2_SHIFT 21
18#define PML3_SHIFT 30
19#define PML4_SHIFT 39
20
21#define PML1_MASK 0x1FFULL
22#define PML2_MASK 0x1FFULL
23#define PML3_MASK 0x1FFULL
24#define PML4_MASK 0x1FFULL
25
26#define PML1_ENTRIES 512
27#define PML2_ENTRIES 512
28#define PML3_ENTRIES 512
29#define PML4_ENTRIES 512
30
31#define MOS_USER_END_VADDR 0x00007FFFFFFFFFFF
32#define MOS_KERNEL_START_VADDR 0xFFFF800000000000
33
34#define MOS_ELF_PLATFORM EM_RISCV
35
36#define MOS_PLATFORM_PANIC_INSTR "unimp"
37
38// clang-format off
39#define MOS_PLATFORM_PANIC_POINT_ASM \
40 ".quad 1b\n\t" \
41 ".quad %0\n\t" \
42 ".quad %1\n\t" \
43 ".quad %2\n\t"
44// clang-format on
45
46#define MOS_PLATFORM_DEBUG_MODULES(X) \
47 X(riscv64_startup) \
48 /**/
49
50#define MOS_PLATFORM_MEMORY_BARRIER() __asm__ __volatile__("fence.i" ::: "memory")
51
52struct platform_regs_t : mos::NamedType<"Platform.Registers">
53{
55 {
56 memzero(this, sizeof(*this));
57 }
58
60 {
61 *this = *regs;
62 }
63
67 reg_t a0, a1, a2, a3, a4, a5, a6, a7;
68 reg_t s2, s3, s4, s5, s6, s7, s8, s9, s10, s11;
70
71 // below are the CSR registers
73};
74
75typedef struct _platform_process_options
76{
79
80typedef struct _platform_thread_options
81{
82 reg64_t f[32]; // f0-f31
83 reg32_t fcsr; // fcsr
85
86typedef struct _platform_cpuinfo
87{
90
91typedef struct _platform_arch_info
92{
93 void *fdt;
#define memzero(ptr, size)
void * fdt
pointer to the device tree
platform_regs_t(const platform_regs_t *regs)
uintn reg_t
Definition types.h:47
unsigned int u32
Definition types.h:17
u32 reg32_t
Definition types.h:49
u64 reg64_t
Definition types.h:50
unsigned long ptr_t
Definition types.h:21