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