[BOOTLIB] Fix 64 bit issues (#433)
[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 FORCEINLINE
1389 PVOID
1390 PhysicalAddressToPtr (
1391 _In_ PHYSICAL_ADDRESS PhysicalAddress)
1392 {
1393 return (PVOID)(ULONG_PTR)PhysicalAddress.QuadPart;
1394 }
1395
1396 /* INITIALIZATION ROUTINES ***************************************************/
1397
1398 NTSTATUS
1399 BlInitializeLibrary(
1400 _In_ PBOOT_APPLICATION_PARAMETER_BLOCK BootAppParameters,
1401 _In_ PBL_LIBRARY_PARAMETERS LibraryParameters
1402 );
1403
1404 NTSTATUS
1405 BlpArchInitialize (
1406 _In_ ULONG Phase
1407 );
1408
1409 NTSTATUS
1410 BlpFwInitialize (
1411 _In_ ULONG Phase,
1412 _In_ PBL_FIRMWARE_DESCRIPTOR FirmwareParameters
1413 );
1414
1415 NTSTATUS
1416 BlpMmInitialize (
1417 _In_ PBL_MEMORY_DATA MemoryData,
1418 _In_ BL_TRANSLATION_TYPE TranslationType,
1419 _In_ PBL_LIBRARY_PARAMETERS LibraryParameters
1420 );
1421
1422 NTSTATUS
1423 MmBaInitialize (
1424 VOID
1425 );
1426
1427 NTSTATUS
1428 MmPaInitialize (
1429 _In_ PBL_MEMORY_DATA MemoryData,
1430 _In_ ULONG MinimumPages
1431 );
1432
1433 NTSTATUS
1434 MmArchInitialize (
1435 _In_ ULONG Phase,
1436 _In_ PBL_MEMORY_DATA MemoryData,
1437 _In_ BL_TRANSLATION_TYPE TranslationType,
1438 _In_ BL_TRANSLATION_TYPE LibraryTranslationType
1439 );
1440
1441 NTSTATUS
1442 MmHaInitialize (
1443 _In_ ULONG HeapSize,
1444 _In_ ULONG HeapAttributes
1445 );
1446
1447 VOID
1448 MmMdInitialize (
1449 _In_ ULONG Phase,
1450 _In_ PBL_LIBRARY_PARAMETERS LibraryParameters
1451 );
1452
1453 NTSTATUS
1454 BlpDeviceInitialize (
1455 VOID
1456 );
1457
1458 NTSTATUS
1459 BlpIoInitialize (
1460 VOID
1461 );
1462
1463 NTSTATUS
1464 BlpFileInitialize (
1465 VOID
1466 );
1467
1468 NTSTATUS
1469 BlpDisplayInitialize (
1470 _In_ ULONG Flags
1471 );
1472
1473 NTSTATUS
1474 BlpDisplayReinitialize (
1475 VOID
1476 );
1477
1478 VOID
1479 BlDestroyLibrary (
1480 VOID
1481 );
1482
1483 NTSTATUS
1484 BcInitialize (
1485 VOID
1486 );
1487
1488 /* FIRMWARE ROUTINES *********************************************************/
1489
1490 VOID
1491 EfiPrintf (
1492 _In_ PWCHAR Format,
1493 ...
1494 );
1495
1496 NTSTATUS
1497 BlFwGetParameters(
1498 _In_ PBL_FIRMWARE_DESCRIPTOR Parameters
1499 );
1500
1501 NTSTATUS
1502 BlFwEnumerateDevice (
1503 _In_ PBL_DEVICE_DESCRIPTOR Device
1504 );
1505
1506 NTSTATUS
1507 EfiAllocatePages (
1508 _In_ ULONG Type,
1509 _In_ ULONG Pages,
1510 _Inout_ EFI_PHYSICAL_ADDRESS* Memory
1511 );
1512
1513 NTSTATUS
1514 EfiStall (
1515 _In_ ULONG StallTime
1516 );
1517
1518 NTSTATUS
1519 EfiConInExReset (
1520 VOID
1521 );
1522
1523 NTSTATUS
1524 EfiConInReset (
1525 VOID
1526 );
1527
1528 NTSTATUS
1529 EfiConOutOutputString (
1530 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1531 _In_ PWCHAR String
1532 );
1533
1534 NTSTATUS
1535 EfiConOutQueryMode (
1536 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1537 _In_ ULONG Mode,
1538 _In_ UINTN* Columns,
1539 _In_ UINTN* Rows
1540 );
1541
1542 NTSTATUS
1543 EfiConOutSetMode (
1544 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1545 _In_ ULONG Mode
1546 );
1547
1548 VOID
1549 EfiConOutReadCurrentMode (
1550 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1551 _Out_ EFI_SIMPLE_TEXT_OUTPUT_MODE* Mode
1552 );
1553
1554 NTSTATUS
1555 EfiConOutSetAttribute (
1556 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1557 _In_ ULONG Attribute
1558 );
1559
1560 NTSTATUS
1561 EfiConOutSetCursorPosition (
1562 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1563 _In_ ULONG Column,
1564 _In_ ULONG Row
1565 );
1566
1567 NTSTATUS
1568 EfiConOutEnableCursor (
1569 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1570 _In_ BOOLEAN Visible
1571 );
1572
1573 NTSTATUS
1574 EfiLocateHandleBuffer (
1575 _In_ EFI_LOCATE_SEARCH_TYPE SearchType,
1576 _In_ EFI_GUID *Protocol,
1577 _Inout_ PULONG HandleCount,
1578 _Inout_ EFI_HANDLE** Buffer
1579 );
1580
1581 NTSTATUS
1582 EfiOpenProtocol (
1583 _In_ EFI_HANDLE Handle,
1584 _In_ EFI_GUID *Protocol,
1585 _Out_ PVOID* Interface
1586 );
1587
1588 NTSTATUS
1589 EfiCloseProtocol (
1590 _In_ EFI_HANDLE Handle,
1591 _In_ EFI_GUID *Protocol
1592 );
1593
1594 NTSTATUS
1595 EfiGopGetCurrentMode (
1596 _In_ EFI_GRAPHICS_OUTPUT_PROTOCOL *GopInterface,
1597 _Out_ UINTN* Mode,
1598 _Out_ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Information
1599 );
1600
1601 NTSTATUS
1602 EfiGopSetMode (
1603 _In_ EFI_GRAPHICS_OUTPUT_PROTOCOL *GopInterface,
1604 _In_ ULONG Mode
1605 );
1606
1607 VOID
1608 EfiGopGetFrameBuffer (
1609 _In_ EFI_GRAPHICS_OUTPUT_PROTOCOL *GopInterface,
1610 _Out_ PHYSICAL_ADDRESS* FrameBuffer,
1611 _Out_ UINTN *FrameBufferSize
1612 );
1613
1614 VOID
1615 EfiResetSystem (
1616 _In_ EFI_RESET_TYPE ResetType
1617 );
1618
1619 EFI_DEVICE_PATH*
1620 EfiGetLeafNode (
1621 _In_ EFI_DEVICE_PATH *DevicePath
1622 );
1623
1624 EFI_DEVICE_PATH *
1625 EfiIsDevicePathParent (
1626 _In_ EFI_DEVICE_PATH *DevicePath1,
1627 _In_ EFI_DEVICE_PATH *DevicePath2
1628 );
1629
1630 NTSTATUS
1631 EfipGetRsdt (
1632 _Out_ PPHYSICAL_ADDRESS FoundRsdt
1633 );
1634
1635 NTSTATUS
1636 EfiFreePages (
1637 _In_ ULONG Pages,
1638 _In_ EFI_PHYSICAL_ADDRESS PhysicalAddress
1639 );
1640
1641 /* PLATFORM TIMER ROUTINES ***************************************************/
1642
1643 NTSTATUS
1644 BlpTimeCalibratePerformanceCounter (
1645 VOID
1646 );
1647
1648 ULONGLONG
1649 BlTimeQueryPerformanceCounter (
1650 _Out_opt_ PLARGE_INTEGER Frequency
1651 );
1652
1653 ULONGLONG
1654 BlArchGetPerformanceCounter (
1655 VOID
1656 );
1657
1658 /* RESOURCE LOCALE INTERNATIONALIZATION ROUTINES *****************************/
1659
1660 NTSTATUS
1661 BlpDisplayRegisterLocale (
1662 _In_ PWCHAR Locale
1663 );
1664
1665 /* FONT ROUTINES *************************************************************/
1666
1667 VOID
1668 BfiFreeDeferredFontFile (
1669 _In_ PBL_DEFERRED_FONT_FILE DeferredFontFile
1670 );
1671
1672 NTSTATUS
1673 BfLoadFontFile (
1674 _In_ PBL_DEVICE_DESCRIPTOR Device,
1675 _In_ PWCHAR FontPath
1676 );
1677
1678 NTSTATUS
1679 BfLoadDeferredFontFiles (
1680 VOID
1681 );
1682
1683 NTSTATUS
1684 BfClearScreen (
1685 _In_ PBL_GRAPHICS_CONSOLE Console
1686 );
1687
1688 NTSTATUS
1689 BfClearToEndOfLine (
1690 _In_ PBL_GRAPHICS_CONSOLE Console
1691 );
1692
1693 /* FILESYSTEM ROUTINES *******************************************************/
1694
1695 NTSTATUS
1696 FatInitialize (
1697 VOID
1698 );
1699
1700 NTSTATUS
1701 FatMount (
1702 _In_ ULONG DeviceId,
1703 _In_ ULONG Unknown,
1704 _Out_ PBL_FILE_ENTRY* FileEntry
1705 );
1706
1707 NTSTATUS
1708 EtfsInitialize (
1709 VOID
1710 );
1711
1712 NTSTATUS
1713 EtfsMount (
1714 _In_ ULONG DeviceId,
1715 _In_ ULONG Unknown,
1716 _Out_ PBL_FILE_ENTRY* FileEntry
1717 );
1718
1719 /* DEBUG ROUTINES ************************************************************/
1720
1721 BOOLEAN
1722 BlBdDebuggerEnabled (
1723 VOID
1724 );
1725
1726 NTSTATUS
1727 BlBdPullRemoteFile (
1728 _In_ PWCHAR FilePath,
1729 _Out_ PVOID BaseAddress,
1730 _Out_ PULONGLONG FileSize
1731 );
1732
1733 VOID
1734 BlStatusPrint (
1735 _In_ PCWCH Format,
1736 ...
1737 );
1738
1739 VOID
1740 BlStatusError (
1741 _In_ ULONG ErrorCode,
1742 _In_ ULONG Parameter1,
1743 _In_ ULONG_PTR Parameter2,
1744 _In_ ULONG_PTR Parameter3,
1745 _In_ ULONG_PTR Parameter4
1746 );
1747
1748 /* UTILITY ROUTINES **********************************************************/
1749
1750 VOID
1751 BlArchCpuId (
1752 _In_ ULONG Function,
1753 _In_ ULONG SubFunction,
1754 _Out_ PCPU_INFO Result
1755 );
1756
1757 CPU_VENDORS
1758 BlArchGetCpuVendor (
1759 VOID
1760 );
1761
1762 BOOLEAN
1763 BlArchIsCpuIdFunctionSupported (
1764 _In_ ULONG Function
1765 );
1766
1767 VOID
1768 BlUtlUpdateProgress (
1769 _In_ ULONG Percentage,
1770 _Out_opt_ PBOOLEAN Completed
1771 );
1772
1773 NTSTATUS
1774 BlUtlGetAcpiTable (
1775 _Out_ PVOID* TableAddress,
1776 _In_ ULONG Signature
1777 );
1778
1779 NTSTATUS
1780 BlUtlInitialize (
1781 VOID
1782 );
1783
1784 NTSTATUS
1785 BlUtlRegisterProgressRoutine (
1786 VOID
1787 );
1788
1789 ULONG
1790 BlUtlCheckSum (
1791 _In_ ULONG PartialSum,
1792 _In_ PUCHAR Buffer,
1793 _In_ ULONG Length,
1794 _In_ ULONG Flags
1795 );
1796
1797 NTSTATUS
1798 BlGetApplicationBaseAndSize (
1799 _Out_ PVOID* ImageBase,
1800 _Out_ PULONG ImageSize
1801 );
1802
1803 VOID
1804 BlDestroyBootEntry (
1805 _In_ PBL_LOADED_APPLICATION_ENTRY AppEntry
1806 );
1807
1808 NTSTATUS
1809 BlPdQueryData (
1810 _In_ const GUID* DataGuid,
1811 _In_ PVOID Unknown,
1812 _Inout_ PBL_PD_DATA_BLOB DataBlob
1813 );
1814
1815 /* FIRMWARE UTILITY ROUTINES *************************************************/
1816
1817 EFI_STATUS
1818 EfiGetEfiStatusCode(
1819 _In_ NTSTATUS Status
1820 );
1821
1822 NTSTATUS
1823 EfiGetNtStatusCode (
1824 _In_ EFI_STATUS EfiStatus
1825 );
1826
1827 VOID
1828 BlFwReboot (
1829 VOID
1830 );
1831
1832 NTSTATUS
1833 MmFwFreePages (
1834 _In_ ULONG BasePage,
1835 _In_ ULONG PageCount
1836 );
1837
1838 PGUID
1839 BlGetApplicationIdentifier (
1840 VOID
1841 );
1842
1843 NTSTATUS
1844 BlpSecureBootEFIIsEnabled (
1845 VOID
1846 );
1847
1848 NTSTATUS
1849 BlSecureBootIsEnabled (
1850 _Out_ PBOOLEAN SecureBootEnabled
1851 );
1852
1853 NTSTATUS
1854 BlSecureBootCheckForFactoryReset (
1855 VOID
1856 );
1857
1858 /* RESOURCE ROUTINES *********************************************************/
1859
1860 PWCHAR
1861 BlResourceFindMessage (
1862 _In_ ULONG MsgId
1863 );
1864
1865 PWCHAR
1866 BlResourceFindHtml (
1867 VOID
1868 );
1869
1870 NTSTATUS
1871 BlpResourceInitialize (
1872 VOID
1873 );
1874
1875 /* TABLE ROUTINES ************************************************************/
1876
1877 NTSTATUS
1878 BlTblMap (
1879 _In_ PVOID *Table,
1880 _In_ ULONG Count,
1881 _In_ PBL_TBL_MAP_ROUTINE MapCallback
1882 );
1883
1884 PVOID
1885 BlTblFindEntry (
1886 _In_ PVOID *Table,
1887 _In_ ULONG Count,
1888 _Out_ PULONG EntryIndex,
1889 _In_ PBL_TBL_LOOKUP_ROUTINE Callback,
1890 _In_ PVOID Argument1,
1891 _In_ PVOID Argument2,
1892 _In_ PVOID Argument3,
1893 _In_ PVOID Argument4
1894 );
1895
1896 NTSTATUS
1897 BlTblSetEntry (
1898 _Inout_ PVOID** Table,
1899 _Inout_ PULONG Count,
1900 _In_ PVOID Entry,
1901 _Out_ PULONG EntryIndex,
1902 _In_ PBL_TBL_SET_ROUTINE Callback
1903 );
1904
1905 NTSTATUS
1906 TblDoNotPurgeEntry (
1907 _In_ PVOID Entry
1908 );
1909
1910 /* HASH TABLE ROUTINES *******************************************************/
1911
1912 NTSTATUS
1913 BlHtStore (
1914 _In_ ULONG TableId,
1915 _In_ PBL_HASH_ENTRY Entry,
1916 _In_ PVOID Data,
1917 _In_ ULONG DataSize
1918 );
1919
1920 NTSTATUS
1921 BlHtDelete (
1922 _In_ ULONG TableId,
1923 _In_ PBL_HASH_ENTRY Entry
1924 );
1925
1926 NTSTATUS
1927 BlHtLookup (
1928 _In_ ULONG TableId,
1929 _In_ PBL_HASH_ENTRY Entry,
1930 _Out_ PBL_HASH_VALUE *Value
1931 );
1932
1933 NTSTATUS
1934 BlHtCreate (
1935 _In_ ULONG Size,
1936 _In_ PBL_HASH_TABLE_HASH_FUNCTION HashFunction,
1937 _In_ PBL_HASH_TABLE_COMPARE_FUNCTION CompareFunction,
1938 _Out_ PULONG Id
1939 );
1940
1941 /* BCD OPTION ROUTINES *******************************************************/
1942
1943 PBL_BCD_OPTION
1944 MiscGetBootOption (
1945 _In_ PBL_BCD_OPTION List,
1946 _In_ ULONG Type
1947 );
1948
1949 ULONG
1950 BlGetBootOptionListSize (
1951 _In_ PBL_BCD_OPTION BcdOption
1952 );
1953
1954 ULONG
1955 BlGetBootOptionSize (
1956 _In_ PBL_BCD_OPTION BcdOption
1957 );
1958
1959 NTSTATUS
1960 BlGetBootOptionString (
1961 _In_ PBL_BCD_OPTION List,
1962 _In_ ULONG Type,
1963 _Out_ PWCHAR* Value
1964 );
1965
1966 NTSTATUS
1967 BlGetBootOptionInteger (
1968 _In_ PBL_BCD_OPTION List,
1969 _In_ ULONG Type,
1970 _Out_ PULONGLONG Value
1971 );
1972
1973 NTSTATUS
1974 BlGetBootOptionBoolean (
1975 _In_ PBL_BCD_OPTION List,
1976 _In_ ULONG Type,
1977 _Out_ PBOOLEAN Value
1978 );
1979
1980 NTSTATUS
1981 BlpGetBootOptionIntegerList (
1982 _In_ PBL_BCD_OPTION List,
1983 _In_ ULONG Type,
1984 _Out_ PULONGLONG* Value,
1985 _Out_ PULONGLONG Count,
1986 _In_ BOOLEAN NoCopy
1987 );
1988
1989 NTSTATUS
1990 BlGetBootOptionDevice (
1991 _In_ PBL_BCD_OPTION List,
1992 _In_ ULONG Type,
1993 _Out_ PBL_DEVICE_DESCRIPTOR* Value,
1994 _In_opt_ PBL_BCD_OPTION* ExtraOptions
1995 );
1996
1997 NTSTATUS
1998 BlGetBootOptionGuid (
1999 _In_ PBL_BCD_OPTION List,
2000 _In_ ULONG Type,
2001 _Out_ PGUID Value
2002 );
2003
2004 NTSTATUS
2005 BlGetBootOptionGuidList (
2006 _In_ PBL_BCD_OPTION List,
2007 _In_ ULONG Type,
2008 _Out_ PGUID *Value,
2009 _In_ PULONG Count
2010 );
2011
2012 NTSTATUS
2013 BlCopyBootOptions (
2014 _In_ PBL_BCD_OPTION OptionList,
2015 _Out_ PBL_BCD_OPTION *CopiedOptions
2016 );
2017
2018 NTSTATUS
2019 BlAppendBootOptionBoolean (
2020 _In_ PBL_LOADED_APPLICATION_ENTRY AppEntry,
2021 _In_ ULONG OptionId,
2022 _In_ BOOLEAN Value
2023 );
2024
2025 NTSTATUS
2026 BlAppendBootOptionInteger (
2027 _In_ PBL_LOADED_APPLICATION_ENTRY AppEntry,
2028 _In_ ULONG OptionId,
2029 _In_ ULONGLONG Value
2030 );
2031
2032 NTSTATUS
2033 BlAppendBootOptionString (
2034 _In_ PBL_LOADED_APPLICATION_ENTRY AppEntry,
2035 _In_ ULONG OptionId,
2036 _In_ PWCHAR OptionString
2037 );
2038
2039 NTSTATUS
2040 BlAppendBootOptions (
2041 _In_ PBL_LOADED_APPLICATION_ENTRY AppEntry,
2042 _In_ PBL_BCD_OPTION Options
2043 );
2044
2045 VOID
2046 BlRemoveBootOption (
2047 _In_ PBL_BCD_OPTION List,
2048 _In_ ULONG Type
2049 );
2050
2051 NTSTATUS
2052 BlReplaceBootOptions (
2053 _In_ PBL_LOADED_APPLICATION_ENTRY AppEntry,
2054 _In_ PBL_BCD_OPTION NewOptions
2055 );
2056
2057 /* BOOT REGISTRY ROUTINES ****************************************************/
2058
2059 VOID
2060 BiCloseKey (
2061 _In_ HANDLE KeyHandle
2062 );
2063
2064 NTSTATUS
2065 BiOpenKey(
2066 _In_ HANDLE ParentHandle,
2067 _In_ PWCHAR KeyName,
2068 _Out_ PHANDLE Handle
2069 );
2070
2071 NTSTATUS
2072 BiLoadHive (
2073 _In_ PBL_FILE_PATH_DESCRIPTOR FilePath,
2074 _Out_ PHANDLE HiveHandle
2075 );
2076
2077 NTSTATUS
2078 BiGetRegistryValue (
2079 _In_ HANDLE KeyHandle,
2080 _In_ PWCHAR ValueName,
2081 _In_ ULONG Type,
2082 _Out_ PVOID* Buffer,
2083 _Out_ PULONG ValueLength
2084 );
2085
2086 NTSTATUS
2087 BiEnumerateSubKeys (
2088 _In_ HANDLE KeyHandle,
2089 _Out_ PWCHAR** SubKeyList,
2090 _Out_ PULONG SubKeyCount
2091 );
2092
2093 NTSTATUS
2094 BiDeleteKey (
2095 _In_ HANDLE KeyHandle
2096 );
2097
2098 VOID
2099 BiDereferenceHive (
2100 _In_ HANDLE KeyHandle
2101 );
2102
2103 /* CONTEXT ROUTINES **********************************************************/
2104
2105 VOID
2106 BlpArchSwitchContext (
2107 _In_ BL_ARCH_MODE NewMode
2108 );
2109
2110 VOID
2111 BlpArchEnableTranslation (
2112 VOID
2113 );
2114
2115 VOID
2116 Archx86TransferTo32BitApplicationAsm (
2117 VOID
2118 );
2119
2120 /* MEMORY DESCRIPTOR ROUTINES ************************************************/
2121
2122 VOID
2123 MmMdDbgDumpList (
2124 _In_ PBL_MEMORY_DESCRIPTOR_LIST DescriptorList,
2125 _In_opt_ ULONG MaxCount
2126 );
2127
2128 VOID
2129 MmMdInitializeList (
2130 _In_ PBL_MEMORY_DESCRIPTOR_LIST DescriptorList,
2131 _In_ ULONG Type,
2132 _In_ PLIST_ENTRY ListHead
2133 );
2134
2135 PBL_MEMORY_DESCRIPTOR
2136 MmMdFindDescriptor (
2137 _In_ ULONG WhichList,
2138 _In_ ULONG Flags,
2139 _In_ ULONGLONG Page
2140 );
2141
2142 PBL_MEMORY_DESCRIPTOR
2143 MmMdFindDescriptorFromMdl (
2144 _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList,
2145 _In_ ULONG Flags,
2146 _In_ ULONGLONG Page
2147 );
2148
2149 NTSTATUS
2150 MmMdCopyList (
2151 _In_ PBL_MEMORY_DESCRIPTOR_LIST DestinationList,
2152 _In_ PBL_MEMORY_DESCRIPTOR_LIST SourceList,
2153 _In_opt_ PBL_MEMORY_DESCRIPTOR ListDescriptor,
2154 _Out_ PULONG ActualCount,
2155 _In_ ULONG Count,
2156 _In_ ULONG Flags
2157 );
2158
2159 ULONG
2160 MmMdCountList (
2161 _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList
2162 );
2163
2164 VOID
2165 MmMdFreeList(
2166 _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList
2167 );
2168
2169 PBL_MEMORY_DESCRIPTOR
2170 MmMdInitByteGranularDescriptor (
2171 _In_ ULONG Flags,
2172 _In_ BL_MEMORY_TYPE Type,
2173 _In_ ULONGLONG BasePage,
2174 _In_ ULONGLONG VirtualPage,
2175 _In_ ULONGLONG PageCount
2176 );
2177
2178 VOID
2179 MmMdFreeGlobalDescriptors (
2180 VOID
2181 );
2182
2183 NTSTATUS
2184 MmMdAddDescriptorToList (
2185 _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList,
2186 _In_ PBL_MEMORY_DESCRIPTOR MemoryDescriptor,
2187 _In_ ULONG Flags
2188 );
2189
2190 NTSTATUS
2191 MmMdTruncateDescriptors (
2192 _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList,
2193 _In_ PBL_MEMORY_DESCRIPTOR_LIST NewList,
2194 _In_ ULONGLONG BasePage
2195 );
2196
2197 VOID
2198 MmMdRemoveDescriptorFromList (
2199 _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList,
2200 _In_ PBL_MEMORY_DESCRIPTOR Entry
2201 );
2202
2203 BOOLEAN
2204 MmMdFindSatisfyingRegion (
2205 _In_ PBL_MEMORY_DESCRIPTOR Descriptor,
2206 _Out_ PBL_MEMORY_DESCRIPTOR NewDescriptor,
2207 _In_ ULONGLONG Pages,
2208 _In_ PBL_ADDRESS_RANGE BaseRange,
2209 _In_ PBL_ADDRESS_RANGE VirtualRange,
2210 _In_ BOOLEAN TopDown,
2211 _In_ BL_MEMORY_TYPE MemoryType,
2212 _In_ ULONG Flags,
2213 _In_ ULONG Alignment
2214 );
2215
2216 NTSTATUS
2217 MmMdRemoveRegionFromMdlEx (
2218 __in PBL_MEMORY_DESCRIPTOR_LIST MdList,
2219 __in ULONG Flags,
2220 __in ULONGLONG BasePage,
2221 __in ULONGLONG PageCount,
2222 __in PBL_MEMORY_DESCRIPTOR_LIST NewMdList
2223 );
2224
2225 NTSTATUS
2226 MmMdFreeDescriptor (
2227 _In_ PBL_MEMORY_DESCRIPTOR MemoryDescriptor
2228 );
2229
2230 /* PAGE ALLOCATOR ROUTINES ***************************************************/
2231
2232 NTSTATUS
2233 MmPaTruncateMemory (
2234 _In_ ULONGLONG BasePage
2235 );
2236
2237 NTSTATUS
2238 BlMmAllocatePhysicalPages(
2239 _Inout_ PPHYSICAL_ADDRESS Address,
2240 _In_ BL_MEMORY_TYPE MemoryType,
2241 _In_ ULONGLONG PageCount,
2242 _In_ ULONG Attributes,
2243 _In_ ULONG Alignment
2244 );
2245
2246 NTSTATUS
2247 MmPapAllocatePhysicalPagesInRange (
2248 _Inout_ PPHYSICAL_ADDRESS BaseAddress,
2249 _In_ BL_MEMORY_TYPE MemoryType,
2250 _In_ ULONGLONG Pages,
2251 _In_ ULONG Attributes,
2252 _In_ ULONG Alignment,
2253 _In_ PBL_MEMORY_DESCRIPTOR_LIST NewList,
2254 _In_opt_ PBL_ADDRESS_RANGE Range,
2255 _In_ ULONG RangeType
2256 );
2257
2258 NTSTATUS
2259 MmPaReleaseSelfMapPages (
2260 _In_ PHYSICAL_ADDRESS Address
2261 );
2262
2263 NTSTATUS
2264 MmPaReserveSelfMapPages (
2265 _Inout_ PPHYSICAL_ADDRESS PhysicalAddress,
2266 _In_ ULONG Alignment,
2267 _In_ ULONG PageCount
2268 );
2269
2270 NTSTATUS
2271 BlMmFreePhysicalPages (
2272 _In_ PHYSICAL_ADDRESS Address
2273 );
2274
2275 NTSTATUS
2276 MmPapFreePages (
2277 _In_ PVOID Address,
2278 _In_ ULONG WhichList
2279 );
2280
2281 NTSTATUS
2282 MmPapAllocatePagesInRange (
2283 _Inout_ PVOID* PhysicalAddress,
2284 _In_ BL_MEMORY_TYPE MemoryType,
2285 _In_ ULONGLONG Pages,
2286 _In_ ULONG Attributes,
2287 _In_ ULONG Alignment,
2288 _In_opt_ PBL_ADDRESS_RANGE Range,
2289 _In_ ULONG Type
2290 );
2291
2292 NTSTATUS
2293 MmFwGetMemoryMap (
2294 _Out_ PBL_MEMORY_DESCRIPTOR_LIST MemoryMap,
2295 _In_ ULONG Flags
2296 );
2297
2298 NTSTATUS
2299 BlpMmInitializeConstraints (
2300 VOID
2301 );
2302
2303 NTSTATUS
2304 BlMmRemoveBadMemory (
2305 VOID
2306 );
2307
2308 NTSTATUS
2309 BlMmGetMemoryMap (
2310 _In_ PLIST_ENTRY MemoryMap,
2311 _In_ PBL_BUFFER_DESCRIPTOR MemoryParameters,
2312 _In_ ULONG WhichTypes,
2313 _In_ ULONG Flags
2314 );
2315
2316 /* VIRTUAL MEMORY ROUTINES ***************************************************/
2317
2318 NTSTATUS
2319 MmSelectMappingAddress (
2320 _Out_ PVOID* MappingAddress,
2321 _In_ PVOID PreferredAddress,
2322 _In_ ULONGLONG Size,
2323 _In_ ULONG AllocationAttributes,
2324 _In_ ULONG Flags,
2325 _In_ PHYSICAL_ADDRESS PhysicalAddress
2326 );
2327
2328 NTSTATUS
2329 MmMapPhysicalAddress (
2330 _Inout_ PPHYSICAL_ADDRESS PhysicalAddress,
2331 _Out_ PVOID* VirtualAddress,
2332 _Inout_ PULONGLONG Size,
2333 _In_ ULONG CacheAttributes
2334 );
2335
2336 NTSTATUS
2337 MmUnmapVirtualAddress (
2338 _Inout_ PVOID* VirtualAddress,
2339 _Inout_ PULONGLONG Size
2340 );
2341
2342 NTSTATUS
2343 BlMmMapPhysicalAddressEx (
2344 _In_ PVOID* VirtualAddress,
2345 _In_ ULONG Attributes,
2346 _In_ ULONGLONG Size,
2347 _In_ PHYSICAL_ADDRESS PhysicalAddress
2348 );
2349
2350 NTSTATUS
2351 BlMmUnmapVirtualAddressEx (
2352 _In_ PVOID VirtualAddress,
2353 _In_ ULONGLONG Size
2354 );
2355
2356 BOOLEAN
2357 BlMmTranslateVirtualAddress (
2358 _In_ PVOID VirtualAddress,
2359 _Out_ PPHYSICAL_ADDRESS PhysicalAddress
2360 );
2361
2362 BOOLEAN
2363 MmArchTranslateVirtualAddress (
2364 _In_ PVOID VirtualAddress,
2365 _Out_opt_ PPHYSICAL_ADDRESS PhysicalAddress,
2366 _Out_opt_ PULONG CachingFlags
2367 );
2368
2369 /* BLOCK ALLOCATOR ROUTINES **************************************************/
2370
2371 NTSTATUS
2372 BlpMmCreateBlockAllocator (
2373 VOID
2374 );
2375
2376 /* HEAP ALLOCATOR ROUTINES ***************************************************/
2377
2378 PVOID
2379 BlMmAllocateHeap (
2380 _In_ SIZE_T Size
2381 );
2382
2383 NTSTATUS
2384 BlMmFreeHeap (
2385 _In_ PVOID Buffer
2386 );
2387
2388 /* DISPLAY ROUTINES **********************************************************/
2389
2390 VOID
2391 BlDisplayGetTextCellResolution (
2392 _Out_ PULONG TextWidth,
2393 _Out_ PULONG TextHeight
2394 );
2395
2396 NTSTATUS
2397 BlDisplaySetScreenResolution (
2398 VOID
2399 );
2400
2401 NTSTATUS
2402 BlDisplayGetScreenResolution (
2403 _Out_ PULONG HRes,
2404 _Out_ PULONG Vres
2405 );
2406
2407 VOID
2408 BlDisplayInvalidateOemBitmap (
2409 VOID
2410 );
2411
2412 PBITMAP
2413 BlDisplayGetOemBitmap (
2414 _Out_ PCOORD Offset,
2415 _Out_opt_ PULONG Flags
2416 );
2417
2418 BOOLEAN
2419 BlDisplayValidOemBitmap (
2420 VOID
2421 );
2422
2423 NTSTATUS
2424 BlDisplayClearScreen (
2425 VOID
2426 );
2427
2428 NTSTATUS
2429 BlDisplaySetCursorType (
2430 _In_ ULONG Type
2431 );
2432
2433 /* I/O ROUTINES **************************************************************/
2434
2435 NTSTATUS
2436 BlpIoRegisterDestroyRoutine (
2437 _In_ PBL_IO_DESTROY_ROUTINE DestroyRoutine
2438 );
2439
2440 NTSTATUS
2441 BlDeviceClose (
2442 _In_ ULONG DeviceId
2443 );
2444
2445 BOOLEAN
2446 BlDeviceIsVirtualPartitionDevice (
2447 _In_ PBL_DEVICE_DESCRIPTOR InputDevice,
2448 _Outptr_ PBL_DEVICE_DESCRIPTOR* VirtualDevice
2449 );
2450
2451 NTSTATUS
2452 BlpDeviceOpen (
2453 _In_ PBL_DEVICE_DESCRIPTOR Device,
2454 _In_ ULONG Flags,
2455 _In_ ULONG Unknown,
2456 _Out_ PULONG DeviceId
2457 );
2458
2459 NTSTATUS
2460 BlDeviceGetInformation (
2461 _In_ ULONG DeviceId,
2462 _Out_ PBL_DEVICE_INFORMATION DeviceInformation
2463 );
2464
2465 NTSTATUS
2466 BlDeviceSetInformation (
2467 _In_ ULONG DeviceId,
2468 _In_ PBL_DEVICE_INFORMATION DeviceInformation
2469 );
2470
2471 NTSTATUS
2472 BlDeviceReadAtOffset (
2473 _In_ ULONG DeviceId,
2474 _In_ ULONG Size,
2475 _In_ ULONGLONG Offset,
2476 _In_ PVOID Buffer,
2477 _Out_ PULONG BytesRead
2478 );
2479
2480 /* IMAGE ROUTINES ************************************************************/
2481
2482 NTSTATUS
2483 BlImgLoadImageWithProgress2 (
2484 _In_ ULONG DeviceId,
2485 _In_ BL_MEMORY_TYPE MemoryType,
2486 _In_ PWCHAR FileName,
2487 _Inout_ PVOID* MappedBase,
2488 _Inout_ PULONG MappedSize,
2489 _In_ ULONG ImageFlags,
2490 _In_ BOOLEAN ShowProgress,
2491 _Out_opt_ PUCHAR* HashBuffer,
2492 _Out_opt_ PULONG HashSize
2493 );
2494
2495 PIMAGE_SECTION_HEADER
2496 BlImgFindSection (
2497 _In_ PVOID ImageBase,
2498 _In_ ULONG ImageSize
2499 );
2500
2501 NTSTATUS
2502 BlImgLoadBootApplication (
2503 _In_ PBL_LOADED_APPLICATION_ENTRY BootEntry,
2504 _Out_ PULONG AppHandle
2505 );
2506
2507 NTSTATUS
2508 BlImgStartBootApplication (
2509 _In_ ULONG AppHandle,
2510 _Inout_ PBL_RETURN_ARGUMENTS ReturnArguments
2511 );
2512
2513 NTSTATUS
2514 BlImgUnloadBootApplication (
2515 _In_ ULONG AppHandle
2516 );
2517
2518 VOID
2519 BlImgQueryCodeIntegrityBootOptions (
2520 _In_ PBL_LOADED_APPLICATION_ENTRY ApplicationEntry,
2521 _Out_ PBOOLEAN IntegrityChecksDisabled,
2522 _Out_ PBOOLEAN TestSigning
2523 );
2524
2525 /* FILE I/O ROUTINES *********************************************************/
2526
2527 NTSTATUS
2528 BlFileClose (
2529 _In_ ULONG FileId
2530 );
2531
2532 NTSTATUS
2533 BlFileReadAtOffsetEx (
2534 _In_ ULONG FileId,
2535 _In_ ULONG Size,
2536 _In_ ULONGLONG ByteOffset,
2537 _In_ PVOID Buffer,
2538 _Out_ PULONG BytesReturned,
2539 _In_ ULONG Flags
2540 );
2541
2542 NTSTATUS
2543 BlFileGetInformation (
2544 _In_ ULONG FileId,
2545 _In_ PBL_FILE_INFORMATION FileInfo
2546 );
2547
2548 NTSTATUS
2549 BlFileOpen (
2550 _In_ ULONG DeviceId,
2551 _In_ PWCHAR FileName,
2552 _In_ ULONG Flags,
2553 _Out_ PULONG FileId
2554 );
2555
2556 /* BLOCK I/O ROUTINES *******************************************************/
2557
2558 NTSTATUS
2559 BlockIoEfiCompareDevice (
2560 _In_ PBL_DEVICE_DESCRIPTOR Device,
2561 _In_ EFI_HANDLE Handle
2562 );
2563
2564 /* INPUT CONSOLE ROUTINES ****************************************************/
2565
2566 VOID
2567 ConsoleInputLocalDestruct (
2568 _In_ struct _BL_INPUT_CONSOLE* Console
2569 );
2570
2571 NTSTATUS
2572 ConsoleInputBaseReinitialize (
2573 _In_ struct _BL_INPUT_CONSOLE* Console
2574 );
2575
2576 NTSTATUS
2577 ConsoleCreateLocalInputCnsole (
2578 VOID
2579 );
2580
2581 /* TEXT CONSOLE ROUTINES *****************************************************/
2582
2583 VOID
2584 ConsoleGraphicalDestruct (
2585 _In_ struct _BL_GRAPHICS_CONSOLE* Console
2586 );
2587
2588 NTSTATUS
2589 ConsoleGraphicalClearText (
2590 _In_ PBL_GRAPHICS_CONSOLE Console,
2591 _In_ BOOLEAN LineOnly
2592 );
2593
2594 NTSTATUS
2595 ConsoleGraphicalClearPixels (
2596 _In_ PBL_GRAPHICS_CONSOLE Console,
2597 _In_ ULONG Color
2598 );
2599
2600 NTSTATUS
2601 ConsoleGraphicalReinitialize (
2602 _In_ struct _BL_GRAPHICS_CONSOLE* Console
2603 );
2604
2605 NTSTATUS
2606 ConsoleGraphicalSetTextState (
2607 _In_ PBL_GRAPHICS_CONSOLE Console,
2608 _In_ ULONG Mask,
2609 _In_ PBL_DISPLAY_STATE TextState
2610 );
2611
2612 BOOLEAN
2613 ConsoleGraphicalIsEnabled (
2614 _In_ struct _BL_GRAPHICS_CONSOLE* Console
2615 );
2616
2617 NTSTATUS
2618 ConsoleGraphicalGetGraphicalResolution (
2619 _In_ struct _BL_GRAPHICS_CONSOLE* Console,
2620 _In_ PBL_DISPLAY_MODE DisplayMode
2621 );
2622
2623 NTSTATUS
2624 ConsoleGraphicalGetOriginalResolution (
2625 _In_ struct _BL_GRAPHICS_CONSOLE* Console,
2626 _In_ PBL_DISPLAY_MODE DisplayMode
2627 );
2628
2629 NTSTATUS
2630 ConsoleGraphicalEnable (
2631 _In_ struct _BL_GRAPHICS_CONSOLE* Console,
2632 _In_ BOOLEAN Enable
2633 );
2634
2635 VOID
2636 ConsoleTextLocalDestruct (
2637 _In_ struct _BL_TEXT_CONSOLE* Console
2638 );
2639
2640 NTSTATUS
2641 ConsoleTextLocalReinitialize (
2642 _In_ struct _BL_TEXT_CONSOLE* Console
2643 );
2644
2645 NTSTATUS
2646 ConsoleTextBaseGetTextState (
2647 _In_ struct _BL_TEXT_CONSOLE* Console,
2648 _Out_ PBL_DISPLAY_STATE TextState
2649 );
2650
2651 NTSTATUS
2652 ConsoleTextLocalSetTextState (
2653 _In_ struct _BL_TEXT_CONSOLE* Console,
2654 _In_ ULONG Flags,
2655 _In_ PBL_DISPLAY_STATE TextState
2656 );
2657
2658 NTSTATUS
2659 ConsoleTextBaseGetTextResolution (
2660 _In_ struct _BL_TEXT_CONSOLE* Console,
2661 _Out_ PULONG TextResolution
2662 );
2663
2664 NTSTATUS
2665 ConsoleTextLocalSetTextResolution (
2666 _In_ struct _BL_TEXT_CONSOLE* Console,
2667 _In_ ULONG NewTextResolution,
2668 _Out_ PULONG OldTextResolution
2669 );
2670
2671 NTSTATUS
2672 ConsoleTextLocalClearText (
2673 _In_ struct _BL_TEXT_CONSOLE* Console,
2674 _In_ BOOLEAN LineOnly
2675 );
2676
2677 NTSTATUS
2678 ConsoleTextLocalWriteText (
2679 _In_ struct _BL_TEXT_CONSOLE* Console,
2680 _In_ PCHAR Text,
2681 _In_ ULONG Attribute
2682 );
2683
2684 NTSTATUS
2685 ConsoleTextLocalConstruct (
2686 _In_ PBL_TEXT_CONSOLE TextConsole,
2687 _In_ BOOLEAN Activate
2688 );
2689
2690 BOOLEAN
2691 ConsolepFindResolution (
2692 _In_ PBL_DISPLAY_MODE Mode,
2693 _In_ PBL_DISPLAY_MODE List,
2694 _In_ ULONG MaxIndex
2695 );
2696
2697 NTSTATUS
2698 ConsoleFirmwareTextClear (
2699 _In_ PBL_TEXT_CONSOLE Console,
2700 _In_ BOOLEAN LineOnly
2701 );
2702
2703 VOID
2704 ConsoleFirmwareTextClose (
2705 _In_ PBL_TEXT_CONSOLE TextConsole
2706 );
2707
2708 NTSTATUS
2709 ConsoleFirmwareTextOpen (
2710 _In_ PBL_TEXT_CONSOLE TextConsole
2711 );
2712
2713 NTSTATUS
2714 ConsoleFirmwareTextSetState (
2715 _In_ PBL_TEXT_CONSOLE TextConsole,
2716 _In_ UCHAR Mask,
2717 _In_ PBL_DISPLAY_STATE State
2718 );
2719
2720 NTSTATUS
2721 ConsoleGraphicalConstruct (
2722 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
2723 );
2724
2725 NTSTATUS
2726 ConsoleCreateRemoteConsole (
2727 _In_ PBL_TEXT_CONSOLE* TextConsole
2728 );
2729
2730 NTSTATUS
2731 ConsoleEfiGraphicalOpenProtocol (
2732 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole,
2733 _In_ BL_GRAPHICS_CONSOLE_TYPE Type
2734 );
2735
2736 VOID
2737 ConsoleFirmwareGraphicalClose (
2738 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
2739 );
2740
2741 VOID
2742 ConsoleFirmwareGraphicalDisable (
2743 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
2744 );
2745
2746 NTSTATUS
2747 ConsoleFirmwareGraphicalClear (
2748 _In_ PBL_GRAPHICS_CONSOLE Console,
2749 _In_ ULONG Color
2750 );
2751
2752 NTSTATUS
2753 ConsoleFirmwareGraphicalEnable (
2754 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
2755 );
2756
2757 NTSTATUS
2758 ConsoleEfiUgaOpen (
2759 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
2760 );
2761
2762 VOID
2763 ConsoleEfiUgaClose (
2764 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
2765 );
2766
2767 VOID
2768 ConsoleEfiGopClose (
2769 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
2770 );
2771
2772 NTSTATUS
2773 ConsoleEfiGopOpen (
2774 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
2775 );
2776
2777 NTSTATUS
2778 ConsoleEfiGopEnable (
2779 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
2780 );
2781
2782 NTSTATUS
2783 ConsoleEfiUgaSetResolution (
2784 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole,
2785 _In_ PBL_DISPLAY_MODE DisplayMode,
2786 _In_ ULONG DisplayModeCount
2787 );
2788
2789 NTSTATUS
2790 ConsoleCreateLocalInputConsole (
2791 VOID
2792 );
2793
2794 NTSTATUS
2795 ConsoleInputLocalEraseBuffer (
2796 _In_ PBL_INPUT_CONSOLE Console,
2797 _In_opt_ PULONG ValueToFill
2798 );
2799
2800 VOID
2801 ConsolepClearBuffer (
2802 _In_ PUCHAR FrameBuffer,
2803 _In_ ULONG Width,
2804 _In_ PUCHAR FillColor,
2805 _In_ ULONG Height,
2806 _In_ ULONG ScanlineWidth,
2807 _In_ ULONG PixelDepth
2808 );
2809
2810 NTSTATUS
2811 ConsolepConvertColorToPixel (
2812 _In_ BL_COLOR Color,
2813 _Out_ PUCHAR Pixel
2814 );
2815
2816 extern ULONG MmDescriptorCallTreeCount;
2817 extern ULONG BlpApplicationFlags;
2818 extern BL_LIBRARY_PARAMETERS BlpLibraryParameters;
2819 extern BL_TRANSLATION_TYPE MmTranslationType;
2820 extern PBL_ARCH_CONTEXT CurrentExecutionContext;
2821 extern PBL_DEVICE_DESCRIPTOR BlpBootDevice;
2822 extern BL_LOADED_APPLICATION_ENTRY BlpApplicationEntry;
2823 extern EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *EfiConOut;
2824 extern EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *EfiConInEx;
2825 extern EFI_GUID EfiGraphicsOutputProtocol;
2826 extern EFI_GUID EfiUgaDrawProtocol;
2827 extern EFI_GUID EfiLoadedImageProtocol;
2828 extern EFI_GUID EfiDevicePathProtocol;
2829 extern EFI_GUID EfiBlockIoProtocol;
2830 extern EFI_GUID EfiSimpleTextInputExProtocol;
2831 extern EFI_GUID EfiRootAcpiTableGuid;
2832 extern EFI_GUID EfiRootAcpiTable10Guid;
2833 extern EFI_GUID EfiGlobalVariable;
2834 extern ULONG ConsoleGraphicalResolutionListFlags;
2835 extern BL_DISPLAY_MODE ConsoleGraphicalResolutionList[];
2836 extern BL_DISPLAY_MODE ConsoleTextResolutionList[];
2837 extern ULONG ConsoleGraphicalResolutionListSize;
2838 extern PVOID DspRemoteInputConsole;
2839 extern PVOID DspLocalInputConsole;
2840 extern WCHAR BlScratchBuffer[8192];
2841 extern BL_MEMORY_DESCRIPTOR_LIST MmMdlMappedAllocated;
2842 extern BL_MEMORY_DESCRIPTOR_LIST MmMdlMappedUnallocated;
2843 extern BL_MEMORY_DESCRIPTOR_LIST MmMdlFwAllocationTracker;
2844 extern BL_MEMORY_DESCRIPTOR_LIST MmMdlUnmappedAllocated;
2845 extern BL_MEMORY_DESCRIPTOR_LIST MmMdlUnmappedUnallocated;
2846 extern BL_MEMORY_DESCRIPTOR_LIST MmMdlReservedAllocated;
2847 extern BL_MEMORY_DESCRIPTOR_LIST MmMdlBadMemory;
2848 extern BL_MEMORY_DESCRIPTOR_LIST MmMdlTruncatedMemory;
2849 extern BL_MEMORY_DESCRIPTOR_LIST MmMdlPersistentMemory;
2850 extern BL_MEMORY_DESCRIPTOR_LIST MmMdlCompleteBadMemory;
2851 extern BL_MEMORY_DESCRIPTOR_LIST MmMdlFreeVirtual;
2852 extern BL_MEMORY_DESCRIPTOR_LIST MmMdlMappingTrackers;
2853 extern ULONGLONG BlpTimePerformanceFrequency;
2854 extern LIST_ENTRY RegisteredFileSystems;
2855 extern BL_ADDRESS_RANGE MmArchKsegAddressRange;
2856 extern ULONG_PTR MmArchTopOfApplicationAddressSpace;
2857 extern PBL_MM_RELOCATE_SELF_MAP BlMmRelocateSelfMap;
2858 extern PBL_MM_FLUSH_TLB BlMmFlushTlb;
2859 extern PBL_MM_MOVE_VIRTUAL_ADDRESS_RANGE BlMmMoveVirtualAddressRange;
2860 extern PBL_MM_ZERO_VIRTUAL_ADDRESS_RANGE BlMmZeroVirtualAddressRange;
2861 extern PBL_STATUS_ERROR_HANDLER BlpStatusErrorHandler;
2862
2863 #endif