cfdd6877ebe4ab638fbaa11c15136a03cec204ac
[reactos.git] / reactos / boot / environ / include / bl.h
1 /*
2 * COPYRIGHT: See COPYING.ARM in the top level directory
3 * PROJECT: ReactOS UEFI Boot Library
4 * FILE: boot/environ/include/bl.h
5 * PURPOSE: Main Boot Library Header
6 * PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
7 */
8
9 #ifndef _BL_H
10 #define _BL_H
11
12 /* INCLUDES ******************************************************************/
13
14 /* C Headers */
15 #include <stdlib.h>
16 #include <stdio.h>
17 #include <wchar.h>
18
19 /* NT Base Headers */
20 #include <ntifs.h>
21
22 /* NDK Headers */
23 #include <ntndk.h>
24
25 /* NT SafeInt Header */
26 #include <ntintsafe.h>
27
28 /* PE Headers */
29 #include <ntimage.h>
30
31 /* ACPI Headers */
32 #include <drivers/acpi/acpi.h>
33
34 /* UEFI Headers */
35 #include <Uefi.h>
36 #include <DevicePath.h>
37 #include <LoadedImage.h>
38 #include <GraphicsOutput.h>
39 #include <UgaDraw.h>
40 #include <BlockIo.h>
41 #include <Acpi.h>
42 #include <GlobalVariable.h>
43
44 /* Registry Headers */
45 #define __FREELDR_H
46 #include <cmlib.h>
47
48 /* DEFINES *******************************************************************/
49
50 DEFINE_GUID(BadMemoryGuid, 0x54B8275B, 0xD431, 0x473F, 0xAC, 0xFB, 0xE5, 0x36, 0xA0, 0x84, 0x94, 0xA3);
51
52 #define BL_APPLICATION_FLAG_CONVERTED_FROM_EFI 0x01
53
54 #define BL_APP_ENTRY_SIGNATURE "BTAPENT"
55
56 #define BOOT_APPLICATION_SIGNATURE_1 'TOOB'
57 #define BOOT_APPLICATION_SIGNATURE_2 ' PPA'
58
59 #define BOOT_MEMORY_TRANSLATION_TYPE_PHYSICAL 0
60 #define BOOT_MEMORY_TRANSLATION_TYPE_VIRTUAL 1
61
62 #define BOOT_APPLICATION_VERSION 2
63 #define BL_MEMORY_DATA_VERSION 1
64 #define BL_RETURN_ARGUMENTS_VERSION 1
65 #define BL_FIRMWARE_DESCRIPTOR_VERSION 2
66
67 #define BL_RETURN_ARGUMENTS_NO_PAE_FLAG 0x40
68
69 #define BL_APPLICATION_ENTRY_FLAG_NO_GUID 0x01
70 #define BL_APPLICATION_ENTRY_BCD_OPTIONS_INTERNAL 0x02
71 #define BL_APPLICATION_ENTRY_WINLOAD 0x04
72 #define BL_APPLICATION_ENTRY_STARTUP 0x08
73 #define BL_APPLICATION_ENTRY_REBOOT_ON_ERROR 0x20
74 #define BL_APPLICATION_ENTRY_NTLDR 0x40
75 #define BL_APPLICATION_ENTRY_BCD_OPTIONS_EXTERNAL 0x80
76 #define BL_APPLICATION_ENTRY_WINRESUME 0x100
77 #define BL_APPLICATION_ENTRY_SETUPLDR 0x200
78 #define BL_APPLICATION_ENTRY_BOOTSECTOR 0x400
79 #define BL_APPLICATION_ENTRY_BOOTMGR 0x1000
80 #define BL_APPLICATION_ENTRY_DISPLAY_ORDER 0x800000
81 #define BL_APPLICATION_ENTRY_FIXED_SEQUENCE 0x20000000
82 #define BL_APPLICATION_ENTRY_RECOVERY 0x40000000
83
84 #define BL_CONTEXT_PAGING_ON 1
85 #define BL_CONTEXT_INTERRUPTS_ON 2
86
87 #define BL_MM_FLAG_USE_FIRMWARE_FOR_MEMORY_MAP_BUFFERS 0x01
88 #define BL_MM_FLAG_REQUEST_COALESCING 0x02
89
90 #define BL_MM_ADD_DESCRIPTOR_COALESCE_FLAG 0x01
91 #define BL_MM_ADD_DESCRIPTOR_TRUNCATE_FLAG 0x02
92 #define BL_MM_ADD_DESCRIPTOR_NEVER_COALESCE_FLAG 0x10
93 #define BL_MM_ADD_DESCRIPTOR_NEVER_TRUNCATE_FLAG 0x20
94 #define BL_MM_ADD_DESCRIPTOR_ALLOCATE_FLAG 0x1000
95 #define BL_MM_ADD_DESCRIPTOR_UPDATE_LIST_POINTER_FLAG 0x2000
96
97 #define BL_MM_INCLUDE_MAPPED_ALLOCATED 0x01
98 #define BL_MM_INCLUDE_MAPPED_UNALLOCATED 0x02
99 #define BL_MM_INCLUDE_UNMAPPED_ALLOCATED 0x04
100 #define BL_MM_INCLUDE_UNMAPPED_UNALLOCATED 0x08
101 #define BL_MM_INCLUDE_RESERVED_ALLOCATED 0x10
102 #define BL_MM_INCLUDE_BAD_MEMORY 0x20
103 #define BL_MM_INCLUDE_FIRMWARE_MEMORY 0x40
104 #define BL_MM_INCLUDE_TRUNCATED_MEMORY 0x80
105 #define BL_MM_INCLUDE_PERSISTENT_MEMORY 0x100
106 #define BL_MM_INCLUDE_FIRMWARE_MEMORY_2 0x200
107
108 #define BL_MM_INCLUDE_NO_FIRMWARE_MEMORY (BL_MM_INCLUDE_PERSISTENT_MEMORY | \
109 BL_MM_INCLUDE_TRUNCATED_MEMORY | \
110 BL_MM_INCLUDE_BAD_MEMORY | \
111 BL_MM_INCLUDE_RESERVED_ALLOCATED | \
112 BL_MM_INCLUDE_UNMAPPED_UNALLOCATED | \
113 BL_MM_INCLUDE_UNMAPPED_ALLOCATED | \
114 BL_MM_INCLUDE_MAPPED_UNALLOCATED | \
115 BL_MM_INCLUDE_MAPPED_ALLOCATED)
116 C_ASSERT(BL_MM_INCLUDE_NO_FIRMWARE_MEMORY == 0x1BF);
117
118 #define BL_MM_INCLUDE_ONLY_FIRMWARE_MEMORY (BL_MM_INCLUDE_FIRMWARE_MEMORY_2 | \
119 BL_MM_INCLUDE_FIRMWARE_MEMORY)
120 C_ASSERT(BL_MM_INCLUDE_ONLY_FIRMWARE_MEMORY == 0x240);
121
122 #define BL_MM_REQUEST_DEFAULT_TYPE 1
123 #define BL_MM_REQUEST_TOP_DOWN_TYPE 2
124
125 #define BL_MM_REMOVE_PHYSICAL_REGION_FLAG 0x40000000
126 #define BL_MM_REMOVE_VIRTUAL_REGION_FLAG 0x80000000
127
128 #define BL_LIBRARY_FLAG_NO_DISPLAY 0x01
129 #define BL_LIBRARY_FLAG_REINITIALIZE 0x02
130 #define BL_LIBRARY_FLAG_REINITIALIZE_ALL 0x04
131 #define BL_LIBRARY_FLAG_ZERO_HEAP_ALLOCATIONS_ON_FREE 0x10
132 #define BL_LIBRARY_FLAG_INITIALIZATION_COMPLETED 0x20
133 #define BL_LIBRARY_FLAG_NO_GRAPHICS_CONSOLE 0x800
134
135 #define BL_DISPLAY_GRAPHICS_FORCED_VIDEO_MODE_FLAG 0x01
136 #define BL_DISPLAY_GRAPHICS_FORCED_HIGH_RES_MODE_FLAG 0x02
137
138 #define BL_HT_VALUE_IS_INLINE 0x01
139
140 #define BL_FS_REGISTER_AT_HEAD_FLAG 1
141
142 #define BL_BLOCK_DEVICE_REMOVABLE_FLAG 0x01
143 #define BL_BLOCK_DEVICE_PRESENT_FLAG 0x02
144 #define BL_BLOCK_DEVICE_VIRTUAL_FLAG 0x04
145
146 #define BL_MEMORY_CLASS_SHIFT 28
147
148 #define BL_FILE_READ_ACCESS 0x01
149 #define BL_FILE_WRITE_ACCESS 0x02
150 #define BL_DIRECTORY_ACCESS 0x04
151 #define BL_UNKNOWN_ACCESS 0x10
152
153 #define BL_DEVICE_READ_ACCESS 0x01
154 #define BL_DEVICE_WRITE_ACCESS 0x02
155
156 #define BL_DEVICE_ENTRY_OPENED 0x01
157 #define BL_DEVICE_ENTRY_READ_ACCESS 0x02
158 #define BL_DEVICE_ENTRY_WRITE_ACCESS 0x04
159
160 #define BL_FILE_ENTRY_OPENED 0x01
161 #define BL_FILE_ENTRY_READ_ACCESS 0x02
162 #define BL_FILE_ENTRY_WRITE_ACCESS 0x04
163 #define BL_FILE_ENTRY_UNKNOWN_ACCESS 0x10
164 #define BL_FILE_ENTRY_DIRECTORY 0x10000
165
166 #define BL_ETFS_FILE_ENTRY_DIRECTORY 0x01
167
168 #define BL_IMG_VALID_FILE 0x01
169 #define BL_IMG_MEMORY_FILE 0x02
170 #define BL_IMG_REMOTE_FILE 0x04
171
172 #define BL_LOAD_IMG_VIRTUAL_BUFFER 0x01
173 #define BL_LOAD_IMG_EXISTING_BUFFER 0x04
174 #define BL_LOAD_IMG_UNKNOWN_BUFFER_FLAG 0x08
175 #define BL_LOAD_IMG_COMPUTE_SIGNATURE 0x10
176 #define BL_LOAD_IMG_COMPUTE_HASH 0x40000
177
178 #define BL_LOAD_PE_IMG_VIRTUAL_BUFFER BL_LOAD_IMG_VIRTUAL_BUFFER
179 #define BL_LOAD_PE_IMG_CHECK_MACHINE 0x02
180 #define BL_LOAD_PE_IMG_EXISTING_BUFFER BL_LOAD_IMG_EXISTING_BUFFER
181 #define BL_LOAD_PE_IMG_COMPUTE_HASH 0x10
182 #define BL_LOAD_PE_IMG_CHECK_SUBSYSTEM 0x80
183 #define BL_LOAD_PE_IMG_SKIP_RELOCATIONS 0x100
184 #define BL_LOAD_PE_IMG_CHECK_FORCED_INTEGRITY 0x200
185 #define BL_LOAD_PE_IMG_IGNORE_CHECKSUM_MISMATCH 0x10000
186 #define BL_LOAD_PE_IMG_VALIDATE_ORIGINAL_FILENAME 0x400000
187
188 #define BL_UTL_CHECKSUM_COMPLEMENT 0x10000
189 #define BL_UTL_CHECKSUM_ROTATE 0x20000
190 #define BL_UTL_CHECKSUM_NEGATE 0x40000
191 #define BL_UTL_CHECKSUM_UCHAR_BUFFER 0x01
192 #define BL_UTL_CHECKSUM_USHORT_BUFFER 0x02
193
194 /* ENUMERATIONS **************************************************************/
195
196 typedef enum _BL_COLOR
197 {
198 Black,
199 Blue,
200 Green,
201 Cyan,
202 Red,
203 Magenta,
204 Brown,
205 LtGray,
206 Gray,
207 LtBlue,
208 LtGreen,
209 LtCyan,
210 LtRed,
211 LtMagenta,
212 Yellow,
213 White
214 } BL_COLOR, *PBL_COLOR;
215
216 typedef enum _BL_MENU_POLICY
217 {
218 MenuPolicyLegacy = 0,
219 MenuPolicyStandard = 1
220 } BL_MENU_POLICY;
221
222 typedef enum _BL_MEMORY_DESCRIPTOR_TYPE
223 {
224 BlMdPhysical,
225 BlMdVirtual,
226 BlMdTracker
227 } BL_MEMORY_DESCRIPTOR_TYPE;
228
229 typedef enum _BL_TRANSLATION_TYPE
230 {
231 BlNone,
232 BlVirtual,
233 BlPae,
234 BlMax
235 } BL_TRANSLATION_TYPE;
236
237 typedef enum _BL_ARCH_MODE
238 {
239 BlProtectedMode,
240 BlRealMode
241 } BL_ARCH_MODE;
242
243 //
244 // Boot Device Types
245 //
246 typedef enum _BL_DEVICE_TYPE
247 {
248 DiskDevice = 0,
249 LegacyPartitionDevice = 2,
250 SerialDevice = 3,
251 UdpDevice = 4,
252 BootDevice = 5,
253 PartitionDevice = 6,
254 LocateDevice = 8,
255 } BL_DEVICE_TYPE;
256
257 //
258 // Local Device Types
259 //
260 typedef enum _BL_LOCAL_DEVICE_TYPE
261 {
262 LocalDevice = 0,
263 FloppyDevice = 1,
264 CdRomDevice = 2,
265 RamDiskDevice = 3,
266 FileDevice = 5,
267 VirtualDiskDevice = 6
268 } BL_LOCAL_DEVICE_TYPE;
269
270 //
271 // Partition types
272 //
273 typedef enum _BL_PARTITION_TYPE
274 {
275 GptPartition,
276 MbrPartition,
277 RawPartition,
278 } BL_PARTITION_TYPE;
279
280 //
281 // File Path Types
282 //
283 typedef enum _BL_PATH_TYPE
284 {
285 InternalPath = 3,
286 EfiPath = 4
287 } BL_PATH_TYPE;
288
289 //
290 // Classes of Memory
291 //
292 typedef enum _BL_MEMORY_CLASS
293 {
294 BlLoaderClass = 0xD,
295 BlApplicationClass,
296 BlSystemClass
297 } BL_MEMORY_CLASS;
298
299 //
300 // Types of Memory
301 //
302 typedef enum _BL_MEMORY_TYPE
303 {
304 //
305 // Loader Memory
306 //
307 BlLoaderMemory = 0xD0000002,
308 BlLoaderDeviceMemory = 0xD0000004,
309 BlLoaderHeap = 0xD0000005,
310 BlLoaderPageDirectory = 0xD0000006,
311 BlLoaderReferencePage = 0xD0000007,
312 BlLoaderRamDisk = 0xD0000008,
313 BlLoaderArchData = 0xD0000009,
314 BlLoaderData = 0xD000000A,
315 BlLoaderRegistry = 0xD000000B,
316 BlLoaderBlockMemory = 0xD000000C,
317 BlLoaderSelfMap = 0xD000000F,
318
319 //
320 // Application Memory
321 //
322 BlApplicationReserved = 0xE0000001,
323 BlApplicationData = 0xE0000004,
324
325 //
326 // System Memory
327 //
328 BlConventionalMemory = 0xF0000001,
329 BlUnusableMemory = 0xF0000002,
330 BlReservedMemory = 0xF0000003,
331 BlEfiBootMemory = 0xF0000004,
332 BlEfiRuntimeMemory = 0xF0000006,
333 BlAcpiReclaimMemory = 0xF0000008,
334 BlAcpiNvsMemory = 0xF0000009,
335 BlDeviceIoMemory = 0xF000000A,
336 BlDevicePortMemory = 0xF000000B,
337 BlPalMemory = 0xF000000C,
338 } BL_MEMORY_TYPE;
339
340 typedef enum _BL_MEMORY_ATTR
341 {
342 //
343 // Memory Caching Attributes
344 //
345 BlMemoryUncached = 0x00000001,
346 BlMemoryWriteCombined = 0x00000002,
347 BlMemoryWriteThrough = 0x00000004,
348 BlMemoryWriteBack = 0x00000008,
349 BlMemoryUncachedExported = 0x00000010,
350 BlMemoryValidCacheAttributes = BlMemoryUncached | BlMemoryWriteCombined | BlMemoryWriteThrough | BlMemoryWriteBack | BlMemoryUncachedExported,
351 BlMemoryValidCacheAttributeMask = 0x000000FF,
352
353 //
354 // Memory Protection Attributes
355 //
356 BlMemoryWriteProtected = 0x00000100,
357 BlMemoryReadProtected = 0x00000200,
358 BlMemoryExecuteProtected = 0x00000400,
359 BlMemoryValidProtectionAttributes = BlMemoryWriteProtected | BlMemoryReadProtected | BlMemoryExecuteProtected,
360 BlMemoryValidProtectionAttributeMask = 0x0000FF00,
361
362 //
363 // Memory Allocation Attributes
364 //
365 BlMemoryUnknown = 0x00010000,
366 BlMemoryNonFixed = 0x00020000,
367 BlMemoryFixed = 0x00040000,
368 BlMemoryBelow1MB = 0x00080000,
369 BlMemoryValidAllocationAttributes = BlMemoryNonFixed | BlMemoryFixed | BlMemoryBelow1MB | BlMemoryUnknown,
370 BlMemoryValidAllocationAttributeMask = 0x00FF0000,
371
372 //
373 // Memory Type Attributes
374 //
375 BlMemoryRuntime = 0x01000000,
376 BlMemoryCoalesced = 0x02000000,
377 BlMemoryUpdate = 0x04000000,
378 BlMemoryNonFirmware = 0x08000000,
379 BlMemoryPersistent = 0x10000000,
380 BlMemorySpecial = 0x20000000,
381 BlMemoryFirmware = 0x80000000,
382 BlMemoryValidTypeAttributes = BlMemoryRuntime | BlMemoryCoalesced | BlMemoryUpdate | BlMemoryNonFirmware | BlMemoryPersistent | BlMemorySpecial | BlMemoryFirmware,
383 BlMemoryValidTypeAttributeMask = 0xFF000000,
384 } BL_MEMORY_ATTR;
385
386 /* CALLBACKS *****************************************************************/
387
388 struct _BL_FILE_ENTRY;
389 struct _BL_FILE_INFORMATION;
390 typedef
391 NTSTATUS
392 (*PBL_FILE_OPEN) (
393 _In_ struct _BL_FILE_ENTRY* Directory,
394 _In_ PWCHAR FileName,
395 _In_ ULONG Flags,
396 _Out_ struct _BL_FILE_ENTRY** FileEntry
397 );
398
399 typedef
400 NTSTATUS
401 (*PBL_FILE_CLOSE) (
402 _In_ struct _BL_FILE_ENTRY* FileEntry
403 );
404
405 typedef
406 NTSTATUS
407 (*PBL_FILE_READ) (
408 _In_ struct _BL_FILE_ENTRY* FileEntry,
409 _In_ PVOID Buffer,
410 _In_ ULONG Size,
411 _Out_opt_ PULONG BytesRead
412 );
413
414 typedef
415 NTSTATUS
416 (*PBL_FILE_WRITE) (
417 VOID
418 );
419
420 typedef
421 NTSTATUS
422 (*PBL_FILE_GET_NEXT) (
423 VOID
424 );
425
426 typedef
427 NTSTATUS
428 (*PBL_FILE_GET_INFO) (
429 _In_ struct _BL_FILE_ENTRY* FileEntry,
430 _Out_ struct _BL_FILE_INFORMATION* FileInfo
431 );
432
433 typedef
434 NTSTATUS
435 (*PBL_FILE_SET_INFO) (
436 _In_ struct _BL_FILE_ENTRY* FileEntry,
437 _In_ struct _BL_FILE_INFORMATION* FileInfo
438 );
439
440 typedef
441 NTSTATUS
442 (*PBL_FS_INIT_CALLBACK) (
443 VOID
444 );
445
446 typedef
447 NTSTATUS
448 (*PBL_FS_DESTROY_CALLBACK) (
449 VOID
450 );
451
452 typedef
453 NTSTATUS
454 (*PBL_FS_MOUNT_CALLBACK) (
455 _In_ ULONG DeviceId,
456 _In_ ULONG Unknown,
457 _Out_ struct _BL_FILE_ENTRY** FileEntry
458 );
459
460 typedef
461 NTSTATUS
462 (*PBL_FS_PURGE_CALLBACK) (
463 VOID
464 );
465
466 typedef
467 NTSTATUS
468 (*PBL_FILE_DESTROY_CALLBACK) (
469 _In_ PVOID Entry
470 );
471
472 struct _BL_TEXT_CONSOLE;
473 struct _BL_DISPLAY_STATE;
474 struct _BL_DISPLAY_MODE;
475 struct _BL_INPUT_CONSOLE;
476 struct _BL_REMOTE_CONSOLE;
477 struct _BL_GRAPHICS_CONSOLE;
478 typedef
479 VOID
480 (*PCONSOLE_DESTRUCT) (
481 _In_ struct _BL_TEXT_CONSOLE* Console
482 );
483
484 typedef
485 NTSTATUS
486 (*PCONSOLE_REINITIALIZE) (
487 _In_ struct _BL_TEXT_CONSOLE* Console
488 );
489
490 typedef
491 NTSTATUS
492 (*PCONSOLE_GET_TEXT_STATE) (
493 _In_ struct _BL_TEXT_CONSOLE* Console,
494 _Out_ struct _BL_DISPLAY_STATE* TextState
495 );
496
497 typedef
498 NTSTATUS
499 (*PCONSOLE_SET_TEXT_STATE) (
500 _In_ struct _BL_TEXT_CONSOLE* Console,
501 _In_ ULONG Flags,
502 _In_ struct _BL_DISPLAY_STATE* TextState
503 );
504
505 typedef
506 NTSTATUS
507 (*PCONSOLE_GET_TEXT_RESOLUTION) (
508 _In_ struct _BL_TEXT_CONSOLE* Console,
509 _Out_ PULONG TextResolution
510 );
511
512 typedef
513 NTSTATUS
514 (*PCONSOLE_SET_TEXT_RESOLUTION) (
515 _In_ struct _BL_TEXT_CONSOLE* Console,
516 _In_ ULONG NewTextResolution,
517 _Out_ PULONG OldTextResolution
518 );
519
520 typedef
521 NTSTATUS
522 (*PCONSOLE_CLEAR_TEXT) (
523 _In_ struct _BL_TEXT_CONSOLE* Console,
524 _In_ BOOLEAN LineOnly
525 );
526
527 typedef
528 BOOLEAN
529 (*PCONSOLE_IS_ENABLED) (
530 _In_ struct _BL_GRAPHICS_CONSOLE* Console
531 );
532
533 typedef
534 NTSTATUS
535 (*PCONSOLE_GET_GRAPHICAL_RESOLUTION) (
536 _In_ struct _BL_GRAPHICS_CONSOLE* Console,
537 _Out_ struct _BL_DISPLAY_MODE* DisplayMode
538 );
539
540 typedef
541 NTSTATUS
542 (*PCONSOLE_SET_GRAPHICAL_RESOLUTION) (
543 _In_ struct _BL_GRAPHICS_CONSOLE* Console,
544 _In_ struct _BL_DISPLAY_MODE DisplayMode
545 );
546
547 typedef
548 NTSTATUS
549 (*PCONSOLE_ENABLE) (
550 _In_ struct _BL_GRAPHICS_CONSOLE* Console,
551 _In_ BOOLEAN Enable
552 );
553
554 typedef
555 NTSTATUS
556 (*PCONSOLE_WRITE_TEXT) (
557 _In_ struct _BL_TEXT_CONSOLE* Console,
558 _In_ PCHAR Text,
559 _In_ ULONG Attribute
560 );
561
562 typedef
563 BOOLEAN
564 (*PBL_TBL_LOOKUP_ROUTINE) (
565 _In_ PVOID Entry,
566 _In_ PVOID Argument1,
567 _In_ PVOID Argument2,
568 _In_ PVOID Argument3,
569 _In_ PVOID Argument4
570 );
571
572 typedef
573 NTSTATUS
574 (*PBL_TBL_MAP_ROUTINE) (
575 _In_ PVOID Entry,
576 _In_ ULONG EntryIndex
577 );
578
579 typedef
580 NTSTATUS
581 (*PBL_TBL_SET_ROUTINE) (
582 _In_ PVOID Entry
583 );
584
585 typedef
586 NTSTATUS
587 (*PBL_IO_DESTROY_ROUTINE) (
588 VOID
589 );
590
591 struct _BL_HASH_ENTRY;
592 typedef
593 BOOLEAN
594 (*PBL_HASH_TABLE_COMPARE_FUNCTION) (
595 _In_ struct _BL_HASH_ENTRY* Entry1,
596 _In_ struct _BL_HASH_ENTRY* Entry2
597 );
598
599 typedef
600 ULONG
601 (*PBL_HASH_TABLE_HASH_FUNCTION) (
602 _In_ struct _BL_HASH_ENTRY* Entry,
603 _In_ ULONG TableSize
604 );
605
606 struct _BL_DEVICE_ENTRY;
607 struct _BL_DEVICE_DESCRIPTOR;
608 struct _BL_DEVICE_INFORMATION;
609
610 typedef
611 NTSTATUS
612 (*PBL_DEVICE_ENUMERATE_DEVICE_CLASS) (
613 VOID
614 );
615
616 typedef
617 NTSTATUS
618 (*PBL_DEVICE_OPEN) (
619 _In_ struct _BL_DEVICE_DESCRIPTOR* Device,
620 _In_ struct _BL_DEVICE_ENTRY* DeviceEntry
621 );
622
623 typedef
624 NTSTATUS
625 (*PBL_DEVICE_CLOSE) (
626 _In_ struct _BL_DEVICE_ENTRY* DeviceEntry
627 );
628
629 typedef
630 NTSTATUS
631 (*PBL_DEVICE_READ) (
632 _In_ struct _BL_DEVICE_ENTRY* DeviceEntry,
633 _In_ PVOID Buffer,
634 _In_ ULONG Size,
635 _Out_ PULONG BytesRead
636 );
637
638 typedef
639 NTSTATUS
640 (*PBL_DEVICE_WRITE) (
641 VOID
642 );
643
644 typedef
645 NTSTATUS
646 (*PBL_DEVICE_GET_INFORMATION) (
647 _In_ struct _BL_DEVICE_ENTRY* DeviceEntry,
648 _Out_ struct _BL_DEVICE_INFORMATION* DeviceInformation
649 );
650
651 typedef
652 NTSTATUS
653 (*PBL_DEVICE_SET_INFORMATION) (
654 _In_ struct _BL_DEVICE_ENTRY* DeviceEntry,
655 _In_ struct _BL_DEVICE_INFORMATION* DeviceInformation
656 );
657
658 typedef
659 NTSTATUS
660 (*PBL_DEVICE_RESET) (
661 VOID
662 );
663
664 typedef
665 NTSTATUS
666 (*PBL_DEVICE_FLUSH) (
667 VOID
668 );
669
670 typedef
671 NTSTATUS
672 (*PBL_DEVICE_CREATE) (
673 VOID
674 );
675
676 /* DATA STRUCTURES ***********************************************************/
677
678 typedef struct _BL_LIBRARY_PARAMETERS
679 {
680 ULONG LibraryFlags;
681 ULONG TranslationType;
682 ULONG MinimumAllocationCount;
683 ULONG MinimumHeapSize;
684 ULONG HeapAllocationAttributes;
685 PWCHAR ApplicationBaseDirectory;
686 ULONG DescriptorCount;
687 PWCHAR FontBaseDirectory;
688 } BL_LIBRARY_PARAMETERS, *PBL_LIBRARY_PARAMETERS;
689
690 /* This should eventually go into a more public header */
691 typedef struct _BOOT_APPLICATION_PARAMETER_BLOCK
692 {
693 /* This header tells the library what image we're dealing with */
694 ULONG Signature[2];
695 ULONG Version;
696 ULONG Size;
697 ULONG ImageType;
698 ULONG MemoryTranslationType;
699
700 /* Where is the image located */
701 ULONGLONG ImageBase;
702 ULONG ImageSize;
703
704 /* Offset to BL_MEMORY_DATA */
705 ULONG MemoryDataOffset;
706
707 /* Offset to BL_APPLICATION_ENTRY */
708 ULONG AppEntryOffset;
709
710 /* Offset to BL_DEVICE_DESCRPIPTOR */
711 ULONG BootDeviceOffset;
712
713 /* Offset to BL_FIRMWARE_PARAMETERS */
714 ULONG FirmwareParametersOffset;
715
716 /* Offset to BL_RETURN_ARGUMENTS */
717 ULONG ReturnArgumentsOffset;
718 } BOOT_APPLICATION_PARAMETER_BLOCK, *PBOOT_APPLICATION_PARAMETER_BLOCK;
719
720 typedef struct _BL_MEMORY_DATA
721 {
722 ULONG Version;
723 ULONG MdListOffset;
724 ULONG DescriptorCount;
725 ULONG DescriptorSize;
726 ULONG DescriptorOffset;
727 } BL_MEMORY_DATA, *PBL_MEMORY_DATA;
728
729 typedef struct _BL_FIRMWARE_DESCRIPTOR
730 {
731 ULONG Version;
732 ULONG Unknown;
733 EFI_HANDLE ImageHandle;
734 EFI_SYSTEM_TABLE *SystemTable;
735 } BL_FIRMWARE_DESCRIPTOR, *PBL_FIRMWARE_DESCRIPTOR;
736
737 typedef struct _BL_RETURN_ARGUMENTS
738 {
739 ULONG Version;
740 NTSTATUS Status;
741 ULONG Flags;
742 ULONGLONG DataSize;
743 ULONGLONG DataPage;
744 } BL_RETURN_ARGUMENTS, *PBL_RETURN_ARGUMENTS;
745
746 typedef struct _BL_MEMORY_DESCRIPTOR
747 {
748 LIST_ENTRY ListEntry;
749 union
750 {
751 struct
752 {
753 ULONGLONG BasePage;
754 ULONGLONG VirtualPage;
755 };
756 struct
757 {
758 ULONGLONG BaseAddress;
759 ULONGLONG VirtualAddress;
760 };
761 };
762 ULONGLONG PageCount;
763 ULONG Flags;
764 BL_MEMORY_TYPE Type;
765 } BL_MEMORY_DESCRIPTOR, *PBL_MEMORY_DESCRIPTOR;
766
767 typedef struct _BL_BCD_OPTION
768 {
769 ULONG Type;
770 ULONG DataOffset;
771 ULONG DataSize;
772 ULONG ListOffset;
773 ULONG NextEntryOffset;
774 ULONG Empty;
775 } BL_BCD_OPTION, *PBL_BCD_OPTION;
776
777 typedef struct _BL_APPLICATION_ENTRY
778 {
779 CHAR Signature[8];
780 ULONG Flags;
781 GUID Guid;
782 ULONG Unknown[4];
783 BL_BCD_OPTION BcdData;
784 } BL_APPLICATION_ENTRY, *PBL_APPLICATION_ENTRY;
785
786 typedef struct _BL_LOADED_APPLICATION_ENTRY
787 {
788 ULONG Flags;
789 GUID Guid;
790 PBL_BCD_OPTION BcdData;
791 } BL_LOADED_APPLICATION_ENTRY, *PBL_LOADED_APPLICATION_ENTRY;
792
793 typedef struct _BL_MENU_STATUS
794 {
795 union
796 {
797 struct
798 {
799 ULONG AnyKey : 1;
800 ULONG AdvancedOptions : 1;
801 ULONG BootOptions : 1;
802 ULONG OemKey : 1;
803 ULONG Exit : 1;
804 ULONG Reserved : 27;
805 };
806 ULONG AsULong;
807 };
808 ULONG BootIndex;
809 WCHAR KeyValue;
810 } BL_MENU_STATUS, *PL_MENU_STATUS;
811
812 typedef enum _BL_BOOT_ERROR_STATUS
813 {
814 Reboot = 1,
815 Recover = 2,
816 RecoverOem = 3,
817 OsSelection = 4,
818 NextOs = 5,
819 TryAgain = 6,
820 AdvancedOptions = 7,
821 BootOptions = 8
822 } BL_BOOT_ERROR_STATUS;
823
824 typedef struct _BL_HARDDISK_DEVICE
825 {
826 ULONG PartitionType;
827 union
828 {
829 struct
830 {
831 ULONG PartitionSignature;
832 } Mbr;
833
834 struct
835 {
836 GUID PartitionSignature;
837 } Gpt;
838
839 struct
840 {
841 ULONG DiskNumber;
842 } Raw;
843 };
844 } BL_HARDDISK_DEVICE;
845
846 typedef struct _BL_LOCAL_DEVICE
847 {
848 ULONG Type;
849 union
850 {
851 struct
852 {
853 ULONG DriveNumber;
854 } FloppyDisk;
855
856 BL_HARDDISK_DEVICE HardDisk;
857
858 struct
859 {
860 PHYSICAL_ADDRESS ImageBase;
861 LARGE_INTEGER ImageSize;
862 ULONG ImageOffset;
863 } RamDisk;
864
865 ULONG File; // unknown for now
866 };
867 } BL_LOCAL_DEVICE, *PBL_LOCAL_DEVICE;
868
869 typedef struct _BL_DEVICE_DESCRIPTOR
870 {
871 DEVICE_TYPE DeviceType;
872 ULONG Flags;
873 ULONG Size;
874 ULONG Unknown;
875 union
876 {
877 BL_LOCAL_DEVICE Local;
878
879 struct
880 {
881 ULONG Unknown;
882 } Remote;
883
884 struct
885 {
886 union
887 {
888 ULONG PartitionNumber;
889 } Mbr;
890
891 union
892 {
893 GUID PartitionGuid;
894 } Gpt;
895
896 BL_LOCAL_DEVICE Disk;
897 } Partition;
898 };
899 } BL_DEVICE_DESCRIPTOR, *PBL_DEVICE_DESCRIPTOR;
900
901 typedef struct _BL_FILE_PATH_DESCRIPTOR
902 {
903 ULONG Version;
904 ULONG Length;
905 ULONG PathType;
906 UCHAR Path[ANYSIZE_ARRAY];
907 } BL_FILE_PATH_DESCRIPTOR, *PBL_FILE_PATH_DESCRIPTOR;
908
909 typedef struct _BL_WINDOWS_LOAD_OPTIONS
910 {
911 CHAR Signature[8];
912 ULONG Version;
913 ULONG Length;
914 ULONG OsPathOffset;
915 WCHAR LoadOptions[ANYSIZE_ARRAY];
916 } BL_WINDOWS_LOAD_OPTIONS, *PBL_WINDOWS_LOAD_OPTIONS;
917
918 typedef struct _BL_ARCH_CONTEXT
919 {
920 BL_ARCH_MODE Mode;
921 BL_TRANSLATION_TYPE TranslationType;
922 ULONG ContextFlags;
923 } BL_ARCH_CONTEXT, *PBL_ARCH_CONTEXT;
924
925 typedef struct _BL_MEMORY_DESCRIPTOR_LIST
926 {
927 LIST_ENTRY ListHead;
928 PLIST_ENTRY First;
929 PLIST_ENTRY This;
930 ULONG Type;
931 } BL_MEMORY_DESCRIPTOR_LIST, *PBL_MEMORY_DESCRIPTOR_LIST;
932
933 typedef struct _BL_ADDRESS_RANGE
934 {
935 ULONGLONG Minimum;
936 ULONGLONG Maximum;
937 } BL_ADDRESS_RANGE, *PBL_ADDRESS_RANGE;
938
939 typedef struct _BL_FILE_INFORMATION
940 {
941 ULONGLONG Size;
942 ULONGLONG Offset;
943 PWCHAR FsName;
944 ULONG Flags;
945 } BL_FILE_INFORMATION, *PBL_FILE_INFORMATION;
946
947 typedef struct _BL_FILE_CALLBACKS
948 {
949 PBL_FILE_OPEN Open;
950 PBL_FILE_CLOSE Close;
951 PBL_FILE_READ Read;
952 PBL_FILE_WRITE Write;
953 PBL_FILE_GET_NEXT GetNext;
954 PBL_FILE_GET_INFO GetInfo;
955 PBL_FILE_SET_INFO SetInfo;
956 } BL_FILE_CALLBACKS, *PBL_FILE_CALLBACKS;
957
958 typedef struct _BL_FILE_ENTRY
959 {
960 PWCHAR FilePath;
961 ULONG DeviceId;
962 ULONG FileId;
963 ULONG Flags;
964 ULONG ReferenceCount;
965 ULONG Unknown;
966 ULONGLONG TotalBytesRead;
967 ULONGLONG Unknown2;
968 BL_FILE_CALLBACKS Callbacks;
969 PVOID FsSpecificData;
970 } BL_FILE_ENTRY, *PBL_FILE_ENTRY;
971
972 typedef struct _BL_FILE_SYSTEM_ENTRY
973 {
974 LIST_ENTRY ListEntry;
975 PBL_FS_INIT_CALLBACK InitCallback;
976 PBL_FS_DESTROY_CALLBACK DestroyCallback;
977 PBL_FS_MOUNT_CALLBACK MountCallback;
978 PBL_FS_PURGE_CALLBACK PurgeCallback;
979 } BL_FILE_SYSTEM_ENTRY, *PBL_FILE_SYSTEM_ENTRY;
980
981 typedef struct _BL_FILE_SYSTEM_REGISTRATION_TABLE
982 {
983 PBL_FS_INIT_CALLBACK Init;
984 PBL_FS_DESTROY_CALLBACK Destroy;
985 PBL_FS_MOUNT_CALLBACK Mount;
986 PBL_FS_PURGE_CALLBACK Purge;
987 } BL_FILE_SYSTEM_REGISTRATION_TABLE;
988
989 typedef struct _BL_DISPLAY_STATE
990 {
991 ULONG BgColor;
992 ULONG FgColor;
993 ULONG XPos;
994 ULONG YPos;
995 ULONG CursorVisible;
996 } BL_DISPLAY_STATE, *PBL_DISPLAY_STATE;
997
998 typedef struct _BL_DISPLAY_MODE
999 {
1000 ULONG HRes;
1001 ULONG VRes;
1002 ULONG HRes2;
1003 } BL_DISPLAY_MODE, *PBL_DISPLAY_MODE;
1004
1005 typedef struct _BL_TEXT_CONSOLE_VTABLE
1006 {
1007 PCONSOLE_DESTRUCT Destruct;
1008 PCONSOLE_REINITIALIZE Reinitialize;
1009 PCONSOLE_GET_TEXT_STATE GetTextState;
1010 PCONSOLE_SET_TEXT_STATE SetTextState;
1011 PCONSOLE_GET_TEXT_RESOLUTION GetTextResolution;
1012 PCONSOLE_SET_TEXT_RESOLUTION SetTextResolution;
1013 PCONSOLE_CLEAR_TEXT ClearText;
1014 PCONSOLE_WRITE_TEXT WriteText;
1015 } BL_TEXT_CONSOLE_VTABLE, *PBL_TEXT_CONSOLE_VTABLE;
1016
1017 typedef struct _BL_GRAPHICS_CONSOLE_VTABLE
1018 {
1019 BL_TEXT_CONSOLE_VTABLE Text;
1020 PCONSOLE_IS_ENABLED IsEnabled;
1021 PCONSOLE_ENABLE Enable;
1022 PVOID GetConsoleResolution;
1023 PCONSOLE_GET_GRAPHICAL_RESOLUTION GetGraphicalResolution;
1024 PCONSOLE_GET_GRAPHICAL_RESOLUTION GetOriginalResolution;
1025 PCONSOLE_SET_GRAPHICAL_RESOLUTION SetOriginalResolution;
1026 /// more for graphics ///
1027 } BL_GRAPHICS_CONSOLE_VTABLE, *PBL_GRAPHICS_CONSOLE_VTABLE;
1028
1029 typedef struct _BL_TEXT_CONSOLE
1030 {
1031 PBL_TEXT_CONSOLE_VTABLE Callbacks;
1032 BL_DISPLAY_STATE State;
1033 BL_DISPLAY_MODE DisplayMode;
1034 BOOLEAN Active;
1035 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* Protocol;
1036 ULONG Mode;
1037 EFI_SIMPLE_TEXT_OUTPUT_MODE OldMode;
1038 } BL_TEXT_CONSOLE, *PBL_TEXT_CONSOLE;
1039
1040 typedef struct _BL_INPUT_CONSOLE_VTABLE
1041 {
1042 PCONSOLE_DESTRUCT Destruct;
1043 PCONSOLE_REINITIALIZE Reinitialize;
1044 //PCONSOLE_IS_KEY_PENDING IsKeyPending;
1045 //PCONSOLE_READ_INPUT ReadInput;
1046 //PCONSOLE_ERASE_BUFFER EraseBuffer;
1047 //PCONSOLE_FILL_BUFFER FillBuffer;
1048 } BL_INPUT_CONSOLE_VTABLE, *PBL_INPUT_CONSOLE_VTABLE;
1049
1050 typedef struct _BL_INPUT_CONSOLE
1051 {
1052 PBL_INPUT_CONSOLE_VTABLE Callbacks;
1053 PULONG Buffer;
1054 PULONG DataStart;
1055 PULONG DataEnd;
1056 PULONG EndBuffer;
1057 } BL_INPUT_CONSOLE, *PBL_INPUT_CONSOLE;
1058
1059 typedef enum _BL_GRAPHICS_CONSOLE_TYPE
1060 {
1061 BlGopConsole,
1062 BlUgaConsole
1063 } BL_GRAPHICS_CONSOLE_TYPE;
1064
1065 typedef struct _BL_GRAPHICS_CONSOLE
1066 {
1067 BL_TEXT_CONSOLE TextConsole;
1068 BL_DISPLAY_MODE DisplayMode;
1069 ULONG PixelDepth;
1070 ULONG FgColor;
1071 ULONG BgColor;
1072 BL_DISPLAY_MODE OldDisplayMode;
1073 ULONG OldPixelDepth;
1074 EFI_HANDLE Handle;
1075 BL_GRAPHICS_CONSOLE_TYPE Type;
1076 EFI_GRAPHICS_OUTPUT_PROTOCOL* Protocol;
1077 PVOID FrameBuffer;
1078 ULONG FrameBufferSize;
1079 ULONG PixelsPerScanLine;
1080 ULONG Mode;
1081 ULONG OldMode;
1082 } BL_GRAPHICS_CONSOLE, *PBL_GRAPHICS_CONSOLE;
1083
1084 typedef struct _BL_REMOTE_CONSOLE
1085 {
1086 BL_TEXT_CONSOLE TextConsole;
1087 } BL_REMOTE_CONSOLE, *PBL_REMOTE_CONSOLE;
1088
1089 typedef struct _BL_HASH_TABLE
1090 {
1091 PLIST_ENTRY HashLinks;
1092 ULONG Size;
1093 PBL_HASH_TABLE_COMPARE_FUNCTION CompareFunction;
1094 PBL_HASH_TABLE_HASH_FUNCTION HashFunction;
1095 } BL_HASH_TABLE, *PBL_HASH_TABLE;
1096
1097 typedef struct _BL_HASH_ENTRY
1098 {
1099 ULONG Size;
1100 ULONG Flags;
1101 PVOID Value;
1102 } BL_HASH_ENTRY, *PBL_HASH_ENTRY;
1103
1104 typedef struct _BL_HASH_VALUE
1105 {
1106 ULONG DataSize;
1107 PVOID Data;
1108 } BL_HASH_VALUE, *PBL_HASH_VALUE;
1109
1110 typedef struct _BL_HASH_NODE
1111 {
1112 LIST_ENTRY ListEntry;
1113 BL_HASH_ENTRY Entry;
1114 BL_HASH_VALUE Value;
1115 } BL_HASH_NODE, *PBL_HASH_NODE;
1116
1117 typedef struct _BL_BLOCK_DEVICE_INFORMATION
1118 {
1119 BL_LOCAL_DEVICE_TYPE Type;
1120 ULONG DeviceFlags;
1121 ULONG Unknown;
1122 BL_PARTITION_TYPE PartitionType;
1123 ULONG BlockSize;
1124 ULONG Alignment;
1125 ULONGLONG LastBlock;
1126 ULONGLONG Offset;
1127 ULONG Block;
1128 struct
1129 {
1130 union
1131 {
1132 struct
1133 {
1134 ULONG Signature;
1135 } Mbr;
1136 struct
1137 {
1138 GUID Signature;
1139 } Gpt;
1140 };
1141 } Disk;
1142 } BL_BLOCK_DEVICE_INFORMATION, *PBL_BLOCK_DEVICE_INFORMATION;
1143
1144 typedef struct _BL_DEVICE_INFORMATION
1145 {
1146 BL_DEVICE_TYPE DeviceType;
1147 union
1148 {
1149 BL_BLOCK_DEVICE_INFORMATION BlockDeviceInfo;
1150 };
1151 } BL_DEVICE_INFORMATION, *PBL_DEVICE_INFORMATION;
1152
1153 typedef struct _BL_BLOCK_DEVICE
1154 {
1155 BL_BLOCK_DEVICE_INFORMATION;
1156 ULONGLONG StartOffset;
1157 EFI_BLOCK_IO* Protocol;
1158 EFI_HANDLE Handle;
1159 } BL_BLOCK_DEVICE, *PBL_BLOCK_DEVICE;
1160
1161 typedef struct _BL_PROTOCOL_HANDLE
1162 {
1163 EFI_HANDLE Handle;
1164 PVOID Interface;
1165 } BL_PROTOCOL_HANDLE, *PBL_PROTOCOL_HANDLE;
1166
1167 typedef struct _BL_DEVICE_CALLBACKS
1168 {
1169 PBL_DEVICE_ENUMERATE_DEVICE_CLASS EnumerateDeviceClass;
1170 PBL_DEVICE_OPEN Open;
1171 PBL_DEVICE_CLOSE Close;
1172 PBL_DEVICE_READ Read;
1173 PBL_DEVICE_WRITE Write;
1174 PBL_DEVICE_GET_INFORMATION GetInformation;
1175 PBL_DEVICE_SET_INFORMATION SetInformation;
1176 PBL_DEVICE_RESET Reset;
1177 PBL_DEVICE_FLUSH Flush;
1178 PBL_DEVICE_CREATE Create;
1179 } BL_DEVICE_CALLBACKS, *PBL_DEVICE_CALLBACKS;
1180
1181 typedef struct _BL_DEVICE_ENTRY
1182 {
1183 ULONG DeviceId;
1184 ULONG Flags;
1185 ULONG Unknown;
1186 ULONG ReferenceCount;
1187 BL_DEVICE_CALLBACKS Callbacks;
1188 PVOID DeviceSpecificData;
1189 PBL_DEVICE_DESCRIPTOR DeviceDescriptor;
1190 } BL_DEVICE_ENTRY, *PBL_DEVICE_ENTRY;
1191
1192 typedef struct _BL_IMG_FILE
1193 {
1194 UCHAR Flags;
1195 union
1196 {
1197 PVOID BaseAddress;
1198 ULONG FileId;
1199 };
1200 ULONG FileSize;
1201 PWCHAR FileName;
1202 } BL_IMG_FILE, *PBL_IMG_FILE;
1203
1204 typedef struct _BL_IMAGE_APPLICATION_ENTRY
1205 {
1206 PBL_APPLICATION_ENTRY AppEntry;
1207 PVOID ImageBase;
1208 ULONG ImageSize;
1209 } BL_IMAGE_APPLICATION_ENTRY, *PBL_IMAGE_APPLICATION_ENTRY;
1210
1211 typedef struct _BL_IMAGE_PARAMETERS
1212 {
1213 PVOID Buffer;
1214 ULONG ActualSize;
1215 ULONG BufferSize;
1216 } BL_IMAGE_PARAMETERS, *PBL_IMAGE_PARAMETERS;
1217
1218 typedef struct _BL_DEFERRED_FONT_FILE
1219 {
1220 LIST_ENTRY ListEntry;
1221 ULONG Flags;
1222 PBL_DEVICE_DESCRIPTOR Device;
1223 PWCHAR FontPath;
1224 } BL_DEFERRED_FONT_FILE, *PBL_DEFERRED_FONT_FILE;
1225
1226 #pragma pack(push)
1227 #pragma pack(1)
1228 typedef struct _BMP_HEADER
1229 {
1230 USHORT Signature;
1231 ULONG Size;
1232 USHORT Reserved[2];
1233 ULONG Offset;
1234 } BMP_HEADER, *PBMP_HEADER;
1235
1236 typedef struct _DIB_HEADER
1237 {
1238 ULONG Size;
1239 ULONG Width;
1240 ULONG Height;
1241 USHORT Planes;
1242 USHORT BitCount;
1243 ULONG Compression;
1244 ULONG SizeImage;
1245 ULONG XPelsPerMeter;
1246 ULONG YPelsPerMEter;
1247 ULONG ClrUsed;
1248 ULONG ClrImportant;
1249 } DIB_HEADER, *PDIB_HEADER;
1250
1251 typedef struct _BITMAP
1252 {
1253 BMP_HEADER BmpHeader;
1254 DIB_HEADER DibHeader;
1255 } BITMAP, *PBITMAP;
1256 #pragma pack(pop)
1257
1258 typedef struct _COORD
1259 {
1260 ULONG X;
1261 ULONG Y;
1262 } COORD, *PCOORD;
1263
1264 typedef struct _BL_PD_DATA_BLOB
1265 {
1266 PVOID Data;
1267 ULONG DataSize;
1268 ULONG BlobSize;
1269 } BL_PD_DATA_BLOB, *PBL_PD_DATA_BLOB;
1270
1271 /* INLINE ROUTINES ***********************************************************/
1272
1273 FORCEINLINE
1274 VOID
1275 BlSetupDefaultParameters (
1276 _Out_ PBL_LIBRARY_PARAMETERS LibraryParameters
1277 )
1278 {
1279 BL_LIBRARY_PARAMETERS DefaultParameters =
1280 {
1281 0x20,
1282 BlVirtual,
1283 1024,
1284 2 * 1024 * 1024,
1285 0,
1286 NULL,
1287 0,
1288 NULL
1289 };
1290
1291 /* Copy the defaults */
1292 RtlCopyMemory(LibraryParameters, &DefaultParameters, sizeof(*LibraryParameters));
1293 }
1294
1295 FORCEINLINE
1296 VOID
1297 MmMdInitializeListHead (
1298 _In_ PBL_MEMORY_DESCRIPTOR_LIST List
1299 )
1300 {
1301 /* Initialize the list */
1302 InitializeListHead(&List->ListHead);
1303 List->First = &List->ListHead;
1304 List->This = NULL;
1305 List->Type = 0;
1306 }
1307
1308 /* INITIALIZATION ROUTINES ***************************************************/
1309
1310 NTSTATUS
1311 BlInitializeLibrary(
1312 _In_ PBOOT_APPLICATION_PARAMETER_BLOCK BootAppParameters,
1313 _In_ PBL_LIBRARY_PARAMETERS LibraryParameters
1314 );
1315
1316 NTSTATUS
1317 BlpArchInitialize (
1318 _In_ ULONG Phase
1319 );
1320
1321 NTSTATUS
1322 BlpFwInitialize (
1323 _In_ ULONG Phase,
1324 _In_ PBL_FIRMWARE_DESCRIPTOR FirmwareParameters
1325 );
1326
1327 NTSTATUS
1328 BlpMmInitialize (
1329 _In_ PBL_MEMORY_DATA MemoryData,
1330 _In_ BL_TRANSLATION_TYPE TranslationType,
1331 _In_ PBL_LIBRARY_PARAMETERS LibraryParameters
1332 );
1333
1334 NTSTATUS
1335 MmBaInitialize (
1336 VOID
1337 );
1338
1339 NTSTATUS
1340 MmPaInitialize (
1341 _In_ PBL_MEMORY_DATA MemoryData,
1342 _In_ ULONG MinimumPages
1343 );
1344
1345 NTSTATUS
1346 MmArchInitialize (
1347 _In_ ULONG Phase,
1348 _In_ PBL_MEMORY_DATA MemoryData,
1349 _In_ BL_TRANSLATION_TYPE TranslationType,
1350 _In_ BL_TRANSLATION_TYPE LibraryTranslationType
1351 );
1352
1353 NTSTATUS
1354 MmHaInitialize (
1355 _In_ ULONG HeapSize,
1356 _In_ ULONG HeapAttributes
1357 );
1358
1359 VOID
1360 MmMdInitialize (
1361 _In_ ULONG Phase,
1362 _In_ PBL_LIBRARY_PARAMETERS LibraryParameters
1363 );
1364
1365 NTSTATUS
1366 BlpDeviceInitialize (
1367 VOID
1368 );
1369
1370 NTSTATUS
1371 BlpIoInitialize (
1372 VOID
1373 );
1374
1375 NTSTATUS
1376 BlpFileInitialize (
1377 VOID
1378 );
1379
1380 NTSTATUS
1381 BlpDisplayInitialize (
1382 _In_ ULONG Flags
1383 );
1384
1385 NTSTATUS
1386 BlpDisplayReinitialize (
1387 VOID
1388 );
1389
1390 VOID
1391 BlDestroyLibrary (
1392 VOID
1393 );
1394
1395 NTSTATUS
1396 BcInitialize (
1397 VOID
1398 );
1399
1400 /* FIRMWARE ROUTINES *********************************************************/
1401
1402 VOID
1403 EfiPrintf (
1404 _In_ PWCHAR Format,
1405 ...
1406 );
1407
1408 NTSTATUS
1409 BlFwGetParameters(
1410 _In_ PBL_FIRMWARE_DESCRIPTOR Parameters
1411 );
1412
1413 NTSTATUS
1414 BlFwEnumerateDevice (
1415 _In_ PBL_DEVICE_DESCRIPTOR Device
1416 );
1417
1418 NTSTATUS
1419 EfiAllocatePages (
1420 _In_ ULONG Type,
1421 _In_ ULONG Pages,
1422 _Inout_ EFI_PHYSICAL_ADDRESS* Memory
1423 );
1424
1425 NTSTATUS
1426 EfiStall (
1427 _In_ ULONG StallTime
1428 );
1429
1430 NTSTATUS
1431 EfiConInExReset (
1432 VOID
1433 );
1434
1435 NTSTATUS
1436 EfiConInReset (
1437 VOID
1438 );
1439
1440 NTSTATUS
1441 EfiConOutOutputString (
1442 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1443 _In_ PWCHAR String
1444 );
1445
1446 NTSTATUS
1447 EfiConOutQueryMode (
1448 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1449 _In_ ULONG Mode,
1450 _In_ UINTN* Columns,
1451 _In_ UINTN* Rows
1452 );
1453
1454 NTSTATUS
1455 EfiConOutSetMode (
1456 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1457 _In_ ULONG Mode
1458 );
1459
1460 VOID
1461 EfiConOutReadCurrentMode (
1462 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1463 _Out_ EFI_SIMPLE_TEXT_OUTPUT_MODE* Mode
1464 );
1465
1466 NTSTATUS
1467 EfiConOutSetAttribute (
1468 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1469 _In_ ULONG Attribute
1470 );
1471
1472 NTSTATUS
1473 EfiConOutSetCursorPosition (
1474 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1475 _In_ ULONG Column,
1476 _In_ ULONG Row
1477 );
1478
1479 NTSTATUS
1480 EfiConOutEnableCursor (
1481 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1482 _In_ BOOLEAN Visible
1483 );
1484
1485 NTSTATUS
1486 EfiLocateHandleBuffer (
1487 _In_ EFI_LOCATE_SEARCH_TYPE SearchType,
1488 _In_ EFI_GUID *Protocol,
1489 _Inout_ PULONG HandleCount,
1490 _Inout_ EFI_HANDLE** Buffer
1491 );
1492
1493 NTSTATUS
1494 EfiOpenProtocol (
1495 _In_ EFI_HANDLE Handle,
1496 _In_ EFI_GUID *Protocol,
1497 _Out_ PVOID* Interface
1498 );
1499
1500 NTSTATUS
1501 EfiCloseProtocol (
1502 _In_ EFI_HANDLE Handle,
1503 _In_ EFI_GUID *Protocol
1504 );
1505
1506 NTSTATUS
1507 EfiGopGetCurrentMode (
1508 _In_ EFI_GRAPHICS_OUTPUT_PROTOCOL *GopInterface,
1509 _Out_ UINTN* Mode,
1510 _Out_ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Information
1511 );
1512
1513 NTSTATUS
1514 EfiGopSetMode (
1515 _In_ EFI_GRAPHICS_OUTPUT_PROTOCOL *GopInterface,
1516 _In_ ULONG Mode
1517 );
1518
1519 VOID
1520 EfiGopGetFrameBuffer (
1521 _In_ EFI_GRAPHICS_OUTPUT_PROTOCOL *GopInterface,
1522 _Out_ PHYSICAL_ADDRESS* FrameBuffer,
1523 _Out_ UINTN *FrameBufferSize
1524 );
1525
1526 VOID
1527 EfiResetSystem (
1528 _In_ EFI_RESET_TYPE ResetType
1529 );
1530
1531 EFI_DEVICE_PATH*
1532 EfiGetLeafNode (
1533 _In_ EFI_DEVICE_PATH *DevicePath
1534 );
1535
1536 EFI_DEVICE_PATH *
1537 EfiIsDevicePathParent (
1538 _In_ EFI_DEVICE_PATH *DevicePath1,
1539 _In_ EFI_DEVICE_PATH *DevicePath2
1540 );
1541
1542 NTSTATUS
1543 EfipGetRsdt (
1544 _Out_ PPHYSICAL_ADDRESS FoundRsdt
1545 );
1546
1547 NTSTATUS
1548 EfiFreePages (
1549 _In_ ULONG Pages,
1550 _In_ EFI_PHYSICAL_ADDRESS PhysicalAddress
1551 );
1552
1553 /* PLATFORM TIMER ROUTINES ***************************************************/
1554
1555 NTSTATUS
1556 BlpTimeCalibratePerformanceCounter (
1557 VOID
1558 );
1559
1560 ULONGLONG
1561 BlTimeQueryPerformanceCounter (
1562 _Out_opt_ PLARGE_INTEGER Frequency
1563 );
1564
1565 ULONGLONG
1566 BlArchGetPerformanceCounter (
1567 VOID
1568 );
1569
1570 /* RESOURCE LOCALE INTERNATIONALIZATION ROUTINES *****************************/
1571
1572 NTSTATUS
1573 BlpDisplayRegisterLocale (
1574 _In_ PWCHAR Locale
1575 );
1576
1577 /* FONT ROUTINES *************************************************************/
1578
1579 VOID
1580 BfiFreeDeferredFontFile (
1581 _In_ PBL_DEFERRED_FONT_FILE DeferredFontFile
1582 );
1583
1584 NTSTATUS
1585 BfLoadFontFile (
1586 _In_ PBL_DEVICE_DESCRIPTOR Device,
1587 _In_ PWCHAR FontPath
1588 );
1589
1590 NTSTATUS
1591 BfLoadDeferredFontFiles (
1592 VOID
1593 );
1594
1595 NTSTATUS
1596 BfClearScreen (
1597 _In_ PBL_GRAPHICS_CONSOLE Console
1598 );
1599
1600 NTSTATUS
1601 BfClearToEndOfLine (
1602 _In_ PBL_GRAPHICS_CONSOLE Console
1603 );
1604
1605 /* FILESYSTEM ROUTINES *******************************************************/
1606
1607 NTSTATUS
1608 FatInitialize (
1609 VOID
1610 );
1611
1612 NTSTATUS
1613 FatMount (
1614 _In_ ULONG DeviceId,
1615 _In_ ULONG Unknown,
1616 _Out_ PBL_FILE_ENTRY* FileEntry
1617 );
1618
1619 NTSTATUS
1620 EtfsInitialize (
1621 VOID
1622 );
1623
1624 NTSTATUS
1625 EtfsMount (
1626 _In_ ULONG DeviceId,
1627 _In_ ULONG Unknown,
1628 _Out_ PBL_FILE_ENTRY* FileEntry
1629 );
1630
1631 /* DEBUG ROUTINES ************************************************************/
1632
1633
1634 BOOLEAN
1635 BlBdDebuggerEnabled (
1636 VOID
1637 );
1638
1639 NTSTATUS
1640 BlBdPullRemoteFile (
1641 _In_ PWCHAR FilePath,
1642 _Out_ PVOID BaseAddress,
1643 _Out_ PULONGLONG FileSize
1644 );
1645
1646 VOID
1647 BlStatusPrint (
1648 _In_ PCWCH Format,
1649 ...
1650 );
1651
1652 VOID
1653 BlStatusError (
1654 _In_ ULONG ErrorCode,
1655 _In_ ULONG Parameter1,
1656 _In_ ULONG_PTR Parameter2,
1657 _In_ ULONG_PTR Parameter3,
1658 _In_ ULONG_PTR Parameter4
1659 );
1660
1661 /* UTILITY ROUTINES **********************************************************/
1662
1663 VOID
1664 BlArchCpuId (
1665 _In_ ULONG Function,
1666 _In_ ULONG SubFunction,
1667 _Out_ INT* Result
1668 );
1669
1670 BOOLEAN
1671 BlArchIsCpuIdFunctionSupported (
1672 _In_ ULONG Function
1673 );
1674
1675 VOID
1676 BlUtlUpdateProgress (
1677 _In_ ULONG Percentage,
1678 _Out_opt_ PBOOLEAN Completed
1679 );
1680
1681 NTSTATUS
1682 BlUtlGetAcpiTable (
1683 _Out_ PVOID* TableAddress,
1684 _In_ ULONG Signature
1685 );
1686
1687 NTSTATUS
1688 BlUtlInitialize (
1689 VOID
1690 );
1691
1692 NTSTATUS
1693 BlUtlRegisterProgressRoutine (
1694 VOID
1695 );
1696
1697 ULONG
1698 BlUtlCheckSum (
1699 _In_ ULONG PartialSum,
1700 _In_ PUCHAR Buffer,
1701 _In_ ULONG Length,
1702 _In_ ULONG Flags
1703 );
1704
1705 NTSTATUS
1706 BlGetApplicationBaseAndSize (
1707 _Out_ PVOID* ImageBase,
1708 _Out_ PULONG ImageSize
1709 );
1710
1711 VOID
1712 BlDestroyBootEntry (
1713 _In_ PBL_LOADED_APPLICATION_ENTRY AppEntry
1714 );
1715
1716 NTSTATUS
1717 BlPdQueryData (
1718 _In_ const GUID* DataGuid,
1719 _In_ PVOID Unknown,
1720 _Inout_ PBL_PD_DATA_BLOB DataBlob
1721 );
1722
1723 /* FIRMWARE UTILITY ROUTINES *************************************************/
1724
1725 EFI_STATUS
1726 EfiGetEfiStatusCode(
1727 _In_ NTSTATUS Status
1728 );
1729
1730 NTSTATUS
1731 EfiGetNtStatusCode (
1732 _In_ EFI_STATUS EfiStatus
1733 );
1734
1735 VOID
1736 BlFwReboot (
1737 VOID
1738 );
1739
1740 NTSTATUS
1741 MmFwFreePages (
1742 _In_ ULONG BasePage,
1743 _In_ ULONG PageCount
1744 );
1745
1746 PGUID
1747 BlGetApplicationIdentifier (
1748 VOID
1749 );
1750
1751 NTSTATUS
1752 BlpSecureBootEFIIsEnabled (
1753 VOID
1754 );
1755
1756 NTSTATUS
1757 BlSecureBootIsEnabled (
1758 _Out_ PBOOLEAN SecureBootEnabled
1759 );
1760
1761 NTSTATUS
1762 BlSecureBootCheckForFactoryReset (
1763 VOID
1764 );
1765
1766 /* RESOURCE ROUTINES *********************************************************/
1767
1768 PWCHAR
1769 BlResourceFindMessage (
1770 _In_ ULONG MsgId
1771 );
1772
1773 PWCHAR
1774 BlResourceFindHtml (
1775 VOID
1776 );
1777
1778 NTSTATUS
1779 BlpResourceInitialize (
1780 VOID
1781 );
1782
1783 /* TABLE ROUTINES ************************************************************/
1784
1785 NTSTATUS
1786 BlTblMap (
1787 _In_ PVOID *Table,
1788 _In_ ULONG Count,
1789 _In_ PBL_TBL_MAP_ROUTINE MapCallback
1790 );
1791
1792 PVOID
1793 BlTblFindEntry (
1794 _In_ PVOID *Table,
1795 _In_ ULONG Count,
1796 _Out_ PULONG EntryIndex,
1797 _In_ PBL_TBL_LOOKUP_ROUTINE Callback,
1798 _In_ PVOID Argument1,
1799 _In_ PVOID Argument2,
1800 _In_ PVOID Argument3,
1801 _In_ PVOID Argument4
1802 );
1803
1804 NTSTATUS
1805 BlTblSetEntry (
1806 _Inout_ PVOID** Table,
1807 _Inout_ PULONG Count,
1808 _In_ PVOID Entry,
1809 _Out_ PULONG EntryIndex,
1810 _In_ PBL_TBL_SET_ROUTINE Callback
1811 );
1812
1813 NTSTATUS
1814 TblDoNotPurgeEntry (
1815 _In_ PVOID Entry
1816 );
1817
1818 /* HASH TABLE ROUTINES *******************************************************/
1819
1820 NTSTATUS
1821 BlHtStore (
1822 _In_ ULONG TableId,
1823 _In_ PBL_HASH_ENTRY Entry,
1824 _In_ PVOID Data,
1825 _In_ ULONG DataSize
1826 );
1827
1828 NTSTATUS
1829 BlHtLookup (
1830 _In_ ULONG TableId,
1831 _In_ PBL_HASH_ENTRY Entry,
1832 _Out_ PBL_HASH_VALUE *Value
1833 );
1834
1835 NTSTATUS
1836 BlHtCreate (
1837 _In_ ULONG Size,
1838 _In_ PBL_HASH_TABLE_HASH_FUNCTION HashFunction,
1839 _In_ PBL_HASH_TABLE_COMPARE_FUNCTION CompareFunction,
1840 _Out_ PULONG Id
1841 );
1842
1843 /* BCD OPTION ROUTINES *******************************************************/
1844
1845 PBL_BCD_OPTION
1846 MiscGetBootOption (
1847 _In_ PBL_BCD_OPTION List,
1848 _In_ ULONG Type
1849 );
1850
1851 ULONG
1852 BlGetBootOptionListSize (
1853 _In_ PBL_BCD_OPTION BcdOption
1854 );
1855
1856 ULONG
1857 BlGetBootOptionSize (
1858 _In_ PBL_BCD_OPTION BcdOption
1859 );
1860
1861 NTSTATUS
1862 BlGetBootOptionString (
1863 _In_ PBL_BCD_OPTION List,
1864 _In_ ULONG Type,
1865 _Out_ PWCHAR* Value
1866 );
1867
1868 NTSTATUS
1869 BlGetBootOptionInteger (
1870 _In_ PBL_BCD_OPTION List,
1871 _In_ ULONG Type,
1872 _Out_ PULONGLONG Value
1873 );
1874
1875 NTSTATUS
1876 BlGetBootOptionBoolean (
1877 _In_ PBL_BCD_OPTION List,
1878 _In_ ULONG Type,
1879 _Out_ PBOOLEAN Value
1880 );
1881
1882 NTSTATUS
1883 BlpGetBootOptionIntegerList (
1884 _In_ PBL_BCD_OPTION List,
1885 _In_ ULONG Type,
1886 _Out_ PULONGLONG* Value,
1887 _Out_ PULONGLONG Count,
1888 _In_ BOOLEAN NoCopy
1889 );
1890
1891 NTSTATUS
1892 BlGetBootOptionDevice (
1893 _In_ PBL_BCD_OPTION List,
1894 _In_ ULONG Type,
1895 _Out_ PBL_DEVICE_DESCRIPTOR* Value,
1896 _In_opt_ PBL_BCD_OPTION* ExtraOptions
1897 );
1898
1899 NTSTATUS
1900 BlGetBootOptionGuid (
1901 _In_ PBL_BCD_OPTION List,
1902 _In_ ULONG Type,
1903 _Out_ PGUID Value
1904 );
1905
1906 NTSTATUS
1907 BlGetBootOptionGuidList (
1908 _In_ PBL_BCD_OPTION List,
1909 _In_ ULONG Type,
1910 _Out_ PGUID *Value,
1911 _In_ PULONG Count
1912 );
1913
1914 NTSTATUS
1915 BlCopyBootOptions (
1916 _In_ PBL_BCD_OPTION OptionList,
1917 _Out_ PBL_BCD_OPTION *CopiedOptions
1918 );
1919
1920 NTSTATUS
1921 BlAppendBootOptionBoolean (
1922 _In_ PBL_LOADED_APPLICATION_ENTRY AppEntry,
1923 _In_ ULONG OptionId
1924 );
1925
1926 NTSTATUS
1927 BlAppendBootOptionInteger (
1928 _In_ PBL_LOADED_APPLICATION_ENTRY AppEntry,
1929 _In_ ULONG OptionId,
1930 _In_ ULONGLONG Value
1931 );
1932
1933 NTSTATUS
1934 BlAppendBootOptionString (
1935 _In_ PBL_LOADED_APPLICATION_ENTRY AppEntry,
1936 _In_ PWCHAR OptionString
1937 );
1938
1939 NTSTATUS
1940 BlAppendBootOptions (
1941 _In_ PBL_LOADED_APPLICATION_ENTRY AppEntry,
1942 _In_ PBL_BCD_OPTION Options
1943 );
1944
1945 VOID
1946 BlRemoveBootOption (
1947 _In_ PBL_BCD_OPTION List,
1948 _In_ ULONG Type
1949 );
1950
1951 NTSTATUS
1952 BlReplaceBootOptions (
1953 _In_ PBL_LOADED_APPLICATION_ENTRY AppEntry,
1954 _In_ PBL_BCD_OPTION NewOptions
1955 );
1956
1957 /* BOOT REGISTRY ROUTINES ****************************************************/
1958
1959 VOID
1960 BiCloseKey (
1961 _In_ HANDLE KeyHandle
1962 );
1963
1964 NTSTATUS
1965 BiOpenKey(
1966 _In_ HANDLE ParentHandle,
1967 _In_ PWCHAR KeyName,
1968 _Out_ PHANDLE Handle
1969 );
1970
1971 NTSTATUS
1972 BiLoadHive (
1973 _In_ PBL_FILE_PATH_DESCRIPTOR FilePath,
1974 _Out_ PHANDLE HiveHandle
1975 );
1976
1977 NTSTATUS
1978 BiGetRegistryValue (
1979 _In_ HANDLE KeyHandle,
1980 _In_ PWCHAR ValueName,
1981 _In_ ULONG Type,
1982 _Out_ PVOID* Buffer,
1983 _Out_ PULONG ValueLength
1984 );
1985
1986 NTSTATUS
1987 BiEnumerateSubKeys (
1988 _In_ HANDLE KeyHandle,
1989 _Out_ PWCHAR** SubKeyList,
1990 _Out_ PULONG SubKeyCount
1991 );
1992
1993 NTSTATUS
1994 BiDeleteKey (
1995 _In_ HANDLE KeyHandle
1996 );
1997
1998 VOID
1999 BiDereferenceHive (
2000 _In_ HANDLE KeyHandle
2001 );
2002
2003 /* CONTEXT ROUTINES **********************************************************/
2004
2005 VOID
2006 BlpArchSwitchContext (
2007 _In_ BL_ARCH_MODE NewMode
2008 );
2009
2010 VOID
2011 Archx86TransferTo32BitApplicationAsm (
2012 VOID
2013 );
2014
2015 /* MEMORY DESCRIPTOR ROUTINES ************************************************/
2016
2017 VOID
2018 MmMdInitializeList (
2019 _In_ PBL_MEMORY_DESCRIPTOR_LIST DescriptorList,
2020 _In_ ULONG Type,
2021 _In_ PLIST_ENTRY ListHead
2022 );
2023
2024 PBL_MEMORY_DESCRIPTOR
2025 MmMdFindDescriptor (
2026 _In_ ULONG WhichList,
2027 _In_ ULONG Flags,
2028 _In_ ULONGLONG Page
2029 );
2030
2031 PBL_MEMORY_DESCRIPTOR
2032 MmMdFindDescriptorFromMdl (
2033 _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList,
2034 _In_ ULONG Flags,
2035 _In_ ULONGLONG Page
2036 );
2037
2038 NTSTATUS
2039 MmMdCopyList (
2040 _In_ PBL_MEMORY_DESCRIPTOR_LIST DestinationList,
2041 _In_ PBL_MEMORY_DESCRIPTOR_LIST SourceList,
2042 _In_opt_ PBL_MEMORY_DESCRIPTOR ListDescriptor,
2043 _Out_ PULONG ActualCount,
2044 _In_ ULONG Count,
2045 _In_ ULONG Flags
2046 );
2047
2048 ULONG
2049 MmMdCountList (
2050 _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList
2051 );
2052
2053 VOID
2054 MmMdFreeList(
2055 _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList
2056 );
2057
2058 PBL_MEMORY_DESCRIPTOR
2059 MmMdInitByteGranularDescriptor (
2060 _In_ ULONG Flags,
2061 _In_ BL_MEMORY_TYPE Type,
2062 _In_ ULONGLONG BasePage,
2063 _In_ ULONGLONG VirtualPage,
2064 _In_ ULONGLONG PageCount
2065 );
2066
2067 VOID
2068 MmMdFreeGlobalDescriptors (
2069 VOID
2070 );
2071
2072 NTSTATUS
2073 MmMdAddDescriptorToList (
2074 _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList,
2075 _In_ PBL_MEMORY_DESCRIPTOR MemoryDescriptor,
2076 _In_ ULONG Flags
2077 );
2078
2079 VOID
2080 MmMdRemoveDescriptorFromList (
2081 _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList,
2082 _In_ PBL_MEMORY_DESCRIPTOR Entry
2083 );
2084
2085 BOOLEAN
2086 MmMdFindSatisfyingRegion (
2087 _In_ PBL_MEMORY_DESCRIPTOR Descriptor,
2088 _Out_ PBL_MEMORY_DESCRIPTOR NewDescriptor,
2089 _In_ ULONGLONG Pages,
2090 _In_ PBL_ADDRESS_RANGE BaseRange,
2091 _In_ PBL_ADDRESS_RANGE VirtualRange,
2092 _In_ BOOLEAN TopDown,
2093 _In_ BL_MEMORY_TYPE MemoryType,
2094 _In_ ULONG Flags,
2095 _In_ ULONG Alignment
2096 );
2097
2098 NTSTATUS
2099 MmMdRemoveRegionFromMdlEx (
2100 __in PBL_MEMORY_DESCRIPTOR_LIST MdList,
2101 __in ULONG Flags,
2102 __in ULONGLONG BasePage,
2103 __in ULONGLONG PageCount,
2104 __in PBL_MEMORY_DESCRIPTOR_LIST NewMdList
2105 );
2106
2107 NTSTATUS
2108 MmMdFreeDescriptor (
2109 _In_ PBL_MEMORY_DESCRIPTOR MemoryDescriptor
2110 );
2111
2112 /* PAGE ALLOCATOR ROUTINES ***************************************************/
2113
2114 NTSTATUS
2115 BlMmAllocatePhysicalPages(
2116 _Inout_ PPHYSICAL_ADDRESS Address,
2117 _In_ BL_MEMORY_TYPE MemoryType,
2118 _In_ ULONGLONG PageCount,
2119 _In_ ULONG Attributes,
2120 _In_ ULONG Alignment
2121 );
2122
2123 NTSTATUS
2124 MmPapAllocatePhysicalPagesInRange (
2125 _Inout_ PPHYSICAL_ADDRESS BaseAddress,
2126 _In_ BL_MEMORY_TYPE MemoryType,
2127 _In_ ULONGLONG Pages,
2128 _In_ ULONG Attributes,
2129 _In_ ULONG Alignment,
2130 _In_ PBL_MEMORY_DESCRIPTOR_LIST NewList,
2131 _In_opt_ PBL_ADDRESS_RANGE Range,
2132 _In_ ULONG RangeType
2133 );
2134
2135 NTSTATUS
2136 MmPaReleaseSelfMapPages (
2137 _In_ PHYSICAL_ADDRESS Address
2138 );
2139
2140 NTSTATUS
2141 MmPaReserveSelfMapPages (
2142 _Inout_ PPHYSICAL_ADDRESS PhysicalAddress,
2143 _In_ ULONG Alignment,
2144 _In_ ULONG PageCount
2145 );
2146 NTSTATUS
2147 BlMmFreePhysicalPages (
2148 _In_ PHYSICAL_ADDRESS Address
2149 );
2150
2151 NTSTATUS
2152 MmPapFreePages (
2153 _In_ PVOID Address,
2154 _In_ ULONG WhichList
2155 );
2156
2157 NTSTATUS
2158 MmPapAllocatePagesInRange (
2159 _Inout_ PVOID* PhysicalAddress,
2160 _In_ BL_MEMORY_TYPE MemoryType,
2161 _In_ ULONGLONG Pages,
2162 _In_ ULONG Attributes,
2163 _In_ ULONG Alignment,
2164 _In_opt_ PBL_ADDRESS_RANGE Range,
2165 _In_ ULONG Type
2166 );
2167
2168 NTSTATUS
2169 MmFwGetMemoryMap (
2170 _Out_ PBL_MEMORY_DESCRIPTOR_LIST MemoryMap,
2171 _In_ ULONG Flags
2172 );
2173
2174 NTSTATUS
2175 BlpMmInitializeConstraints (
2176 VOID
2177 );
2178
2179 NTSTATUS
2180 BlMmRemoveBadMemory (
2181 VOID
2182 );
2183
2184 NTSTATUS
2185 BlMmGetMemoryMap (
2186 _In_ PLIST_ENTRY MemoryMap,
2187 _In_ PBL_IMAGE_PARAMETERS MemoryParameters,
2188 _In_ ULONG WhichTypes,
2189 _In_ ULONG Flags
2190 );
2191
2192 /* VIRTUAL MEMORY ROUTINES ***************************************************/
2193
2194 NTSTATUS
2195 MmSelectMappingAddress (
2196 _Out_ PVOID* MappingAddress,
2197 _In_ ULONGLONG Size,
2198 _In_ ULONG AllocationAttributes,
2199 _In_ ULONG Flags,
2200 _In_ PHYSICAL_ADDRESS PhysicalAddress
2201 );
2202
2203 NTSTATUS
2204 MmMapPhysicalAddress (
2205 _Inout_ PPHYSICAL_ADDRESS PhysicalAddress,
2206 _Out_ PVOID* VirtualAddress,
2207 _Inout_ PULONGLONG Size,
2208 _In_ ULONG CacheAttributes
2209 );
2210
2211 NTSTATUS
2212 MmUnmapVirtualAddress (
2213 _Inout_ PVOID* VirtualAddress,
2214 _Inout_ PULONGLONG Size
2215 );
2216
2217 NTSTATUS
2218 BlMmMapPhysicalAddressEx (
2219 _In_ PVOID* VirtualAddress,
2220 _In_ ULONG Attributes,
2221 _In_ ULONGLONG Size,
2222 _In_ PHYSICAL_ADDRESS PhysicalAddress
2223 );
2224
2225 NTSTATUS
2226 BlMmUnmapVirtualAddressEx (
2227 _In_ PVOID VirtualAddress,
2228 _In_ ULONGLONG Size
2229 );
2230
2231 BOOLEAN
2232 BlMmTranslateVirtualAddress (
2233 _In_ PVOID VirtualAddress,
2234 _Out_ PPHYSICAL_ADDRESS PhysicalAddress
2235 );
2236
2237 BOOLEAN
2238 MmArchTranslateVirtualAddress (
2239 _In_ PVOID VirtualAddress,
2240 _Out_opt_ PPHYSICAL_ADDRESS PhysicalAddress,
2241 _Out_opt_ PULONG CachingFlags
2242 );
2243
2244 /* BLOCK ALLOCATOR ROUTINES **************************************************/
2245
2246 NTSTATUS
2247 BlpMmCreateBlockAllocator (
2248 VOID
2249 );
2250
2251 /* HEAP ALLOCATOR ROUTINES ***************************************************/
2252
2253 PVOID
2254 BlMmAllocateHeap (
2255 _In_ ULONG Size
2256 );
2257
2258 NTSTATUS
2259 BlMmFreeHeap (
2260 _In_ PVOID Buffer
2261 );
2262
2263 /* DISPLAY ROUTINES **********************************************************/
2264
2265 VOID
2266 BlDisplayGetTextCellResolution (
2267 _Out_ PULONG TextWidth,
2268 _Out_ PULONG TextHeight
2269 );
2270
2271 NTSTATUS
2272 BlDisplaySetScreenResolution (
2273 VOID
2274 );
2275
2276 NTSTATUS
2277 BlDisplayGetScreenResolution (
2278 _Out_ PULONG HRes,
2279 _Out_ PULONG Vres
2280 );
2281
2282 VOID
2283 BlDisplayInvalidateOemBitmap (
2284 VOID
2285 );
2286
2287 PBITMAP
2288 BlDisplayGetOemBitmap (
2289 _Out_ PCOORD Offset,
2290 _Out_opt_ PULONG Flags
2291 );
2292
2293 BOOLEAN
2294 BlDisplayValidOemBitmap (
2295 VOID
2296 );
2297
2298 NTSTATUS
2299 BlDisplayClearScreen (
2300 VOID
2301 );
2302
2303 NTSTATUS
2304 BlDisplaySetCursorType (
2305 _In_ ULONG Type
2306 );
2307
2308 /* I/O ROUTINES **************************************************************/
2309
2310 NTSTATUS
2311 BlpIoRegisterDestroyRoutine (
2312 _In_ PBL_IO_DESTROY_ROUTINE DestroyRoutine
2313 );
2314
2315 NTSTATUS
2316 BlDeviceClose (
2317 _In_ ULONG DeviceId
2318 );
2319
2320 NTSTATUS
2321 BlpDeviceOpen (
2322 _In_ PBL_DEVICE_DESCRIPTOR Device,
2323 _In_ ULONG Flags,
2324 _In_ ULONG Unknown,
2325 _Out_ PULONG DeviceId
2326 );
2327
2328 NTSTATUS
2329 BlDeviceGetInformation (
2330 _In_ ULONG DeviceId,
2331 _Out_ PBL_DEVICE_INFORMATION DeviceInformation
2332 );
2333
2334 NTSTATUS
2335 BlDeviceSetInformation (
2336 _In_ ULONG DeviceId,
2337 _In_ PBL_DEVICE_INFORMATION DeviceInformation
2338 );
2339
2340 NTSTATUS
2341 BlDeviceReadAtOffset (
2342 _In_ ULONG DeviceId,
2343 _In_ ULONG Size,
2344 _In_ ULONGLONG Offset,
2345 _In_ PVOID Buffer,
2346 _Out_ PULONG BytesRead
2347 );
2348
2349 /* IMAGE ROUTINES ************************************************************/
2350
2351 NTSTATUS
2352 BlImgLoadImageWithProgress2 (
2353 _In_ ULONG DeviceId,
2354 _In_ BL_MEMORY_TYPE MemoryType,
2355 _In_ PWCHAR FileName,
2356 _Inout_ PVOID* MappedBase,
2357 _Inout_ PULONG MappedSize,
2358 _In_ ULONG ImageFlags,
2359 _In_ BOOLEAN ShowProgress,
2360 _Out_opt_ PUCHAR* HashBuffer,
2361 _Out_opt_ PULONG HashSize
2362 );
2363
2364 PIMAGE_SECTION_HEADER
2365 BlImgFindSection (
2366 _In_ PVOID ImageBase,
2367 _In_ ULONG ImageSize
2368 );
2369
2370 NTSTATUS
2371 BlImgLoadBootApplication (
2372 _In_ PBL_LOADED_APPLICATION_ENTRY BootEntry,
2373 _Out_ PULONG AppHandle
2374 );
2375
2376 NTSTATUS
2377 BlImgStartBootApplication (
2378 _In_ ULONG AppHandle,
2379 _Inout_ PBL_RETURN_ARGUMENTS ReturnArguments
2380 );
2381
2382 NTSTATUS
2383 BlImgUnloadBootApplication (
2384 _In_ ULONG AppHandle
2385 );
2386
2387 VOID
2388 BlImgQueryCodeIntegrityBootOptions (
2389 _In_ PBL_LOADED_APPLICATION_ENTRY ApplicationEntry,
2390 _Out_ PBOOLEAN IntegrityChecksDisabled,
2391 _Out_ PBOOLEAN TestSigning
2392 );
2393
2394 /* FILE I/O ROUTINES *********************************************************/
2395
2396 NTSTATUS
2397 BlFileClose (
2398 _In_ ULONG FileId
2399 );
2400
2401 NTSTATUS
2402 BlFileReadAtOffsetEx (
2403 _In_ ULONG FileId,
2404 _In_ ULONG Size,
2405 _In_ ULONGLONG ByteOffset,
2406 _In_ PVOID Buffer,
2407 _Out_ PULONG BytesReturned,
2408 _In_ ULONG Flags
2409 );
2410
2411 NTSTATUS
2412 BlFileGetInformation (
2413 _In_ ULONG FileId,
2414 _In_ PBL_FILE_INFORMATION FileInfo
2415 );
2416
2417 NTSTATUS
2418 BlFileOpen (
2419 _In_ ULONG DeviceId,
2420 _In_ PWCHAR FileName,
2421 _In_ ULONG Flags,
2422 _Out_ PULONG FileId
2423 );
2424
2425 /* BLOCK I/O ROUTINES *******************************************************/
2426
2427 NTSTATUS
2428 BlockIoEfiCompareDevice (
2429 _In_ PBL_DEVICE_DESCRIPTOR Device,
2430 _In_ EFI_HANDLE Handle
2431 );
2432
2433 /* INPUT CONSOLE ROUTINES ****************************************************/
2434
2435 VOID
2436 ConsoleInputLocalDestruct (
2437 _In_ struct _BL_INPUT_CONSOLE* Console
2438 );
2439
2440 NTSTATUS
2441 ConsoleInputBaseReinitialize (
2442 _In_ struct _BL_INPUT_CONSOLE* Console
2443 );
2444
2445 NTSTATUS
2446 ConsoleCreateLocalInputCnsole (
2447 VOID
2448 );
2449
2450 /* TEXT CONSOLE ROUTINES *****************************************************/
2451
2452 VOID
2453 ConsoleGraphicalDestruct (
2454 _In_ struct _BL_GRAPHICS_CONSOLE* Console
2455 );
2456
2457 NTSTATUS
2458 ConsoleGraphicalClearText (
2459 _In_ PBL_GRAPHICS_CONSOLE Console,
2460 _In_ BOOLEAN LineOnly
2461 );
2462
2463 NTSTATUS
2464 ConsoleGraphicalClearPixels (
2465 _In_ PBL_GRAPHICS_CONSOLE Console,
2466 _In_ ULONG Color
2467 );
2468
2469 NTSTATUS
2470 ConsoleGraphicalReinitialize (
2471 _In_ struct _BL_GRAPHICS_CONSOLE* Console
2472 );
2473
2474 NTSTATUS
2475 ConsoleGraphicalSetTextState (
2476 _In_ PBL_GRAPHICS_CONSOLE Console,
2477 _In_ ULONG Mask,
2478 _In_ PBL_DISPLAY_STATE TextState
2479 );
2480
2481 BOOLEAN
2482 ConsoleGraphicalIsEnabled (
2483 _In_ struct _BL_GRAPHICS_CONSOLE* Console
2484 );
2485
2486 NTSTATUS
2487 ConsoleGraphicalGetGraphicalResolution (
2488 _In_ struct _BL_GRAPHICS_CONSOLE* Console,
2489 _In_ PBL_DISPLAY_MODE DisplayMode
2490 );
2491
2492 NTSTATUS
2493 ConsoleGraphicalGetOriginalResolution (
2494 _In_ struct _BL_GRAPHICS_CONSOLE* Console,
2495 _In_ PBL_DISPLAY_MODE DisplayMode
2496 );
2497
2498 NTSTATUS
2499 ConsoleGraphicalEnable (
2500 _In_ struct _BL_GRAPHICS_CONSOLE* Console,
2501 _In_ BOOLEAN Enable
2502 );
2503
2504 VOID
2505 ConsoleTextLocalDestruct (
2506 _In_ struct _BL_TEXT_CONSOLE* Console
2507 );
2508
2509 NTSTATUS
2510 ConsoleTextLocalReinitialize (
2511 _In_ struct _BL_TEXT_CONSOLE* Console
2512 );
2513
2514 NTSTATUS
2515 ConsoleTextBaseGetTextState (
2516 _In_ struct _BL_TEXT_CONSOLE* Console,
2517 _Out_ PBL_DISPLAY_STATE TextState
2518 );
2519
2520 NTSTATUS
2521 ConsoleTextLocalSetTextState (
2522 _In_ struct _BL_TEXT_CONSOLE* Console,
2523 _In_ ULONG Flags,
2524 _In_ PBL_DISPLAY_STATE TextState
2525 );
2526
2527 NTSTATUS
2528 ConsoleTextBaseGetTextResolution (
2529 _In_ struct _BL_TEXT_CONSOLE* Console,
2530 _Out_ PULONG TextResolution
2531 );
2532
2533 NTSTATUS
2534 ConsoleTextLocalSetTextResolution (
2535 _In_ struct _BL_TEXT_CONSOLE* Console,
2536 _In_ ULONG NewTextResolution,
2537 _Out_ PULONG OldTextResolution
2538 );
2539
2540 NTSTATUS
2541 ConsoleTextLocalClearText (
2542 _In_ struct _BL_TEXT_CONSOLE* Console,
2543 _In_ BOOLEAN LineOnly
2544 );
2545
2546 NTSTATUS
2547 ConsoleTextLocalWriteText (
2548 _In_ struct _BL_TEXT_CONSOLE* Console,
2549 _In_ PCHAR Text,
2550 _In_ ULONG Attribute
2551 );
2552
2553 NTSTATUS
2554 ConsoleTextLocalConstruct (
2555 _In_ PBL_TEXT_CONSOLE TextConsole,
2556 _In_ BOOLEAN Activate
2557 );
2558
2559 BOOLEAN
2560 ConsolepFindResolution (
2561 _In_ PBL_DISPLAY_MODE Mode,
2562 _In_ PBL_DISPLAY_MODE List,
2563 _In_ ULONG MaxIndex
2564 );
2565
2566 NTSTATUS
2567 ConsoleFirmwareTextClear (
2568 _In_ PBL_TEXT_CONSOLE Console,
2569 _In_ BOOLEAN LineOnly
2570 );
2571
2572 VOID
2573 ConsoleFirmwareTextClose (
2574 _In_ PBL_TEXT_CONSOLE TextConsole
2575 );
2576
2577 NTSTATUS
2578 ConsoleFirmwareTextOpen (
2579 _In_ PBL_TEXT_CONSOLE TextConsole
2580 );
2581
2582 NTSTATUS
2583 ConsoleFirmwareTextSetState (
2584 _In_ PBL_TEXT_CONSOLE TextConsole,
2585 _In_ UCHAR Mask,
2586 _In_ PBL_DISPLAY_STATE State
2587 );
2588
2589 NTSTATUS
2590 ConsoleGraphicalConstruct (
2591 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
2592 );
2593
2594 NTSTATUS
2595 ConsoleCreateRemoteConsole (
2596 _In_ PBL_TEXT_CONSOLE* TextConsole
2597 );
2598
2599 NTSTATUS
2600 ConsoleEfiGraphicalOpenProtocol (
2601 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole,
2602 _In_ BL_GRAPHICS_CONSOLE_TYPE Type
2603 );
2604
2605 VOID
2606 ConsoleFirmwareGraphicalClose (
2607 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
2608 );
2609
2610 VOID
2611 ConsoleFirmwareGraphicalDisable (
2612 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
2613 );
2614
2615 NTSTATUS
2616 ConsoleFirmwareGraphicalClear (
2617 _In_ PBL_GRAPHICS_CONSOLE Console,
2618 _In_ ULONG Color
2619 );
2620
2621 NTSTATUS
2622 ConsoleFirmwareGraphicalEnable (
2623 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
2624 );
2625
2626 NTSTATUS
2627 ConsoleEfiUgaOpen (
2628 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
2629 );
2630
2631 VOID
2632 ConsoleEfiUgaClose (
2633 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
2634 );
2635
2636 VOID
2637 ConsoleEfiGopClose (
2638 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
2639 );
2640
2641 NTSTATUS
2642 ConsoleEfiGopOpen (
2643 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
2644 );
2645
2646 NTSTATUS
2647 ConsoleEfiGopEnable (
2648 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
2649 );
2650
2651 NTSTATUS
2652 ConsoleEfiUgaSetResolution (
2653 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole,
2654 _In_ PBL_DISPLAY_MODE DisplayMode,
2655 _In_ ULONG DisplayModeCount
2656 );
2657
2658 NTSTATUS
2659 ConsoleCreateLocalInputConsole (
2660 VOID
2661 );
2662
2663 NTSTATUS
2664 ConsoleInputLocalEraseBuffer (
2665 _In_ PBL_INPUT_CONSOLE Console,
2666 _In_opt_ PULONG ValueToFill
2667 );
2668
2669 VOID
2670 ConsolepClearBuffer (
2671 _In_ PUCHAR FrameBuffer,
2672 _In_ ULONG Width,
2673 _In_ PUCHAR FillColor,
2674 _In_ ULONG Height,
2675 _In_ ULONG ScanlineWidth,
2676 _In_ ULONG PixelDepth
2677 );
2678
2679 NTSTATUS
2680 ConsolepConvertColorToPixel (
2681 _In_ BL_COLOR Color,
2682 _Out_ PUCHAR Pixel
2683 );
2684
2685 extern ULONG MmDescriptorCallTreeCount;
2686 extern ULONG BlpApplicationFlags;
2687 extern BL_LIBRARY_PARAMETERS BlpLibraryParameters;
2688 extern BL_TRANSLATION_TYPE MmTranslationType;
2689 extern PBL_ARCH_CONTEXT CurrentExecutionContext;
2690 extern PBL_DEVICE_DESCRIPTOR BlpBootDevice;
2691 extern BL_LOADED_APPLICATION_ENTRY BlpApplicationEntry;
2692 extern EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *EfiConOut;
2693 extern EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *EfiConInEx;
2694 extern EFI_GUID EfiGraphicsOutputProtocol;
2695 extern EFI_GUID EfiUgaDrawProtocol;
2696 extern EFI_GUID EfiLoadedImageProtocol;
2697 extern EFI_GUID EfiDevicePathProtocol;
2698 extern EFI_GUID EfiBlockIoProtocol;
2699 extern EFI_GUID EfiSimpleTextInputExProtocol;
2700 extern EFI_GUID EfiRootAcpiTableGuid;
2701 extern EFI_GUID EfiRootAcpiTable10Guid;
2702 extern EFI_GUID EfiGlobalVariable;
2703 extern ULONG ConsoleGraphicalResolutionListFlags;
2704 extern BL_DISPLAY_MODE ConsoleGraphicalResolutionList[];
2705 extern BL_DISPLAY_MODE ConsoleTextResolutionList[];
2706 extern ULONG ConsoleGraphicalResolutionListSize;
2707 extern PVOID DspRemoteInputConsole;
2708 extern PVOID DspLocalInputConsole;
2709 extern WCHAR BlScratchBuffer[8192];
2710 extern BL_MEMORY_DESCRIPTOR_LIST MmMdlMappedAllocated;
2711 extern BL_MEMORY_DESCRIPTOR_LIST MmMdlMappedUnallocated;
2712 extern BL_MEMORY_DESCRIPTOR_LIST MmMdlFwAllocationTracker;
2713 extern BL_MEMORY_DESCRIPTOR_LIST MmMdlUnmappedAllocated;
2714 extern BL_MEMORY_DESCRIPTOR_LIST MmMdlUnmappedUnallocated;
2715 extern BL_MEMORY_DESCRIPTOR_LIST MmMdlReservedAllocated;
2716 extern BL_MEMORY_DESCRIPTOR_LIST MmMdlBadMemory;
2717 extern BL_MEMORY_DESCRIPTOR_LIST MmMdlTruncatedMemory;
2718 extern BL_MEMORY_DESCRIPTOR_LIST MmMdlPersistentMemory;
2719 extern BL_MEMORY_DESCRIPTOR_LIST MmMdlCompleteBadMemory;
2720 extern BL_MEMORY_DESCRIPTOR_LIST MmMdlFreeVirtual;
2721 extern BL_MEMORY_DESCRIPTOR_LIST MmMdlMappingTrackers;
2722 extern ULONGLONG BlpTimePerformanceFrequency;
2723 extern LIST_ENTRY RegisteredFileSystems;
2724
2725 #endif