0a444cf8dca8854075f9b8c72b58cf960c13e121
[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* ParentFileEntry,
273 _In_ PWCHAR FileName,
274 _In_ ULONG OpenFlags,
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 ULONG ReferenceCount;
762 ULONG FileId;
763 ULONG DeviceId;
764 ULONG Flags;
765 PWCHAR FilePath;
766 ULONG Unknown;
767 ULONG Unknown1;
768 ULONG Unknown2;
769 BL_FILE_CALLBACKS Callbacks;
770 PBL_FILE_DESTROY_CALLBACK DestroyCallback;
771 } BL_FILE_ENTRY, *PBL_FILE_ENTRY;
772
773 typedef struct _BL_FILE_SYSTEM_ENTRY
774 {
775 LIST_ENTRY ListEntry;
776 PBL_FS_INIT_CALLBACK InitCallback;
777 PBL_FS_DESTROY_CALLBACK DestroyCallback;
778 PBL_FS_MOUNT_CALLBACK MountCallback;
779 PBL_FS_PURGE_CALLBACK PurgeCallback;
780 } BL_FILE_SYSTEM_ENTRY, *PBL_FILE_SYSTEM_ENTRY;
781
782 typedef struct _BL_FILE_SYSTEM_REGISTRATION_TABLE
783 {
784 PBL_FS_INIT_CALLBACK Init;
785 PBL_FS_DESTROY_CALLBACK Destroy;
786 PBL_FS_MOUNT_CALLBACK Mount;
787 PBL_FS_PURGE_CALLBACK Purge;
788 } BL_FILE_SYSTEM_REGISTRATION_TABLE;
789
790 typedef struct _BL_DISPLAY_STATE
791 {
792 ULONG BgColor;
793 ULONG FgColor;
794 ULONG XPos;
795 ULONG YPos;
796 ULONG CursorVisible;
797 } BL_DISPLAY_STATE, *PBL_DISPLAY_STATE;
798
799 typedef struct _BL_DISPLAY_MODE
800 {
801 ULONG HRes;
802 ULONG VRes;
803 ULONG HRes2;
804 } BL_DISPLAY_MODE, *PBL_DISPLAY_MODE;
805
806 typedef struct _BL_TEXT_CONSOLE_VTABLE
807 {
808 PCONSOLE_DESTRUCT Destruct;
809 PCONSOLE_REINITIALIZE Reinitialize;
810 PCONSOLE_GET_TEXT_STATE GetTextState;
811 PCONSOLE_SET_TEXT_STATE SetTextState;
812 PCONSOLE_GET_TEXT_RESOLUTION GetTextResolution;
813 PCONSOLE_SET_TEXT_RESOLUTION SetTextResolution;
814 PCONSOLE_CLEAR_TEXT ClearText;
815 PCONSOLE_WRITE_TEXT WriteText;
816 } BL_TEXT_CONSOLE_VTABLE, *PBL_TEXT_CONSOLE_VTABLE;
817
818 typedef struct _BL_GRAPHICS_CONSOLE_VTABLE
819 {
820 BL_TEXT_CONSOLE_VTABLE Text;
821 /// more for graphics ///
822 } BL_GRAPHICS_CONSOLE_VTABLE, *PBL_GRAPHICS_CONSOLE_VTABLE;
823
824 typedef struct _BL_TEXT_CONSOLE
825 {
826 PBL_TEXT_CONSOLE_VTABLE Callbacks;
827 BL_DISPLAY_STATE State;
828 BL_DISPLAY_MODE DisplayMode;
829 BOOLEAN Active;
830 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL* Protocol;
831 ULONG Mode;
832 EFI_SIMPLE_TEXT_OUTPUT_MODE OldMode;
833 } BL_TEXT_CONSOLE, *PBL_TEXT_CONSOLE;
834
835 typedef enum _BL_GRAPHICS_CONSOLE_TYPE
836 {
837 BlGopConsole,
838 BlUgaConsole
839 } BL_GRAPHICS_CONSOLE_TYPE;
840
841 typedef struct _BL_GRAPHICS_CONSOLE
842 {
843 BL_TEXT_CONSOLE TextConsole;
844 BL_DISPLAY_MODE DisplayMode;
845 ULONG PixelDepth;
846 ULONG FgColor;
847 ULONG BgColor;
848 BL_DISPLAY_MODE OldDisplayMode;
849 ULONG OldPixelDepth;
850 EFI_HANDLE Handle;
851 BL_GRAPHICS_CONSOLE_TYPE Type;
852 EFI_GRAPHICS_OUTPUT_PROTOCOL* Protocol;
853 PVOID FrameBuffer;
854 ULONG FrameBufferSize;
855 ULONG PixelsPerScanLine;
856 ULONG Mode;
857 ULONG OldMode;
858 } BL_GRAPHICS_CONSOLE, *PBL_GRAPHICS_CONSOLE;
859
860 typedef struct _BL_REMOTE_CONSOLE
861 {
862 BL_TEXT_CONSOLE TextConsole;
863 } BL_REMOTE_CONSOLE, *PBL_REMOTE_CONSOLE;
864
865 typedef struct _BL_HASH_TABLE
866 {
867 PLIST_ENTRY HashLinks;
868 ULONG Size;
869 PBL_HASH_TABLE_COMPARE_FUNCTION CompareFunction;
870 PBL_HASH_TABLE_HASH_FUNCTION HashFunction;
871 } BL_HASH_TABLE, *PBL_HASH_TABLE;
872
873 typedef struct _BL_HASH_ENTRY
874 {
875 ULONG Size;
876 ULONG Flags;
877 PVOID Value;
878 } BL_HASH_ENTRY, *PBL_HASH_ENTRY;
879
880 typedef struct _BL_HASH_VALUE
881 {
882 ULONG DataSize;
883 PVOID Data;
884 } BL_HASH_VALUE, *PBL_HASH_VALUE;
885
886 typedef struct _BL_HASH_NODE
887 {
888 LIST_ENTRY ListEntry;
889 BL_HASH_ENTRY Entry;
890 BL_HASH_VALUE Value;
891 } BL_HASH_NODE, *PBL_HASH_NODE;
892
893 typedef struct _BL_BLOCK_DEVICE_INFORMATION
894 {
895 BL_LOCAL_DEVICE_TYPE Type;
896 ULONG DeviceFlags;
897 ULONG Unknown;
898 BL_PARTITION_TYPE PartitionType;
899 ULONG BlockSize;
900 ULONG Alignment;
901 ULONGLONG LastBlock;
902 ULONGLONG Offset;
903 ULONG Block;
904 struct
905 {
906 union
907 {
908 struct
909 {
910 ULONG Signature;
911 } Mbr;
912 struct
913 {
914 GUID Signature;
915 } Gpt;
916 };
917 } Disk;
918 } BL_BLOCK_DEVICE_INFORMATION, *PBL_BLOCK_DEVICE_INFORMATION;
919
920 typedef struct _BL_DEVICE_INFORMATION
921 {
922 BL_DEVICE_TYPE DeviceType;
923 union
924 {
925 BL_BLOCK_DEVICE_INFORMATION BlockDeviceInfo;
926 };
927 } BL_DEVICE_INFORMATION, *PBL_DEVICE_INFORMATION;
928
929 typedef struct _BL_BLOCK_DEVICE
930 {
931 BL_BLOCK_DEVICE_INFORMATION;
932 ULONGLONG StartOffset;
933 EFI_BLOCK_IO* Protocol;
934 EFI_HANDLE Handle;
935 } BL_BLOCK_DEVICE, *PBL_BLOCK_DEVICE;
936
937 typedef struct _BL_PROTOCOL_HANDLE
938 {
939 EFI_HANDLE Handle;
940 PVOID Interface;
941 } BL_PROTOCOL_HANDLE, *PBL_PROTOCOL_HANDLE;
942
943 typedef struct _BL_DEVICE_CALLBACKS
944 {
945 PBL_DEVICE_ENUMERATE_DEVICE_CLASS EnumerateDeviceClass;
946 PBL_DEVICE_OPEN Open;
947 PBL_DEVICE_CLOSE Close;
948 PBL_DEVICE_READ Read;
949 PBL_DEVICE_WRITE Write;
950 PBL_DEVICE_GET_INFORMATION GetInformation;
951 PBL_DEVICE_SET_INFORMATION SetInformation;
952 PBL_DEVICE_RESET Reset;
953 PBL_DEVICE_FLUSH Flush;
954 PBL_DEVICE_CREATE Create;
955 } BL_DEVICE_CALLBACKS, *PBL_DEVICE_CALLBACKS;
956
957 typedef struct _BL_DEVICE_ENTRY
958 {
959 ULONG DeviceId;
960 ULONG Flags;
961 ULONG Unknown;
962 ULONG ReferenceCount;
963 BL_DEVICE_CALLBACKS Callbacks;
964 PVOID DeviceSpecificData;
965 PBL_DEVICE_DESCRIPTOR DeviceDescriptor;
966 } BL_DEVICE_ENTRY, *PBL_DEVICE_ENTRY;
967
968 /* INLINE ROUTINES ***********************************************************/
969
970 FORCEINLINE
971 VOID
972 BlSetupDefaultParameters (
973 _Out_ PBL_LIBRARY_PARAMETERS LibraryParameters
974 )
975 {
976 BL_LIBRARY_PARAMETERS DefaultParameters =
977 {
978 0x20,
979 BlVirtual,
980 1024,
981 2 * 1024 * 1024,
982 0,
983 NULL,
984 0,
985 NULL
986 };
987
988 /* Copy the defaults */
989 RtlCopyMemory(LibraryParameters, &DefaultParameters, sizeof(*LibraryParameters));
990 }
991
992 FORCEINLINE
993 VOID
994 MmMdInitializeListHead (
995 _In_ PBL_MEMORY_DESCRIPTOR_LIST List
996 )
997 {
998 /* Initialize the list */
999 InitializeListHead(&List->ListHead);
1000 List->First = &List->ListHead;
1001 List->This = NULL;
1002 }
1003
1004 /* INITIALIZATION ROUTINES ***************************************************/
1005
1006 NTSTATUS
1007 BlInitializeLibrary(
1008 _In_ PBOOT_APPLICATION_PARAMETER_BLOCK BootAppParameters,
1009 _In_ PBL_LIBRARY_PARAMETERS LibraryParameters
1010 );
1011
1012 NTSTATUS
1013 BlpArchInitialize (
1014 _In_ ULONG Phase
1015 );
1016
1017 NTSTATUS
1018 BlpFwInitialize (
1019 _In_ ULONG Phase,
1020 _In_ PBL_FIRMWARE_DESCRIPTOR FirmwareParameters
1021 );
1022
1023 NTSTATUS
1024 BlpMmInitialize (
1025 _In_ PBL_MEMORY_DATA MemoryData,
1026 _In_ BL_TRANSLATION_TYPE TranslationType,
1027 _In_ PBL_LIBRARY_PARAMETERS LibraryParameters
1028 );
1029
1030 NTSTATUS
1031 MmBaInitialize (
1032 VOID
1033 );
1034
1035 NTSTATUS
1036 MmPaInitialize (
1037 _In_ PBL_MEMORY_DATA MemoryData,
1038 _In_ ULONG MinimumPages
1039 );
1040
1041 NTSTATUS
1042 MmArchInitialize (
1043 _In_ ULONG Phase,
1044 _In_ PBL_MEMORY_DATA MemoryData,
1045 _In_ BL_TRANSLATION_TYPE TranslationType,
1046 _In_ BL_TRANSLATION_TYPE LibraryTranslationType
1047 );
1048
1049 NTSTATUS
1050 MmHaInitialize (
1051 _In_ ULONG HeapSize,
1052 _In_ ULONG HeapAttributes
1053 );
1054
1055 VOID
1056 MmMdInitialize (
1057 _In_ ULONG Phase,
1058 _In_ PBL_LIBRARY_PARAMETERS LibraryParameters
1059 );
1060
1061 NTSTATUS
1062 BlpDeviceInitialize (
1063 VOID
1064 );
1065
1066 NTSTATUS
1067 BlpIoInitialize (
1068 VOID
1069 );
1070
1071 NTSTATUS
1072 BlpFileInitialize (
1073 VOID
1074 );
1075
1076 NTSTATUS
1077 BlpDisplayInitialize (
1078 _In_ ULONG Flags
1079 );
1080
1081 VOID
1082 BlDestroyLibrary (
1083 VOID
1084 );
1085
1086 NTSTATUS
1087 BcInitialize (
1088 VOID
1089 );
1090
1091 /* FIRMWARE ROUTINES *********************************************************/
1092
1093 VOID
1094 EfiPrintf (
1095 _In_ PWCHAR Format,
1096 ...
1097 );
1098
1099 NTSTATUS
1100 EfiAllocatePages (
1101 _In_ ULONG Type,
1102 _In_ ULONG Pages,
1103 _Inout_ EFI_PHYSICAL_ADDRESS* Memory
1104 );
1105
1106 NTSTATUS
1107 EfiStall (
1108 _In_ ULONG StallTime
1109 );
1110
1111 NTSTATUS
1112 EfiConOutQueryMode (
1113 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1114 _In_ ULONG Mode,
1115 _In_ UINTN* Columns,
1116 _In_ UINTN* Rows
1117 );
1118
1119 NTSTATUS
1120 EfiConOutSetMode (
1121 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1122 _In_ ULONG Mode
1123 );
1124
1125 VOID
1126 EfiConOutReadCurrentMode (
1127 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1128 _Out_ EFI_SIMPLE_TEXT_OUTPUT_MODE* Mode
1129 );
1130
1131 NTSTATUS
1132 EfiConOutSetAttribute (
1133 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1134 _In_ ULONG Attribute
1135 );
1136
1137 NTSTATUS
1138 EfiConOutSetCursorPosition (
1139 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1140 _In_ ULONG Column,
1141 _In_ ULONG Row
1142 );
1143
1144 NTSTATUS
1145 EfiConOutEnableCursor (
1146 _In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface,
1147 _In_ BOOLEAN Visible
1148 );
1149
1150 NTSTATUS
1151 EfiLocateHandleBuffer (
1152 _In_ EFI_LOCATE_SEARCH_TYPE SearchType,
1153 _In_ EFI_GUID *Protocol,
1154 _Inout_ PULONG HandleCount,
1155 _Inout_ EFI_HANDLE** Buffer
1156 );
1157
1158 NTSTATUS
1159 EfiOpenProtocol (
1160 _In_ EFI_HANDLE Handle,
1161 _In_ EFI_GUID *Protocol,
1162 _Out_ PVOID* Interface
1163 );
1164
1165 NTSTATUS
1166 EfiCloseProtocol (
1167 _In_ EFI_HANDLE Handle,
1168 _In_ EFI_GUID *Protocol
1169 );
1170
1171 NTSTATUS
1172 EfiGopGetCurrentMode (
1173 _In_ EFI_GRAPHICS_OUTPUT_PROTOCOL *GopInterface,
1174 _Out_ UINTN* Mode,
1175 _Out_ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Information
1176 );
1177
1178 NTSTATUS
1179 EfiGopSetMode (
1180 _In_ EFI_GRAPHICS_OUTPUT_PROTOCOL *GopInterface,
1181 _In_ ULONG Mode
1182 );
1183
1184 VOID
1185 EfiGopGetFrameBuffer (
1186 _In_ EFI_GRAPHICS_OUTPUT_PROTOCOL *GopInterface,
1187 _Out_ PHYSICAL_ADDRESS* FrameBuffer,
1188 _Out_ UINTN *FrameBufferSize
1189 );
1190
1191 VOID
1192 EfiResetSystem (
1193 _In_ EFI_RESET_TYPE ResetType
1194 );
1195
1196 EFI_DEVICE_PATH*
1197 EfiGetLeafNode (
1198 _In_ EFI_DEVICE_PATH *DevicePath
1199 );
1200
1201 EFI_DEVICE_PATH *
1202 EfiIsDevicePathParent (
1203 _In_ EFI_DEVICE_PATH *DevicePath1,
1204 _In_ EFI_DEVICE_PATH *DevicePath2
1205 );
1206
1207 /* PLATFORM TIMER ROUTINES ***************************************************/
1208
1209 NTSTATUS
1210 BlpTimeCalibratePerformanceCounter (
1211 VOID
1212 );
1213
1214 /* FILESYSTEM ROUTINES *******************************************************/
1215
1216 NTSTATUS
1217 FatInitialize (
1218 VOID
1219 );
1220
1221 NTSTATUS
1222 FatMount (
1223 _In_ ULONG DeviceId,
1224 _In_ ULONG Unknown,
1225 _Out_ PBL_FILE_ENTRY* FileEntry
1226 );
1227
1228 /* UTILITY ROUTINES **********************************************************/
1229
1230 EFI_STATUS
1231 EfiGetEfiStatusCode(
1232 _In_ NTSTATUS Status
1233 );
1234
1235 NTSTATUS
1236 EfiGetNtStatusCode (
1237 _In_ EFI_STATUS EfiStatus
1238 );
1239
1240 NTSTATUS
1241 BlUtlInitialize (
1242 VOID
1243 );
1244
1245 VOID
1246 BlFwReboot (
1247 VOID
1248 );
1249
1250 PGUID
1251 BlGetApplicationIdentifier (
1252 VOID
1253 );
1254
1255 /* TABLE ROUTINES ************************************************************/
1256
1257 NTSTATUS
1258 BlTblMap (
1259 _In_ PVOID *Table,
1260 _In_ ULONG Count,
1261 _In_ PBL_TBL_MAP_ROUTINE MapCallback
1262 );
1263
1264 PVOID
1265 BlTblFindEntry (
1266 _In_ PVOID *Table,
1267 _In_ ULONG Count,
1268 _Out_ PULONG EntryIndex,
1269 _In_ PBL_TBL_LOOKUP_ROUTINE Callback,
1270 _In_ PVOID Argument1,
1271 _In_ PVOID Argument2,
1272 _In_ PVOID Argument3,
1273 _In_ PVOID Argument4
1274 );
1275
1276 NTSTATUS
1277 BlTblSetEntry (
1278 _Inout_ PVOID** Table,
1279 _Inout_ PULONG Count,
1280 _In_ PVOID Entry,
1281 _Out_ PULONG EntryIndex,
1282 _In_ PBL_TBL_SET_ROUTINE Callback
1283 );
1284
1285 NTSTATUS
1286 TblDoNotPurgeEntry (
1287 _In_ PVOID Entry
1288 );
1289
1290 /* HASH TABLE ROUTINES *******************************************************/
1291
1292 NTSTATUS
1293 BlHtStore (
1294 _In_ ULONG TableId,
1295 _In_ PBL_HASH_ENTRY Entry,
1296 _In_ PVOID Data,
1297 _In_ ULONG DataSize
1298 );
1299
1300 NTSTATUS
1301 BlHtLookup (
1302 _In_ ULONG TableId,
1303 _In_ PBL_HASH_ENTRY Entry,
1304 _Out_ PBL_HASH_VALUE *Value
1305 );
1306
1307 NTSTATUS
1308 BlHtCreate (
1309 _In_ ULONG Size,
1310 _In_ PBL_HASH_TABLE_HASH_FUNCTION HashFunction,
1311 _In_ PBL_HASH_TABLE_COMPARE_FUNCTION CompareFunction,
1312 _Out_ PULONG Id
1313 );
1314
1315 /* BCD ROUTINES **************************************************************/
1316
1317 ULONG
1318 BlGetBootOptionSize (
1319 _In_ PBL_BCD_OPTION BcdOption
1320 );
1321
1322 NTSTATUS
1323 BlGetBootOptionString (
1324 _In_ PBL_BCD_OPTION List,
1325 _In_ ULONG Type,
1326 _Out_ PWCHAR* Value
1327 );
1328
1329 NTSTATUS
1330 BlGetBootOptionInteger (
1331 _In_ PBL_BCD_OPTION List,
1332 _In_ ULONG Type,
1333 _Out_ PULONGLONG Value
1334 );
1335
1336 NTSTATUS
1337 BlGetBootOptionBoolean (
1338 _In_ PBL_BCD_OPTION List,
1339 _In_ ULONG Type,
1340 _Out_ PBOOLEAN Value
1341 );
1342
1343 /* CONTEXT ROUTINES **********************************************************/
1344
1345 VOID
1346 BlpArchSwitchContext (
1347 _In_ BL_ARCH_MODE NewMode
1348 );
1349
1350 /* MEMORY DESCRIPTOR ROUTINES ************************************************/
1351
1352 VOID
1353 MmMdFreeList(
1354 _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList
1355 );
1356
1357 PBL_MEMORY_DESCRIPTOR
1358 MmMdInitByteGranularDescriptor (
1359 _In_ ULONG Flags,
1360 _In_ BL_MEMORY_TYPE Type,
1361 _In_ ULONGLONG BasePage,
1362 _In_ ULONGLONG VirtualPage,
1363 _In_ ULONGLONG PageCount
1364 );
1365
1366 VOID
1367 MmMdFreeGlobalDescriptors (
1368 VOID
1369 );
1370
1371 NTSTATUS
1372 MmMdAddDescriptorToList (
1373 _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList,
1374 _In_ PBL_MEMORY_DESCRIPTOR MemoryDescriptor,
1375 _In_ ULONG Flags
1376 );
1377
1378 VOID
1379 MmMdRemoveDescriptorFromList (
1380 _In_ PBL_MEMORY_DESCRIPTOR_LIST MdList,
1381 _In_ PBL_MEMORY_DESCRIPTOR Entry
1382 );
1383
1384 BOOLEAN
1385 MmMdFindSatisfyingRegion (
1386 _In_ PBL_MEMORY_DESCRIPTOR Descriptor,
1387 _Out_ PBL_MEMORY_DESCRIPTOR NewDescriptor,
1388 _In_ ULONGLONG Pages,
1389 _In_ PBL_ADDRESS_RANGE BaseRange,
1390 _In_ PBL_ADDRESS_RANGE VirtualRange,
1391 _In_ BOOLEAN TopDown,
1392 _In_ BL_MEMORY_TYPE MemoryType,
1393 _In_ ULONG Flags,
1394 _In_ ULONG Alignment
1395 );
1396
1397 NTSTATUS
1398 MmMdRemoveRegionFromMdlEx (
1399 __in PBL_MEMORY_DESCRIPTOR_LIST MdList,
1400 __in ULONG Flags,
1401 __in ULONGLONG BasePage,
1402 __in ULONGLONG PageCount,
1403 __in PBL_MEMORY_DESCRIPTOR_LIST NewMdList
1404 );
1405
1406 NTSTATUS
1407 MmMdFreeDescriptor (
1408 _In_ PBL_MEMORY_DESCRIPTOR MemoryDescriptor
1409 );
1410
1411 /* PAGE ALLOCATOR ROUTINES ***************************************************/
1412
1413 NTSTATUS
1414 MmPapAllocatePagesInRange (
1415 _Inout_ PVOID* PhysicalAddress,
1416 _In_ BL_MEMORY_TYPE MemoryType,
1417 _In_ ULONGLONG Pages,
1418 _In_ ULONG Attributes,
1419 _In_ ULONG Alignment,
1420 _In_opt_ PBL_ADDRESS_RANGE Range,
1421 _In_ ULONG Type
1422 );
1423
1424 NTSTATUS
1425 MmFwGetMemoryMap (
1426 _Out_ PBL_MEMORY_DESCRIPTOR_LIST MemoryMap,
1427 _In_ ULONG Flags
1428 );
1429
1430 /* VIRTUAL MEMORY ROUTINES ***************************************************/
1431
1432 NTSTATUS
1433 BlMmMapPhysicalAddressEx (
1434 _In_ PVOID* VirtualAddress,
1435 _In_ ULONG Attributes,
1436 _In_ ULONGLONG Size,
1437 _In_ PHYSICAL_ADDRESS PhysicalAddress
1438 );
1439
1440 /* BLOCK ALLOCATOR ROUTINES **************************************************/
1441
1442 NTSTATUS
1443 BlpMmCreateBlockAllocator (
1444 VOID
1445 );
1446
1447 /* HEAP ALLOCATOR ROUTINES ***************************************************/
1448
1449 PVOID
1450 BlMmAllocateHeap (
1451 _In_ ULONG Size
1452 );
1453
1454 NTSTATUS
1455 BlMmFreeHeap (
1456 _In_ PVOID Buffer
1457 );
1458
1459 /* DISPLAY ROUTINES **********************************************************/
1460
1461 VOID
1462 BlDisplayGetTextCellResolution (
1463 _Out_ PULONG TextWidth,
1464 _Out_ PULONG TextHeight
1465 );
1466
1467 /* I/O ROUTINES **************************************************************/
1468
1469 NTSTATUS
1470 BlpIoRegisterDestroyRoutine (
1471 _In_ PBL_IO_DESTROY_ROUTINE DestroyRoutine
1472 );
1473
1474 NTSTATUS
1475 BlDeviceClose (
1476 _In_ ULONG DeviceId
1477 );
1478
1479 NTSTATUS
1480 BlpDeviceOpen (
1481 _In_ PBL_DEVICE_DESCRIPTOR Device,
1482 _In_ ULONG Flags,
1483 _In_ ULONG Unknown,
1484 _Out_ PULONG DeviceId
1485 );
1486
1487 NTSTATUS
1488 BlDeviceGetInformation (
1489 _In_ ULONG DeviceId,
1490 _Out_ PBL_DEVICE_INFORMATION DeviceInformation
1491 );
1492
1493 NTSTATUS
1494 BlDeviceSetInformation (
1495 _In_ ULONG DeviceId,
1496 _In_ PBL_DEVICE_INFORMATION DeviceInformation
1497 );
1498
1499 NTSTATUS
1500 BlDeviceReadAtOffset (
1501 _In_ ULONG DeviceId,
1502 _In_ ULONG Size,
1503 _In_ ULONGLONG Offset,
1504 _In_ PVOID Buffer,
1505 _Out_ PULONG BytesRead
1506 );
1507
1508 /* FILE I/O ROUTINES *********************************************************/
1509
1510 NTSTATUS
1511 BlFileClose (
1512 _In_ ULONG FileId
1513 );
1514
1515 NTSTATUS
1516 BlFileOpen (
1517 _In_ ULONG DeviceId,
1518 _In_ PWCHAR FileName,
1519 _In_ ULONG OpenFlags,
1520 _Out_ PULONG FileId
1521 );
1522
1523 /* TEXT CONSOLE ROUTINES *****************************************************/
1524
1525 NTSTATUS
1526 ConsoleTextLocalDestruct (
1527 _In_ struct _BL_TEXT_CONSOLE* Console
1528 );
1529
1530 NTSTATUS
1531 ConsoleTextLocalReinitialize (
1532 _In_ struct _BL_TEXT_CONSOLE* Console
1533 );
1534
1535 NTSTATUS
1536 ConsoleTextBaseGetTextState (
1537 _In_ struct _BL_TEXT_CONSOLE* Console,
1538 _Out_ PBL_DISPLAY_STATE TextState
1539 );
1540
1541 NTSTATUS
1542 ConsoleTextLocalSetTextState (
1543 _In_ struct _BL_TEXT_CONSOLE* Console,
1544 _In_ ULONG Flags,
1545 _In_ PBL_DISPLAY_STATE TextState
1546 );
1547
1548 NTSTATUS
1549 ConsoleTextBaseGetTextResolution (
1550 _In_ struct _BL_TEXT_CONSOLE* Console,
1551 _Out_ PULONG TextResolution
1552 );
1553
1554 NTSTATUS
1555 ConsoleTextLocalSetTextResolution (
1556 _In_ struct _BL_TEXT_CONSOLE* Console,
1557 _In_ ULONG NewTextResolution,
1558 _Out_ PULONG OldTextResolution
1559 );
1560
1561 NTSTATUS
1562 ConsoleTextLocalClearText (
1563 _In_ struct _BL_TEXT_CONSOLE* Console,
1564 _In_ ULONG Attribute
1565 );
1566
1567 NTSTATUS
1568 ConsoleTextLocalWriteText (
1569 _In_ struct _BL_TEXT_CONSOLE* Console,
1570 _In_ PCHAR Text,
1571 _In_ ULONG Attribute
1572 );
1573
1574 NTSTATUS
1575 ConsoleTextLocalConstruct (
1576 _In_ PBL_TEXT_CONSOLE TextConsole,
1577 _In_ BOOLEAN Activate
1578 );
1579
1580 BOOLEAN
1581 ConsolepFindResolution (
1582 _In_ PBL_DISPLAY_MODE Mode,
1583 _In_ PBL_DISPLAY_MODE List,
1584 _In_ ULONG MaxIndex
1585 );
1586
1587 VOID
1588 ConsoleFirmwareTextClose (
1589 _In_ PBL_TEXT_CONSOLE TextConsole
1590 );
1591
1592 NTSTATUS
1593 ConsoleFirmwareTextOpen (
1594 _In_ PBL_TEXT_CONSOLE TextConsole
1595 );
1596
1597 NTSTATUS
1598 ConsoleFirmwareTextSetState (
1599 _In_ PBL_TEXT_CONSOLE TextConsole,
1600 _In_ UCHAR Mask,
1601 _In_ PBL_DISPLAY_STATE State
1602 );
1603
1604 NTSTATUS
1605 ConsoleGraphicalConstruct (
1606 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
1607 );
1608
1609 NTSTATUS
1610 ConsoleCreateRemoteConsole (
1611 _In_ PBL_TEXT_CONSOLE* TextConsole
1612 );
1613
1614 NTSTATUS
1615 ConsoleEfiGraphicalOpenProtocol (
1616 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole,
1617 _In_ BL_GRAPHICS_CONSOLE_TYPE Type
1618 );
1619
1620 VOID
1621 ConsoleFirmwareGraphicalClose (
1622 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
1623 );
1624
1625 NTSTATUS
1626 ConsoleFirmwareGraphicalEnable (
1627 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
1628 );
1629
1630 NTSTATUS
1631 ConsoleEfiUgaOpen (
1632 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
1633 );
1634
1635 VOID
1636 ConsoleEfiUgaClose (
1637 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
1638 );
1639
1640 VOID
1641 ConsoleEfiGopClose (
1642 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
1643 );
1644
1645 NTSTATUS
1646 ConsoleEfiGopOpen (
1647 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
1648 );
1649
1650 NTSTATUS
1651 ConsoleEfiGopEnable (
1652 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole
1653 );
1654
1655 NTSTATUS
1656 ConsoleEfiUgaSetResolution (
1657 _In_ PBL_GRAPHICS_CONSOLE GraphicsConsole,
1658 _In_ PBL_DISPLAY_MODE DisplayMode,
1659 _In_ ULONG DisplayModeCount
1660 );
1661
1662 extern ULONG MmDescriptorCallTreeCount;
1663 extern ULONG BlpApplicationFlags;
1664 extern BL_LIBRARY_PARAMETERS BlpLibraryParameters;
1665 extern BL_TRANSLATION_TYPE MmTranslationType;
1666 extern PBL_ARCH_CONTEXT CurrentExecutionContext;
1667 extern PBL_DEVICE_DESCRIPTOR BlpBootDevice;
1668 extern BL_LOADED_APPLICATION_ENTRY BlpApplicationEntry;
1669 extern SIMPLE_TEXT_OUTPUT_INTERFACE *EfiConOut;
1670 extern EFI_GUID EfiGraphicsOutputProtocol;
1671 extern EFI_GUID EfiUgaDrawProtocol;
1672 extern EFI_GUID EfiLoadedImageProtocol;
1673 extern EFI_GUID EfiDevicePathProtocol;
1674 extern EFI_GUID EfiBlockIoProtocol;
1675 extern EFI_GUID EfiSimpleTextInputExProtocol;
1676 extern ULONG ConsoleGraphicalResolutionListFlags;
1677 extern BL_DISPLAY_MODE ConsoleGraphicalResolutionList[];
1678 extern BL_DISPLAY_MODE ConsoleTextResolutionList[];
1679 extern ULONG ConsoleGraphicalResolutionListSize;
1680 extern PVOID DspRemoteInputConsole;
1681 #endif