-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharch_arm64.asm
More file actions
86 lines (71 loc) · 1.81 KB
/
Copy patharch_arm64.asm
File metadata and controls
86 lines (71 loc) · 1.81 KB
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
;
; EFILOADER
; Copyright (C) 2026 a1ive <https://github.com/a1ive/efiloader>
;
; EFILOADER is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; EFILOADER is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with EFILOADER. If not, see <http://www.gnu.org/licenses/>.
;
AREA |.text|, CODE, READONLY, ALIGN=4
EXPORT ArchRestoreFirmwareContext
; VOID ArchRestoreFirmwareContext(
; const BL_FIRMWARE_PROCESSOR_STATE* State,
; const BL_FIRMWARE_PROCESSOR_STATE* PreviousState)
;
; State layout starts at BL_FIRMWARE_DESCRIPTOR_ARM64 + 0x18:
; +0x00 UINT64 SCTLR
; +0x08 UINT64 VBAR
; +0x10 UINT64 Reserved18
; +0x18 UINT64 Reserved20
; +0x20 UINT64 TPIDR
; +0x28 UINT32 CurrentEl
; +0x30 UINT64 TTBR0
; +0x38 UINT64 TTBR1
; +0x40 UINT64 TCR
; +0x48 UINT64 MAIR
; +0x50 UINT32 InterruptsEnabled
ArchRestoreFirmwareContext PROC
cbz x0, RestoreDone
msr daifset, #2
ldr x8, [x0, #0x30]
msr TTBR0_EL1, x8
isb sy
ldr x8, [x0, #0x38]
msr TTBR1_EL1, x8
isb sy
ldr x8, [x0, #0x48]
msr MAIR_EL1, x8
isb sy
ldr x8, [x0, #0x40]
msr TCR_EL1, x8
isb sy
mov x8, #0
tlbi VMALLE1, x8
dsb sy
isb sy
ldr x8, [x0, #0x20]
msr TPIDR_EL1, x8
dsb sy
ldr x8, [x0]
msr SCTLR_EL1, x8
dsb sy
isb sy
ldr x8, [x0, #0x08]
msr VBAR_EL1, x8
isb sy
ldr w8, [x0, #0x50]
cbz w8, RestoreDone
msr daifclr, #2
RestoreDone
ret
ENDP
END