[BOOTMGFW]
[reactos.git] / reactos / boot / environ / include / bl.h
1 /*
2 * COPYRIGHT: See COPYING.ARM in the top level directory
3 * PROJECT: ReactOS UEFI Boot Library
4 * FILE: boot/environ/include/bl.h
5 * PURPOSE: Main Boot Library Header
6 * PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
7 */
8
9 #ifndef _BL_H
10 #define _BL_H
11
12 /* INCLUDES ******************************************************************/
13
14 /* C Headers */
15 #include <stdlib.h>
16 #include <stdio.h>
17 #include <wchar.h>
18
19 /* NT Base Headers */
20 #include <ntifs.h>
21
22 /* NDK Headers */
23 #include <ntndk.h>
24
25 /* UEFI Headers */
26 #include <Uefi.h>
27 #include <DevicePath.h>
28 #include <LoadedImage.h>
29 #include <GraphicsOutput.h>
30 #include <UgaDraw.h>
31 #include <BlockIo.h>
32
33 /* DEFINES *******************************************************************/
34
35 #define BL_APPLICATION_FLAG_CONVERTED_FROM_EFI 0x01
36
37 #define BL_APP_ENTRY_SIGNATURE "BTAPENT"
38
39 #define BOOT_APPLICATION_SIGNATURE_1 'TOOB'
40 #define BOOT_APPLICATION_SIGNATURE_2 ' PPA'
41
42 #define BOOT_MEMORY_TRANSLATION_TYPE_PHYSICAL 0
43 #define BOOT_MEMORY_TRANSLATION_TYPE_VIRTUAL 1
44
45 #define BOOT_APPLICATION_VERSION 2
46 #define BL_MEMORY_DATA_VERSION 1
47 #define BL_RETURN_ARGUMENTS_VERSION 1
48 #define BL_FIRMWARE_DESCRIPTOR_VERSION 2
49
50 #define BL_APPLICATION_ENTRY_FLAG_NO_GUID 0x01
51 #define BL_APPLICATION_ENTRY_REBOOT_ON_ERROR 0x20
52
53 #define BL_CONTEXT_PAGING_ON 1
54 #define BL_CONTEXT_INTERRUPTS_ON 2
55
56 #define BL_MM_FLAG_USE_FIRMWARE_FOR_MEMORY_MAP_BUFFERS 0x01
57 #define BL_MM_FLAG_REQUEST_COALESCING 0x02
58
59 #define BL_MM_ADD_DESCRIPTOR_COALESCE_FLAG 0x01
60 #define BL_MM_ADD_DESCRIPTOR_TRUNCATE_FLAG 0x02
61 #define BL_MM_ADD_DESCRIPTOR_NEVER_COALESCE_FLAG 0x10
62 #define BL_MM_ADD_DESCRIPTOR_NEVER_TRUNCATE_FLAG 0x20
63 #define BL_MM_ADD_DESCRIPTOR_UPDATE_LIST_POINTER_FLAG 0x2000
64
65 #define BL_MM_REQUEST_DEFAULT_TYPE 1
66 #define BL_MM_REQUEST_TOP_DOWN_TYPE 2
67
68 #define BL_MM_REMOVE_VIRTUAL_REGION_FLAG 0x80000000
69
70 #define BL_LIBRARY_FLAG_NO_DISPLAY 0x01
71 #define BL_LIBRARY_FLAG_REINITIALIZE 0x02
72 #define BL_LIBRARY_FLAG_REINITIALIZE_ALL 0x04
73 #define BL_LIBRARY_FLAG_ZERO_HEAP_ALLOCATIONS_ON_FREE 0x10
74 #define BL_LIBRARY_FLAG_INITIALIZATION_COMPLETED 0x20
75 #define BL_LIBRARY_FLAG_NO_GRAPHICS_CONSOLE 0x800
76
77 #define BL_DISPLAY_GRAPHICS_FORCED_VIDEO_MODE_FLAG 0x01
78 #define BL_DISPLAY_GRAPHICS_FORCED_HIGH_RES_MODE_FLAG 0x02
79
80 #define BL_HT_VALUE_IS_INLINE 0x01
81
82 #define BL_FS_REGISTER_AT_HEAD_FLAG 1
83
84 #define BL_BLOCK_DEVICE_REMOVABLE_FLAG 0x01
85
86 #define BL_MEMORY_CLASS_SHIFT 28
87
88 /* ENUMERATIONS **************************************************************/
89
90 typedef enum _BL_COLOR
91 {
92 Black,
93 Blue,
94 Green,
95 Cyan,
96 Red,
97 Magenta,
98 Brown,
99 LtGray,
100 Gray,
101 LtBlue,
102 LtGreen,
103 LtCyan,
104 LtRed,
105 LtMagenta,
106 Yellow,
107 White
108 } BL_COLOR, *PBL_COLOR;
109
110 typedef enum _BL_MEMORY_DESCRIPTOR_TYPE
111 {
112 BlMdPhysical,
113 BlMdVirtual,
114 } BL_MEMORY_DESCRIPTOR_TYPE;
115
116 typedef enum _BL_TRANSLATION_TYPE
117 {
118 BlNone,
119 BlVirtual,
120 BlPae,
121 BlMax
122 } BL_TRANSLATION_TYPE;
123
124 typedef enum _BL_ARCH_MODE
125 {
126 BlProtectedMode,
127 BlRealMode
128 } BL_ARCH_MODE;
129
130 //
131 // Boot Device Types
132 //
133 typedef enum _BL_DEVICE_TYPE
134 {
135 DiskDevice = 0,
136 LegacyPartitionDevice = 2,
137 SerialDevice = 3,
138 UdpDevice = 4,
139 BootDevice = 5,
140 PartitionDevice = 6,
141 LocateDevice = 8,
142 } BL_DEVICE_TYPE;
143
144 //
145 // Local Device Types
146 //
147 typedef enum _BL_LOCAL_DEVICE_TYPE
148 {
149 LocalDevice = 0,
150 FloppyDevice = 1,
151 CdRomDevice = 2,
152 RamDiskDevice = 3,
153 FileDevice = 5,
154 VirtualDiskDevice = 6
155 } BL_LOCAL_DEVICE_TYPE;
156
157 //
158 // Partition types
159 //
160 typedef enum _BL_PARTITION_TYPE
161 {
162 GptPartition,
163 MbrPartition,
164 RawPartition,
165 } BL_PARTITION_TYPE;
166
167 //
168 // File Path Types
169 //
170 typedef enum _BL_PATH_TYPE
171 {
172 EfiPath = 4
173 } BL_PATH_TYPE;
174
175 //
176 // Classes of Memory
177 //
178 typedef enum _BL_MEMORY_CLASS
179 {
180 BlLoaderClass = 0xD,
181 BlApplicationClass,
182 BlSystemClass
183 } BL_MEMORY_CLASS;
184
185 //
186 // Types of Memory
187 //
188 typedef enum _BL_MEMORY_TYPE
189 {
190 //
191 // Loader Memory
192 //
193 BlLoaderMemory = 0xD0000002,
194 BlLoaderDeviceMemory = 0xD0000004,
195 BlLoaderHeap = 0xD0000005,
196 BlLoaderPageDirectory = 0xD0000006,
197 BlLoaderReferencePage = 0xD0000007,
198 BlLoaderRamDisk = 0xD0000008,
199 BlLoaderData = 0xD000000A,
200 BlLoaderBlockMemory = 0xD000000C,
201 BlLoaderSelfMap = 0xD000000F,
202
203 //
204 // Application Memory
205 //
206 BlApplicationData = 0xE0000004,
207
208 //
209 // System Memory
210 //
211 BlConventionalMemory = 0xF0000001,
212 BlUnusableMemory = 0xF0000002,
213 BlReservedMemory = 0xF0000003,
214 BlEfiBootMemory = 0xF0000004,
215 BlEfiRuntimeMemory = 0xF0000006,
216 BlAcpiReclaimMemory = 0xF0000008,
217 BlAcpiNvsMemory = 0xF0000009,
218 BlDeviceIoMemory = 0xF000000A,
219 BlDevicePortMemory = 0xF000000B,
220 BlPalMemory = 0xF000000C,
221 } BL_MEMORY_TYPE;
222
223 typedef enum _BL_MEMORY_ATTR
224 {
225 //
226 // Memory Caching Attributes
227 //
228 BlMemoryUncached = 0x00000001,
229 BlMemoryWriteCombined = 0x00000002,
230 BlMemoryWriteThrough = 0x00000004,
231 BlMemoryWriteBack = 0x00000008,
232 BlMemoryUncachedExported = 0x00000010,
233 BlMemoryValidCacheAttributes = BlMemoryUncached | BlMemoryWriteCombined | BlMemoryWriteThrough | BlMemoryWriteBack | BlMemoryUncachedExported,
234 BlMemoryValidCacheAttributeMask = 0x000000FF,
235
236 //
237 // Memory Protection Attributes
238 //
239 BlMemoryWriteProtected = 0x00000100,
240 BlMemoryReadProtected = 0x00000200,
241 BlMemoryExecuteProtected = 0x00000400,
242 BlMemoryValidProtectionAttributes = BlMemoryWriteProtected | BlMemoryReadProtected | BlMemoryExecuteProtected,
243 BlMemoryValidProtectionAttributeMask = 0x0000FF00,
244
245 //
246 // Memory Allocation Attributes
247 //
248 BlMemoryNonFixed = 0x00020000,
249 BlMemoryFixed = 0x00040000,
250 BlMemoryValidAllocationAttributes = BlMemoryNonFixed | BlMemoryFixed,
251 BlMemoryValidAllocationAttributeMask = 0x00FF0000,
252
253 //
254 // Memory Type Attributes
255 //
256 BlMemoryRuntime = 0x01000000,
257 BlMemoryCoalesced = 0x02000000,
258 BlMemoryUpdate = 0x04000000,
259 BlMemoryNonFirmware = 0x08000000,
260 BlMemorySpecial = 0x20000000,
261 BlMemoryFirmware = 0x80000000,
262 BlMemoryValidTypeAttributes = BlMemoryRuntime | BlMemoryCoalesced | BlMemoryUpdate | BlMemoryNonFirmware | BlMemorySpecial | BlMemoryFirmware,
263 BlMemoryValidTypeAttributeMask = 0xFF000000,
264 } BL_MEMORY_ATTR;
265
266 /* CALLBACKS *****************************************************************/
267
268 struct _BL_FILE_ENTRY;
269 typedef
270 NTSTATUS
271 (*PBL_FILE_OPEN) (
272 _In_ struct _BL_FILE_ENTRY* Directory,
273 _In_ PWCHAR FileName,
274 _In_ ULONG Flags,
275 _Out_ struct _BL_FILE_ENTRY** FileEntry
276 );
277
278 typedef
279 NTSTATUS
280 (*PBL_FILE_CLOSE) (
281 _In_ struct _BL_FILE_ENTRY* FileEntry
282 );
283
284 typedef
285 NTSTATUS
286 (*PBL_FILE_READ) (
287 VOID
288 );
289
290 typedef
291 NTSTATUS
292 (*PBL_FILE_WRITE) (
293 VOID
294 );
295
296 typedef
297 NTSTATUS
298 (*PBL_FILE_GET_NEXT) (
299 VOID
300 );
301
302 typedef
303 NTSTATUS
304 (*PBL_FILE_GET_INFO) (
305 VOID
306 );
307
308 typedef
309 NTSTATUS
310 (*PBL_FILE_SET_INFO) (
311 VOID
312 );
313
314 typedef
315 NTSTATUS
316 (*PBL_FS_INIT_CALLBACK) (
317 VOID
318 );
319
320 typedef
321 NTSTATUS
322 (*PBL_FS_DESTROY_CALLBACK) (
323 VOID
324 );
325
326 typedef
327 NTSTATUS
328 (*PBL_FS_MOUNT_CALLBACK) (
329 _In_ ULONG DeviceId,
330 _In_ ULONG Unknown,
331 _Out_ struct _BL_FILE_ENTRY** FileEntry
332 );
333
334 typedef
335 NTSTATUS
336 (*PBL_FS_PURGE_CALLBACK) (
337 VOID
338 );
339
340 typedef
341 NTSTATUS
342 (*PBL_FILE_DESTROY_CALLBACK) (
343 _In_ PVOID Entry
344 );
345
346 struct _BL_TEXT_CONSOLE;
347 struct _BL_DISPLAY_STATE;
348 typedef
349 NTSTATUS
350 (*PCONSOLE_DESTRUCT) (
351 _In_ struct _BL_TEXT_CONSOLE* Console
352 );
353
354 typedef
355 NTSTATUS
356 (*PCONSOLE_REINITIALIZE) (
357 _In_ struct _BL_TEXT_CONSOLE* Console
358 );
359
360 typedef
361 NTSTATUS
362 (*PCONSOLE_GET_TEXT_STATE) (
363 _In_ struct _BL_TEXT_CONSOLE* Console,
364 _Out_ struct _BL_DISPLAY_STATE* TextState
365 );
366
367 typedef
368 NTSTATUS
369 (*PCONSOLE_SET_TEXT_STATE) (
370 _In_ struct _BL_TEXT_CONSOLE* Console,
371 _In_ ULONG Flags,
372 _In_ struct _BL_DISPLAY_STATE* TextState
373 );
374
375 typedef
376 NTSTATUS
377 (*PCONSOLE_GET_TEXT_RESOLUTION) (
378 _In_ struct _BL_TEXT_CONSOLE* Console,
379 _Out_ PULONG TextResolution
380 );
381
382 typedef
383 NTSTATUS
384 (*PCONSOLE_SET_TEXT_RESOLUTION) (
385 _In_ struct _BL_TEXT_CONSOLE* Console,
386 _In_ ULONG NewTextResolution,
387 _Out_ PULONG OldTextResolution
388 );
389
390 typedef
391 NTSTATUS
392 (*PCONSOLE_CLEAR_TEXT) (
393 _In_ struct _BL_TEXT_CONSOLE* Console,
394 _In_ ULONG Attribute
395 );
396
397 typedef
398 NTSTATUS
399 (*PCONSOLE_WRITE_TEXT) (
400 _In_ struct _BL_TEXT_CONSOLE* Console,
401 _In_ PCHAR Text,
402 _In_ ULONG Attribute
403 );
404
405 typedef
406 BOOLEAN
407 (*PBL_TBL_LOOKUP_ROUTINE) (
408 _In_ PVOID Entry,
409 _In_ PVOID Argument1,
410 _In_ PVOID Argument2,
411 _In_ PVOID Argument3,
412 _In_ PVOID Argument4
413 );
414
415 typedef
416 NTSTATUS
417 (*PBL_TBL_MAP_ROUTINE) (
418 _In_ PVOID Entry,
419 _In_ ULONG EntryIndex
420 );
421
422 typedef
423 NTSTATUS
424 (*PBL_TBL_SET_ROUTINE) (
425 _In_ PVOID Entry
426 );
427
428 typedef
429 NTSTATUS
430 (*PBL_IO_DESTROY_ROUTINE) (
431 VOID
432 );
433
434 struct _BL_HASH_ENTRY;
435 typedef
436 BOOLEAN
437 (*PBL_HASH_TABLE_COMPARE_FUNCTION) (
438 _In_ struct _BL_HASH_ENTRY* Entry1,
439 _In_ struct _BL_HASH_ENTRY* Entry2
440 );
441
442 typedef
443 ULONG
444 (*PBL_HASH_TABLE_HASH_FUNCTION) (
445 _In_ struct _BL_HASH_ENTRY* Entry,
446 _In_ ULONG TableSize
447 );
448
449 struct _BL_DEVICE_ENTRY;
450 struct _BL_DEVICE_DESCRIPTOR;
451 struct _BL_DEVICE_INFORMATION;
452
453 typedef
454 NTSTATUS
455 (*PBL_DEVICE_ENUMERATE_DEVICE_CLASS) (
456 VOID
457 );
458
459 typedef
460 NTSTATUS
461 (*PBL_DEVICE_OPEN) (
462 _In_ struct _BL_DEVICE_DESCRIPTOR* Device,
463 _In_ struct _BL_DEVICE_ENTRY* DeviceEntry
464 );
465
466 typedef
467 NTSTATUS
468 (*PBL_DEVICE_CLOSE) (
469 _In_ struct _BL_DEVICE_ENTRY* DeviceEntry
470 );
471
472 typedef
473 NTSTATUS
474 (*PBL_DEVICE_READ) (
475 _In_ struct _BL_DEVICE_ENTRY* DeviceEntry,
476 _In_ PVOID Buffer,
477 _In_ ULONG Size,
478 _Out_ PULONG BytesRead
479 );
480
481 typedef
482 NTSTATUS
483 (*PBL_DEVICE_WRITE) (
484 VOID
485 );
486
487 typedef
488 NTSTATUS
489 (*PBL_DEVICE_GET_INFORMATION) (
490 _In_ struct _BL_DEVICE_ENTRY* DeviceEntry,
491 _Out_ struct _BL_DEVICE_INFORMATION* DeviceInformation
492 );
493
494 typedef
495 NTSTATUS
496 (*PBL_DEVICE_SET_INFORMATION) (
497 _In_ struct _BL_DEVICE_ENTRY* DeviceEntry,
498 _In_ struct _BL_DEVICE_INFORMATION* DeviceInformation
499 );
500
501 typedef
502 NTSTATUS
503 (*PBL_DEVICE_RESET) (
504 VOID
505 );
506
507 typedef
508 NTSTATUS
509 (*PBL_DEVICE_FLUSH) (
510 VOID
511 );
512
513 typedef
514 NTSTATUS
515 (*PBL_DEVICE_CREATE) (
516 VOID
517 );
518
519
520 /* DATA STRUCTURES ***********************************************************/
521
522 typedef struct _BL_LIBRARY_PARAMETERS
523 {
524 ULONG LibraryFlags;
525 ULONG TranslationType;
526 ULONG MinimumAllocationCount;
527 ULONG MinimumHeapSize;
528 ULONG HeapAllocationAttributes;
529 PWCHAR ApplicationBaseDirectory;
530 ULONG DescriptorCount;
531 PWCHAR FontBaseDirectory;
532 } BL_LIBRARY_PARAMETERS, *PBL_LIBRARY_PARAMETERS;
533
534 /* This should eventually go into a more public header */
535 typedef struct _BOOT_APPLICATION_PARAMETER_BLOCK
536 {
537 /* This header tells the library what image we're dealing with */
538 ULONG Signature[2];
539 ULONG Version;
540 ULONG Size;
541 ULONG ImageType;
542 ULONG MemoryTranslationType;
543
544 /* Where is the image located */
545 ULONGLONG ImageBase;
546 ULONG ImageSize;
547
548 /* Offset to BL_MEMORY_DATA */
549 ULONG MemoryDataOffset;
550
551 /* Offset to BL_APPLICATION_ENTRY */
552 ULONG AppEntryOffset;
553
554 /* Offset to BL_DEVICE_DESCRPIPTOR */
555 ULONG BootDeviceOffset;
556
557 /* Offset to BL_FIRMWARE_PARAMETERS */
558 ULONG FirmwareParametersOffset;
559
560 /* Offset to BL_RETURN_ARGUMENTS */
561 ULONG ReturnArgumentsOffset;
562 } BOOT_APPLICATION_PARAMETER_BLOCK, *PBOOT_APPLICATION_PARAMETER_BLOCK;
563
564 typedef struct _BL_MEMORY_DATA
565 {
566 ULONG Version;
567 ULONG MdListOffset;
568 ULONG DescriptorCount;
569 ULONG DescriptorSize;
570 ULONG DescriptorOffset;
571 } BL_MEMORY_DATA, *PBL_MEMORY_DATA;
572
573 typedef struct _BL_FIRMWARE_DESCRIPTOR
574 {
575 ULONG Version;
576 ULONG Unknown;
577 EFI_HANDLE ImageHandle;
578 EFI_SYSTEM_TABLE *SystemTable;
579 } BL_FIRMWARE_DESCRIPTOR, *PBL_FIRMWARE_DESCRIPTOR;
580
581 typedef struct _BL_RETURN_ARGUMENTS
582 {
583 ULONG Version;
584 NTSTATUS Status;
585 ULONG ReturnArgumentData[5];
586 } BL_RETURN_ARGUMENTS, *PBL_RETURN_ARGUMENTS;
587
588 typedef struct _BL_MEMORY_DESCRIPTOR
589 {
590 LIST_ENTRY ListEntry;
591 union
592 {
593 struct
594 {
595 ULONGLONG BasePage;
596 ULONGLONG VirtualPage;
597 };
598 struct
599 {
600 ULONGLONG BaseAddress;
601 ULONGLONG VirtualAddress;
602 };
603 };
604 ULONGLONG PageCount;
605 ULONG Flags;
606 BL_MEMORY_TYPE Type;
607 } BL_MEMORY_DESCRIPTOR, *PBL_MEMORY_DESCRIPTOR;
608
609 typedef struct _BL_BCD_OPTION
610 {
611 ULONG Type;
612 ULONG DataOffset;
613 ULONG DataSize;
614 ULONG ListOffset;
615 ULONG NextEntryOffset;
616 ULONG Empty;
617 } BL_BCD_OPTION, *PBL_BCD_OPTION;
618
619 typedef struct _BL_APPLICATION_ENTRY
620 {
621 CHAR Signature[8];
622 ULONG Flags;
623 GUID Guid;
624 ULONG Unknown[4];
625 BL_BCD_OPTION BcdData;
626 } BL_APPLICATION_ENTRY, *PBL_APPLICATION_ENTRY;
627
628 typedef struct _BL_LOADED_APPLICATION_ENTRY
629 {
630 ULONG Flags;
631 GUID Guid;
632 PBL_BCD_OPTION BcdData;
633 } BL_LOADED_APPLICATION_ENTRY, *PBL_LOADED_APPLICATION_ENTRY;
634
635 typedef struct _BL_HARDDISK_DEVICE
636 {
637 ULONG PartitionType;
638 union
639 {
640 struct
641 {
642 ULONG PartitionSignature;
643 } Mbr;
644
645 struct
646 {
647 GUID PartitionSignature;
648 } Gpt;
649
650 struct
651 {
652 ULONG DiskNumber;
653 } Raw;
654 };
655 } BL_HARDDISK_DEVICE;
656
657 typedef struct _BL_LOCAL_DEVICE
658 {
659 ULONG Type;
660 union
661 {
662 struct
663 {
664 ULONG DriveNumber;
665 } FloppyDisk;
666
667 BL_HARDDISK_DEVICE HardDisk;
668
669 struct
670 {
671 PHYSICAL_ADDRESS ImageBase;
672 LARGE_INTEGER ImageSize;
673 ULONG ImageOffset;
674 } RamDisk;
675 };
676 } BL_LOCAL_DEVICE;
677
678 typedef struct _BL_DEVICE_DESCRIPTOR
679 {
680 ULONG Size;
681 ULONG Flags;
682 DEVICE_TYPE DeviceType;
683 ULONG Unknown;
684 union
685 {
686 BL_LOCAL_DEVICE Local;
687
688 struct
689 {
690 ULONG Unknown;
691 } Remote;
692
693 struct
694 {
695 union
696 {
697 ULONG PartitionNumber;
698 } Mbr;
699
700 union
701 {
702 GUID PartitionGuid;
703 } Gpt;
704
705 BL_LOCAL_DEVICE Disk;
706 } Partition;
707 };
708 } BL_DEVICE_DESCRIPTOR, *PBL_DEVICE_DESCRIPTOR;
709
710 typedef struct _BL_FILE_PATH_DESCRIPTOR
711 {
712 ULONG Version;
713 ULONG Length;
714 ULONG PathType;
715 UCHAR Path[ANYSIZE_ARRAY];
716 } BL_FILE_PATH_DESCRIPTOR, *PBL_FILE_PATH_DESCRIPTOR;
717
718 typedef struct _BL_WINDOWS_LOAD_OPTIONS
719 {
720 CHAR Signature[8];
721 ULONG Version;
722 ULONG Length;
723 ULONG OsPathOffset;
724 WCHAR LoadOptions[ANYSIZE_ARRAY];
725 } BL_WINDOWS_LOAD_OPTIONS, *PBL_WINDOWS_LOAD_OPTIONS;
726
727 typedef struct _BL_ARCH_CONTEXT
728 {
729 BL_ARCH_MODE Mode;
730 BL_TRANSLATION_TYPE TranslationType;
731 ULONG ContextFlags;
732 } BL_ARCH_CONTEXT, *PBL_ARCH_CONTEXT;
733
734 typedef struct _BL_MEMORY_DESCRIPTOR_LIST
735 {
736 LIST_ENTRY ListHead;
737 PLIST_ENTRY First;
738 PLIST_ENTRY This;
739 ULONG Type;
740 } BL_MEMORY_DESCRIPTOR_LIST, *PBL_MEMORY_DESCRIPTOR_LIST;
741
742 typedef struct _BL_ADDRESS_RANGE
743 {
744 ULONGLONG Minimum;
745 ULONGLONG Maximum;
746 } BL_ADDRESS_RANGE, *PBL_ADDRESS_RANGE;
747
748 typedef struct _BL_FILE_CALLBACKS
749 {
750 PBL_FILE_OPEN Open;
751 PBL_FILE_CLOSE Close;
752 PBL_FILE_READ Read;
753 PBL_FILE_WRITE Write;
754 PBL_FILE_GET_NEXT GetNext;
755 PBL_FILE_GET_INFO GetInfo;
756 PBL_FILE_SET_INFO SetInfo;
757 } BL_FILE_CALLBACKS, *PBL_FILE_CALLBACKS;
758
759 typedef struct _BL_FILE_ENTRY
760 {
761 PWCHAR FilePath;
762 ULONG DeviceId;
763 ULONG FileId;
764 ULONG Flags;
765 ULONG ReferenceCount;
766 ULONG Unknown;
767 ULONGLONG Unknown1;
768 ULONGLONG Unknown2;
769 BL_FILE_CALLBACKS Callbacks;
770 //PBL_FILE_DESTROY_CALLBACK DestroyCallback;
771 PVOID FsSpecificData;
772 } BL_FILE_ENTRY, *PBL_FILE_ENTRY;
773
774 typedef struct _BL_FILE_SYSTEM_ENTRY
775 {
776 LIST_ENTRY ListEntry;
777 PBL_FS_INIT_CALLBACK InitCallback;
778 PBL_FS_DESTROY_CALLBACK DestroyCallback;
779 PBL_FS_MOUNT_CALLBACK MountCallback;
780 PBL_FS_PURGE_CALLBACK PurgeCallback;
781 } BL_FILE_SYSTEM_ENTRY, *PBL_FILE_SYSTEM_ENTRY;
782
783 typedef struct _BL_FILE_SYSTEM_REGISTRATION_TABLE
784 {
785 PBL_FS_INIT_CALLBACK Init;
786 PBL_FS_DESTROY_CALLBACK Destroy;
787 PBL_FS_MOUNT_CALLBACK Mount;
788 PBL_FS_PURGE_CALLBACK Purge;
789 } BL_FILE_SYSTEM_REGISTRATION_TABLE;
790
791 typedef struct _BL_DISPLAY_STATE
792 {
793 ULONG BgColor;
794 ULONG FgColor;
795 ULONG XPos;
796 ULONG YPos;
797 ULONG CursorVisible;
798 } BL_DISPLAY_STATE, *PBL_DISPLAY_STATE;
799
800 typedef struct _BL_DISPLAY_MODE
801 {
802 ULONG HRes;
803 ULONG VRes;
804 ULONG HRes2;
805 } BL_DISPLAY_MODE, *PBL_DISPLAY_MODE;
806
807 typedef struct _BL_TEXT_CONSOLE_VTABLE
808 {
809 PCONSOLE_DESTRUCT Destruct;
810 PCONSOLE_REINITIALIZE Reinitialize;
811 PCONSOLE_GET_TEXT_STATE GetTextState;
812 PCONSOLE_SET_TEXT_STATE SetTextState;
813 PCONSOLE_GET_TEXT_RESOLUTION GetTextResolution;
814 PCONSOLE_SET_TEXT_RESOLUTION SetTextResolution;
815 PCONSOLE_CLEAR_TEXT ClearText;
816 PCONSOLE_WRITE_TEXT WriteText;
817 } BL_TEXT_CONSOLE_VTABLE, *PBL_TEXT_CONSOLE_VTABLE;
818
819 typedef struct _BL_GRAPHICS_CONSOLE_VTABLE
820 {
821 BL_TEXT_CONSOLE_VTABLE Text;
822 /// more for graphics ///
823 } BL_GRAPHICS_CONSOLE_VTABLE, *PBL_GRAPHICS_CONSOLE_VTABLE;
824
825 typedef struct _BL_TEXT_CONSOLE
826 {
827 PBL_TEXT_CONSOLE_VTABLE Callbacks;
828 BL_DISPLAY_STATE State;
829 BL_DISPLAY_MODE DisplayMode;
830 BOOLEAN Active;
831 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* Protocol;
832 ULONG Mode;
833 EFI_SIMPLE_TEXT_OUTPUT_MODE OldMode;
834 } BL_TEXT_CONSOLE, *PBL_TEXT_CONSOLE;
835
836 typedef enum _BL_GRAPHICS_CONSOLE_TYPE
837 {
838 BlGopConsole,
839 BlUgaConsole
840 } BL_GRAPHICS_CONSOLE_TYPE;
841
842 typedef struct _BL_GRAPHICS_CONSOLE
843 {
844 BL_TEXT_CONSOLE TextConsole;
845 BL_DISPLAY_MODE DisplayMode;
846 ULONG PixelDepth;
847 ULONG FgColor;
848 ULONG BgColor;
849 BL_DISPLAY_MODE OldDisplayMode;
850 ULONG OldPixelDepth;
851 EFI_HANDLE Handle;
852 BL_GRAPHICS_CONSOLE_TYPE Type;
853 EFI_GRAPHICS_OUTPUT_PROTOCOL* Protocol;
854 PVOID FrameBuffer;
855 ULONG FrameBufferSize;
856 ULONG PixelsPerScanLine;
857 ULONG Mode;
858 ULONG OldMode;
859 } BL_GRAPHICS_CONSOLE, *PBL_GRAPHICS_CONSOLE;
860
861 typedef struct _BL_REMOTE_CONSOLE
862 {
863 BL_TEXT_CONSOLE TextConsole;
864 } BL_REMOTE_CONSOLE, *PBL_REMOTE_CONSOLE;
865
866 typedef struct _BL_HASH_TABLE
867 {
868 PLIST_ENTRY HashLinks;
869 ULONG Size;
870 PBL_HASH_TABLE_COMPARE_FUNCTION CompareFunction;
871 PBL_HASH_TABLE_HASH_FUNCTION HashFunction;
872 } BL_HASH_TABLE, *PBL_HASH_TABLE;
873
874 typedef struct _BL_HASH_ENTRY
875 {
876 ULONG Size;
877 ULONG Flags;
878 PVOID Value;
879 } BL_HASH_ENTRY, *PBL_HASH_ENTRY;
880
881 typedef struct _BL_HASH_VALUE
882 {
883 ULONG DataSize;
884 PVOID Data;
885 } BL_HASH_VALUE, *PBL_HASH_VALUE;
886
887 typedef struct _BL_HASH_NODE
888 {
889 LIST_ENTRY ListEntry;
890 BL_HASH_ENTRY Entry;
891 BL_HASH_VALUE Value;
892 } BL_HASH_NODE, *PBL_HASH_NODE;
893
894 typedef struct _BL_BLOCK_DEVICE_INFORMATION
895 {
896 BL_LOCAL_DEVICE_TYPE Type;
897 ULONG DeviceFlags;
898 ULONG Unknown;
899 BL_PARTITION_TYPE PartitionType;
900 ULONG BlockSize;
901 ULONG Alignment;
902 ULONGLONG LastBlock;
903 ULONGLONG Offset;
904 ULONG Block;
905 struct
906 {
907 union
908 {
909 struct
910 {
911 ULONG Signature;
912 } Mbr;
913 struct
914 {
915 GUID Signature;
916 } Gpt;
917 };
918 } Disk;
919 } BL_BLOCK_DEVICE_INFORMATION, *PBL_BLOCK_DEVICE_INFORMATION;
920
921 typedef struct _BL_DEVICE_INFORMATION
922 {
923 BL_DEVICE_TYPE DeviceType;
924 union
925 {
926 BL_BLOCK_DEVICE_INFORMATION BlockDeviceInfo;
927 };
928 } BL_DEVICE_INFORMATION, *PBL_DEVICE_INFORMATION;
929
930 typedef struct _BL_BLOCK_DEVICE
931 {
932 BL_BLOCK_DEVICE_INFORMATION;
933 ULONGLONG StartOffset;
934 EFI_BLOCK_IO* Protocol;
935 EFI_HANDLE Handle;
936 } BL_BLOCK_DEVICE, *PBL_BLOCK_DEVICE;
937
938 typedef struct _BL_PROTOCOL_HANDLE
939 {
940 EFI_HANDLE Handle;
941 PVOID Interface;
942 } BL_PROTOCOL_HANDLE, *PBL_PROTOCOL_HANDLE;
943
944 typedef struct _BL_DEVICE_CALLBACKS
945 {
946 PBL_DEVICE_ENUMERATE_DEVICE_CLASS EnumerateDeviceClass;
947 PBL_DEVICE_OPEN Open;
948 PBL_DEVICE_CLOSE Close;
949 PBL_DEVICE_READ Read;
950 PBL_DEVICE_WRITE Write;
951 PBL_DEVICE_GET_INFORMATION GetInformation;
952 PBL_DEVICE_SET_INFORMATION SetInformation;
953 PBL_DEVICE_RESET Reset;
954 PBL_DEVICE_FLUSH Flush;
955 PBL_DEVICE_CREATE Create;
956 } BL_DEVICE_CALLBACKS, *PBL_DEVICE_CALLBACKS;
957
958 typedef struct _BL_DEVICE_ENTRY
959 {
960 ULONG DeviceId;
961 ULONG Flags;
962 ULONG Unknown;
963 ULONG ReferenceCount;
964 BL_DEVICE_CALLBACKS Callbacks;
965 PVOID DeviceSpecificData;
966 PBL_DEVICE_DESCRIPTOR DeviceDescriptor;
967 } BL_DEVICE_ENTRY, *PBL_DEVICE_ENTRY;
968
969 /* INLINE ROUTINES ***********************************************************/
970
971 FORCEINLINE
972 VOID
973 BlSetupDefaultParameters (
974 _Out_ PBL_LIBRARY_PARAMETERS LibraryParameters
975 )
976 {
977 BL_LIBRARY_PARAMETERS DefaultParameters =
978 {
979 0x20,
980 BlVirtual,
981 1024,
982 2 * 1024 * 1024,
983 0,
984 NULL,
985 0,
986 NULL
987 };
988
989 /* Copy the defaults */
990 RtlCopyMemory(LibraryParameters, &DefaultParameters, sizeof(*LibraryParameters));
991 }
992
993 FORCEINLINE
994 VOID
995 MmMdInitializeListHead (
996 _In_ PBL_MEMORY_DESCRIPTOR_LIST List
997 )
998 {
999 /* Initialize the list */
1000 InitializeListHead(&List->ListHead);
1001 List->First = &List->ListHead;
1002 List->This = NULL;
1003 }
1004
1005 /* INITIALIZATION ROUTINES ***************************************************/
1006
1007 NTSTATUS
1008 BlInitializeLibrary(
1009 _In_ PBOOT_APPLICATION_PARAMETER_BLOCK BootAppParameters,
1010 _In_ PBL_LIBRARY_PARAMETERS LibraryParameters
1011 );
1012
1013 NTSTATUS
1014 BlpArchInitialize (
1015 _In_ ULONG Phase
1016 );
1017
1018 NTSTATUS
1019 BlpFwInitialize (
1020 _In_ ULONG Phase,
1021 _In_ PBL_FIRMWARE_DESCRIPTOR FirmwareParameters
1022 );
1023
1024 NTSTATUS
1025 BlpMmInitialize (
1026 _In_ PBL_MEMORY_DATA MemoryData,
1027 _In_ BL_TRANSLATION_TYPE TranslationType,
1028 _In_ PBL_LIBRARY_PARAMETERS LibraryParameters
1029 );
1030
1031 NTSTATUS
1032 MmBaInitialize (
1033 VOID
1034 );
1035
1036 NTSTATUS
1037 MmPaInitialize (
1038 _In_ PBL_MEMORY_DATA MemoryData,
1039 _In_ ULONG MinimumPages
1040 );
1041
1042 NTSTATUS
1043 MmArchInitialize (
1044 _In_ ULONG Phase,
1045 _In_ PBL_MEMORY_DATA MemoryData,
1046 _In_ BL_TRANSLATION_TYPE TranslationType,
1047 _In_ BL_TRANSLATION_TYPE LibraryTranslationType
1048 );
1049
1050 NTSTATUS
1051 MmHaInitialize (
1052 _In_ ULONG HeapSize,
1053 _In_ ULONG HeapAttributes
1054 );
1055
1056 VOID
1057 MmMdInitialize (
1058 _In_ ULONG Phase,
1059 _In_ PBL_LIBRARY_PARAMETERS LibraryParameters
1060 );
1061
1062 NTSTATUS
1063 BlpDeviceInitialize (
1064 VOID
1065 );
1066
1067 NTSTATUS
1068 BlpIoInitialize (
1069 VOID
1070 );
1071
1072 NTSTATUS
1073 BlpFileInitialize (
1074 VOID
1075 );
1076
1077 NTSTATUS
1078 BlpDisplayInitialize (
1079 _In_ ULONG Flags
1080 );
1081
1082 VOID
1083 BlDestroyLibrary (
1084 VOID
1085 );
1086
1087 NTSTATUS
1088 BcInitialize (
1089 VOID
1090 );
1091
1092 /* FIRMWARE ROUTINES *********************************************************/
1093
1094 VOID
1095 EfiPrintf (
1096 _In_ PWCHAR Format,
1097 ...
1098 );
1099
1100 NTSTATUS
1101 EfiAllocatePages (
1102 _In_ ULONG Type,
1103 _In_ ULONG Pages,
1104 _Inout_ EFI_PHYSICAL_ADDRESS* Memory
1105 );
1106
1107 NTSTATUS
1108 EfiStall (
1109 _In_ ULONG StallTime
1110 );
1111
1112 NTSTATUS
1113 EfiConOutQueryMode (
1114 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1115 _In_ ULONG Mode,
1116 _In_ UINTN* Columns,
1117 _In_ UINTN* Rows
1118 );
1119
1120 NTSTATUS
1121 EfiConOutSetMode (
1122 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1123 _In_ ULONG Mode
1124 );
1125
1126 VOID
1127 EfiConOutReadCurrentMode (
1128 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1129 _Out_ EFI_SIMPLE_TEXT_OUTPUT_MODE* Mode
1130 );
1131
1132 NTSTATUS
1133 EfiConOutSetAttribute (
1134 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1135 _In_ ULONG Attribute
1136 );
1137
1138 NTSTATUS
1139 EfiConOutSetCursorPosition (
1140 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1141 _In_ ULONG Column,
1142 _In_ ULONG Row
1143 );
1144
1145 NTSTATUS
1146 EfiConOutEnableCursor (
1147 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1148 _In_ BOOLEAN Visible
1149 );
1150
1151 NTSTATUS
1152 EfiLocateHandleBuffer (
1153 _In_ EFI_LOCATE_SEARCH_TYPE SearchType,
1154 _In_ EFI_GUID *Protocol,
1155 _Inout_ PULONG HandleCount,
1156 _Inout_ EFI_HANDLE** Buffer
1157 );
1158
1159 NTSTATUS
1160 EfiOpenProtocol (
1161 _In_ EFI_HANDLE Handle,
1162 _In_ EFI_GUID *Protocol,
1163 _Out_ PVOID* Interface
1164 );
1165
1166 NTSTATUS
1167 EfiCloseProtocol (
1168 _In_ EFI_HANDLE Handle,
1169 _In_ EFI_GUID *Protocol
1170 );
1171
1172 NTSTATUS
1173 EfiGopGetCurrentMode (
1174 _In_ EFI_GRAPHICS_OUTPUT_PROTOCOL *GopInterface,
1175 _Out_ UINTN* Mode,
1176 _Out_ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Information
1177 );
1178
1179 NTSTATUS
1180 EfiGopSetMode (
1181 _In_ EFI_GRAPHICS_OUTPUT_PROTOCOL *GopInterface,
1182 _In_ ULONG Mode
1183 );
1184
1185 VOID
1186 EfiGopGetFrameBuffer (
1187 _In_ EFI_GRAPHICS_OUTPUT_PROTOCOL *GopInterface,
1188 _Out_ PHYSICAL_ADDRESS* FrameBuffer,
1189 _Out_ UINTN *FrameBufferSize
1190 );
1191
1192 VOID
1193 EfiResetSystem (
1194 _In_ EFI_RESET_TYPE ResetType
1195 );
1196
1197 EFI_DEVICE_PATH*
1198 EfiGetLeafNode (
1199 _In_ EFI_DEVICE_PATH *DevicePath
1200 );
1201
1202 EFI_DEVICE_PATH *
1203 EfiIsDevicePathParent (
1204 _In_ EFI_DEVICE_PATH *DevicePath1,
1205 _In_ EFI_DEVICE_PATH *DevicePath2
1206 );
1207
1208 /* PLATFORM TIMER ROUTINES ***************************************************/
1209
1210 NTSTATUS
1211 BlpTimeCalibratePerformanceCounter (
1212 VOID
1213 );
1214
1215 /* FILESYSTEM ROUTINES *******************************************************/
1216
1217 NTSTATUS
1218 FatInitialize (
1219 VOID
1220 );
1221
1222 NTSTATUS
1223 FatMount (
1224 _In_ ULONG DeviceId,
1225 _In_ ULONG Unknown,
1226 _Out_ PBL_FILE_ENTRY* FileEntry
1227 );
1228
1229 NTSTATUS
1230 EtfsInitialize (
1231 VOID
1232 );
1233
1234 NTSTATUS
1235 EtfsMount (
1236 _In_ ULONG DeviceId,
1237 _In_ ULONG Unknown,
1238 _Out_ PBL_FILE_ENTRY* FileEntry
1239 );
1240
1241 /* UTILITY ROUTINES **********************************************************/
1242
1243 EFI_STATUS
1244 EfiGetEfiStatusCode(
1245 _In_ NTSTATUS Status
1246 );
1247
1248 NTSTATUS
1249 EfiGetNtStatusCode (
1250 _In_ EFI_STATUS EfiStatus
1251 );
1252
1253 NTSTATUS
1254 BlUtlInitialize (
1255 VOID
1256 );
1257
1258 VOID
1259 BlFwReboot (
1260 VOID
1261 );
1262
1263 PGUID
1264 BlGetApplicationIdentifier (
1265 VOID
1266 );
1267
1268 /* TABLE ROUTINES ************************************************************/
1269
1270 NTSTATUS
1271 BlTblMap (
1272 _In_ PVOID *Table,
1273 _In_ ULONG Count,
1274 _In_ PBL_TBL_MAP_ROUTINE MapCallback
1275 );
1276
1277 PVOID
1278 BlTblFindEntry (
1279 _In_ PVOID *Table,
1280 _In_ ULONG Count,
1281 _Out_ PULONG EntryIndex,
1282 _In_ PBL_TBL_LOOKUP_ROUTINE Callback,
1283 _In_ PVOID Argument1,
1284 _In_ PVOID Argument2,
1285 _In_ PVOID Argument3,
1286 _In_ PVOID Argument4
1287 );
1288
1289 NTSTATUS
1290 BlTblSetEntry (
1291 _Inout_ PVOID** Table,
1292 _Inout_ PULONG Count,
1293 _In_ PVOID Entry,
1294 _Out_ PULONG EntryIndex,
1295 _In_ PBL_TBL_SET_ROUTINE Callback
1296 );
1297
1298 NTSTATUS
1299 TblDoNotPurgeEntry (
1300 _In_ PVOID Entry
1301 );
1302
1303 /* HASH TABLE ROUTINES *******************************************************/
1304
1305 NTSTATUS
1306 BlHtStore (
1307 _In_ ULONG TableId,
1308 _In_ PBL_HASH_ENTRY Entry,
1309 _In_ PVOID Data,
1310 _In_ ULONG DataSize
1311 );
1312
1313 NTSTATUS
1314 BlHtLookup (
1315 _In_ ULONG TableId,
1316 _In_ PBL_HASH_ENTRY Entry,
1317 _Out_ PBL_HASH_VALUE *Value
1318 );
1319
1320 NTSTATUS
1321 BlHtCreate (
1322 _In_ ULONG Size,
1323 _In_ PBL_HASH_TABLE_HASH_FUNCTION HashFunction,
1324 _In_ PBL_HASH_TABLE_COMPARE_FUNCTION CompareFunction,
1325 _Out_ PULONG Id
1326 );
1327
1328 /* BCD ROUTINES **************************************************************/
1329
1330 ULONG
1331 BlGetBootOptionSize (
1332 _In_ PBL_BCD_OPTION BcdOption
1333 );
1334
1335 NTSTATUS
1336 BlGetBootOptionString (
1337 _In_ PBL_BCD_OPTION List,
1338 _In_ ULONG Type,
1339 _Out_ PWCHAR* Value
1340 );
1341
1342 NTSTATUS
1343 BlGetBootOptionInteger (
1344 _In_ PBL_BCD_OPTION List,
1345 _In_ ULONG Type,
1346 _Out_ PULONGLONG Value
1347 );
1348
1349 NTSTATUS
1350 BlGetBootOptionBoolean (
1351 _In_ PBL_BCD_OPTION List,
1352 _In_ ULONG Type,
1353 _Out_ PBOOLEAN Value
1354 );
1355
1356 /* CONTEXT ROUTINES **********************************************************/
1357
1358 VOID
1359 BlpArchSwitchContext (
1360 _In_ BL_ARCH_MODE NewMode
1361 );
1362
1363 /* MEMORY DESCRIPTOR ROUTINES ************************************************/
1364
1365 VOID
1366 MmMdFreeList(
1367 _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList
1368 );
1369
1370 PBL_MEMORY_DESCRIPTOR
1371 MmMdInitByteGranularDescriptor (
1372 _In_ ULONG Flags,
1373 _In_ BL_MEMORY_TYPE Type,
1374 _In_ ULONGLONG BasePage,
1375 _In_ ULONGLONG VirtualPage,
1376 _In_ ULONGLONG PageCount
1377 );
1378
1379 VOID
1380 MmMdFreeGlobalDescriptors (
1381 VOID
1382 );
1383
1384 NTSTATUS
1385 MmMdAddDescriptorToList (
1386 _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList,
1387 _In_ PBL_MEMORY_DESCRIPTOR MemoryDescriptor,
1388 _In_ ULONG Flags
1389 );
1390
1391 VOID
1392 MmMdRemoveDescriptorFromList (
1393 _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList,
1394 _In_ PBL_MEMORY_DESCRIPTOR Entry
1395 );
1396
1397 BOOLEAN
1398 MmMdFindSatisfyingRegion (
1399 _In_ PBL_MEMORY_DESCRIPTOR Descriptor,
1400 _Out_ PBL_MEMORY_DESCRIPTOR NewDescriptor,
1401 _In_ ULONGLONG Pages,
1402 _In_ PBL_ADDRESS_RANGE BaseRange,
1403 _In_ PBL_ADDRESS_RANGE VirtualRange,
1404 _In_ BOOLEAN TopDown,
1405 _In_ BL_MEMORY_TYPE MemoryType,
1406 _In_ ULONG Flags,
1407 _In_ ULONG Alignment
1408 );
1409
1410 NTSTATUS
1411 MmMdRemoveRegionFromMdlEx (
1412 __in PBL_MEMORY_DESCRIPTOR_LIST MdList,
1413 __in ULONG Flags,
1414 __in ULONGLONG BasePage,
1415 __in ULONGLONG PageCount,
1416 __in PBL_MEMORY_DESCRIPTOR_LIST NewMdList
1417 );
1418
1419 NTSTATUS
1420 MmMdFreeDescriptor (
1421 _In_ PBL_MEMORY_DESCRIPTOR MemoryDescriptor
1422 );
1423
1424 /* PAGE ALLOCATOR ROUTINES ***************************************************/
1425
1426 NTSTATUS
1427 MmPapAllocatePagesInRange (
1428 _Inout_ PVOID* PhysicalAddress,
1429 _In_ BL_MEMORY_TYPE MemoryType,
1430 _In_ ULONGLONG Pages,
1431 _In_ ULONG Attributes,
1432 _In_ ULONG Alignment,
1433 _In_opt_ PBL_ADDRESS_RANGE Range,
1434 _In_ ULONG Type
1435 );
1436
1437 NTSTATUS
1438 MmFwGetMemoryMap (
1439 _Out_ PBL_MEMORY_DESCRIPTOR_LIST MemoryMap,
1440 _In_ ULONG Flags
1441 );
1442
1443 /* VIRTUAL MEMORY ROUTINES ***************************************************/
1444
1445 NTSTATUS
1446 BlMmMapPhysicalAddressEx (
1447 _In_ PVOID* VirtualAddress,
1448 _In_ ULONG Attributes,
1449 _In_ ULONGLONG Size,
1450 _In_ PHYSICAL_ADDRESS PhysicalAddress
1451 );
1452
1453 /* BLOCK ALLOCATOR ROUTINES **************************************************/
1454
1455 NTSTATUS
1456 BlpMmCreateBlockAllocator (
1457 VOID
1458 );
1459
1460 /* HEAP ALLOCATOR ROUTINES ***************************************************/
1461
1462 PVOID
1463 BlMmAllocateHeap (
1464 _In_ ULONG Size
1465 );
1466
1467 NTSTATUS
1468 BlMmFreeHeap (
1469 _In_ PVOID Buffer
1470 );
1471
1472 /* DISPLAY ROUTINES **********************************************************/
1473
1474 VOID
1475 BlDisplayGetTextCellResolution (
1476 _Out_ PULONG TextWidth,
1477 _Out_ PULONG TextHeight
1478 );
1479
1480 /* I/O ROUTINES **************************************************************/
1481
1482 NTSTATUS
1483 BlpIoRegisterDestroyRoutine (
1484 _In_ PBL_IO_DESTROY_ROUTINE DestroyRoutine
1485 );
1486
1487 NTSTATUS
1488 BlDeviceClose (
1489 _In_ ULONG DeviceId
1490 );
1491
1492 NTSTATUS
1493 BlpDeviceOpen (
1494 _In_ PBL_DEVICE_DESCRIPTOR Device,
1495 _In_ ULONG Flags,
1496 _In_ ULONG Unknown,
1497 _Out_ PULONG DeviceId
1498 );
1499
1500 NTSTATUS
1501 BlDeviceGetInformation (
1502 _In_ ULONG DeviceId,
1503 _Out_ PBL_DEVICE_INFORMATION DeviceInformation
1504 );
1505
1506 NTSTATUS
1507 BlDeviceSetInformation (
1508 _In_ ULONG DeviceId,
1509 _In_ PBL_DEVICE_INFORMATION DeviceInformation
1510 );
1511
1512 NTSTATUS
1513 BlDeviceReadAtOffset (
1514 _In_ ULONG DeviceId,
1515 _In_ ULONG Size,
1516 _In_ ULONGLONG Offset,
1517 _In_ PVOID Buffer,
1518 _Out_ PULONG BytesRead
1519 );
1520
1521 /* FILE I/O ROUTINES *********************************************************/
1522
1523 NTSTATUS
1524 BlFileClose (
1525 _In_ ULONG FileId
1526 );
1527
1528 NTSTATUS
1529 BlFileOpen (
1530 _In_ ULONG DeviceId,
1531 _In_ PWCHAR FileName,
1532 _In_ ULONG OpenFlags,
1533 _Out_ PULONG FileId
1534 );
1535
1536 /* TEXT CONSOLE ROUTINES *****************************************************/
1537
1538 NTSTATUS
1539 ConsoleTextLocalDestruct (
1540 _In_ struct _BL_TEXT_CONSOLE* Console
1541 );
1542
1543 NTSTATUS
1544 ConsoleTextLocalReinitialize (
1545 _In_ struct _BL_TEXT_CONSOLE* Console
1546 );
1547
1548 NTSTATUS
1549 ConsoleTextBaseGetTextState (
1550 _In_ struct _BL_TEXT_CONSOLE* Console,
1551 _Out_ PBL_DISPLAY_STATE TextState
1552 );
1553
1554 NTSTATUS
1555 ConsoleTextLocalSetTextState (
1556 _In_ struct _BL_TEXT_CONSOLE* Console,
1557 _In_ ULONG Flags,
1558 _In_ PBL_DISPLAY_STATE TextState
1559 );
1560
1561 NTSTATUS
1562 ConsoleTextBaseGetTextResolution (
1563 _In_ struct _BL_TEXT_CONSOLE* Console,
1564 _Out_ PULONG TextResolution
1565 );
1566
1567 NTSTATUS
1568 ConsoleTextLocalSetTextResolution (
1569 _In_ struct _BL_TEXT_CONSOLE* Console,
1570 _In_ ULONG NewTextResolution,
1571 _Out_ PULONG OldTextResolution
1572 );
1573
1574 NTSTATUS
1575 ConsoleTextLocalClearText (
1576 _In_ struct _BL_TEXT_CONSOLE* Console,
1577 _In_ ULONG Attribute
1578 );
1579
1580 NTSTATUS
1581 ConsoleTextLocalWriteText (
1582 _In_ struct _BL_TEXT_CONSOLE* Console,
1583 _In_ PCHAR Text,
1584 _In_ ULONG Attribute
1585 );
1586
1587 NTSTATUS
1588 ConsoleTextLocalConstruct (
1589 _In_ PBL_TEXT_CONSOLE TextConsole,
1590 _In_ BOOLEAN Activate
1591 );
1592
1593 BOOLEAN
1594 ConsolepFindResolution (
1595 _In_ PBL_DISPLAY_MODE Mode,
1596 _In_ PBL_DISPLAY_MODE List,
1597 _In_ ULONG MaxIndex
1598 );
1599
1600 VOID
1601 ConsoleFirmwareTextClose (
1602 _In_ PBL_TEXT_CONSOLE TextConsole
1603 );
1604
1605 NTSTATUS
1606 ConsoleFirmwareTextOpen (
1607 _In_ PBL_TEXT_CONSOLE TextConsole
1608 );
1609
1610 NTSTATUS
1611 ConsoleFirmwareTextSetState (
1612 _In_ PBL_TEXT_CONSOLE TextConsole,
1613 _In_ UCHAR Mask,
1614 _In_ PBL_DISPLAY_STATE State
1615 );
1616
1617 NTSTATUS
1618 ConsoleGraphicalConstruct (
1619 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
1620 );
1621
1622 NTSTATUS
1623 ConsoleCreateRemoteConsole (
1624 _In_ PBL_TEXT_CONSOLE* TextConsole
1625 );
1626
1627 NTSTATUS
1628 ConsoleEfiGraphicalOpenProtocol (
1629 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole,
1630 _In_ BL_GRAPHICS_CONSOLE_TYPE Type
1631 );
1632
1633 VOID
1634 ConsoleFirmwareGraphicalClose (
1635 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
1636 );
1637
1638 NTSTATUS
1639 ConsoleFirmwareGraphicalEnable (
1640 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
1641 );
1642
1643 NTSTATUS
1644 ConsoleEfiUgaOpen (
1645 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
1646 );
1647
1648 VOID
1649 ConsoleEfiUgaClose (
1650 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
1651 );
1652
1653 VOID
1654 ConsoleEfiGopClose (
1655 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
1656 );
1657
1658 NTSTATUS
1659 ConsoleEfiGopOpen (
1660 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
1661 );
1662
1663 NTSTATUS
1664 ConsoleEfiGopEnable (
1665 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
1666 );
1667
1668 NTSTATUS
1669 ConsoleEfiUgaSetResolution (
1670 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole,
1671 _In_ PBL_DISPLAY_MODE DisplayMode,
1672 _In_ ULONG DisplayModeCount
1673 );
1674
1675 extern ULONG MmDescriptorCallTreeCount;
1676 extern ULONG BlpApplicationFlags;
1677 extern BL_LIBRARY_PARAMETERS BlpLibraryParameters;
1678 extern BL_TRANSLATION_TYPE MmTranslationType;
1679 extern PBL_ARCH_CONTEXT CurrentExecutionContext;
1680 extern PBL_DEVICE_DESCRIPTOR BlpBootDevice;
1681 extern BL_LOADED_APPLICATION_ENTRY BlpApplicationEntry;
1682 extern SIMPLE_TEXT_OUTPUT_INTERFACE *EfiConOut;
1683 extern EFI_GUID EfiGraphicsOutputProtocol;
1684 extern EFI_GUID EfiUgaDrawProtocol;
1685 extern EFI_GUID EfiLoadedImageProtocol;
1686 extern EFI_GUID EfiDevicePathProtocol;
1687 extern EFI_GUID EfiBlockIoProtocol;
1688 extern EFI_GUID EfiSimpleTextInputExProtocol;
1689 extern ULONG ConsoleGraphicalResolutionListFlags;
1690 extern BL_DISPLAY_MODE ConsoleGraphicalResolutionList[];
1691 extern BL_DISPLAY_MODE ConsoleTextResolutionList[];
1692 extern ULONG ConsoleGraphicalResolutionListSize;
1693 extern PVOID DspRemoteInputConsole;
1694 #endif