commit 5f5c0d27ade3c1857df6d99591c7915385924434
parent 0b544320f42ecdd1b105aff22b56de2f80d4ecfa
Author: Christian Ermann <christianermann@gmail.com>
Date: Wed, 28 Aug 2024 19:04:00 -0400
Call UEFI ResetSystem
Diffstat:
3 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/base.forth b/base.forth
@@ -4,6 +4,12 @@
>CFA ,
;
+
+\ -----------------------------------------------------------------------------
+\
+\ Section X - Defining Primitives
+\
+
: CODE
WORD CREATE
LATEST @ >CFA 8 + ,
@@ -35,6 +41,20 @@
: PUSH IMMEDIATE 50 + C, ;
: POP IMMEDIATE 58 + C, ;
+: DEC-RSP IMMEDIATE
+ 48 C,
+ 83 C,
+ EC C,
+ 20 C,
+;
+
+: INC-RSP IMMEDIATE
+ 48 C,
+ 83 C,
+ C4 C,
+ 20 C,
+;
+
: CALL-INDIRECT IMMEDIATE
FF C,
10 + C,
diff --git a/efi.forth b/efi.forth
@@ -100,7 +100,7 @@ FIELD EFI:BootServices:CreateEventEx EFI:int64
ENDSTRUCT EFI:BootServices
STRUCT
-FIELD EFI:RuntimeServices:Hdr EFI:int64
+FIELD EFI:RuntimeServices:Hdr EFI:TableHeader
FIELD EFI:RuntimeServices:GetTime EFI:int64
FIELD EFI:RuntimeServices:SetTime EFI:int64
FIELD EFI:RuntimeServices:GetWakeupTime EFI:int64
@@ -117,6 +117,12 @@ FIELD EFI:RuntimeServices:QueryCapsuleCapabilities EFI:int64
FIELD EFI:RuntimeServices:QueryVariableInfo EFI:int64
ENDSTRUCT EFI:RuntimeServices
+: EFI:RuntimeServices:ResetSystem
+ EFI:SystemTablePtr @
+ EFI:SystemTable:RuntimeServices + @
+ EFI:RuntimeServices:ResetSystem +
+;
+
CODE EFI:CALL0
RAX POP
RAX CALL-INDIRECT
@@ -153,7 +159,9 @@ CODE EFI:CALL4
RDX POP
RCX POP
RAX POP
+ DEC-RSP
RAX CALL-INDIRECT
+ INC-RSP
RAX PUSH
;CODE
diff --git a/forth.asm b/forth.asm
@@ -1177,6 +1177,10 @@ defcode "LOAD_EFI", 8, 0, LOAD_EFI
mov [input_buffer.len], forth_efi.len
NEXT
+defcode "EFI:SystemTablePtr", 18, 0, EFI_SYSTEM_TABLE_PTR
+ push system_table
+ NEXT
+
section '.data' data readable writable
version_string db 'soup forth v0.1', 0xA