From: Jonas Hvid Date: Mon, 5 Oct 2020 01:33:07 +0000 (+0200) Subject: Support calling EFI functions directly from Forth X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=a391c86c2800f3b776bef167b7d43e33a03ec673;hp=0344d8645260cfe0f81912a775d775db39fc0624;p=rrq%2Fjonasforth.git Support calling EFI functions directly from Forth Obviously, this doesn't work with the Linux backend. Maybe we'll have to remove that again, since it would basically require a UEFI emulator. --- diff --git a/main.asm b/main.asm index 93e576f..54b2a5d 100644 --- a/main.asm +++ b/main.asm @@ -588,6 +588,27 @@ forth MAIN, 'MAIN' dq BRANCH, -8 * 2 dq TERMINATE +;; EFI: + +forth EFI_SYSTEM_TABLE_CONSTANT, 'SystemTable' + dq LIT, system_table, GET + dq EXIT + +forth_asm EFICALL2, 'EFICALL2' + pop rax ; function pointer + pop rdx ; 2nd argument + pop rcx ; 1st argument + + push rsi + + sub rsp, 32 + call rax + add rsp, 32 + + pop rsi + + next + ;; Built-in variables: forth STATE, 'STATE' @@ -665,6 +686,6 @@ return_stack_top: ;; include the file directly in the binary, and then interpret it at startup. sysf: file 'sys.f' -file 'example.f' +file 'uefi.f' sysf.len = $ - sysf diff --git a/uefi.f b/uefi.f new file mode 100644 index 0000000..bc030d1 --- /dev/null +++ b/uefi.f @@ -0,0 +1,7 @@ +: ConOut SystemTable 64 + @ ; +: ConOut.OutputString ConOut 8 + @ ; +: ConOut.OutputString() ConOut SWAP ConOut.OutputString EFICALL2 ; + +HERE @ + 97 C, 0 C, 98 C, 0 C, 99 C, 0 C, \ "ABC\0" +ConOut.OutputString()