1 \ ##############################
2 \ Handle hexadecimal EFI GUID into a 2-word record on the heap
3 \ The GUID text format consists is as a series of hexadecomal codes that
4 \ maps to byte codes as follows
5 \ 4 byte LE hexcode (8 digits)
6 \ 2 x 2 byte LE hexcode (4 digits)
7 \ 8 x 1 byte hexcode (2 digits)
9 \ The following is a code example:
12 \ {0x9042a9de,0x23dc,0x4a38, {0x96,0xfb,0x7a,0xde,0xd0,0x80,0x51,0x6a}}
14 \ Though, the parsing actually first grabs the word via CONSTANT, and then just\ scans for "x" as hex number prefix, thus reading like
15 \ GUID: {word}*x........*x....*x....*x..*x..*x..*x..*x..*x..*x..*x..{word}
16 \ where, as usual, "{word}" are anything up to reading the subsequent space.
18 \ Allocate a variable for the list of all GUIDS
20 HERE @ 0 , CONSTANT GUIDS
22 ( [name] -- ; declare a guid constant with name and guid as per the above, )
23 ( Followed by pointer to the previous guid )
29 120 SCANTO HEX8 OVER C4! 4 +
30 2 BEGIN SWAP 120 SCANTO HEX4 OVER C2! 2 + SWAP 1 - DUP 0 = UNTIL DROP
31 8 BEGIN SWAP 120 SCANTO HEX2 OVER C! 1 + SWAP 1 - DUP 0 = UNTIL DROP
32 DROP READ-WORD DROP DROP
35 ( *guid -- *guid ; Get next GUID word )
38 ( *guid -- *chars length ; Find the dicitonary name of the guid )
41 ( *guid1 *guid2 -- x ; Check if two GUID are equal )
42 : GUID= OVER @ OVER @ = IF 8 + @ SWAP 8 + @ = ELSE DROP DROP 0 THEN ;
44 ( *guidp -- ; Tell name of GUID )
45 : GUID.Tellname DUP IF GUID.name ELSE DROP S" unknown" THEN TELL ;
47 ( *guidp -- *guid ; Find dictionary guid same as the given )
53 NEWLINE DUP GUID.Tellname NEWLINE
54 IF 2DUP GUID= IF SWAP EXIT THEN GUID.next ELSE SWAP EXIT THEN
58 ( *guid -- ; Print a GUID in parsable hex form )
60 DUP GUID.find GUID.Tellname
62 DUP @ 4294967296 /MOD .U S" ,0x" TELL
63 65536 /MOD .U S" ,0x" TELL .U
65 BEGIN DUP 8 = IF S" ,{0x" ELSE S" ,0x" THEN TELL
72 \ ##############################
73 \ System table entry labelling
77 8 FIELD* SystemTable.Signature
78 4 FIELD* SystemTable.Revision
79 4 FIELD* SystemTable.HeaderSize
80 4 FIELD* SystemTable.CRC32
81 4 FIELD* SystemTable.Reserved
82 ( CHAR16 ) FIELD@ FirmwareVendor
83 4 FIELD* FirmwareRevision
84 4 FIELD* FirmwareRevisionPad
86 ( EFI_HANDLE ) FIELD@ ConsoleInHandle
87 ( EFI_SIMPLE_TEXT_INPUT_PROTOCOL ) FIELD@ ConIn
88 ( EFI_HANDLE ) FIELD@ ConsoleOutHandle
89 ( EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL ) FIELD@ ConOut
90 ( EFI_HANDLE ) FIELD@ StandardErrorHandle
91 ( EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL ) FIELD@ StdErr
93 ( EFI_RUNTIME_SERVICES ) FIELD@ RuntimeServices
94 ( EFI_BOOT_SERVICES ) FIELD@ BootServices
95 \ -- ConfigurationTable
96 8 FIELD* SystemTable.NumberOfTableEntries \ UINTN = native size uint
97 ( EFI_CONFIGURATION_TABLE ) FIELD@ ConfigurationTable
100 \ ##############################
101 \ : ConOut entry labelling
104 ( EFI_TEXT_RESET ) FIELD@ ConOut.Reset
105 ( EFI_TEXT_STRING ) FIELD@ ConOut.OutputString
106 ( EFI_TEXT_TEST_STRING ) FIELD@ ConOut.TestString
107 ( EFI_TEXT_QUERY_MODE ) FIELD@ ConOut.QueryMode
108 ( EFI_TEXT_SET_MODE ) FIELD@ ConOut.SetMode
109 ( EFI_TEXT_SET_ATTRIBUTE ) FIELD@ ConOut.SetAttribute
110 ( EFI_TEXT_CLEAR_SCREEN ) FIELD@ ConOut.ClearScreen
111 ( EFI_TEXT_SET_CURSOR_POSITION ) FIELD@ ConOut.SetCursorPosition
112 ( EFI_TEXT_ENABLE_CURSOR ) FIELD@ ConOut.EnableCursor
113 ( SIMPLE_TEXT_OUTPUT_MODE ) FIELD@ ConOut.Mode
116 : ConOut.OutputString() ConOut SWAP ConOut.OutputString EFICALL2 ;
117 : ConOut.ClearScreen() ConOut ConOut.ClearScreen EFICALL1 ;
119 \ ##############################
120 \ BootServices entry labelling
122 0 CONSTANT SearchKey.NONE
124 \ ENUM EFI_LOCATE_SEARCH_TYPE
125 0 CONSTANT SearchType.AllHandles
126 1 CONSTANT SearchType.ByRegisterNotify
127 2 CONSTANT SearchType.ByProtocol
131 8 FIELD* BootServices.Signature
132 4 FIELD* BootServices.Revision
133 4 FIELD* BootServices.HeaderSize
134 4 FIELD* BootServices.CRC32
135 4 FIELD* BootServices.Reserved
136 \ Task Priority Services
145 \ Event & Timer Services
152 \ Protocol Handler Services
153 FIELD@ InstallProtocolInterface
154 FIELD@ ReinstallProtocolInterface
155 FIELD@ UninstallProtocolInterface
156 FIELD@ HandleProtocol
158 FIELD@ RegisterProtocolNotify
160 FIELD@ LocateDevicePath
161 FIELD@ InstallConfigurationTable
167 FIELD@ ExitBootServices
168 \ Miscellaneous Services
169 FIELD@ GetNextMonotonicCount
171 FIELD@ SetWatchdogTimer
172 \ DriverSupport Services
173 FIELD@ ConnectController
174 FIELD@ DisconnectController
175 \ Open and Close Protocol Services
178 FIELD@ OpenProtocolInformation
180 FIELD@ ProtocolsPerHandle
181 FIELD@ LocateHandleBuffer
182 FIELD@ LocateProtocol
183 FIELD@ InstallMultipleProtocolInterfaces
184 FIELD@ UninstallMultipleProtocolInterfaces
185 \ 32-bit CRC Services
186 FIELD@ CalculateCrc32
187 \ Miscellaneous Services
194 : BootServices.FreePool()
195 FreePool EFICALL1 \ No return value?
198 ( handle, *guid -- *interface ; Queries a handle to determine if it supports
199 a specified protocol, and returns interface pointer or null )
200 : BootServices.HandleProtocol()
201 HERE @ 0 OVER ! HandleProtocol EFICALL3
202 DUP IF S" **HandleProtocol: " TELL .U NEWLINE ELSE DROP THEN
206 ( Handle -- *buffer count ; Retrieves The List Of Protocol Interface
207 GUIDs that are installed on a handle in a buffer allocated from pool. )
208 : BootServices.ProtocolsPerHandle()
209 HERE @ 0 , HERE @ 0 , ProtocolsPerHandle EFICALL3
210 HERE @ 16 - @ HERE @ 8 - @ HERE @ 16 - HERE !
211 ROT DUP IF S" **ProtocolsPerHandle: " TELL .U NEWLINE ELSE DROP THEN
214 ( *guid *Registration -- *Interface ;
215 Returns the first protocol interface that matches the given protocol. )
216 : BootServices.LocateProtocol()
218 LocateProtocol EFICALL3
219 DUP IF S" **LocateProtocol: " TELL .U NEWLINE ELSE DROP THEN
223 ( *protocol type -- *array count ; locate handles )
224 ( returns array in allocated space )
225 : BootServices.LocateHandleBuffer()
226 ( searchtype, protocol, searchkey, *count, *arrayp )
227 SWAP SearchKey.NONE HERE @ HERE @ 8 +
228 ( type *protocol searchkey *count **array )
229 LocateHandleBuffer EFICALL5
230 DUP IF S" **LocateHandleBuffer: " TELL .U NEWLINE ELSE DROP THEN
231 ( HERE@ = nohandles , *buffer )
232 HERE @ 8 + @ HERE @ @
235 ( -- buffer* n ; locate handles )
236 ( returns array in allocated space )
237 : BootServices.LocateHandleBuffer(AllHandles)
238 0 SearchType.AllHandles BootServices.LocateHandleBuffer()
241 ( protocol -- buffer* n ; locate handles )
242 ( returns array in allocated space )
243 : BootServices.LocateHandleBuffer(ByProtocol)
244 SearchType.ByProtocol BootServices.LocateHandleBuffer()
247 \ ##############################
248 \ GOP = GraphicsOutputProtocol
251 {0x9042a9de,0x23dc,0x4a38, {0x96,0xfb,0x7a,0xde,0xd0,0x80,0x51,0x6a}}
253 GOP.GUID 0 BootServices.LocateProtocol()
258 ( guid buffer mode sx sy dx dy dw dh pitch -- )
260 GOP.Blt EFICALL10 0 =
261 IF ELSE S" Warning: Invalid Blt()" TELL THEN
264 \ ##############################
265 \ DPP = EFI_DEVICE_PATH_PROTOCOL
267 {0x09576e91,0x6d3f,0x11d2, {0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b}}
269 ( *protocol -- ; Tell about DPP protocol )
272 256 /MOD S" DPP{" TELL .
273 256 /MOD S" ," TELL .
280 \ ##############################
281 \ EFI_BLOCK_IO_MEDIA struct
284 \ ##############################
285 \ BIP = EFI_BLOCK_IO_PROTOCOL
287 0x964e5b21,0x6459,0x11d2, {0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b}}
289 \ ##############################
290 \ LIP = LoadedImageProtocol
292 {0x5b1b31a1,0x9562,0x11d2, {0x8e,0x3f,0x00,0xa0,0xc9,0x69,0x72,0x3b}}
294 \ ##############################
295 \ SFSP = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
297 0x0964e5b22,0x6459,0x11d2, {0x8e,0x39,0x00,0xa0,0xc9,0x69,0x72,0x3b}}