\ ############################## \ Handle hexadecimal EFI GUID into a 2-word record on the heap \ The GUID text format consists is as a series of hexadecomal codes that \ maps to byte codes as follows \ 4 byte LE hexcode (8 digits) \ 2 x 2 byte LE hexcode (4 digits) \ 8 x 1 byte hexcode (2 digits) \ and with braces \ The following is a code example: \ ---- \ GUID: GOP.GUID \ {0x9042a9de,0x23dc,0x4a38, {0x96,0xfb,0x7a,0xde,0xd0,0x80,0x51,0x6a}} \ ---- \ Though, the parsing actually first grabs the word via CONSTANT, and then just\ scans for "x" as hex number prefix, thus reading like \ GUID: {word}*x........*x....*x....*x..*x..*x..*x..*x..*x..*x..*x..{word} \ where, as usual, "{word}" are anything up to reading the subsequent space. \ Allocate a variable for the list of all GUIDS HERE @ 0 , CONSTANT GUIDS ( [name] -- ; declare a guid constant with name and guid as per the above, ) ( Followed by pointer to the previous guid ) : GUID: HERE @ 0 , 0 , GUIDS @ , DUP CONSTANT DUP GUIDS ! 120 SCANTO HEX8 OVER C4! 4 + 2 BEGIN SWAP 120 SCANTO HEX4 OVER C2! 2 + SWAP 1 - DUP 0 = UNTIL DROP 8 BEGIN SWAP 120 SCANTO HEX2 OVER C! 1 + SWAP 1 - DUP 0 = UNTIL DROP DROP READ-WORD DROP DROP ; ( *guid -- *guid ; Get next GUID word ) : GUID.next 16 + @ ; ( *guid -- *chars length ; Find the dicitonary name of the guid ) : GUID.name 33 + S@ ; ( *guid1 *guid2 -- x ; Check if two GUID are equal ) : GUID= OVER @ OVER @ = IF 8 + @ SWAP 8 + @ = ELSE DROP DROP 0 THEN ; ( *guidp -- ; Tell name of GUID ) : GUID.Tellname DUP IF GUID.name ELSE DROP S" unknown" THEN TELL ; ( *guidp -- *guid ; Find dictionary guid same as the given ) : GUID.find GUIDS ( *guidp *list-guid ) BEGIN DUP NEWLINE DUP GUID.Tellname NEWLINE IF 2DUP GUID= IF SWAP EXIT THEN GUID.next ELSE SWAP EXIT THEN AGAIN ; ( *guid -- ; Print a GUID in parsable hex form ) : GUID.Tell DUP GUID.find GUID.Tellname S" = {0x" TELL DUP @ 4294967296 /MOD .U S" ,0x" TELL 65536 /MOD .U S" ,0x" TELL .U 8 + @ 8 BEGIN DUP 8 = IF S" ,{0x" ELSE S" ,0x" THEN TELL SWAP 256 /MOD .U SWAP 1 - DUP 0 = UNTIL DROP DROP S" }}" TELL ; \ ############################## \ System table entry labelling SystemTable \ EFI_TABLE_HEADER 8 FIELD* SystemTable.Signature 4 FIELD* SystemTable.Revision 4 FIELD* SystemTable.HeaderSize 4 FIELD* SystemTable.CRC32 4 FIELD* SystemTable.Reserved ( CHAR16 ) FIELD@ FirmwareVendor 4 FIELD* FirmwareRevision 4 FIELD* FirmwareRevisionPad \ -- stdio ( EFI_HANDLE ) FIELD@ ConsoleInHandle ( EFI_SIMPLE_TEXT_INPUT_PROTOCOL ) FIELD@ ConIn ( EFI_HANDLE ) FIELD@ ConsoleOutHandle ( EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL ) FIELD@ ConOut ( EFI_HANDLE ) FIELD@ StandardErrorHandle ( EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL ) FIELD@ StdErr \ -- services ( EFI_RUNTIME_SERVICES ) FIELD@ RuntimeServices ( EFI_BOOT_SERVICES ) FIELD@ BootServices \ -- ConfigurationTable 8 FIELD* SystemTable.NumberOfTableEntries \ UINTN = native size uint ( EFI_CONFIGURATION_TABLE ) FIELD@ ConfigurationTable DROP \ ############################## \ : ConOut entry labelling ConOut ( EFI_TEXT_RESET ) FIELD@ ConOut.Reset ( EFI_TEXT_STRING ) FIELD@ ConOut.OutputString ( EFI_TEXT_TEST_STRING ) FIELD@ ConOut.TestString ( EFI_TEXT_QUERY_MODE ) FIELD@ ConOut.QueryMode ( EFI_TEXT_SET_MODE ) FIELD@ ConOut.SetMode ( EFI_TEXT_SET_ATTRIBUTE ) FIELD@ ConOut.SetAttribute ( EFI_TEXT_CLEAR_SCREEN ) FIELD@ ConOut.ClearScreen ( EFI_TEXT_SET_CURSOR_POSITION ) FIELD@ ConOut.SetCursorPosition ( EFI_TEXT_ENABLE_CURSOR ) FIELD@ ConOut.EnableCursor ( SIMPLE_TEXT_OUTPUT_MODE ) FIELD@ ConOut.Mode DROP : ConOut.OutputString() ConOut SWAP ConOut.OutputString EFICALL2 ; : ConOut.ClearScreen() ConOut ConOut.ClearScreen EFICALL1 ; \ ############################## \ BootServices entry labelling 0 CONSTANT SearchKey.NONE \ ENUM EFI_LOCATE_SEARCH_TYPE 0 CONSTANT SearchType.AllHandles 1 CONSTANT SearchType.ByRegisterNotify 2 CONSTANT SearchType.ByProtocol BootServices \ EFI_TABLE_HEADER 8 FIELD* BootServices.Signature 4 FIELD* BootServices.Revision 4 FIELD* BootServices.HeaderSize 4 FIELD* BootServices.CRC32 4 FIELD* BootServices.Reserved \ Task Priority Services FIELD@ RaiseTPL FIELD@ RestoreTPL \ Memory Services FIELD@ AllocatePages FIELD@ FreePages FIELD@ GetMemoryMap FIELD@ AllocatePool FIELD@ FreePool \ Event & Timer Services FIELD@ CreateEvent FIELD@ SetTimer FIELD@ WaitForEvent FIELD@ SignalEvent FIELD@ CloseEvent FIELD@ CheckEvent \ Protocol Handler Services FIELD@ InstallProtocolInterface FIELD@ ReinstallProtocolInterface FIELD@ UninstallProtocolInterface FIELD@ HandleProtocol FIELD@ Reserved2 FIELD@ RegisterProtocolNotify FIELD@ LocateHandle FIELD@ LocateDevicePath FIELD@ InstallConfigurationTable \ Image Services FIELD@ LoadImage FIELD@ StartImage FIELD@ Exit FIELD@ UnloadImage FIELD@ ExitBootServices \ Miscellaneous Services FIELD@ GetNextMonotonicCount FIELD@ Stall FIELD@ SetWatchdogTimer \ DriverSupport Services FIELD@ ConnectController FIELD@ DisconnectController \ Open and Close Protocol Services FIELD@ OpenProtocol FIELD@ CloseProtocol FIELD@ OpenProtocolInformation \ Library Services FIELD@ ProtocolsPerHandle FIELD@ LocateHandleBuffer FIELD@ LocateProtocol FIELD@ InstallMultipleProtocolInterfaces FIELD@ UninstallMultipleProtocolInterfaces \ 32-bit CRC Services FIELD@ CalculateCrc32 \ Miscellaneous Services FIELD@ CopyMem FIELD@ SetMem FIELD@ CreateEventEx DROP ( buffer -- ) : BootServices.FreePool() FreePool EFICALL1 \ No return value? ; ( handle, *guid -- *interface ; Queries a handle to determine if it supports a specified protocol, and returns interface pointer or null ) : BootServices.HandleProtocol() HERE @ 0 OVER ! HandleProtocol EFICALL3 DUP IF S" **HandleProtocol: " TELL .U NEWLINE ELSE DROP THEN HERE @ @ ; ( Handle -- *buffer count ; Retrieves The List Of Protocol Interface GUIDs that are installed on a handle in a buffer allocated from pool. ) : BootServices.ProtocolsPerHandle() HERE @ 0 , HERE @ 0 , ProtocolsPerHandle EFICALL3 HERE @ 16 - @ HERE @ 8 - @ HERE @ 16 - HERE ! ROT DUP IF S" **ProtocolsPerHandle: " TELL .U NEWLINE ELSE DROP THEN ; ( *guid *Registration -- *Interface ; Returns the first protocol interface that matches the given protocol. ) : BootServices.LocateProtocol() HERE @ 0 OVER ! LocateProtocol EFICALL3 DUP IF S" **LocateProtocol: " TELL .U NEWLINE ELSE DROP THEN HERE @ @ ; ( *protocol type -- *array count ; locate handles ) ( returns array in allocated space ) : BootServices.LocateHandleBuffer() ( searchtype, protocol, searchkey, *count, *arrayp ) SWAP SearchKey.NONE HERE @ HERE @ 8 + ( type *protocol searchkey *count **array ) LocateHandleBuffer EFICALL5 DUP IF S" **LocateHandleBuffer: " TELL .U NEWLINE ELSE DROP THEN ( HERE@ = nohandles , *buffer ) HERE @ 8 + @ HERE @ @ ; ( -- buffer* n ; locate handles ) ( returns array in allocated space ) : BootServices.LocateHandleBuffer(AllHandles) 0 SearchType.AllHandles BootServices.LocateHandleBuffer() ; ( protocol -- buffer* n ; locate handles ) ( returns array in allocated space ) : BootServices.LocateHandleBuffer(ByProtocol) SearchType.ByProtocol BootServices.LocateHandleBuffer() ; \ ############################## \ GOP = GraphicsOutputProtocol GUID: GOP.GUID {0x9042a9de,0x23dc,0x4a38, {0x96,0xfb,0x7a,0xde,0xd0,0x80,0x51,0x6a}} GOP.GUID 0 BootServices.LocateProtocol() FIELD@ GOP.QueryMode FIELD@ GOP.SetMode FIELD@ GOP.Blt ( guid buffer mode sx sy dx dy dw dh pitch -- ) : GOP.Blt() GOP.Blt EFICALL10 0 = IF ELSE S" Warning: Invalid Blt()" TELL THEN ; \ ############################## \ DPP = EFI_DEVICE_PATH_PROTOCOL GUID: DPP.GUID {0x09576e91,0x6d3f,0x11d2, {0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b}} ( *protocol -- ; Tell about DPP protocol ) : DPP.Tell DUP @ 4294967295 & 256 /MOD S" DPP{" TELL . 256 /MOD S" ," TELL . DUP S" ," TELL . S" }" TELL SWAP 4 + SWAP .BYTES ; \ ############################## \ EFI_BLOCK_IO_MEDIA struct \ ############################## \ BIP = EFI_BLOCK_IO_PROTOCOL GUID: BIP.GUID 0x964e5b21,0x6459,0x11d2, {0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b}} \ ############################## \ LIP = LoadedImageProtocol GUID: LIP.GUID {0x5b1b31a1,0x9562,0x11d2, {0x8e,0x3f,0x00,0xa0,0xc9,0x69,0x72,0x3b}} \ ############################## \ SFSP = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL GUID: SFSP.GUID 0x0964e5b22,0x6459,0x11d2, {0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b}}