MOS Source Code
Loading...
Searching...
No Matches
cpu.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 <
mos/types.h
>
7
8
typedef
struct
_platform_regs
9
{
10
reg_t
ra, sp,
gp
, tp;
11
reg_t
t0
, t1, t2;
12
reg_t
fp
, s1;
13
reg_t
a0
, a1, a2, a3, a4, a5, a6, a7;
14
reg_t
s2, s3, s4, s5, s6, s7,
s8
, s9,
s10
, s11;
15
reg_t
t3
, t4, t5, t6;
16
17
// below are the CSR registers
18
reg_t
sstatus,
sepc
;
19
}
__packed
platform_regs_t
;
20
21
MOS_STATIC_ASSERT
(
sizeof
(
platform_regs_t
) == 264,
"please also change cpu/interrupt.S"
);
22
23
#define read_csr(reg) statement_expr(reg_t, { asm volatile("csrr %0, " #reg : "=r"(retval)); })
24
#define write_csr(reg, val) __asm__ volatile("csrw " #reg ", %0" ::"r"(val))
25
26
#define make_satp(mode, asid, ppn) ((u64) (mode) << 60 | ((u64) (asid) << 44) | (ppn))
27
28
#define SATP_MODE_SV39 8
29
#define SATP_MODE_SV48 9
30
#define SATP_MODE_SV57 10
31
32
#define SSTATUS_SIE BIT(1)
// Supervisor Interrupt Enable
33
#define SSTATUS_SPIE BIT(5)
// Supervisor Previous Interrupt Enable
34
#define SSTATUS_SPP BIT(8)
// Supervisor Previous Privilege
35
#define SSTATUS_SUM BIT(18)
// Supervisor User Memory Access Enable
36
37
#define SSTATUS_FS_OFF 0
38
#define SSTATUS_FS_INITIAL BIT(13)
39
#define SSTATUS_FS_CLEAN BIT(14)
40
#define SSTATUS_FS_DIRTY (BIT(13) | BIT(14))
41
42
#define SIE_SEIE BIT(9)
43
#define SIE_STIE BIT(5)
44
#define SIE_SSIE BIT(1)
45
46
[[noreturn]]
extern
void
riscv64_trap_exit
(
platform_regs_t
*regs);
47
48
extern
const
char
__riscv64_trap_entry
[];
49
extern
const
char
__riscv64_usermode_trap_entry
[];
mos_global.h
__packed
#define __packed
Definition
mos_global.h:29
MOS_STATIC_ASSERT
#define MOS_STATIC_ASSERT
Definition
mos_global.h:14
platform_regs_t
struct _platform_regs platform_regs_t
Definition
platform.h:86
__riscv64_usermode_trap_entry
const char __riscv64_usermode_trap_entry[]
riscv64_trap_exit
void riscv64_trap_exit(platform_regs_t *regs)
__riscv64_trap_entry
const char __riscv64_trap_entry[]
platform_regs_t
Definition
cpu.h:9
platform_regs_t::sepc
reg_t sepc
Definition
cpu.h:18
platform_regs_t::t3
reg_t t3
Definition
cpu.h:15
platform_regs_t::a0
reg_t a0
Definition
cpu.h:13
platform_regs_t::gp
reg_t gp
Definition
cpu.h:10
platform_regs_t::s10
reg_t s10
Definition
cpu.h:14
platform_regs_t::t0
reg_t t0
Definition
cpu.h:11
platform_regs_t::fp
reg_t fp
Definition
cpu.h:12
types.h
reg_t
uintn reg_t
Definition
types.h:51
s8
signed char s8
Definition
types.h:13
kernel
arch
riscv64
include
private
mos
riscv64
cpu
cpu.h
Generated on Sun Sep 1 2024 18:22:52 for MOS Source Code by
1.12.0