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