Implement UEFI functionality in Forth
[rrq/jonasforth.git] / uefi.f
1 : ConOut SystemTable 64 + @ ;
2 : ConOut.OutputString ConOut 8 + @ ;
3 : ConOut.OutputString() ConOut SWAP ConOut.OutputString EFICALL2 ;
4
5 : BootServices SystemTable 96 + @ ;
6 : BootServices.LocateProtocol BootServices 320 + @ ;
7 : GraphicsOutputProtocol
8   \ [TODO] It would be nice to cache this value, so we don't have to get it
9   \ every time.
10   HERE @ 5348063987722529246 , 7661046075708078998 , \ *Protocol = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID
11   0 \ *Registration
12   HERE @ 0 , \ **Interface
13   BootServices.LocateProtocol EFICALL3 DROP
14   HERE @ 8 - @ \ *Interface
15   ;
16 : GOP.Blt GraphicsOutputProtocol 16 + @ ;
17 : GOP.Blt() ( GOP buffer mode sx sy dx dy dw dh pitch -- )
18   GOP.Blt EFICALL10 0 = IF ELSE S" Warning: Invalid Blt()" TELL THEN ;
19 : GOP.SetMode GraphicsOutputProtocol 8 + @ ;
20
21 : EfiBltVideoFill 0 ;
22
23 \ Store a null-terminated UTF-16 string HERE, and return a pointer to its buffer
24 \ at runtime.
25 : UTF16"
26   HERE @
27   BEGIN
28     KEY DUP C,
29     0 C,
30   34 = UNTIL
31   HERE @ 2 - HERE ! \ Remove final "
32   0 C, 0 C, \ Null terminator
33   ;