From fe5967a09f12cc09640d8284ac6f554ee3bf4357 Mon Sep 17 00:00:00 2001 From: Jonas Hvid Date: Mon, 5 Oct 2020 06:22:27 +0200 Subject: [PATCH] Use Graphics Output Protocol to draw a rectangle --- main.asm | 46 ++++++++++++++++++++++++++++++++++++++++++++-- uefi.f | 25 ++++++++++++++++++++++++- 2 files changed, 68 insertions(+), 3 deletions(-) diff --git a/main.asm b/main.asm index 54b2a5d..e510410 100644 --- a/main.asm +++ b/main.asm @@ -599,13 +599,55 @@ forth_asm EFICALL2, 'EFICALL2' pop rdx ; 2nd argument pop rcx ; 1st argument - push rsi + sub rsp, 32 + call rax + add rsp, 32 + + next + +forth_asm EFICALL3, 'EFICALL3' + pop rax ; function pointer + pop r8 ; 3rd argument + pop rdx ; 2nd argument + pop rcx ; 1st argument sub rsp, 32 call rax add rsp, 32 - pop rsi + push rax + + next + +forth_asm EFICALL10, 'EFICALL10' + pop rax ; function pointer + + mov rcx, [rsp + 8 * 9] + mov rdx, [rsp + 8 * 8] + mov r8, [rsp + 8 * 7] + mov r9, [rsp + 8 * 6] + + ;; Reverse order of stack arguments + mov r10, [rsp + 8 * 5] + mov r11, [rsp + 8 * 0] + mov [rsp + 8 * 5], r11 + mov [rsp + 8 * 0], r10 + + mov r10, [rsp + 8 * 4] + mov r11, [rsp + 8 * 1] + mov [rsp + 8 * 4], r11 + mov [rsp + 8 * 1], r10 + + mov r10, [rsp + 8 * 3] + mov r11, [rsp + 8 * 2] + mov [rsp + 8 * 3], r11 + mov [rsp + 8 * 2], r10 + + sub rsp, 32 + call rax + add rsp, 32 + 8 * 10 + + push rax next diff --git a/uefi.f b/uefi.f index 03587a8..91ea453 100644 --- a/uefi.f +++ b/uefi.f @@ -2,6 +2,18 @@ : ConOut.OutputString ConOut 8 + @ ; : ConOut.OutputString() ConOut SWAP ConOut.OutputString EFICALL2 ; +: BootServices SystemTable 96 + @ ; +: BootServices.LocateProtocol BootServices 320 + @ ; +: BootServices.LocateProtocol(GOP) + HERE @ 5348063987722529246 , 7661046075708078998 , \ *Protocol = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID + 0 \ *Registration + HERE @ 0 , \ **Interface + BootServices.LocateProtocol EFICALL3 DROP + HERE @ 8 - @ \ *Interface + ; +: GOP.Blt BootServices.LocateProtocol(GOP) 16 + @ ; +: GOP.SetMode BootServices.LocateProtocol(GOP) 8 + @ ; + \ Store a null-terminated UTF-16 string HERE, and return a pointer to its buffer \ at runtime. : UTF16" @@ -14,4 +26,15 @@ 0 C, 0 C, \ Null terminator ; -UTF16" Hello UEFI!" ConOut.OutputString() + BootServices.LocateProtocol(GOP) \ *This + HERE @ 255 C, 0 C, 0 C, 0 C, \ *BltBuffer = single blue pixel + 0 \ BltOperation = EfiBltVideoFill + 0 \ SourceX + 0 \ SourceY + 100 \ DestinationX + 200 \ DestinationY + 400 \ Width + 20 \ Height + 0 \ Delta (unused) +GOP.Blt EFICALL10 +.U NEWLINE -- 2.39.2