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