hc
2024-03-25 edb30157bad0c0001c32b854271ace01d3b9a16a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//------------------------------------------------------------------------------
//
// RISC-V CPU functions.
//
// Copyright (c) 2016 - 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
//------------------------------------------------------------------------------
#include <Base.h>
#include <RiscVImpl.h>
 
.data
 
.text
.align 3
 
//
// Set machine mode scratch.
// @param a0 : Pointer to RISCV_MACHINE_MODE_CONTEXT.
//
ASM_FUNC (RiscVSetMachineScratch)
    csrrw a1, RISCV_CSR_MACHINE_MSCRATCH, a0
    ret
 
//
// Get machine mode scratch.
// @retval a0 : Pointer to RISCV_MACHINE_MODE_CONTEXT.
//
ASM_FUNC (RiscVGetMachineScratch)
    csrrs a0, RISCV_CSR_MACHINE_MSCRATCH, 0
    ret
 
//
// Get machine trap cause CSR.
//
ASM_FUNC (RiscVGetMachineTrapCause)
    csrrs a0, RISCV_CSR_MACHINE_MCAUSE, 0
    ret
 
//
// Get machine interrupt enable
//
ASM_FUNC (RiscVReadMachineInterruptEnable)
    csrr a0, RISCV_CSR_MACHINE_MIE
    ret
 
//
// Get machine interrupt pending
//
ASM_FUNC (RiscVReadMachineInterruptPending)
    csrr a0, RISCV_CSR_MACHINE_MIP
    ret
 
//
// Get machine status
//
ASM_FUNC (RiscVReadMachineStatus)
    csrr a0, RISCV_CSR_MACHINE_MSTATUS
    ret
 
//
// Set machine status
//
ASM_FUNC (RiscVWriteMachineStatus)
    csrw RISCV_CSR_MACHINE_MSTATUS, a0
    ret
 
//
// Get machine trap vector
//
ASM_FUNC (RiscVReadMachineTrapVector)
    csrr a0, RISCV_CSR_MACHINE_MTVEC
    ret
 
//
// Read machine ISA
//
ASM_FUNC (RiscVReadMachineIsa)
    csrr a0, RISCV_CSR_MACHINE_MISA
    ret
 
//
// Read machine vendor ID
//
ASM_FUNC (RiscVReadMachineVendorId)
    csrr a0, RISCV_CSR_MACHINE_MVENDORID
    ret
 
//
// Read machine architecture ID
//
ASM_FUNC (RiscVReadMachineArchitectureId)
    csrr a0, RISCV_CSR_MACHINE_MARCHID
    ret
 
//
// Read machine implementation ID
//
ASM_FUNC (RiscVReadMachineImplementId)
    csrr a0, RISCV_CSR_MACHINE_MIMPID
    ret
 
//
// Set Supervisor Address Translation and
// Protection Register.
//
ASM_FUNC (RiscVSetSupervisorAddressTranslationRegister)
    csrw  RISCV_CSR_SUPERVISOR_SATP, a0
    ret