ReactOS 0.4.15-dev-7788-g1ad9096
bl.h File Reference
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
#include <ntifs.h>
#include <ntndk.h>
#include <ntintsafe.h>
#include <ntimage.h>
#include <drivers/acpi/acpi.h>
#include <Uefi.h>
#include <DevicePath.h>
#include <LoadedImage.h>
#include <GraphicsOutput.h>
#include <UgaDraw.h>
#include <BlockIo.h>
#include <Acpi.h>
#include <GlobalVariable.h>
#include <cmlib.h>
Include dependency graph for bl.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _BL_LIBRARY_PARAMETERS
 
struct  _BOOT_APPLICATION_PARAMETER_BLOCK
 
struct  _BL_MEMORY_DATA
 
struct  _BL_FIRMWARE_DESCRIPTOR
 
struct  _BL_RETURN_ARGUMENTS
 
struct  _BL_MEMORY_DESCRIPTOR
 
struct  _BL_BCD_OPTION
 
struct  _BL_APPLICATION_ENTRY
 
struct  _BL_LOADED_APPLICATION_ENTRY
 
struct  _BL_MENU_STATUS
 
struct  _BL_HARDDISK_DEVICE
 
struct  _BL_LOCAL_DEVICE
 
struct  _BL_DEVICE_DESCRIPTOR
 
struct  _BL_FILE_PATH_DESCRIPTOR
 
struct  _BL_WINDOWS_LOAD_OPTIONS
 
struct  _BL_ARCH_CONTEXT
 
struct  _BL_MEMORY_DESCRIPTOR_LIST
 
struct  _BL_ADDRESS_RANGE
 
struct  _BL_FILE_INFORMATION
 
struct  _BL_FILE_CALLBACKS
 
struct  _BL_FILE_ENTRY
 
struct  _BL_FILE_SYSTEM_ENTRY
 
struct  _BL_FILE_SYSTEM_REGISTRATION_TABLE
 
struct  _BL_DISPLAY_STATE
 
struct  _BL_DISPLAY_MODE
 
struct  _BL_TEXT_CONSOLE_VTABLE
 
struct  _BL_GRAPHICS_CONSOLE_VTABLE
 
struct  _BL_TEXT_CONSOLE
 
struct  _BL_INPUT_CONSOLE_VTABLE
 
struct  _BL_INPUT_CONSOLE
 
struct  _BL_GRAPHICS_CONSOLE
 
struct  _BL_REMOTE_CONSOLE
 
struct  _BL_HASH_TABLE
 
struct  _BL_HASH_ENTRY
 
struct  _BL_HASH_VALUE
 
struct  _BL_HASH_NODE
 
struct  _BL_BLOCK_DEVICE_INFORMATION
 
struct  _BL_DEVICE_INFORMATION
 
struct  _BL_BLOCK_DEVICE
 
struct  _BL_PROTOCOL_HANDLE
 
struct  _BL_DEVICE_CALLBACKS
 
struct  _BL_DEVICE_ENTRY
 
struct  _BL_IMG_FILE
 
struct  _BL_IMAGE_APPLICATION_ENTRY
 
struct  _BL_BUFFER_DESCRIPTOR
 
struct  _BL_DEFERRED_FONT_FILE
 
struct  _BMP_HEADER
 
struct  _DIB_HEADER
 
struct  _BITMAP
 
struct  _COORD
 
struct  _BL_PD_DATA_BLOB
 

Macros

#define BL_APPLICATION_FLAG_CONVERTED_FROM_EFI   0x01
 
#define BL_APP_ENTRY_SIGNATURE   "BTAPENT"
 
#define BOOT_APPLICATION_SIGNATURE_1   'TOOB'
 
#define BOOT_APPLICATION_SIGNATURE_2   ' PPA'
 
#define BOOT_MEMORY_TRANSLATION_TYPE_PHYSICAL   0
 
#define BOOT_MEMORY_TRANSLATION_TYPE_VIRTUAL   1
 
#define BOOT_APPLICATION_VERSION   2
 
#define BL_MEMORY_DATA_VERSION   1
 
#define BL_RETURN_ARGUMENTS_VERSION   1
 
#define BL_FIRMWARE_DESCRIPTOR_VERSION   2
 
#define BL_RETURN_ARGUMENTS_NO_PAE_FLAG   0x40
 
#define BL_APPLICATION_ENTRY_FLAG_NO_GUID   0x01
 
#define BL_APPLICATION_ENTRY_BCD_OPTIONS_INTERNAL   0x02
 
#define BL_APPLICATION_ENTRY_WINLOAD   0x04
 
#define BL_APPLICATION_ENTRY_STARTUP   0x08
 
#define BL_APPLICATION_ENTRY_REBOOT_ON_ERROR   0x20
 
#define BL_APPLICATION_ENTRY_NTLDR   0x40
 
#define BL_APPLICATION_ENTRY_BCD_OPTIONS_EXTERNAL   0x80
 
#define BL_APPLICATION_ENTRY_WINRESUME   0x100
 
#define BL_APPLICATION_ENTRY_SETUPLDR   0x200
 
#define BL_APPLICATION_ENTRY_BOOTSECTOR   0x400
 
#define BL_APPLICATION_ENTRY_BOOTMGR   0x1000
 
#define BL_APPLICATION_ENTRY_DISPLAY_ORDER   0x800000
 
#define BL_APPLICATION_ENTRY_FIXED_SEQUENCE   0x20000000
 
#define BL_APPLICATION_ENTRY_RECOVERY   0x40000000
 
#define BL_CONTEXT_PAGING_ON   1
 
#define BL_CONTEXT_INTERRUPTS_ON   2
 
#define BL_MM_FLAG_USE_FIRMWARE_FOR_MEMORY_MAP_BUFFERS   0x01
 
#define BL_MM_FLAG_REQUEST_COALESCING   0x02
 
#define BL_MM_ADD_DESCRIPTOR_COALESCE_FLAG   0x01
 
#define BL_MM_ADD_DESCRIPTOR_TRUNCATE_FLAG   0x02
 
#define BL_MM_ADD_DESCRIPTOR_NEVER_COALESCE_FLAG   0x10
 
#define BL_MM_ADD_DESCRIPTOR_NEVER_TRUNCATE_FLAG   0x20
 
#define BL_MM_ADD_DESCRIPTOR_ALLOCATE_FLAG   0x1000
 
#define BL_MM_ADD_DESCRIPTOR_UPDATE_LIST_POINTER_FLAG   0x2000
 
#define BL_MM_INCLUDE_MAPPED_ALLOCATED   0x01
 
#define BL_MM_INCLUDE_MAPPED_UNALLOCATED   0x02
 
#define BL_MM_INCLUDE_UNMAPPED_ALLOCATED   0x04
 
#define BL_MM_INCLUDE_UNMAPPED_UNALLOCATED   0x08
 
#define BL_MM_INCLUDE_RESERVED_ALLOCATED   0x10
 
#define BL_MM_INCLUDE_BAD_MEMORY   0x20
 
#define BL_MM_INCLUDE_FIRMWARE_MEMORY   0x40
 
#define BL_MM_INCLUDE_TRUNCATED_MEMORY   0x80
 
#define BL_MM_INCLUDE_PERSISTENT_MEMORY   0x100
 
#define BL_MM_INCLUDE_FIRMWARE_MEMORY_2   0x200
 
#define BL_MM_INCLUDE_NO_FIRMWARE_MEMORY
 
#define BL_MM_INCLUDE_ONLY_FIRMWARE_MEMORY
 
#define BL_MM_REQUEST_DEFAULT_TYPE   1
 
#define BL_MM_REQUEST_TOP_DOWN_TYPE   2
 
#define BL_MM_REMOVE_PHYSICAL_REGION_FLAG   0x40000000
 
#define BL_MM_REMOVE_VIRTUAL_REGION_FLAG   0x80000000
 
#define BL_LIBRARY_FLAG_NO_DISPLAY   0x01
 
#define BL_LIBRARY_FLAG_REINITIALIZE   0x02
 
#define BL_LIBRARY_FLAG_REINITIALIZE_ALL   0x04
 
#define BL_LIBRARY_FLAG_ZERO_HEAP_ALLOCATIONS_ON_FREE   0x10
 
#define BL_LIBRARY_FLAG_INITIALIZATION_COMPLETED   0x20
 
#define BL_LIBRARY_FLAG_NO_GRAPHICS_CONSOLE   0x800
 
#define BL_DISPLAY_GRAPHICS_FORCED_VIDEO_MODE_FLAG   0x01
 
#define BL_DISPLAY_GRAPHICS_FORCED_HIGH_RES_MODE_FLAG   0x02
 
#define BL_HT_VALUE_IS_INLINE   0x01
 
#define BL_FS_REGISTER_AT_HEAD_FLAG   1
 
#define BL_BLOCK_DEVICE_REMOVABLE_FLAG   0x01
 
#define BL_BLOCK_DEVICE_PRESENT_FLAG   0x02
 
#define BL_BLOCK_DEVICE_VIRTUAL_FLAG   0x04
 
#define BL_MEMORY_CLASS_SHIFT   28
 
#define BL_FILE_READ_ACCESS   0x01
 
#define BL_FILE_WRITE_ACCESS   0x02
 
#define BL_DIRECTORY_ACCESS   0x04
 
#define BL_UNKNOWN_ACCESS   0x10
 
#define BL_DEVICE_READ_ACCESS   0x01
 
#define BL_DEVICE_WRITE_ACCESS   0x02
 
#define BL_DEVICE_ENTRY_OPENED   0x01
 
#define BL_DEVICE_ENTRY_READ_ACCESS   0x02
 
#define BL_DEVICE_ENTRY_WRITE_ACCESS   0x04
 
#define BL_FILE_ENTRY_OPENED   0x01
 
#define BL_FILE_ENTRY_READ_ACCESS   0x02
 
#define BL_FILE_ENTRY_WRITE_ACCESS   0x04
 
#define BL_FILE_ENTRY_UNKNOWN_ACCESS   0x10
 
#define BL_FILE_ENTRY_DIRECTORY   0x10000
 
#define BL_ETFS_FILE_ENTRY_DIRECTORY   0x01
 
#define BL_IMG_VALID_FILE   0x01
 
#define BL_IMG_MEMORY_FILE   0x02
 
#define BL_IMG_REMOTE_FILE   0x04
 
#define BL_LOAD_IMG_VIRTUAL_BUFFER   0x01
 
#define BL_LOAD_IMG_EXISTING_BUFFER   0x04
 
#define BL_LOAD_IMG_UNKNOWN_BUFFER_FLAG   0x08
 
#define BL_LOAD_IMG_COMPUTE_SIGNATURE   0x10
 
#define BL_LOAD_IMG_COMPUTE_HASH   0x40000
 
#define BL_LOAD_PE_IMG_VIRTUAL_BUFFER   BL_LOAD_IMG_VIRTUAL_BUFFER
 
#define BL_LOAD_PE_IMG_CHECK_MACHINE   0x02
 
#define BL_LOAD_PE_IMG_EXISTING_BUFFER   BL_LOAD_IMG_EXISTING_BUFFER
 
#define BL_LOAD_PE_IMG_COMPUTE_HASH   0x10
 
#define BL_LOAD_PE_IMG_CHECK_SUBSYSTEM   0x80
 
#define BL_LOAD_PE_IMG_SKIP_RELOCATIONS   0x100
 
#define BL_LOAD_PE_IMG_CHECK_FORCED_INTEGRITY   0x200
 
#define BL_LOAD_PE_IMG_IGNORE_CHECKSUM_MISMATCH   0x10000
 
#define BL_LOAD_PE_IMG_VALIDATE_ORIGINAL_FILENAME   0x400000
 
#define BL_UTL_CHECKSUM_COMPLEMENT   0x10000
 
#define BL_UTL_CHECKSUM_ROTATE   0x20000
 
#define BL_UTL_CHECKSUM_NEGATE   0x40000
 
#define BL_UTL_CHECKSUM_UCHAR_BUFFER   0x01
 
#define BL_UTL_CHECKSUM_USHORT_BUFFER   0x02
 

Typedefs

typedef enum _BL_COLOR BL_COLOR
 
typedef enum _BL_COLORPBL_COLOR
 
typedef enum _BL_MENU_POLICY BL_MENU_POLICY
 
typedef enum _BL_MEMORY_DESCRIPTOR_TYPE BL_MEMORY_DESCRIPTOR_TYPE
 
typedef enum _BL_TRANSLATION_TYPE BL_TRANSLATION_TYPE
 
typedef enum _BL_ARCH_MODE BL_ARCH_MODE
 
typedef enum _BL_DEVICE_TYPE BL_DEVICE_TYPE
 
typedef enum _BL_LOCAL_DEVICE_TYPE BL_LOCAL_DEVICE_TYPE
 
typedef enum _BL_PARTITION_TYPE BL_PARTITION_TYPE
 
typedef enum _BL_PATH_TYPE BL_PATH_TYPE
 
typedef enum _BL_MEMORY_CLASS BL_MEMORY_CLASS
 
typedef enum _BL_MEMORY_TYPE BL_MEMORY_TYPE
 
typedef enum _BL_MEMORY_ATTR BL_MEMORY_ATTR
 
typedef NTSTATUS(* PBL_FILE_OPEN) (_In_ struct _BL_FILE_ENTRY *Directory, _In_ PWCHAR FileName, _In_ ULONG Flags, _Out_ struct _BL_FILE_ENTRY **FileEntry)
 
typedef NTSTATUS(* PBL_FILE_CLOSE) (_In_ struct _BL_FILE_ENTRY *FileEntry)
 
typedef NTSTATUS(* PBL_FILE_READ) (_In_ struct _BL_FILE_ENTRY *FileEntry, _In_ PVOID Buffer, _In_ ULONG Size, _Out_opt_ PULONG BytesRead)
 
typedef NTSTATUS(* PBL_FILE_WRITE) (VOID)
 
typedef NTSTATUS(* PBL_FILE_GET_NEXT) (VOID)
 
typedef NTSTATUS(* PBL_FILE_GET_INFO) (_In_ struct _BL_FILE_ENTRY *FileEntry, _Out_ struct _BL_FILE_INFORMATION *FileInfo)
 
typedef NTSTATUS(* PBL_FILE_SET_INFO) (_In_ struct _BL_FILE_ENTRY *FileEntry, _In_ struct _BL_FILE_INFORMATION *FileInfo)
 
typedef NTSTATUS(* PBL_FS_INIT_CALLBACK) (VOID)
 
typedef NTSTATUS(* PBL_FS_DESTROY_CALLBACK) (VOID)
 
typedef NTSTATUS(* PBL_FS_MOUNT_CALLBACK) (_In_ ULONG DeviceId, _In_ ULONG Unknown, _Out_ struct _BL_FILE_ENTRY **FileEntry)
 
typedef NTSTATUS(* PBL_FS_PURGE_CALLBACK) (VOID)
 
typedef NTSTATUS(* PBL_FILE_DESTROY_CALLBACK) (_In_ PVOID Entry)
 
typedef VOID(* PCONSOLE_DESTRUCT) (_In_ struct _BL_TEXT_CONSOLE *Console)
 
typedef NTSTATUS(* PCONSOLE_REINITIALIZE) (_In_ struct _BL_TEXT_CONSOLE *Console)
 
typedef NTSTATUS(* PCONSOLE_GET_TEXT_STATE) (_In_ struct _BL_TEXT_CONSOLE *Console, _Out_ struct _BL_DISPLAY_STATE *TextState)
 
typedef NTSTATUS(* PCONSOLE_SET_TEXT_STATE) (_In_ struct _BL_TEXT_CONSOLE *Console, _In_ ULONG Flags, _In_ struct _BL_DISPLAY_STATE *TextState)
 
typedef NTSTATUS(* PCONSOLE_GET_TEXT_RESOLUTION) (_In_ struct _BL_TEXT_CONSOLE *Console, _Out_ PULONG TextResolution)
 
typedef NTSTATUS(* PCONSOLE_SET_TEXT_RESOLUTION) (_In_ struct _BL_TEXT_CONSOLE *Console, _In_ ULONG NewTextResolution, _Out_ PULONG OldTextResolution)
 
typedef NTSTATUS(* PCONSOLE_CLEAR_TEXT) (_In_ struct _BL_TEXT_CONSOLE *Console, _In_ BOOLEAN LineOnly)
 
typedef BOOLEAN(* PCONSOLE_IS_ENABLED) (_In_ struct _BL_GRAPHICS_CONSOLE *Console)
 
typedef NTSTATUS(* PCONSOLE_GET_GRAPHICAL_RESOLUTION) (_In_ struct _BL_GRAPHICS_CONSOLE *Console, _Out_ struct _BL_DISPLAY_MODE *DisplayMode)
 
typedef NTSTATUS(* PCONSOLE_SET_GRAPHICAL_RESOLUTION) (_In_ struct _BL_GRAPHICS_CONSOLE *Console, _In_ struct _BL_DISPLAY_MODE DisplayMode)
 
typedef NTSTATUS(* PCONSOLE_ENABLE) (_In_ struct _BL_GRAPHICS_CONSOLE *Console, _In_ BOOLEAN Enable)
 
typedef NTSTATUS(* PCONSOLE_WRITE_TEXT) (_In_ struct _BL_TEXT_CONSOLE *Console, _In_ PCHAR Text, _In_ ULONG Attribute)
 
typedef BOOLEAN(* PBL_TBL_LOOKUP_ROUTINE) (_In_ PVOID Entry, _In_ PVOID Argument1, _In_ PVOID Argument2, _In_ PVOID Argument3, _In_ PVOID Argument4)
 
typedef NTSTATUS(* PBL_TBL_MAP_ROUTINE) (_In_ PVOID Entry, _In_ ULONG EntryIndex)
 
typedef NTSTATUS(* PBL_TBL_SET_ROUTINE) (_In_ PVOID Entry)
 
typedef NTSTATUS(* PBL_IO_DESTROY_ROUTINE) (VOID)
 
typedef BOOLEAN(* PBL_HASH_TABLE_COMPARE_FUNCTION) (_In_ struct _BL_HASH_ENTRY *Entry1, _In_ struct _BL_HASH_ENTRY *Entry2)
 
typedef ULONG(* PBL_HASH_TABLE_HASH_FUNCTION) (_In_ struct _BL_HASH_ENTRY *Entry, _In_ ULONG TableSize)
 
typedef NTSTATUS(* PBL_DEVICE_ENUMERATE_DEVICE_CLASS) (VOID)
 
typedef NTSTATUS(* PBL_DEVICE_OPEN) (_In_ struct _BL_DEVICE_DESCRIPTOR *Device, _In_ struct _BL_DEVICE_ENTRY *DeviceEntry)
 
typedef NTSTATUS(* PBL_DEVICE_CLOSE) (_In_ struct _BL_DEVICE_ENTRY *DeviceEntry)
 
typedef NTSTATUS(* PBL_DEVICE_READ) (_In_ struct _BL_DEVICE_ENTRY *DeviceEntry, _In_ PVOID Buffer, _In_ ULONG Size, _Out_ PULONG BytesRead)
 
typedef NTSTATUS(* PBL_DEVICE_WRITE) (VOID)
 
typedef NTSTATUS(* PBL_DEVICE_GET_INFORMATION) (_In_ struct _BL_DEVICE_ENTRY *DeviceEntry, _Out_ struct _BL_DEVICE_INFORMATION *DeviceInformation)
 
typedef NTSTATUS(* PBL_DEVICE_SET_INFORMATION) (_In_ struct _BL_DEVICE_ENTRY *DeviceEntry, _In_ struct _BL_DEVICE_INFORMATION *DeviceInformation)
 
typedef NTSTATUS(* PBL_DEVICE_RESET) (VOID)
 
typedef NTSTATUS(* PBL_DEVICE_FLUSH) (VOID)
 
typedef NTSTATUS(* PBL_DEVICE_CREATE) (VOID)
 
typedef VOID(* PBL_MM_FLUSH_TLB) (VOID)
 
typedef VOID(* PBL_MM_RELOCATE_SELF_MAP) (VOID)
 
typedef NTSTATUS(* PBL_MM_MOVE_VIRTUAL_ADDRESS_RANGE) (_In_ PVOID DestinationAddress, _In_ PVOID SourceAddress, _In_ ULONGLONG Size)
 
typedef NTSTATUS(* PBL_MM_ZERO_VIRTUAL_ADDRESS_RANGE) (_In_ PVOID DestinationAddress, _In_ ULONGLONG Size)
 
typedef VOID(* PBL_MM_DESTROY_SELF_MAP) (VOID)
 
typedef VOID(* PBL_MM_FLUSH_TLB_ENTRY) (_In_ PVOID VirtualAddress)
 
typedef NTSTATUS(* PBL_MM_UNMAP_VIRTUAL_ADDRESS) (_In_ PVOID VirtualAddress, _In_ ULONG Size)
 
typedef NTSTATUS(* PBL_MM_REMAP_VIRTUAL_ADDRESS) (_In_ PPHYSICAL_ADDRESS PhysicalAddress, _Out_ PVOID VirtualAddress, _In_ ULONG Size, _In_ ULONG CacheAttributes)
 
typedef NTSTATUS(* PBL_MM_MAP_PHYSICAL_ADDRESS) (_In_ PHYSICAL_ADDRESS PhysicalAddress, _Out_ PVOID VirtualAddress, _In_ ULONG Size, _In_ ULONG CacheAttributes)
 
typedef BOOLEAN(* PBL_MM_TRANSLATE_VIRTUAL_ADDRESS) (_In_ PVOID VirtualAddress, _Out_ PPHYSICAL_ADDRESS PhysicalAddress, _Out_opt_ PULONG CacheAttributes)
 
typedef NTSTATUS(* PBL_STATUS_ERROR_HANDLER) (_In_ ULONG ErrorCode, _In_ ULONG Parameter1, _In_ ULONG_PTR Parameter2, _In_ ULONG_PTR Parameter3, _In_ ULONG_PTR Parameter4)
 
typedef struct _BL_LIBRARY_PARAMETERS BL_LIBRARY_PARAMETERS
 
typedef struct _BL_LIBRARY_PARAMETERSPBL_LIBRARY_PARAMETERS
 
typedef struct _BOOT_APPLICATION_PARAMETER_BLOCK BOOT_APPLICATION_PARAMETER_BLOCK
 
typedef struct _BOOT_APPLICATION_PARAMETER_BLOCKPBOOT_APPLICATION_PARAMETER_BLOCK
 
typedef struct _BL_MEMORY_DATA BL_MEMORY_DATA
 
typedef struct _BL_MEMORY_DATAPBL_MEMORY_DATA
 
typedef struct _BL_FIRMWARE_DESCRIPTOR BL_FIRMWARE_DESCRIPTOR
 
typedef struct _BL_FIRMWARE_DESCRIPTORPBL_FIRMWARE_DESCRIPTOR
 
typedef struct _BL_RETURN_ARGUMENTS BL_RETURN_ARGUMENTS
 
typedef struct _BL_RETURN_ARGUMENTSPBL_RETURN_ARGUMENTS
 
typedef struct _BL_MEMORY_DESCRIPTOR BL_MEMORY_DESCRIPTOR
 
typedef struct _BL_MEMORY_DESCRIPTORPBL_MEMORY_DESCRIPTOR
 
typedef struct _BL_BCD_OPTION BL_BCD_OPTION
 
typedef struct _BL_BCD_OPTIONPBL_BCD_OPTION
 
typedef struct _BL_APPLICATION_ENTRY BL_APPLICATION_ENTRY
 
typedef struct _BL_APPLICATION_ENTRYPBL_APPLICATION_ENTRY
 
typedef struct _BL_LOADED_APPLICATION_ENTRY BL_LOADED_APPLICATION_ENTRY
 
typedef struct _BL_LOADED_APPLICATION_ENTRYPBL_LOADED_APPLICATION_ENTRY
 
typedef struct _BL_MENU_STATUS BL_MENU_STATUS
 
typedef struct _BL_MENU_STATUSPL_MENU_STATUS
 
typedef enum _BL_BOOT_ERROR_STATUS BL_BOOT_ERROR_STATUS
 
typedef struct _BL_HARDDISK_DEVICE BL_HARDDISK_DEVICE
 
typedef struct _BL_LOCAL_DEVICE BL_LOCAL_DEVICE
 
typedef struct _BL_LOCAL_DEVICEPBL_LOCAL_DEVICE
 
typedef struct _BL_DEVICE_DESCRIPTOR BL_DEVICE_DESCRIPTOR
 
typedef struct _BL_DEVICE_DESCRIPTORPBL_DEVICE_DESCRIPTOR
 
typedef struct _BL_FILE_PATH_DESCRIPTOR BL_FILE_PATH_DESCRIPTOR
 
typedef struct _BL_FILE_PATH_DESCRIPTORPBL_FILE_PATH_DESCRIPTOR
 
typedef struct _BL_WINDOWS_LOAD_OPTIONS BL_WINDOWS_LOAD_OPTIONS
 
typedef struct _BL_WINDOWS_LOAD_OPTIONSPBL_WINDOWS_LOAD_OPTIONS
 
typedef struct _BL_ARCH_CONTEXT BL_ARCH_CONTEXT
 
typedef struct _BL_ARCH_CONTEXTPBL_ARCH_CONTEXT
 
typedef struct _BL_MEMORY_DESCRIPTOR_LIST BL_MEMORY_DESCRIPTOR_LIST
 
typedef struct _BL_MEMORY_DESCRIPTOR_LISTPBL_MEMORY_DESCRIPTOR_LIST
 
typedef struct _BL_ADDRESS_RANGE BL_ADDRESS_RANGE
 
typedef struct _BL_ADDRESS_RANGEPBL_ADDRESS_RANGE
 
typedef struct _BL_FILE_INFORMATION BL_FILE_INFORMATION
 
typedef struct _BL_FILE_INFORMATIONPBL_FILE_INFORMATION
 
typedef struct _BL_FILE_CALLBACKS BL_FILE_CALLBACKS
 
typedef struct _BL_FILE_CALLBACKSPBL_FILE_CALLBACKS
 
typedef struct _BL_FILE_ENTRY BL_FILE_ENTRY
 
typedef struct _BL_FILE_ENTRYPBL_FILE_ENTRY
 
typedef struct _BL_FILE_SYSTEM_ENTRY BL_FILE_SYSTEM_ENTRY
 
typedef struct _BL_FILE_SYSTEM_ENTRYPBL_FILE_SYSTEM_ENTRY
 
typedef struct _BL_FILE_SYSTEM_REGISTRATION_TABLE BL_FILE_SYSTEM_REGISTRATION_TABLE
 
typedef struct _BL_DISPLAY_STATE BL_DISPLAY_STATE
 
typedef struct _BL_DISPLAY_STATEPBL_DISPLAY_STATE
 
typedef struct _BL_DISPLAY_MODE BL_DISPLAY_MODE
 
typedef struct _BL_DISPLAY_MODEPBL_DISPLAY_MODE
 
typedef struct _BL_TEXT_CONSOLE_VTABLE BL_TEXT_CONSOLE_VTABLE
 
typedef struct _BL_TEXT_CONSOLE_VTABLEPBL_TEXT_CONSOLE_VTABLE
 
typedef struct _BL_GRAPHICS_CONSOLE_VTABLE BL_GRAPHICS_CONSOLE_VTABLE
 
typedef struct _BL_GRAPHICS_CONSOLE_VTABLEPBL_GRAPHICS_CONSOLE_VTABLE
 
typedef struct _BL_TEXT_CONSOLE BL_TEXT_CONSOLE
 
typedef struct _BL_TEXT_CONSOLEPBL_TEXT_CONSOLE
 
typedef struct _BL_INPUT_CONSOLE_VTABLE BL_INPUT_CONSOLE_VTABLE
 
typedef struct _BL_INPUT_CONSOLE_VTABLEPBL_INPUT_CONSOLE_VTABLE
 
typedef struct _BL_INPUT_CONSOLE BL_INPUT_CONSOLE
 
typedef struct _BL_INPUT_CONSOLEPBL_INPUT_CONSOLE
 
typedef enum _BL_GRAPHICS_CONSOLE_TYPE BL_GRAPHICS_CONSOLE_TYPE
 
typedef struct _BL_GRAPHICS_CONSOLE BL_GRAPHICS_CONSOLE
 
typedef struct _BL_GRAPHICS_CONSOLEPBL_GRAPHICS_CONSOLE
 
typedef struct _BL_REMOTE_CONSOLE BL_REMOTE_CONSOLE
 
typedef struct _BL_REMOTE_CONSOLEPBL_REMOTE_CONSOLE
 
typedef struct _BL_HASH_TABLE BL_HASH_TABLE
 
typedef struct _BL_HASH_TABLEPBL_HASH_TABLE
 
typedef struct _BL_HASH_ENTRY BL_HASH_ENTRY
 
typedef struct _BL_HASH_ENTRYPBL_HASH_ENTRY
 
typedef struct _BL_HASH_VALUE BL_HASH_VALUE
 
typedef struct _BL_HASH_VALUEPBL_HASH_VALUE
 
typedef struct _BL_HASH_NODE BL_HASH_NODE
 
typedef struct _BL_HASH_NODEPBL_HASH_NODE
 
typedef struct _BL_BLOCK_DEVICE_INFORMATION BL_BLOCK_DEVICE_INFORMATION
 
typedef struct _BL_BLOCK_DEVICE_INFORMATIONPBL_BLOCK_DEVICE_INFORMATION
 
typedef struct _BL_DEVICE_INFORMATION BL_DEVICE_INFORMATION
 
typedef struct _BL_DEVICE_INFORMATIONPBL_DEVICE_INFORMATION
 
typedef struct _BL_BLOCK_DEVICE BL_BLOCK_DEVICE
 
typedef struct _BL_BLOCK_DEVICEPBL_BLOCK_DEVICE
 
typedef struct _BL_PROTOCOL_HANDLE BL_PROTOCOL_HANDLE
 
typedef struct _BL_PROTOCOL_HANDLEPBL_PROTOCOL_HANDLE
 
typedef struct _BL_DEVICE_CALLBACKS BL_DEVICE_CALLBACKS
 
typedef struct _BL_DEVICE_CALLBACKSPBL_DEVICE_CALLBACKS
 
typedef struct _BL_DEVICE_ENTRY BL_DEVICE_ENTRY
 
typedef struct _BL_DEVICE_ENTRYPBL_DEVICE_ENTRY
 
typedef struct _BL_IMG_FILE BL_IMG_FILE
 
typedef struct _BL_IMG_FILEPBL_IMG_FILE
 
typedef struct _BL_IMAGE_APPLICATION_ENTRY BL_IMAGE_APPLICATION_ENTRY
 
typedef struct _BL_IMAGE_APPLICATION_ENTRYPBL_IMAGE_APPLICATION_ENTRY
 
typedef struct _BL_BUFFER_DESCRIPTOR BL_BUFFER_DESCRIPTOR
 
typedef struct _BL_BUFFER_DESCRIPTORPBL_BUFFER_DESCRIPTOR
 
typedef struct _BL_DEFERRED_FONT_FILE BL_DEFERRED_FONT_FILE
 
typedef struct _BL_DEFERRED_FONT_FILEPBL_DEFERRED_FONT_FILE
 
typedef struct _BMP_HEADER BMP_HEADER
 
typedef struct _BMP_HEADERPBMP_HEADER
 
typedef struct _DIB_HEADER DIB_HEADER
 
typedef struct _DIB_HEADERPDIB_HEADER
 
typedef struct _BITMAP BITMAP
 
typedef struct _BITMAPPBITMAP
 
typedef struct _COORD COORD
 
typedef struct _COORDPCOORD
 
typedef struct _BL_PD_DATA_BLOB BL_PD_DATA_BLOB
 
typedef struct _BL_PD_DATA_BLOBPBL_PD_DATA_BLOB
 

Enumerations

enum  _BL_COLOR {
  Black , Blue , Green , Cyan ,
  Red , Magenta , Brown , LtGray ,
  Gray , LtBlue , LtGreen , LtCyan ,
  LtRed , LtMagenta , Yellow , White
}
 
enum  _BL_MENU_POLICY { MenuPolicyLegacy = 0 , MenuPolicyStandard = 1 }
 
enum  _BL_MEMORY_DESCRIPTOR_TYPE { BlMdPhysical , BlMdVirtual , BlMdTracker }
 
enum  _BL_TRANSLATION_TYPE { BlNone , BlVirtual , BlPae , BlMax }
 
enum  _BL_ARCH_MODE { BlProtectedMode , BlRealMode }
 
enum  _BL_DEVICE_TYPE {
  DiskDevice = 0 , LegacyPartitionDevice = 2 , SerialDevice = 3 , UdpDevice = 4 ,
  BootDevice = 5 , PartitionDevice = 6 , LocateDevice = 8
}
 
enum  _BL_LOCAL_DEVICE_TYPE {
  LocalDevice = 0 , FloppyDevice = 1 , CdRomDevice = 2 , RamDiskDevice = 3 ,
  FileDevice = 5 , VirtualDiskDevice = 6
}
 
enum  _BL_PARTITION_TYPE { GptPartition , MbrPartition , RawPartition }
 
enum  _BL_PATH_TYPE { InternalPath = 3 , EfiPath = 4 }
 
enum  _BL_MEMORY_CLASS { BlLoaderClass = 0xD , BlApplicationClass , BlSystemClass }
 
enum  _BL_MEMORY_TYPE {
  BlLoaderMemory = 0xD0000002 , BlLoaderDeviceMemory = 0xD0000004 , BlLoaderHeap = 0xD0000005 , BlLoaderPageDirectory = 0xD0000006 ,
  BlLoaderReferencePage = 0xD0000007 , BlLoaderRamDisk = 0xD0000008 , BlLoaderArchData = 0xD0000009 , BlLoaderData = 0xD000000A ,
  BlLoaderRegistry = 0xD000000B , BlLoaderBlockMemory = 0xD000000C , BlLoaderSelfMap = 0xD000000F , BlApplicationReserved = 0xE0000001 ,
  BlApplicationData = 0xE0000004 , BlConventionalMemory = 0xF0000001 , BlUnusableMemory = 0xF0000002 , BlReservedMemory = 0xF0000003 ,
  BlEfiBootMemory = 0xF0000004 , BlConventionalZeroedMemory = 0xF000005 , BlEfiRuntimeCodeMemory = 0xF0000006 , BlAcpiReclaimMemory = 0xF0000008 ,
  BlAcpiNvsMemory = 0xF0000009 , BlDeviceIoMemory = 0xF000000A , BlDevicePortMemory = 0xF000000B , BlPalMemory = 0xF000000C ,
  BlEfiRuntimeDataMemory = 0xF000000E
}
 
enum  _BL_MEMORY_ATTR {
  BlMemoryUncached = 0x00000001 , BlMemoryWriteCombined = 0x00000002 , BlMemoryWriteThrough = 0x00000004 , BlMemoryWriteBack = 0x00000008 ,
  BlMemoryUncachedExported = 0x00000010 , BlMemoryValidCacheAttributes = BlMemoryUncached | BlMemoryWriteCombined | BlMemoryWriteThrough | BlMemoryWriteBack | BlMemoryUncachedExported , BlMemoryValidCacheAttributeMask = 0x000000FF , BlMemoryWriteProtected = 0x00000100 ,
  BlMemoryReadProtected = 0x00000200 , BlMemoryExecuteProtected = 0x00000400 , BlMemoryValidProtectionAttributes = BlMemoryWriteProtected | BlMemoryReadProtected | BlMemoryExecuteProtected , BlMemoryValidProtectionAttributeMask = 0x0000FF00 ,
  BlMemoryLargePages = 0x00010000 , BlMemoryKernelRange = 0x00020000 , BlMemoryFixed = 0x00040000 , BlMemoryBelow1MB = 0x00080000 ,
  BlMemoryValidAllocationAttributes = BlMemoryKernelRange | BlMemoryFixed | BlMemoryBelow1MB | BlMemoryLargePages , BlMemoryValidAllocationAttributeMask = 0x00FF0000 , BlMemoryRuntime = 0x01000000 , BlMemoryCoalesced = 0x02000000 ,
  BlMemoryUpdate = 0x04000000 , BlMemoryNonFirmware = 0x08000000 , BlMemoryPersistent = 0x10000000 , BlMemorySpecial = 0x20000000 ,
  BlMemoryFirmware = 0x80000000 , BlMemoryValidTypeAttributes = BlMemoryRuntime | BlMemoryCoalesced | BlMemoryUpdate | BlMemoryNonFirmware | BlMemoryPersistent | BlMemorySpecial | BlMemoryFirmware , BlMemoryValidTypeAttributeMask = 0xFF000000
}
 
enum  _BL_BOOT_ERROR_STATUS {
  Reboot = 1 , Recover = 2 , RecoverOem = 3 , OsSelection = 4 ,
  NextOs = 5 , TryAgain = 6 , AdvancedOptions = 7 , BootOptions = 8
}
 
enum  _BL_GRAPHICS_CONSOLE_TYPE { BlGopConsole , BlUgaConsole }
 

Functions

 DEFINE_GUID (BadMemoryGuid, 0x54B8275B, 0xD431, 0x473F, 0xAC, 0xFB, 0xE5, 0x36, 0xA0, 0x84, 0x94, 0xA3)
 
 C_ASSERT (BL_MM_INCLUDE_NO_FIRMWARE_MEMORY==0x1BF)
 
 C_ASSERT (BL_MM_INCLUDE_ONLY_FIRMWARE_MEMORY==0x240)
 
FORCEINLINE VOID BlSetupDefaultParameters (_Out_ PBL_LIBRARY_PARAMETERS LibraryParameters)
 
FORCEINLINE VOID MmMdInitializeListHead (_In_ PBL_MEMORY_DESCRIPTOR_LIST List)
 
FORCEINLINE PVOID PhysicalAddressToPtr (_In_ PHYSICAL_ADDRESS PhysicalAddress)
 
NTSTATUS BlInitializeLibrary (_In_ PBOOT_APPLICATION_PARAMETER_BLOCK BootAppParameters, _In_ PBL_LIBRARY_PARAMETERS LibraryParameters)
 
NTSTATUS BlpArchInitialize (_In_ ULONG Phase)
 
NTSTATUS BlpFwInitialize (_In_ ULONG Phase, _In_ PBL_FIRMWARE_DESCRIPTOR FirmwareParameters)
 
NTSTATUS BlpMmInitialize (_In_ PBL_MEMORY_DATA MemoryData, _In_ BL_TRANSLATION_TYPE TranslationType, _In_ PBL_LIBRARY_PARAMETERS LibraryParameters)
 
NTSTATUS MmBaInitialize (VOID)
 
NTSTATUS MmPaInitialize (_In_ PBL_MEMORY_DATA MemoryData, _In_ ULONG MinimumPages)
 
NTSTATUS MmArchInitialize (_In_ ULONG Phase, _In_ PBL_MEMORY_DATA MemoryData, _In_ BL_TRANSLATION_TYPE TranslationType, _In_ BL_TRANSLATION_TYPE LibraryTranslationType)
 
NTSTATUS MmHaInitialize (_In_ ULONG HeapSize, _In_ ULONG HeapAttributes)
 
VOID MmMdInitialize (_In_ ULONG Phase, _In_ PBL_LIBRARY_PARAMETERS LibraryParameters)
 
NTSTATUS BlpDeviceInitialize (VOID)
 
NTSTATUS BlpIoInitialize (VOID)
 
NTSTATUS BlpFileInitialize (VOID)
 
NTSTATUS BlpDisplayInitialize (_In_ ULONG Flags)
 
NTSTATUS BlpDisplayReinitialize (VOID)
 
VOID BlDestroyLibrary (VOID)
 
NTSTATUS BcInitialize (VOID)
 
VOID EfiPrintf (_In_ PWCHAR Format,...)
 
NTSTATUS BlFwGetParameters (_In_ PBL_FIRMWARE_DESCRIPTOR Parameters)
 
NTSTATUS BlFwEnumerateDevice (_In_ PBL_DEVICE_DESCRIPTOR Device)
 
NTSTATUS EfiAllocatePages (_In_ ULONG Type, _In_ ULONG Pages, _Inout_ EFI_PHYSICAL_ADDRESS *Memory)
 
NTSTATUS EfiStall (_In_ ULONG StallTime)
 
NTSTATUS EfiConInExReset (VOID)
 
NTSTATUS EfiConInReset (VOID)
 
NTSTATUS EfiConOutOutputString (_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface, _In_ PWCHAR String)
 
NTSTATUS EfiConOutQueryMode (_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface, _In_ ULONG Mode, _In_ UINTN *Columns, _In_ UINTN *Rows)
 
NTSTATUS EfiConOutSetMode (_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface, _In_ ULONG Mode)
 
VOID EfiConOutReadCurrentMode (_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface, _Out_ EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode)
 
NTSTATUS EfiConOutSetAttribute (_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface, _In_ ULONG Attribute)
 
NTSTATUS EfiConOutSetCursorPosition (_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface, _In_ ULONG Column, _In_ ULONG Row)
 
NTSTATUS EfiConOutEnableCursor (_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface, _In_ BOOLEAN Visible)
 
NTSTATUS EfiLocateHandleBuffer (_In_ EFI_LOCATE_SEARCH_TYPE SearchType, _In_ EFI_GUID *Protocol, _Inout_ PULONG HandleCount, _Inout_ EFI_HANDLE **Buffer)
 
NTSTATUS EfiOpenProtocol (_In_ EFI_HANDLE Handle, _In_ EFI_GUID *Protocol, _Out_ PVOID *Interface)
 
NTSTATUS EfiCloseProtocol (_In_ EFI_HANDLE Handle, _In_ EFI_GUID *Protocol)
 
NTSTATUS EfiGopGetCurrentMode (_In_ EFI_GRAPHICS_OUTPUT_PROTOCOL *GopInterface, _Out_ UINTN *Mode, _Out_ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Information)
 
NTSTATUS EfiGopSetMode (_In_ EFI_GRAPHICS_OUTPUT_PROTOCOL *GopInterface, _In_ ULONG Mode)
 
VOID EfiGopGetFrameBuffer (_In_ EFI_GRAPHICS_OUTPUT_PROTOCOL *GopInterface, _Out_ PHYSICAL_ADDRESS *FrameBuffer, _Out_ UINTN *FrameBufferSize)
 
VOID EfiResetSystem (_In_ EFI_RESET_TYPE ResetType)
 
EFI_DEVICE_PATHEfiGetLeafNode (_In_ EFI_DEVICE_PATH *DevicePath)
 
EFI_DEVICE_PATHEfiIsDevicePathParent (_In_ EFI_DEVICE_PATH *DevicePath1, _In_ EFI_DEVICE_PATH *DevicePath2)
 
NTSTATUS EfipGetRsdt (_Out_ PPHYSICAL_ADDRESS FoundRsdt)
 
NTSTATUS EfiFreePages (_In_ ULONG Pages, _In_ EFI_PHYSICAL_ADDRESS PhysicalAddress)
 
NTSTATUS BlpTimeCalibratePerformanceCounter (VOID)
 
ULONGLONG BlTimeQueryPerformanceCounter (_Out_opt_ PLARGE_INTEGER Frequency)
 
ULONGLONG BlArchGetPerformanceCounter (VOID)
 
NTSTATUS BlpDisplayRegisterLocale (_In_ PWCHAR Locale)
 
VOID BfiFreeDeferredFontFile (_In_ PBL_DEFERRED_FONT_FILE DeferredFontFile)
 
NTSTATUS BfLoadFontFile (_In_ PBL_DEVICE_DESCRIPTOR Device, _In_ PWCHAR FontPath)
 
NTSTATUS BfLoadDeferredFontFiles (VOID)
 
NTSTATUS BfClearScreen (_In_ PBL_GRAPHICS_CONSOLE Console)
 
NTSTATUS BfClearToEndOfLine (_In_ PBL_GRAPHICS_CONSOLE Console)
 
NTSTATUS FatInitialize (VOID)
 
NTSTATUS FatMount (_In_ ULONG DeviceId, _In_ ULONG Unknown, _Out_ PBL_FILE_ENTRY *FileEntry)
 
NTSTATUS EtfsInitialize (VOID)
 
NTSTATUS EtfsMount (_In_ ULONG DeviceId, _In_ ULONG Unknown, _Out_ PBL_FILE_ENTRY *FileEntry)
 
BOOLEAN BlBdDebuggerEnabled (VOID)
 
NTSTATUS BlBdPullRemoteFile (_In_ PWCHAR FilePath, _Out_ PVOID BaseAddress, _Out_ PULONGLONG FileSize)
 
VOID BlStatusPrint (_In_ PCWCH Format,...)
 
VOID BlStatusError (_In_ ULONG ErrorCode, _In_ ULONG Parameter1, _In_ ULONG_PTR Parameter2, _In_ ULONG_PTR Parameter3, _In_ ULONG_PTR Parameter4)
 
VOID BlArchCpuId (_In_ ULONG Function, _In_ ULONG SubFunction, _Out_ PCPU_INFO Result)
 
CPU_VENDORS BlArchGetCpuVendor (VOID)
 
BOOLEAN BlArchIsCpuIdFunctionSupported (_In_ ULONG Function)
 
VOID BlUtlUpdateProgress (_In_ ULONG Percentage, _Out_opt_ PBOOLEAN Completed)
 
NTSTATUS BlUtlGetAcpiTable (_Out_ PVOID *TableAddress, _In_ ULONG Signature)
 
NTSTATUS BlUtlInitialize (VOID)
 
NTSTATUS BlUtlRegisterProgressRoutine (VOID)
 
ULONG BlUtlCheckSum (_In_ ULONG PartialSum, _In_ PUCHAR Buffer, _In_ ULONG Length, _In_ ULONG Flags)
 
NTSTATUS BlGetApplicationBaseAndSize (_Out_ PVOID *ImageBase, _Out_ PULONG ImageSize)
 
VOID BlDestroyBootEntry (_In_ PBL_LOADED_APPLICATION_ENTRY AppEntry)
 
NTSTATUS BlPdQueryData (_In_ const GUID *DataGuid, _In_ PVOID Unknown, _Inout_ PBL_PD_DATA_BLOB DataBlob)
 
EFI_STATUS EfiGetEfiStatusCode (_In_ NTSTATUS Status)
 
NTSTATUS EfiGetNtStatusCode (_In_ EFI_STATUS EfiStatus)
 
VOID BlFwReboot (VOID)
 
NTSTATUS MmFwFreePages (_In_ ULONG BasePage, _In_ ULONG PageCount)
 
PGUID BlGetApplicationIdentifier (VOID)
 
NTSTATUS BlpSecureBootEFIIsEnabled (VOID)
 
NTSTATUS BlSecureBootIsEnabled (_Out_ PBOOLEAN SecureBootEnabled)
 
NTSTATUS BlSecureBootCheckForFactoryReset (VOID)
 
PWCHAR BlResourceFindMessage (_In_ ULONG MsgId)
 
PWCHAR BlResourceFindHtml (VOID)
 
NTSTATUS BlpResourceInitialize (VOID)
 
NTSTATUS BlTblMap (_In_ PVOID *Table, _In_ ULONG Count, _In_ PBL_TBL_MAP_ROUTINE MapCallback)
 
PVOID BlTblFindEntry (_In_ PVOID *Table, _In_ ULONG Count, _Out_ PULONG EntryIndex, _In_ PBL_TBL_LOOKUP_ROUTINE Callback, _In_ PVOID Argument1, _In_ PVOID Argument2, _In_ PVOID Argument3, _In_ PVOID Argument4)
 
NTSTATUS BlTblSetEntry (_Inout_ PVOID **Table, _Inout_ PULONG Count, _In_ PVOID Entry, _Out_ PULONG EntryIndex, _In_ PBL_TBL_SET_ROUTINE Callback)
 
NTSTATUS TblDoNotPurgeEntry (_In_ PVOID Entry)
 
NTSTATUS BlHtStore (_In_ ULONG TableId, _In_ PBL_HASH_ENTRY Entry, _In_ PVOID Data, _In_ ULONG DataSize)
 
NTSTATUS BlHtDelete (_In_ ULONG TableId, _In_ PBL_HASH_ENTRY Entry)
 
NTSTATUS BlHtLookup (_In_ ULONG TableId, _In_ PBL_HASH_ENTRY Entry, _Out_ PBL_HASH_VALUE *Value)
 
NTSTATUS BlHtCreate (_In_ ULONG Size, _In_ PBL_HASH_TABLE_HASH_FUNCTION HashFunction, _In_ PBL_HASH_TABLE_COMPARE_FUNCTION CompareFunction, _Out_ PULONG Id)
 
PBL_BCD_OPTION MiscGetBootOption (_In_ PBL_BCD_OPTION List, _In_ ULONG Type)
 
ULONG BlGetBootOptionListSize (_In_ PBL_BCD_OPTION BcdOption)
 
ULONG BlGetBootOptionSize (_In_ PBL_BCD_OPTION BcdOption)
 
NTSTATUS BlGetBootOptionString (_In_ PBL_BCD_OPTION List, _In_ ULONG Type, _Out_ PWCHAR *Value)
 
NTSTATUS BlGetBootOptionInteger (_In_ PBL_BCD_OPTION List, _In_ ULONG Type, _Out_ PULONGLONG Value)
 
NTSTATUS BlGetBootOptionBoolean (_In_ PBL_BCD_OPTION List, _In_ ULONG Type, _Out_ PBOOLEAN Value)
 
NTSTATUS BlpGetBootOptionIntegerList (_In_ PBL_BCD_OPTION List, _In_ ULONG Type, _Out_ PULONGLONG *Value, _Out_ PULONGLONG Count, _In_ BOOLEAN NoCopy)
 
NTSTATUS BlGetBootOptionDevice (_In_ PBL_BCD_OPTION List, _In_ ULONG Type, _Out_ PBL_DEVICE_DESCRIPTOR *Value, _In_opt_ PBL_BCD_OPTION *ExtraOptions)
 
NTSTATUS BlGetBootOptionGuid (_In_ PBL_BCD_OPTION List, _In_ ULONG Type, _Out_ PGUID Value)
 
NTSTATUS BlGetBootOptionGuidList (_In_ PBL_BCD_OPTION List, _In_ ULONG Type, _Out_ PGUID *Value, _In_ PULONG Count)
 
NTSTATUS BlCopyBootOptions (_In_ PBL_BCD_OPTION OptionList, _Out_ PBL_BCD_OPTION *CopiedOptions)
 
NTSTATUS BlAppendBootOptionBoolean (_In_ PBL_LOADED_APPLICATION_ENTRY AppEntry, _In_ ULONG OptionId, _In_ BOOLEAN Value)
 
NTSTATUS BlAppendBootOptionInteger (_In_ PBL_LOADED_APPLICATION_ENTRY AppEntry, _In_ ULONG OptionId, _In_ ULONGLONG Value)
 
NTSTATUS BlAppendBootOptionString (_In_ PBL_LOADED_APPLICATION_ENTRY AppEntry, _In_ ULONG OptionId, _In_ PWCHAR OptionString)
 
NTSTATUS BlAppendBootOptions (_In_ PBL_LOADED_APPLICATION_ENTRY AppEntry, _In_ PBL_BCD_OPTION Options)
 
VOID BlRemoveBootOption (_In_ PBL_BCD_OPTION List, _In_ ULONG Type)
 
NTSTATUS BlReplaceBootOptions (_In_ PBL_LOADED_APPLICATION_ENTRY AppEntry, _In_ PBL_BCD_OPTION NewOptions)
 
VOID BiCloseKey (_In_ HANDLE KeyHandle)
 
NTSTATUS BiOpenKey (_In_ HANDLE ParentHandle, _In_ PWCHAR KeyName, _Out_ PHANDLE Handle)
 
NTSTATUS BiLoadHive (_In_ PBL_FILE_PATH_DESCRIPTOR FilePath, _Out_ PHANDLE HiveHandle)
 
NTSTATUS BiGetRegistryValue (_In_ HANDLE KeyHandle, _In_ PWCHAR ValueName, _In_ ULONG Type, _Out_ PVOID *Buffer, _Out_ PULONG ValueLength)
 
NTSTATUS BiEnumerateSubKeys (_In_ HANDLE KeyHandle, _Out_ PWCHAR **SubKeyList, _Out_ PULONG SubKeyCount)
 
NTSTATUS BiDeleteKey (_In_ HANDLE KeyHandle)
 
VOID BiDereferenceHive (_In_ HANDLE KeyHandle)
 
VOID BlpArchSwitchContext (_In_ BL_ARCH_MODE NewMode)
 
VOID BlpArchEnableTranslation (VOID)
 
VOID Archx86TransferTo32BitApplicationAsm (VOID)
 
VOID MmMdDbgDumpList (_In_ PBL_MEMORY_DESCRIPTOR_LIST DescriptorList, _In_opt_ ULONG MaxCount)
 
VOID MmMdInitializeList (_In_ PBL_MEMORY_DESCRIPTOR_LIST DescriptorList, _In_ ULONG Type, _In_ PLIST_ENTRY ListHead)
 
PBL_MEMORY_DESCRIPTOR MmMdFindDescriptor (_In_ ULONG WhichList, _In_ ULONG Flags, _In_ ULONGLONG Page)
 
PBL_MEMORY_DESCRIPTOR MmMdFindDescriptorFromMdl (_In_ PBL_MEMORY_DESCRIPTOR_LIST MdList, _In_ ULONG Flags, _In_ ULONGLONG Page)
 
NTSTATUS MmMdCopyList (_In_ PBL_MEMORY_DESCRIPTOR_LIST DestinationList, _In_ PBL_MEMORY_DESCRIPTOR_LIST SourceList, _In_opt_ PBL_MEMORY_DESCRIPTOR ListDescriptor, _Out_ PULONG ActualCount, _In_ ULONG Count, _In_ ULONG Flags)
 
ULONG MmMdCountList (_In_ PBL_MEMORY_DESCRIPTOR_LIST MdList)
 
VOID MmMdFreeList (_In_ PBL_MEMORY_DESCRIPTOR_LIST MdList)
 
PBL_MEMORY_DESCRIPTOR MmMdInitByteGranularDescriptor (_In_ ULONG Flags, _In_ BL_MEMORY_TYPE Type, _In_ ULONGLONG BasePage, _In_ ULONGLONG VirtualPage, _In_ ULONGLONG PageCount)
 
VOID MmMdFreeGlobalDescriptors (VOID)
 
NTSTATUS MmMdAddDescriptorToList (_In_ PBL_MEMORY_DESCRIPTOR_LIST MdList, _In_ PBL_MEMORY_DESCRIPTOR MemoryDescriptor, _In_ ULONG Flags)
 
NTSTATUS MmMdTruncateDescriptors (_In_ PBL_MEMORY_DESCRIPTOR_LIST MdList, _In_ PBL_MEMORY_DESCRIPTOR_LIST NewList, _In_ ULONGLONG BasePage)
 
VOID MmMdRemoveDescriptorFromList (_In_ PBL_MEMORY_DESCRIPTOR_LIST MdList, _In_ PBL_MEMORY_DESCRIPTOR Entry)
 
BOOLEAN MmMdFindSatisfyingRegion (_In_ PBL_MEMORY_DESCRIPTOR Descriptor, _Out_ PBL_MEMORY_DESCRIPTOR NewDescriptor, _In_ ULONGLONG Pages, _In_ PBL_ADDRESS_RANGE BaseRange, _In_ PBL_ADDRESS_RANGE VirtualRange, _In_ BOOLEAN TopDown, _In_ BL_MEMORY_TYPE MemoryType, _In_ ULONG Flags, _In_ ULONG Alignment)
 
NTSTATUS MmMdRemoveRegionFromMdlEx (__in PBL_MEMORY_DESCRIPTOR_LIST MdList, __in ULONG Flags, __in ULONGLONG BasePage, __in ULONGLONG PageCount, __in PBL_MEMORY_DESCRIPTOR_LIST NewMdList)
 
NTSTATUS MmMdFreeDescriptor (_In_ PBL_MEMORY_DESCRIPTOR MemoryDescriptor)
 
NTSTATUS MmPaTruncateMemory (_In_ ULONGLONG BasePage)
 
NTSTATUS BlMmAllocatePhysicalPages (_Inout_ PPHYSICAL_ADDRESS Address, _In_ BL_MEMORY_TYPE MemoryType, _In_ ULONGLONG PageCount, _In_ ULONG Attributes, _In_ ULONG Alignment)
 
NTSTATUS MmPapAllocatePhysicalPagesInRange (_Inout_ PPHYSICAL_ADDRESS BaseAddress, _In_ BL_MEMORY_TYPE MemoryType, _In_ ULONGLONG Pages, _In_ ULONG Attributes, _In_ ULONG Alignment, _In_ PBL_MEMORY_DESCRIPTOR_LIST NewList, _In_opt_ PBL_ADDRESS_RANGE Range, _In_ ULONG RangeType)
 
NTSTATUS MmPaReleaseSelfMapPages (_In_ PHYSICAL_ADDRESS Address)
 
NTSTATUS MmPaReserveSelfMapPages (_Inout_ PPHYSICAL_ADDRESS PhysicalAddress, _In_ ULONG Alignment, _In_ ULONG PageCount)
 
NTSTATUS BlMmFreePhysicalPages (_In_ PHYSICAL_ADDRESS Address)
 
NTSTATUS MmPapFreePages (_In_ PVOID Address, _In_ ULONG WhichList)
 
NTSTATUS MmPapAllocatePagesInRange (_Inout_ PVOID *PhysicalAddress, _In_ BL_MEMORY_TYPE MemoryType, _In_ ULONGLONG Pages, _In_ ULONG Attributes, _In_ ULONG Alignment, _In_opt_ PBL_ADDRESS_RANGE Range, _In_ ULONG Type)
 
NTSTATUS MmFwGetMemoryMap (_Out_ PBL_MEMORY_DESCRIPTOR_LIST MemoryMap, _In_ ULONG Flags)
 
NTSTATUS BlpMmInitializeConstraints (VOID)
 
NTSTATUS BlMmRemoveBadMemory (VOID)
 
NTSTATUS BlMmGetMemoryMap (_In_ PLIST_ENTRY MemoryMap, _In_ PBL_BUFFER_DESCRIPTOR MemoryParameters, _In_ ULONG WhichTypes, _In_ ULONG Flags)
 
NTSTATUS MmSelectMappingAddress (_Out_ PVOID *MappingAddress, _In_ PVOID PreferredAddress, _In_ ULONGLONG Size, _In_ ULONG AllocationAttributes, _In_ ULONG Flags, _In_ PHYSICAL_ADDRESS PhysicalAddress)
 
NTSTATUS MmMapPhysicalAddress (_Inout_ PPHYSICAL_ADDRESS PhysicalAddress, _Out_ PVOID *VirtualAddress, _Inout_ PULONGLONG Size, _In_ ULONG CacheAttributes)
 
NTSTATUS MmUnmapVirtualAddress (_Inout_ PVOID *VirtualAddress, _Inout_ PULONGLONG Size)
 
NTSTATUS BlMmMapPhysicalAddressEx (_In_ PVOID *VirtualAddress, _In_ ULONG Attributes, _In_ ULONGLONG Size, _In_ PHYSICAL_ADDRESS PhysicalAddress)
 
NTSTATUS BlMmUnmapVirtualAddressEx (_In_ PVOID VirtualAddress, _In_ ULONGLONG Size)
 
BOOLEAN BlMmTranslateVirtualAddress (_In_ PVOID VirtualAddress, _Out_ PPHYSICAL_ADDRESS PhysicalAddress)
 
BOOLEAN MmArchTranslateVirtualAddress (_In_ PVOID VirtualAddress, _Out_opt_ PPHYSICAL_ADDRESS PhysicalAddress, _Out_opt_ PULONG CachingFlags)
 
NTSTATUS BlpMmCreateBlockAllocator (VOID)
 
PVOID BlMmAllocateHeap (_In_ SIZE_T Size)
 
NTSTATUS BlMmFreeHeap (_In_ PVOID Buffer)
 
VOID BlDisplayGetTextCellResolution (_Out_ PULONG TextWidth, _Out_ PULONG TextHeight)
 
NTSTATUS BlDisplaySetScreenResolution (VOID)
 
NTSTATUS BlDisplayGetScreenResolution (_Out_ PULONG HRes, _Out_ PULONG Vres)
 
VOID BlDisplayInvalidateOemBitmap (VOID)
 
PBITMAP BlDisplayGetOemBitmap (_Out_ PCOORD Offset, _Out_opt_ PULONG Flags)
 
BOOLEAN BlDisplayValidOemBitmap (VOID)
 
NTSTATUS BlDisplayClearScreen (VOID)
 
NTSTATUS BlDisplaySetCursorType (_In_ ULONG Type)
 
NTSTATUS BlpIoRegisterDestroyRoutine (_In_ PBL_IO_DESTROY_ROUTINE DestroyRoutine)
 
NTSTATUS BlDeviceClose (_In_ ULONG DeviceId)
 
BOOLEAN BlDeviceIsVirtualPartitionDevice (_In_ PBL_DEVICE_DESCRIPTOR InputDevice, _Outptr_ PBL_DEVICE_DESCRIPTOR *VirtualDevice)
 
NTSTATUS BlpDeviceOpen (_In_ PBL_DEVICE_DESCRIPTOR Device, _In_ ULONG Flags, _In_ ULONG Unknown, _Out_ PULONG DeviceId)
 
NTSTATUS BlDeviceGetInformation (_In_ ULONG DeviceId, _Out_ PBL_DEVICE_INFORMATION DeviceInformation)
 
NTSTATUS BlDeviceSetInformation (_In_ ULONG DeviceId, _In_ PBL_DEVICE_INFORMATION DeviceInformation)
 
NTSTATUS BlDeviceReadAtOffset (_In_ ULONG DeviceId, _In_ ULONG Size, _In_ ULONGLONG Offset, _In_ PVOID Buffer, _Out_ PULONG BytesRead)
 
NTSTATUS BlImgLoadImageWithProgress2 (_In_ ULONG DeviceId, _In_ BL_MEMORY_TYPE MemoryType, _In_ PWCHAR FileName, _Inout_ PVOID *MappedBase, _Inout_ PULONG MappedSize, _In_ ULONG ImageFlags, _In_ BOOLEAN ShowProgress, _Out_opt_ PUCHAR *HashBuffer, _Out_opt_ PULONG HashSize)
 
PIMAGE_SECTION_HEADER BlImgFindSection (_In_ PVOID ImageBase, _In_ ULONG ImageSize)
 
NTSTATUS BlImgLoadBootApplication (_In_ PBL_LOADED_APPLICATION_ENTRY BootEntry, _Out_ PULONG AppHandle)
 
NTSTATUS BlImgStartBootApplication (_In_ ULONG AppHandle, _Inout_ PBL_RETURN_ARGUMENTS ReturnArguments)
 
NTSTATUS BlImgUnloadBootApplication (_In_ ULONG AppHandle)
 
VOID BlImgQueryCodeIntegrityBootOptions (_In_ PBL_LOADED_APPLICATION_ENTRY ApplicationEntry, _Out_ PBOOLEAN IntegrityChecksDisabled, _Out_ PBOOLEAN TestSigning)
 
NTSTATUS BlFileClose (_In_ ULONG FileId)
 
NTSTATUS BlFileReadAtOffsetEx (_In_ ULONG FileId, _In_ ULONG Size, _In_ ULONGLONG ByteOffset, _In_ PVOID Buffer, _Out_ PULONG BytesReturned, _In_ ULONG Flags)
 
NTSTATUS BlFileGetInformation (_In_ ULONG FileId, _In_ PBL_FILE_INFORMATION FileInfo)
 
NTSTATUS BlFileOpen (_In_ ULONG DeviceId, _In_ PWCHAR FileName, _In_ ULONG Flags, _Out_ PULONG FileId)
 
NTSTATUS BlockIoEfiCompareDevice (_In_ PBL_DEVICE_DESCRIPTOR Device, _In_ EFI_HANDLE Handle)
 
VOID ConsoleInputLocalDestruct (_In_ struct _BL_INPUT_CONSOLE *Console)
 
NTSTATUS ConsoleInputBaseReinitialize (_In_ struct _BL_INPUT_CONSOLE *Console)
 
NTSTATUS ConsoleCreateLocalInputCnsole (VOID)
 
VOID ConsoleGraphicalDestruct (_In_ struct _BL_GRAPHICS_CONSOLE *Console)
 
NTSTATUS ConsoleGraphicalClearText (_In_ PBL_GRAPHICS_CONSOLE Console, _In_ BOOLEAN LineOnly)
 
NTSTATUS ConsoleGraphicalClearPixels (_In_ PBL_GRAPHICS_CONSOLE Console, _In_ ULONG Color)
 
NTSTATUS ConsoleGraphicalReinitialize (_In_ struct _BL_GRAPHICS_CONSOLE *Console)
 
NTSTATUS ConsoleGraphicalSetTextState (_In_ PBL_GRAPHICS_CONSOLE Console, _In_ ULONG Mask, _In_ PBL_DISPLAY_STATE TextState)
 
BOOLEAN ConsoleGraphicalIsEnabled (_In_ struct _BL_GRAPHICS_CONSOLE *Console)
 
NTSTATUS ConsoleGraphicalGetGraphicalResolution (_In_ struct _BL_GRAPHICS_CONSOLE *Console, _In_ PBL_DISPLAY_MODE DisplayMode)
 
NTSTATUS ConsoleGraphicalGetOriginalResolution (_In_ struct _BL_GRAPHICS_CONSOLE *Console, _In_ PBL_DISPLAY_MODE DisplayMode)
 
NTSTATUS ConsoleGraphicalEnable (_In_ struct _BL_GRAPHICS_CONSOLE *Console, _In_ BOOLEAN Enable)
 
VOID ConsoleTextLocalDestruct (_In_ struct _BL_TEXT_CONSOLE *Console)
 
NTSTATUS ConsoleTextLocalReinitialize (_In_ struct _BL_TEXT_CONSOLE *Console)
 
NTSTATUS ConsoleTextBaseGetTextState (_In_ struct _BL_TEXT_CONSOLE *Console, _Out_ PBL_DISPLAY_STATE TextState)
 
NTSTATUS ConsoleTextLocalSetTextState (_In_ struct _BL_TEXT_CONSOLE *Console, _In_ ULONG Flags, _In_ PBL_DISPLAY_STATE TextState)
 
NTSTATUS ConsoleTextBaseGetTextResolution (_In_ struct _BL_TEXT_CONSOLE *Console, _Out_ PULONG TextResolution)
 
NTSTATUS ConsoleTextLocalSetTextResolution (_In_ struct _BL_TEXT_CONSOLE *Console, _In_ ULONG NewTextResolution, _Out_ PULONG OldTextResolution)
 
NTSTATUS ConsoleTextLocalClearText (_In_ struct _BL_TEXT_CONSOLE *Console, _In_ BOOLEAN LineOnly)
 
NTSTATUS ConsoleTextLocalWriteText (_In_ struct _BL_TEXT_CONSOLE *Console, _In_ PCHAR Text, _In_ ULONG Attribute)
 
NTSTATUS ConsoleTextLocalConstruct (_In_ PBL_TEXT_CONSOLE TextConsole, _In_ BOOLEAN Activate)
 
BOOLEAN ConsolepFindResolution (_In_ PBL_DISPLAY_MODE Mode, _In_ PBL_DISPLAY_MODE List, _In_ ULONG MaxIndex)
 
NTSTATUS ConsoleFirmwareTextClear (_In_ PBL_TEXT_CONSOLE Console, _In_ BOOLEAN LineOnly)
 
VOID ConsoleFirmwareTextClose (_In_ PBL_TEXT_CONSOLE TextConsole)
 
NTSTATUS ConsoleFirmwareTextOpen (_In_ PBL_TEXT_CONSOLE TextConsole)
 
NTSTATUS ConsoleFirmwareTextSetState (_In_ PBL_TEXT_CONSOLE TextConsole, _In_ UCHAR Mask, _In_ PBL_DISPLAY_STATE State)
 
NTSTATUS ConsoleGraphicalConstruct (_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
 
NTSTATUS ConsoleCreateRemoteConsole (_In_ PBL_TEXT_CONSOLE *TextConsole)
 
NTSTATUS ConsoleEfiGraphicalOpenProtocol (_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole, _In_ BL_GRAPHICS_CONSOLE_TYPE Type)
 
VOID ConsoleFirmwareGraphicalClose (_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
 
VOID ConsoleFirmwareGraphicalDisable (_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
 
NTSTATUS ConsoleFirmwareGraphicalClear (_In_ PBL_GRAPHICS_CONSOLE Console, _In_ ULONG Color)
 
NTSTATUS ConsoleFirmwareGraphicalEnable (_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
 
NTSTATUS ConsoleEfiUgaOpen (_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
 
VOID ConsoleEfiUgaClose (_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
 
VOID ConsoleEfiGopClose (_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
 
NTSTATUS ConsoleEfiGopOpen (_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
 
NTSTATUS ConsoleEfiGopEnable (_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
 
NTSTATUS ConsoleEfiUgaSetResolution (_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole, _In_ PBL_DISPLAY_MODE DisplayMode, _In_ ULONG DisplayModeCount)
 
NTSTATUS ConsoleCreateLocalInputConsole (VOID)
 
NTSTATUS ConsoleInputLocalEraseBuffer (_In_ PBL_INPUT_CONSOLE Console, _In_opt_ PULONG ValueToFill)
 
VOID ConsolepClearBuffer (_In_ PUCHAR FrameBuffer, _In_ ULONG Width, _In_ PUCHAR FillColor, _In_ ULONG Height, _In_ ULONG ScanlineWidth, _In_ ULONG PixelDepth)
 
NTSTATUS ConsolepConvertColorToPixel (_In_ BL_COLOR Color, _Out_ PUCHAR Pixel)
 

Variables

ULONG MmDescriptorCallTreeCount
 
ULONG BlpApplicationFlags
 
BL_LIBRARY_PARAMETERS BlpLibraryParameters
 
BL_TRANSLATION_TYPE MmTranslationType
 
PBL_ARCH_CONTEXT CurrentExecutionContext
 
PBL_DEVICE_DESCRIPTOR BlpBootDevice
 
BL_LOADED_APPLICATION_ENTRY BlpApplicationEntry
 
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOLEfiConOut
 
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOLEfiConInEx
 
EFI_GUID EfiGraphicsOutputProtocol
 
EFI_GUID EfiUgaDrawProtocol
 
EFI_GUID EfiLoadedImageProtocol
 
EFI_GUID EfiDevicePathProtocol
 
EFI_GUID EfiBlockIoProtocol
 
EFI_GUID EfiSimpleTextInputExProtocol
 
EFI_GUID EfiRootAcpiTableGuid
 
EFI_GUID EfiRootAcpiTable10Guid
 
EFI_GUID EfiGlobalVariable
 
ULONG ConsoleGraphicalResolutionListFlags
 
BL_DISPLAY_MODE ConsoleGraphicalResolutionList []
 
BL_DISPLAY_MODE ConsoleTextResolutionList []
 
ULONG ConsoleGraphicalResolutionListSize
 
PVOID DspRemoteInputConsole
 
PVOID DspLocalInputConsole
 
WCHAR BlScratchBuffer [8192]
 
BL_MEMORY_DESCRIPTOR_LIST MmMdlMappedAllocated
 
BL_MEMORY_DESCRIPTOR_LIST MmMdlMappedUnallocated
 
BL_MEMORY_DESCRIPTOR_LIST MmMdlFwAllocationTracker
 
BL_MEMORY_DESCRIPTOR_LIST MmMdlUnmappedAllocated
 
BL_MEMORY_DESCRIPTOR_LIST MmMdlUnmappedUnallocated
 
BL_MEMORY_DESCRIPTOR_LIST MmMdlReservedAllocated
 
BL_MEMORY_DESCRIPTOR_LIST MmMdlBadMemory
 
BL_MEMORY_DESCRIPTOR_LIST MmMdlTruncatedMemory
 
BL_MEMORY_DESCRIPTOR_LIST MmMdlPersistentMemory
 
BL_MEMORY_DESCRIPTOR_LIST MmMdlCompleteBadMemory
 
BL_MEMORY_DESCRIPTOR_LIST MmMdlFreeVirtual
 
BL_MEMORY_DESCRIPTOR_LIST MmMdlMappingTrackers
 
ULONGLONG BlpTimePerformanceFrequency
 
LIST_ENTRY RegisteredFileSystems
 
BL_ADDRESS_RANGE MmArchKsegAddressRange
 
ULONG_PTR MmArchTopOfApplicationAddressSpace
 
PBL_MM_RELOCATE_SELF_MAP BlMmRelocateSelfMap
 
PBL_MM_FLUSH_TLB BlMmFlushTlb
 
PBL_MM_MOVE_VIRTUAL_ADDRESS_RANGE BlMmMoveVirtualAddressRange
 
PBL_MM_ZERO_VIRTUAL_ADDRESS_RANGE BlMmZeroVirtualAddressRange
 
PBL_STATUS_ERROR_HANDLER BlpStatusErrorHandler
 

Macro Definition Documentation

◆ BL_APP_ENTRY_SIGNATURE

#define BL_APP_ENTRY_SIGNATURE   "BTAPENT"

Definition at line 53 of file bl.h.

◆ BL_APPLICATION_ENTRY_BCD_OPTIONS_EXTERNAL

#define BL_APPLICATION_ENTRY_BCD_OPTIONS_EXTERNAL   0x80

Definition at line 74 of file bl.h.

◆ BL_APPLICATION_ENTRY_BCD_OPTIONS_INTERNAL

#define BL_APPLICATION_ENTRY_BCD_OPTIONS_INTERNAL   0x02

Definition at line 69 of file bl.h.

◆ BL_APPLICATION_ENTRY_BOOTMGR

#define BL_APPLICATION_ENTRY_BOOTMGR   0x1000

Definition at line 78 of file bl.h.

◆ BL_APPLICATION_ENTRY_BOOTSECTOR

#define BL_APPLICATION_ENTRY_BOOTSECTOR   0x400

Definition at line 77 of file bl.h.

◆ BL_APPLICATION_ENTRY_DISPLAY_ORDER

#define BL_APPLICATION_ENTRY_DISPLAY_ORDER   0x800000

Definition at line 79 of file bl.h.

◆ BL_APPLICATION_ENTRY_FIXED_SEQUENCE

#define BL_APPLICATION_ENTRY_FIXED_SEQUENCE   0x20000000

Definition at line 80 of file bl.h.

◆ BL_APPLICATION_ENTRY_FLAG_NO_GUID

#define BL_APPLICATION_ENTRY_FLAG_NO_GUID   0x01

Definition at line 68 of file bl.h.

◆ BL_APPLICATION_ENTRY_NTLDR

#define BL_APPLICATION_ENTRY_NTLDR   0x40

Definition at line 73 of file bl.h.

◆ BL_APPLICATION_ENTRY_REBOOT_ON_ERROR

#define BL_APPLICATION_ENTRY_REBOOT_ON_ERROR   0x20

Definition at line 72 of file bl.h.

◆ BL_APPLICATION_ENTRY_RECOVERY

#define BL_APPLICATION_ENTRY_RECOVERY   0x40000000

Definition at line 81 of file bl.h.

◆ BL_APPLICATION_ENTRY_SETUPLDR

#define BL_APPLICATION_ENTRY_SETUPLDR   0x200

Definition at line 76 of file bl.h.

◆ BL_APPLICATION_ENTRY_STARTUP

#define BL_APPLICATION_ENTRY_STARTUP   0x08

Definition at line 71 of file bl.h.

◆ BL_APPLICATION_ENTRY_WINLOAD

#define BL_APPLICATION_ENTRY_WINLOAD   0x04

Definition at line 70 of file bl.h.

◆ BL_APPLICATION_ENTRY_WINRESUME

#define BL_APPLICATION_ENTRY_WINRESUME   0x100

Definition at line 75 of file bl.h.

◆ BL_APPLICATION_FLAG_CONVERTED_FROM_EFI

#define BL_APPLICATION_FLAG_CONVERTED_FROM_EFI   0x01

Definition at line 51 of file bl.h.

◆ BL_BLOCK_DEVICE_PRESENT_FLAG

#define BL_BLOCK_DEVICE_PRESENT_FLAG   0x02

Definition at line 142 of file bl.h.

◆ BL_BLOCK_DEVICE_REMOVABLE_FLAG

#define BL_BLOCK_DEVICE_REMOVABLE_FLAG   0x01

Definition at line 141 of file bl.h.

◆ BL_BLOCK_DEVICE_VIRTUAL_FLAG

#define BL_BLOCK_DEVICE_VIRTUAL_FLAG   0x04

Definition at line 143 of file bl.h.

◆ BL_CONTEXT_INTERRUPTS_ON

#define BL_CONTEXT_INTERRUPTS_ON   2

Definition at line 84 of file bl.h.

◆ BL_CONTEXT_PAGING_ON

#define BL_CONTEXT_PAGING_ON   1

Definition at line 83 of file bl.h.

◆ BL_DEVICE_ENTRY_OPENED

#define BL_DEVICE_ENTRY_OPENED   0x01

Definition at line 155 of file bl.h.

◆ BL_DEVICE_ENTRY_READ_ACCESS

#define BL_DEVICE_ENTRY_READ_ACCESS   0x02

Definition at line 156 of file bl.h.

◆ BL_DEVICE_ENTRY_WRITE_ACCESS

#define BL_DEVICE_ENTRY_WRITE_ACCESS   0x04

Definition at line 157 of file bl.h.

◆ BL_DEVICE_READ_ACCESS

#define BL_DEVICE_READ_ACCESS   0x01

Definition at line 152 of file bl.h.

◆ BL_DEVICE_WRITE_ACCESS

#define BL_DEVICE_WRITE_ACCESS   0x02

Definition at line 153 of file bl.h.

◆ BL_DIRECTORY_ACCESS

#define BL_DIRECTORY_ACCESS   0x04

Definition at line 149 of file bl.h.

◆ BL_DISPLAY_GRAPHICS_FORCED_HIGH_RES_MODE_FLAG

#define BL_DISPLAY_GRAPHICS_FORCED_HIGH_RES_MODE_FLAG   0x02

Definition at line 135 of file bl.h.

◆ BL_DISPLAY_GRAPHICS_FORCED_VIDEO_MODE_FLAG

#define BL_DISPLAY_GRAPHICS_FORCED_VIDEO_MODE_FLAG   0x01

Definition at line 134 of file bl.h.

◆ BL_ETFS_FILE_ENTRY_DIRECTORY

#define BL_ETFS_FILE_ENTRY_DIRECTORY   0x01

Definition at line 165 of file bl.h.

◆ BL_FILE_ENTRY_DIRECTORY

#define BL_FILE_ENTRY_DIRECTORY   0x10000

Definition at line 163 of file bl.h.

◆ BL_FILE_ENTRY_OPENED

#define BL_FILE_ENTRY_OPENED   0x01

Definition at line 159 of file bl.h.

◆ BL_FILE_ENTRY_READ_ACCESS

#define BL_FILE_ENTRY_READ_ACCESS   0x02

Definition at line 160 of file bl.h.

◆ BL_FILE_ENTRY_UNKNOWN_ACCESS

#define BL_FILE_ENTRY_UNKNOWN_ACCESS   0x10

Definition at line 162 of file bl.h.

◆ BL_FILE_ENTRY_WRITE_ACCESS

#define BL_FILE_ENTRY_WRITE_ACCESS   0x04

Definition at line 161 of file bl.h.

◆ BL_FILE_READ_ACCESS

#define BL_FILE_READ_ACCESS   0x01

Definition at line 147 of file bl.h.

◆ BL_FILE_WRITE_ACCESS

#define BL_FILE_WRITE_ACCESS   0x02

Definition at line 148 of file bl.h.

◆ BL_FIRMWARE_DESCRIPTOR_VERSION

#define BL_FIRMWARE_DESCRIPTOR_VERSION   2

Definition at line 64 of file bl.h.

◆ BL_FS_REGISTER_AT_HEAD_FLAG

#define BL_FS_REGISTER_AT_HEAD_FLAG   1

Definition at line 139 of file bl.h.

◆ BL_HT_VALUE_IS_INLINE

#define BL_HT_VALUE_IS_INLINE   0x01

Definition at line 137 of file bl.h.

◆ BL_IMG_MEMORY_FILE

#define BL_IMG_MEMORY_FILE   0x02

Definition at line 168 of file bl.h.

◆ BL_IMG_REMOTE_FILE

#define BL_IMG_REMOTE_FILE   0x04

Definition at line 169 of file bl.h.

◆ BL_IMG_VALID_FILE

#define BL_IMG_VALID_FILE   0x01

Definition at line 167 of file bl.h.

◆ BL_LIBRARY_FLAG_INITIALIZATION_COMPLETED

#define BL_LIBRARY_FLAG_INITIALIZATION_COMPLETED   0x20

Definition at line 131 of file bl.h.

◆ BL_LIBRARY_FLAG_NO_DISPLAY

#define BL_LIBRARY_FLAG_NO_DISPLAY   0x01

Definition at line 127 of file bl.h.

◆ BL_LIBRARY_FLAG_NO_GRAPHICS_CONSOLE

#define BL_LIBRARY_FLAG_NO_GRAPHICS_CONSOLE   0x800

Definition at line 132 of file bl.h.

◆ BL_LIBRARY_FLAG_REINITIALIZE

#define BL_LIBRARY_FLAG_REINITIALIZE   0x02

Definition at line 128 of file bl.h.

◆ BL_LIBRARY_FLAG_REINITIALIZE_ALL

#define BL_LIBRARY_FLAG_REINITIALIZE_ALL   0x04

Definition at line 129 of file bl.h.

◆ BL_LIBRARY_FLAG_ZERO_HEAP_ALLOCATIONS_ON_FREE

#define BL_LIBRARY_FLAG_ZERO_HEAP_ALLOCATIONS_ON_FREE   0x10

Definition at line 130 of file bl.h.

◆ BL_LOAD_IMG_COMPUTE_HASH

#define BL_LOAD_IMG_COMPUTE_HASH   0x40000

Definition at line 175 of file bl.h.

◆ BL_LOAD_IMG_COMPUTE_SIGNATURE

#define BL_LOAD_IMG_COMPUTE_SIGNATURE   0x10

Definition at line 174 of file bl.h.

◆ BL_LOAD_IMG_EXISTING_BUFFER

#define BL_LOAD_IMG_EXISTING_BUFFER   0x04

Definition at line 172 of file bl.h.

◆ BL_LOAD_IMG_UNKNOWN_BUFFER_FLAG

#define BL_LOAD_IMG_UNKNOWN_BUFFER_FLAG   0x08

Definition at line 173 of file bl.h.

◆ BL_LOAD_IMG_VIRTUAL_BUFFER

#define BL_LOAD_IMG_VIRTUAL_BUFFER   0x01

Definition at line 171 of file bl.h.

◆ BL_LOAD_PE_IMG_CHECK_FORCED_INTEGRITY

#define BL_LOAD_PE_IMG_CHECK_FORCED_INTEGRITY   0x200

Definition at line 183 of file bl.h.

◆ BL_LOAD_PE_IMG_CHECK_MACHINE

#define BL_LOAD_PE_IMG_CHECK_MACHINE   0x02

Definition at line 178 of file bl.h.

◆ BL_LOAD_PE_IMG_CHECK_SUBSYSTEM

#define BL_LOAD_PE_IMG_CHECK_SUBSYSTEM   0x80

Definition at line 181 of file bl.h.

◆ BL_LOAD_PE_IMG_COMPUTE_HASH

#define BL_LOAD_PE_IMG_COMPUTE_HASH   0x10

Definition at line 180 of file bl.h.

◆ BL_LOAD_PE_IMG_EXISTING_BUFFER

#define BL_LOAD_PE_IMG_EXISTING_BUFFER   BL_LOAD_IMG_EXISTING_BUFFER

Definition at line 179 of file bl.h.

◆ BL_LOAD_PE_IMG_IGNORE_CHECKSUM_MISMATCH

#define BL_LOAD_PE_IMG_IGNORE_CHECKSUM_MISMATCH   0x10000

Definition at line 184 of file bl.h.

◆ BL_LOAD_PE_IMG_SKIP_RELOCATIONS

#define BL_LOAD_PE_IMG_SKIP_RELOCATIONS   0x100

Definition at line 182 of file bl.h.

◆ BL_LOAD_PE_IMG_VALIDATE_ORIGINAL_FILENAME

#define BL_LOAD_PE_IMG_VALIDATE_ORIGINAL_FILENAME   0x400000

Definition at line 185 of file bl.h.

◆ BL_LOAD_PE_IMG_VIRTUAL_BUFFER

#define BL_LOAD_PE_IMG_VIRTUAL_BUFFER   BL_LOAD_IMG_VIRTUAL_BUFFER

Definition at line 177 of file bl.h.

◆ BL_MEMORY_CLASS_SHIFT

#define BL_MEMORY_CLASS_SHIFT   28

Definition at line 145 of file bl.h.

◆ BL_MEMORY_DATA_VERSION

#define BL_MEMORY_DATA_VERSION   1

Definition at line 62 of file bl.h.

◆ BL_MM_ADD_DESCRIPTOR_ALLOCATE_FLAG

#define BL_MM_ADD_DESCRIPTOR_ALLOCATE_FLAG   0x1000

Definition at line 93 of file bl.h.

◆ BL_MM_ADD_DESCRIPTOR_COALESCE_FLAG

#define BL_MM_ADD_DESCRIPTOR_COALESCE_FLAG   0x01

Definition at line 89 of file bl.h.

◆ BL_MM_ADD_DESCRIPTOR_NEVER_COALESCE_FLAG

#define BL_MM_ADD_DESCRIPTOR_NEVER_COALESCE_FLAG   0x10

Definition at line 91 of file bl.h.

◆ BL_MM_ADD_DESCRIPTOR_NEVER_TRUNCATE_FLAG

#define BL_MM_ADD_DESCRIPTOR_NEVER_TRUNCATE_FLAG   0x20

Definition at line 92 of file bl.h.

◆ BL_MM_ADD_DESCRIPTOR_TRUNCATE_FLAG

#define BL_MM_ADD_DESCRIPTOR_TRUNCATE_FLAG   0x02

Definition at line 90 of file bl.h.

◆ BL_MM_ADD_DESCRIPTOR_UPDATE_LIST_POINTER_FLAG

#define BL_MM_ADD_DESCRIPTOR_UPDATE_LIST_POINTER_FLAG   0x2000

Definition at line 94 of file bl.h.

◆ BL_MM_FLAG_REQUEST_COALESCING

#define BL_MM_FLAG_REQUEST_COALESCING   0x02

Definition at line 87 of file bl.h.

◆ BL_MM_FLAG_USE_FIRMWARE_FOR_MEMORY_MAP_BUFFERS

#define BL_MM_FLAG_USE_FIRMWARE_FOR_MEMORY_MAP_BUFFERS   0x01

Definition at line 86 of file bl.h.

◆ BL_MM_INCLUDE_BAD_MEMORY

#define BL_MM_INCLUDE_BAD_MEMORY   0x20

Definition at line 101 of file bl.h.

◆ BL_MM_INCLUDE_FIRMWARE_MEMORY

#define BL_MM_INCLUDE_FIRMWARE_MEMORY   0x40

Definition at line 102 of file bl.h.

◆ BL_MM_INCLUDE_FIRMWARE_MEMORY_2

#define BL_MM_INCLUDE_FIRMWARE_MEMORY_2   0x200

Definition at line 105 of file bl.h.

◆ BL_MM_INCLUDE_MAPPED_ALLOCATED

#define BL_MM_INCLUDE_MAPPED_ALLOCATED   0x01

Definition at line 96 of file bl.h.

◆ BL_MM_INCLUDE_MAPPED_UNALLOCATED

#define BL_MM_INCLUDE_MAPPED_UNALLOCATED   0x02

Definition at line 97 of file bl.h.

◆ BL_MM_INCLUDE_NO_FIRMWARE_MEMORY

#define BL_MM_INCLUDE_NO_FIRMWARE_MEMORY
Value:
#define BL_MM_INCLUDE_TRUNCATED_MEMORY
Definition: bl.h:103
#define BL_MM_INCLUDE_MAPPED_ALLOCATED
Definition: bl.h:96
#define BL_MM_INCLUDE_UNMAPPED_UNALLOCATED
Definition: bl.h:99
#define BL_MM_INCLUDE_MAPPED_UNALLOCATED
Definition: bl.h:97
#define BL_MM_INCLUDE_BAD_MEMORY
Definition: bl.h:101
#define BL_MM_INCLUDE_PERSISTENT_MEMORY
Definition: bl.h:104
#define BL_MM_INCLUDE_UNMAPPED_ALLOCATED
Definition: bl.h:98
#define BL_MM_INCLUDE_RESERVED_ALLOCATED
Definition: bl.h:100

Definition at line 107 of file bl.h.

◆ BL_MM_INCLUDE_ONLY_FIRMWARE_MEMORY

#define BL_MM_INCLUDE_ONLY_FIRMWARE_MEMORY
Value:
#define BL_MM_INCLUDE_FIRMWARE_MEMORY
Definition: bl.h:102
#define BL_MM_INCLUDE_FIRMWARE_MEMORY_2
Definition: bl.h:105

Definition at line 117 of file bl.h.

◆ BL_MM_INCLUDE_PERSISTENT_MEMORY

#define BL_MM_INCLUDE_PERSISTENT_MEMORY   0x100

Definition at line 104 of file bl.h.

◆ BL_MM_INCLUDE_RESERVED_ALLOCATED

#define BL_MM_INCLUDE_RESERVED_ALLOCATED   0x10

Definition at line 100 of file bl.h.

◆ BL_MM_INCLUDE_TRUNCATED_MEMORY

#define BL_MM_INCLUDE_TRUNCATED_MEMORY   0x80

Definition at line 103 of file bl.h.

◆ BL_MM_INCLUDE_UNMAPPED_ALLOCATED

#define BL_MM_INCLUDE_UNMAPPED_ALLOCATED   0x04

Definition at line 98 of file bl.h.

◆ BL_MM_INCLUDE_UNMAPPED_UNALLOCATED

#define BL_MM_INCLUDE_UNMAPPED_UNALLOCATED   0x08

Definition at line 99 of file bl.h.

◆ BL_MM_REMOVE_PHYSICAL_REGION_FLAG

#define BL_MM_REMOVE_PHYSICAL_REGION_FLAG   0x40000000

Definition at line 124 of file bl.h.

◆ BL_MM_REMOVE_VIRTUAL_REGION_FLAG

#define BL_MM_REMOVE_VIRTUAL_REGION_FLAG   0x80000000

Definition at line 125 of file bl.h.

◆ BL_MM_REQUEST_DEFAULT_TYPE

#define BL_MM_REQUEST_DEFAULT_TYPE   1

Definition at line 121 of file bl.h.

◆ BL_MM_REQUEST_TOP_DOWN_TYPE

#define BL_MM_REQUEST_TOP_DOWN_TYPE   2

Definition at line 122 of file bl.h.

◆ BL_RETURN_ARGUMENTS_NO_PAE_FLAG

#define BL_RETURN_ARGUMENTS_NO_PAE_FLAG   0x40

Definition at line 66 of file bl.h.

◆ BL_RETURN_ARGUMENTS_VERSION

#define BL_RETURN_ARGUMENTS_VERSION   1

Definition at line 63 of file bl.h.

◆ BL_UNKNOWN_ACCESS

#define BL_UNKNOWN_ACCESS   0x10

Definition at line 150 of file bl.h.

◆ BL_UTL_CHECKSUM_COMPLEMENT

#define BL_UTL_CHECKSUM_COMPLEMENT   0x10000

Definition at line 187 of file bl.h.

◆ BL_UTL_CHECKSUM_NEGATE

#define BL_UTL_CHECKSUM_NEGATE   0x40000

Definition at line 189 of file bl.h.

◆ BL_UTL_CHECKSUM_ROTATE

#define BL_UTL_CHECKSUM_ROTATE   0x20000

Definition at line 188 of file bl.h.

◆ BL_UTL_CHECKSUM_UCHAR_BUFFER

#define BL_UTL_CHECKSUM_UCHAR_BUFFER   0x01

Definition at line 190 of file bl.h.

◆ BL_UTL_CHECKSUM_USHORT_BUFFER

#define BL_UTL_CHECKSUM_USHORT_BUFFER   0x02

Definition at line 191 of file bl.h.

◆ BOOT_APPLICATION_SIGNATURE_1

#define BOOT_APPLICATION_SIGNATURE_1   'TOOB'

Definition at line 55 of file bl.h.

◆ BOOT_APPLICATION_SIGNATURE_2

#define BOOT_APPLICATION_SIGNATURE_2   ' PPA'

Definition at line 56 of file bl.h.

◆ BOOT_APPLICATION_VERSION

#define BOOT_APPLICATION_VERSION   2

Definition at line 61 of file bl.h.

◆ BOOT_MEMORY_TRANSLATION_TYPE_PHYSICAL

#define BOOT_MEMORY_TRANSLATION_TYPE_PHYSICAL   0

Definition at line 58 of file bl.h.

◆ BOOT_MEMORY_TRANSLATION_TYPE_VIRTUAL

#define BOOT_MEMORY_TRANSLATION_TYPE_VIRTUAL   1

Definition at line 59 of file bl.h.

Typedef Documentation

◆ BITMAP

◆ BL_ADDRESS_RANGE

◆ BL_APPLICATION_ENTRY

◆ BL_ARCH_CONTEXT

◆ BL_ARCH_MODE

◆ BL_BCD_OPTION

◆ BL_BLOCK_DEVICE

◆ BL_BLOCK_DEVICE_INFORMATION

◆ BL_BOOT_ERROR_STATUS

◆ BL_BUFFER_DESCRIPTOR

◆ BL_COLOR

◆ BL_DEFERRED_FONT_FILE

◆ BL_DEVICE_CALLBACKS

◆ BL_DEVICE_DESCRIPTOR

◆ BL_DEVICE_ENTRY

◆ BL_DEVICE_INFORMATION

◆ BL_DEVICE_TYPE

◆ BL_DISPLAY_MODE

◆ BL_DISPLAY_STATE

◆ BL_FILE_CALLBACKS

◆ BL_FILE_ENTRY

◆ BL_FILE_INFORMATION

◆ BL_FILE_PATH_DESCRIPTOR

◆ BL_FILE_SYSTEM_ENTRY

◆ BL_FILE_SYSTEM_REGISTRATION_TABLE

◆ BL_FIRMWARE_DESCRIPTOR

◆ BL_GRAPHICS_CONSOLE

◆ BL_GRAPHICS_CONSOLE_TYPE

◆ BL_GRAPHICS_CONSOLE_VTABLE

◆ BL_HARDDISK_DEVICE

◆ BL_HASH_ENTRY

◆ BL_HASH_NODE

◆ BL_HASH_TABLE

◆ BL_HASH_VALUE

◆ BL_IMAGE_APPLICATION_ENTRY

◆ BL_IMG_FILE

◆ BL_INPUT_CONSOLE

◆ BL_INPUT_CONSOLE_VTABLE

◆ BL_LIBRARY_PARAMETERS

◆ BL_LOADED_APPLICATION_ENTRY

◆ BL_LOCAL_DEVICE

◆ BL_LOCAL_DEVICE_TYPE

◆ BL_MEMORY_ATTR

◆ BL_MEMORY_CLASS

◆ BL_MEMORY_DATA

◆ BL_MEMORY_DESCRIPTOR

◆ BL_MEMORY_DESCRIPTOR_LIST

◆ BL_MEMORY_DESCRIPTOR_TYPE

◆ BL_MEMORY_TYPE

◆ BL_MENU_POLICY

◆ BL_MENU_STATUS

◆ BL_PARTITION_TYPE

◆ BL_PATH_TYPE

◆ BL_PD_DATA_BLOB

◆ BL_PROTOCOL_HANDLE

◆ BL_REMOTE_CONSOLE

◆ BL_RETURN_ARGUMENTS

◆ BL_TEXT_CONSOLE

◆ BL_TEXT_CONSOLE_VTABLE

◆ BL_TRANSLATION_TYPE

◆ BL_WINDOWS_LOAD_OPTIONS

◆ BMP_HEADER

◆ BOOT_APPLICATION_PARAMETER_BLOCK

◆ COORD

typedef struct _COORD COORD

◆ DIB_HEADER

◆ PBITMAP

typedef struct _BITMAP * PBITMAP

◆ PBL_ADDRESS_RANGE

◆ PBL_APPLICATION_ENTRY

◆ PBL_ARCH_CONTEXT

◆ PBL_BCD_OPTION

◆ PBL_BLOCK_DEVICE

◆ PBL_BLOCK_DEVICE_INFORMATION

◆ PBL_BUFFER_DESCRIPTOR

◆ PBL_COLOR

◆ PBL_DEFERRED_FONT_FILE

◆ PBL_DEVICE_CALLBACKS

◆ PBL_DEVICE_CLOSE

typedef NTSTATUS(* PBL_DEVICE_CLOSE) (_In_ struct _BL_DEVICE_ENTRY *DeviceEntry)

Definition at line 625 of file bl.h.

◆ PBL_DEVICE_CREATE

typedef NTSTATUS(* PBL_DEVICE_CREATE) (VOID)

Definition at line 672 of file bl.h.

◆ PBL_DEVICE_DESCRIPTOR

◆ PBL_DEVICE_ENTRY

◆ PBL_DEVICE_ENUMERATE_DEVICE_CLASS

typedef NTSTATUS(* PBL_DEVICE_ENUMERATE_DEVICE_CLASS) (VOID)

Definition at line 612 of file bl.h.

◆ PBL_DEVICE_FLUSH

typedef NTSTATUS(* PBL_DEVICE_FLUSH) (VOID)

Definition at line 666 of file bl.h.

◆ PBL_DEVICE_GET_INFORMATION

typedef NTSTATUS(* PBL_DEVICE_GET_INFORMATION) (_In_ struct _BL_DEVICE_ENTRY *DeviceEntry, _Out_ struct _BL_DEVICE_INFORMATION *DeviceInformation)

Definition at line 646 of file bl.h.

◆ PBL_DEVICE_INFORMATION

◆ PBL_DEVICE_OPEN

typedef NTSTATUS(* PBL_DEVICE_OPEN) (_In_ struct _BL_DEVICE_DESCRIPTOR *Device, _In_ struct _BL_DEVICE_ENTRY *DeviceEntry)

Definition at line 618 of file bl.h.

◆ PBL_DEVICE_READ

typedef NTSTATUS(* PBL_DEVICE_READ) (_In_ struct _BL_DEVICE_ENTRY *DeviceEntry, _In_ PVOID Buffer, _In_ ULONG Size, _Out_ PULONG BytesRead)

Definition at line 631 of file bl.h.

◆ PBL_DEVICE_RESET

typedef NTSTATUS(* PBL_DEVICE_RESET) (VOID)

Definition at line 660 of file bl.h.

◆ PBL_DEVICE_SET_INFORMATION

typedef NTSTATUS(* PBL_DEVICE_SET_INFORMATION) (_In_ struct _BL_DEVICE_ENTRY *DeviceEntry, _In_ struct _BL_DEVICE_INFORMATION *DeviceInformation)

Definition at line 653 of file bl.h.

◆ PBL_DEVICE_WRITE

typedef NTSTATUS(* PBL_DEVICE_WRITE) (VOID)

Definition at line 640 of file bl.h.

◆ PBL_DISPLAY_MODE

◆ PBL_DISPLAY_STATE

◆ PBL_FILE_CALLBACKS

◆ PBL_FILE_CLOSE

typedef NTSTATUS(* PBL_FILE_CLOSE) (_In_ struct _BL_FILE_ENTRY *FileEntry)

Definition at line 401 of file bl.h.

◆ PBL_FILE_DESTROY_CALLBACK

typedef NTSTATUS(* PBL_FILE_DESTROY_CALLBACK) (_In_ PVOID Entry)

Definition at line 468 of file bl.h.

◆ PBL_FILE_ENTRY

◆ PBL_FILE_GET_INFO

typedef NTSTATUS(* PBL_FILE_GET_INFO) (_In_ struct _BL_FILE_ENTRY *FileEntry, _Out_ struct _BL_FILE_INFORMATION *FileInfo)

Definition at line 428 of file bl.h.

◆ PBL_FILE_GET_NEXT

typedef NTSTATUS(* PBL_FILE_GET_NEXT) (VOID)

Definition at line 422 of file bl.h.

◆ PBL_FILE_INFORMATION

◆ PBL_FILE_OPEN

Definition at line 392 of file bl.h.

◆ PBL_FILE_PATH_DESCRIPTOR

◆ PBL_FILE_READ

Definition at line 407 of file bl.h.

◆ PBL_FILE_SET_INFO

typedef NTSTATUS(* PBL_FILE_SET_INFO) (_In_ struct _BL_FILE_ENTRY *FileEntry, _In_ struct _BL_FILE_INFORMATION *FileInfo)

Definition at line 435 of file bl.h.

◆ PBL_FILE_SYSTEM_ENTRY

◆ PBL_FILE_WRITE

typedef NTSTATUS(* PBL_FILE_WRITE) (VOID)

Definition at line 416 of file bl.h.

◆ PBL_FIRMWARE_DESCRIPTOR

◆ PBL_FS_DESTROY_CALLBACK

typedef NTSTATUS(* PBL_FS_DESTROY_CALLBACK) (VOID)

Definition at line 448 of file bl.h.

◆ PBL_FS_INIT_CALLBACK

typedef NTSTATUS(* PBL_FS_INIT_CALLBACK) (VOID)

Definition at line 442 of file bl.h.

◆ PBL_FS_MOUNT_CALLBACK

typedef NTSTATUS(* PBL_FS_MOUNT_CALLBACK) (_In_ ULONG DeviceId, _In_ ULONG Unknown, _Out_ struct _BL_FILE_ENTRY **FileEntry)

Definition at line 454 of file bl.h.

◆ PBL_FS_PURGE_CALLBACK

typedef NTSTATUS(* PBL_FS_PURGE_CALLBACK) (VOID)

Definition at line 462 of file bl.h.

◆ PBL_GRAPHICS_CONSOLE

◆ PBL_GRAPHICS_CONSOLE_VTABLE

◆ PBL_HASH_ENTRY

◆ PBL_HASH_NODE

◆ PBL_HASH_TABLE

◆ PBL_HASH_TABLE_COMPARE_FUNCTION

typedef BOOLEAN(* PBL_HASH_TABLE_COMPARE_FUNCTION) (_In_ struct _BL_HASH_ENTRY *Entry1, _In_ struct _BL_HASH_ENTRY *Entry2)

Definition at line 594 of file bl.h.

◆ PBL_HASH_TABLE_HASH_FUNCTION

typedef ULONG(* PBL_HASH_TABLE_HASH_FUNCTION) (_In_ struct _BL_HASH_ENTRY *Entry, _In_ ULONG TableSize)

Definition at line 601 of file bl.h.

◆ PBL_HASH_VALUE

◆ PBL_IMAGE_APPLICATION_ENTRY

◆ PBL_IMG_FILE

◆ PBL_INPUT_CONSOLE

◆ PBL_INPUT_CONSOLE_VTABLE

◆ PBL_IO_DESTROY_ROUTINE

typedef NTSTATUS(* PBL_IO_DESTROY_ROUTINE) (VOID)

Definition at line 587 of file bl.h.

◆ PBL_LIBRARY_PARAMETERS

◆ PBL_LOADED_APPLICATION_ENTRY

◆ PBL_LOCAL_DEVICE

◆ PBL_MEMORY_DATA

◆ PBL_MEMORY_DESCRIPTOR

◆ PBL_MEMORY_DESCRIPTOR_LIST

◆ PBL_MM_DESTROY_SELF_MAP

typedef VOID(* PBL_MM_DESTROY_SELF_MAP) (VOID)

Definition at line 700 of file bl.h.

◆ PBL_MM_FLUSH_TLB

typedef VOID(* PBL_MM_FLUSH_TLB)(VOID)

Definition at line 677 of file bl.h.

◆ PBL_MM_FLUSH_TLB_ENTRY

typedef VOID(* PBL_MM_FLUSH_TLB_ENTRY) (_In_ PVOID VirtualAddress)

Definition at line 705 of file bl.h.

◆ PBL_MM_MAP_PHYSICAL_ADDRESS

typedef NTSTATUS(* PBL_MM_MAP_PHYSICAL_ADDRESS) (_In_ PHYSICAL_ADDRESS PhysicalAddress, _Out_ PVOID VirtualAddress, _In_ ULONG Size, _In_ ULONG CacheAttributes)

Definition at line 729 of file bl.h.

◆ PBL_MM_MOVE_VIRTUAL_ADDRESS_RANGE

typedef NTSTATUS(* PBL_MM_MOVE_VIRTUAL_ADDRESS_RANGE) (_In_ PVOID DestinationAddress, _In_ PVOID SourceAddress, _In_ ULONGLONG Size)

Definition at line 687 of file bl.h.

◆ PBL_MM_RELOCATE_SELF_MAP

typedef VOID(* PBL_MM_RELOCATE_SELF_MAP) (VOID)

Definition at line 682 of file bl.h.

◆ PBL_MM_REMAP_VIRTUAL_ADDRESS

typedef NTSTATUS(* PBL_MM_REMAP_VIRTUAL_ADDRESS) (_In_ PPHYSICAL_ADDRESS PhysicalAddress, _Out_ PVOID VirtualAddress, _In_ ULONG Size, _In_ ULONG CacheAttributes)

Definition at line 721 of file bl.h.

◆ PBL_MM_TRANSLATE_VIRTUAL_ADDRESS

typedef BOOLEAN(* PBL_MM_TRANSLATE_VIRTUAL_ADDRESS) (_In_ PVOID VirtualAddress, _Out_ PPHYSICAL_ADDRESS PhysicalAddress, _Out_opt_ PULONG CacheAttributes)

Definition at line 737 of file bl.h.

◆ PBL_MM_UNMAP_VIRTUAL_ADDRESS

typedef NTSTATUS(* PBL_MM_UNMAP_VIRTUAL_ADDRESS) (_In_ PVOID VirtualAddress, _In_ ULONG Size)

Definition at line 715 of file bl.h.

◆ PBL_MM_ZERO_VIRTUAL_ADDRESS_RANGE

typedef NTSTATUS(* PBL_MM_ZERO_VIRTUAL_ADDRESS_RANGE) (_In_ PVOID DestinationAddress, _In_ ULONGLONG Size)

Definition at line 694 of file bl.h.

◆ PBL_PD_DATA_BLOB

◆ PBL_PROTOCOL_HANDLE

◆ PBL_REMOTE_CONSOLE

◆ PBL_RETURN_ARGUMENTS

◆ PBL_STATUS_ERROR_HANDLER

typedef NTSTATUS(* PBL_STATUS_ERROR_HANDLER) (_In_ ULONG ErrorCode, _In_ ULONG Parameter1, _In_ ULONG_PTR Parameter2, _In_ ULONG_PTR Parameter3, _In_ ULONG_PTR Parameter4)

Definition at line 744 of file bl.h.

◆ PBL_TBL_LOOKUP_ROUTINE

typedef BOOLEAN(* PBL_TBL_LOOKUP_ROUTINE) (_In_ PVOID Entry, _In_ PVOID Argument1, _In_ PVOID Argument2, _In_ PVOID Argument3, _In_ PVOID Argument4)

Definition at line 564 of file bl.h.

◆ PBL_TBL_MAP_ROUTINE

typedef NTSTATUS(* PBL_TBL_MAP_ROUTINE) (_In_ PVOID Entry, _In_ ULONG EntryIndex)

Definition at line 574 of file bl.h.

◆ PBL_TBL_SET_ROUTINE

typedef NTSTATUS(* PBL_TBL_SET_ROUTINE) (_In_ PVOID Entry)

Definition at line 581 of file bl.h.

◆ PBL_TEXT_CONSOLE

◆ PBL_TEXT_CONSOLE_VTABLE

◆ PBL_WINDOWS_LOAD_OPTIONS

◆ PBMP_HEADER

◆ PBOOT_APPLICATION_PARAMETER_BLOCK

◆ PCONSOLE_CLEAR_TEXT

typedef NTSTATUS(* PCONSOLE_CLEAR_TEXT) (_In_ struct _BL_TEXT_CONSOLE *Console, _In_ BOOLEAN LineOnly)

Definition at line 522 of file bl.h.

◆ PCONSOLE_DESTRUCT

typedef VOID(* PCONSOLE_DESTRUCT) (_In_ struct _BL_TEXT_CONSOLE *Console)

Definition at line 480 of file bl.h.

◆ PCONSOLE_ENABLE

Definition at line 549 of file bl.h.

◆ PCONSOLE_GET_GRAPHICAL_RESOLUTION

typedef NTSTATUS(* PCONSOLE_GET_GRAPHICAL_RESOLUTION) (_In_ struct _BL_GRAPHICS_CONSOLE *Console, _Out_ struct _BL_DISPLAY_MODE *DisplayMode)

Definition at line 535 of file bl.h.

◆ PCONSOLE_GET_TEXT_RESOLUTION

typedef NTSTATUS(* PCONSOLE_GET_TEXT_RESOLUTION) (_In_ struct _BL_TEXT_CONSOLE *Console, _Out_ PULONG TextResolution)

Definition at line 507 of file bl.h.

◆ PCONSOLE_GET_TEXT_STATE

typedef NTSTATUS(* PCONSOLE_GET_TEXT_STATE) (_In_ struct _BL_TEXT_CONSOLE *Console, _Out_ struct _BL_DISPLAY_STATE *TextState)

Definition at line 492 of file bl.h.

◆ PCONSOLE_IS_ENABLED

typedef BOOLEAN(* PCONSOLE_IS_ENABLED) (_In_ struct _BL_GRAPHICS_CONSOLE *Console)

Definition at line 529 of file bl.h.

◆ PCONSOLE_REINITIALIZE

typedef NTSTATUS(* PCONSOLE_REINITIALIZE) (_In_ struct _BL_TEXT_CONSOLE *Console)

Definition at line 486 of file bl.h.

◆ PCONSOLE_SET_GRAPHICAL_RESOLUTION

typedef NTSTATUS(* PCONSOLE_SET_GRAPHICAL_RESOLUTION) (_In_ struct _BL_GRAPHICS_CONSOLE *Console, _In_ struct _BL_DISPLAY_MODE DisplayMode)

Definition at line 542 of file bl.h.

◆ PCONSOLE_SET_TEXT_RESOLUTION

typedef NTSTATUS(* PCONSOLE_SET_TEXT_RESOLUTION) (_In_ struct _BL_TEXT_CONSOLE *Console, _In_ ULONG NewTextResolution, _Out_ PULONG OldTextResolution)

Definition at line 514 of file bl.h.

◆ PCONSOLE_SET_TEXT_STATE

typedef NTSTATUS(* PCONSOLE_SET_TEXT_STATE) (_In_ struct _BL_TEXT_CONSOLE *Console, _In_ ULONG Flags, _In_ struct _BL_DISPLAY_STATE *TextState)

Definition at line 499 of file bl.h.

◆ PCONSOLE_WRITE_TEXT

typedef NTSTATUS(* PCONSOLE_WRITE_TEXT) (_In_ struct _BL_TEXT_CONSOLE *Console, _In_ PCHAR Text, _In_ ULONG Attribute)

Definition at line 556 of file bl.h.

◆ PCOORD

typedef struct _COORD * PCOORD

◆ PDIB_HEADER

◆ PL_MENU_STATUS

Enumeration Type Documentation

◆ _BL_ARCH_MODE

Enumerator
BlProtectedMode 
BlRealMode 

Definition at line 236 of file bl.h.

237{
@ BlProtectedMode
Definition: bl.h:238
@ BlRealMode
Definition: bl.h:239
enum _BL_ARCH_MODE BL_ARCH_MODE

◆ _BL_BOOT_ERROR_STATUS

Enumerator
Reboot 
Recover 
RecoverOem 
OsSelection 
NextOs 
TryAgain 
AdvancedOptions 
BootOptions 

Definition at line 889 of file bl.h.

890{
891 Reboot = 1,
892 Recover = 2,
893 RecoverOem = 3,
894 OsSelection = 4,
895 NextOs = 5,
896 TryAgain = 6,
897 AdvancedOptions = 7,
898 BootOptions = 8
@ BootOptions
Definition: bl.h:898
@ Recover
Definition: bl.h:892
@ RecoverOem
Definition: bl.h:893
@ AdvancedOptions
Definition: bl.h:897
@ Reboot
Definition: bl.h:891
@ NextOs
Definition: bl.h:895
@ TryAgain
Definition: bl.h:896
@ OsSelection
Definition: bl.h:894
enum _BL_BOOT_ERROR_STATUS BL_BOOT_ERROR_STATUS

◆ _BL_COLOR

Enumerator
Black 
Blue 
Green 
Cyan 
Red 
Magenta 
Brown 
LtGray 
Gray 
LtBlue 
LtGreen 
LtCyan 
LtRed 
LtMagenta 
Yellow 
White 

Definition at line 195 of file bl.h.

196{
197 Black,
198 Blue,
199 Green,
200 Cyan,
201 Red,
202 Magenta,
203 Brown,
204 LtGray,
205 Gray,
206 LtBlue,
207 LtGreen,
208 LtCyan,
209 LtRed,
210 LtMagenta,
211 Yellow,
212 White
enum _BL_COLOR * PBL_COLOR
enum _BL_COLOR BL_COLOR
@ LtRed
Definition: bl.h:209
@ LtMagenta
Definition: bl.h:210
@ LtBlue
Definition: bl.h:206
@ LtCyan
Definition: bl.h:208
@ LtGreen
Definition: bl.h:207
@ Gray
Definition: bl.h:205
@ LtGray
Definition: bl.h:204
@ Brown
Definition: bl.h:203
@ Cyan
Definition: bl.h:200
@ Magenta
Definition: bl.h:202
@ White
Definition: bl.h:212
@ Yellow
Definition: bl.h:211
@ Black
Definition: bl.h:197
@ Green
Definition: bl.h:199
@ Red
Definition: bl.h:201
@ Blue
Definition: bl.h:198

◆ _BL_DEVICE_TYPE

Enumerator
DiskDevice 
LegacyPartitionDevice 
SerialDevice 
UdpDevice 
BootDevice 
PartitionDevice 
LocateDevice 

Definition at line 245 of file bl.h.

246{
247 DiskDevice = 0,
249 SerialDevice = 3,
250 UdpDevice = 4,
251 BootDevice = 5,
252 PartitionDevice = 6,
253 LocateDevice = 8,
@ LegacyPartitionDevice
Definition: bl.h:248
@ LocateDevice
Definition: bl.h:253
@ SerialDevice
Definition: bl.h:249
@ DiskDevice
Definition: bl.h:247
@ PartitionDevice
Definition: bl.h:252
@ UdpDevice
Definition: bl.h:250
@ BootDevice
Definition: bl.h:251
enum _BL_DEVICE_TYPE BL_DEVICE_TYPE

◆ _BL_GRAPHICS_CONSOLE_TYPE

Enumerator
BlGopConsole 
BlUgaConsole 

Definition at line 1138 of file bl.h.

1139{
enum _BL_GRAPHICS_CONSOLE_TYPE BL_GRAPHICS_CONSOLE_TYPE
@ BlUgaConsole
Definition: bl.h:1141
@ BlGopConsole
Definition: bl.h:1140

◆ _BL_LOCAL_DEVICE_TYPE

Enumerator
LocalDevice 
FloppyDevice 
CdRomDevice 
RamDiskDevice 
FileDevice 
VirtualDiskDevice 

Definition at line 259 of file bl.h.

260{
261 LocalDevice = 0,
262 FloppyDevice = 1,
263 CdRomDevice = 2,
264 RamDiskDevice = 3,
265 FileDevice = 5,
@ FloppyDevice
Definition: bl.h:262
@ RamDiskDevice
Definition: bl.h:264
@ FileDevice
Definition: bl.h:265
@ LocalDevice
Definition: bl.h:261
@ VirtualDiskDevice
Definition: bl.h:266
@ CdRomDevice
Definition: bl.h:263
enum _BL_LOCAL_DEVICE_TYPE BL_LOCAL_DEVICE_TYPE

◆ _BL_MEMORY_ATTR

Enumerator
BlMemoryUncached 
BlMemoryWriteCombined 
BlMemoryWriteThrough 
BlMemoryWriteBack 
BlMemoryUncachedExported 
BlMemoryValidCacheAttributes 
BlMemoryValidCacheAttributeMask 
BlMemoryWriteProtected 
BlMemoryReadProtected 
BlMemoryExecuteProtected 
BlMemoryValidProtectionAttributes 
BlMemoryValidProtectionAttributeMask 
BlMemoryLargePages 
BlMemoryKernelRange 
BlMemoryFixed 
BlMemoryBelow1MB 
BlMemoryValidAllocationAttributes 
BlMemoryValidAllocationAttributeMask 
BlMemoryRuntime 
BlMemoryCoalesced 
BlMemoryUpdate 
BlMemoryNonFirmware 
BlMemoryPersistent 
BlMemorySpecial 
BlMemoryFirmware 
BlMemoryValidTypeAttributes 
BlMemoryValidTypeAttributeMask 

Definition at line 341 of file bl.h.

342{
343 //
344 // Memory Caching Attributes
345 //
346 BlMemoryUncached = 0x00000001,
347 BlMemoryWriteCombined = 0x00000002,
348 BlMemoryWriteThrough = 0x00000004,
349 BlMemoryWriteBack = 0x00000008,
350 BlMemoryUncachedExported = 0x00000010,
353
354 //
355 // Memory Protection Attributes
356 //
357 BlMemoryWriteProtected = 0x00000100,
358 BlMemoryReadProtected = 0x00000200,
359 BlMemoryExecuteProtected = 0x00000400,
362
363 //
364 // Memory Allocation Attributes
365 //
366 BlMemoryLargePages = 0x00010000,
367 BlMemoryKernelRange = 0x00020000,
368 BlMemoryFixed = 0x00040000,
369 BlMemoryBelow1MB = 0x00080000,
372
373 //
374 // Memory Type Attributes
375 //
376 BlMemoryRuntime = 0x01000000,
377 BlMemoryCoalesced = 0x02000000,
378 BlMemoryUpdate = 0x04000000,
379 BlMemoryNonFirmware = 0x08000000,
380 BlMemoryPersistent = 0x10000000,
381 BlMemorySpecial = 0x20000000,
382 BlMemoryFirmware = 0x80000000,
enum _BL_MEMORY_ATTR BL_MEMORY_ATTR
@ BlMemoryLargePages
Definition: bl.h:366
@ BlMemoryFixed
Definition: bl.h:368
@ BlMemoryReadProtected
Definition: bl.h:358
@ BlMemoryKernelRange
Definition: bl.h:367
@ BlMemoryValidCacheAttributeMask
Definition: bl.h:352
@ BlMemoryExecuteProtected
Definition: bl.h:359
@ BlMemoryWriteThrough
Definition: bl.h:348
@ BlMemoryValidProtectionAttributes
Definition: bl.h:360
@ BlMemoryUpdate
Definition: bl.h:378
@ BlMemoryValidProtectionAttributeMask
Definition: bl.h:361
@ BlMemoryValidAllocationAttributes
Definition: bl.h:370
@ BlMemoryPersistent
Definition: bl.h:380
@ BlMemoryWriteProtected
Definition: bl.h:357
@ BlMemoryValidCacheAttributes
Definition: bl.h:351
@ BlMemorySpecial
Definition: bl.h:381
@ BlMemoryUncached
Definition: bl.h:346
@ BlMemoryValidAllocationAttributeMask
Definition: bl.h:371
@ BlMemoryValidTypeAttributes
Definition: bl.h:383
@ BlMemoryRuntime
Definition: bl.h:376
@ BlMemoryValidTypeAttributeMask
Definition: bl.h:384
@ BlMemoryWriteBack
Definition: bl.h:349
@ BlMemoryWriteCombined
Definition: bl.h:347
@ BlMemoryUncachedExported
Definition: bl.h:350
@ BlMemoryFirmware
Definition: bl.h:382
@ BlMemoryNonFirmware
Definition: bl.h:379
@ BlMemoryBelow1MB
Definition: bl.h:369
@ BlMemoryCoalesced
Definition: bl.h:377

◆ _BL_MEMORY_CLASS

Enumerator
BlLoaderClass 
BlApplicationClass 
BlSystemClass 

Definition at line 291 of file bl.h.

292{
293 BlLoaderClass = 0xD,
@ BlSystemClass
Definition: bl.h:295
@ BlLoaderClass
Definition: bl.h:293
@ BlApplicationClass
Definition: bl.h:294
enum _BL_MEMORY_CLASS BL_MEMORY_CLASS

◆ _BL_MEMORY_DESCRIPTOR_TYPE

Enumerator
BlMdPhysical 
BlMdVirtual 
BlMdTracker 

Definition at line 221 of file bl.h.

222{
@ BlMdTracker
Definition: bl.h:225
@ BlMdVirtual
Definition: bl.h:224
@ BlMdPhysical
Definition: bl.h:223
enum _BL_MEMORY_DESCRIPTOR_TYPE BL_MEMORY_DESCRIPTOR_TYPE

◆ _BL_MEMORY_TYPE

Enumerator
BlLoaderMemory 
BlLoaderDeviceMemory 
BlLoaderHeap 
BlLoaderPageDirectory 
BlLoaderReferencePage 
BlLoaderRamDisk 
BlLoaderArchData 
BlLoaderData 
BlLoaderRegistry 
BlLoaderBlockMemory 
BlLoaderSelfMap 
BlApplicationReserved 
BlApplicationData 
BlConventionalMemory 
BlUnusableMemory 
BlReservedMemory 
BlEfiBootMemory 
BlConventionalZeroedMemory 
BlEfiRuntimeCodeMemory 
BlAcpiReclaimMemory 
BlAcpiNvsMemory 
BlDeviceIoMemory 
BlDevicePortMemory 
BlPalMemory 
BlEfiRuntimeDataMemory 

Definition at line 301 of file bl.h.

302{
303 //
304 // Loader Memory
305 //
306 BlLoaderMemory = 0xD0000002,
307 BlLoaderDeviceMemory = 0xD0000004,
308 BlLoaderHeap = 0xD0000005,
309 BlLoaderPageDirectory = 0xD0000006,
310 BlLoaderReferencePage = 0xD0000007,
311 BlLoaderRamDisk = 0xD0000008,
312 BlLoaderArchData = 0xD0000009,
313 BlLoaderData = 0xD000000A,
314 BlLoaderRegistry = 0xD000000B,
315 BlLoaderBlockMemory = 0xD000000C,
316 BlLoaderSelfMap = 0xD000000F,
317
318 //
319 // Application Memory
320 //
321 BlApplicationReserved = 0xE0000001,
322 BlApplicationData = 0xE0000004,
323
324 //
325 // System Memory
326 //
327 BlConventionalMemory = 0xF0000001,
328 BlUnusableMemory = 0xF0000002,
329 BlReservedMemory = 0xF0000003,
330 BlEfiBootMemory = 0xF0000004,
331 BlConventionalZeroedMemory = 0xF000005,
332 BlEfiRuntimeCodeMemory = 0xF0000006,
333 BlAcpiReclaimMemory = 0xF0000008,
334 BlAcpiNvsMemory = 0xF0000009,
335 BlDeviceIoMemory = 0xF000000A,
336 BlDevicePortMemory = 0xF000000B,
337 BlPalMemory = 0xF000000C,
338 BlEfiRuntimeDataMemory = 0xF000000E,
@ BlLoaderMemory
Definition: bl.h:306
@ BlReservedMemory
Definition: bl.h:329
@ BlUnusableMemory
Definition: bl.h:328
@ BlEfiRuntimeDataMemory
Definition: bl.h:338
@ BlApplicationReserved
Definition: bl.h:321
@ BlDeviceIoMemory
Definition: bl.h:335
@ BlEfiBootMemory
Definition: bl.h:330
@ BlLoaderData
Definition: bl.h:313
@ BlConventionalMemory
Definition: bl.h:327
@ BlPalMemory
Definition: bl.h:337
@ BlEfiRuntimeCodeMemory
Definition: bl.h:332
@ BlLoaderArchData
Definition: bl.h:312
@ BlLoaderSelfMap
Definition: bl.h:316
@ BlLoaderReferencePage
Definition: bl.h:310
@ BlLoaderBlockMemory
Definition: bl.h:315
@ BlLoaderPageDirectory
Definition: bl.h:309
@ BlConventionalZeroedMemory
Definition: bl.h:331
@ BlLoaderDeviceMemory
Definition: bl.h:307
@ BlLoaderHeap
Definition: bl.h:308
@ BlLoaderRamDisk
Definition: bl.h:311
@ BlApplicationData
Definition: bl.h:322
@ BlAcpiNvsMemory
Definition: bl.h:334
@ BlAcpiReclaimMemory
Definition: bl.h:333
@ BlDevicePortMemory
Definition: bl.h:336
@ BlLoaderRegistry
Definition: bl.h:314
enum _BL_MEMORY_TYPE BL_MEMORY_TYPE

◆ _BL_MENU_POLICY

Enumerator
MenuPolicyLegacy 
MenuPolicyStandard 

Definition at line 215 of file bl.h.

216{
@ MenuPolicyLegacy
Definition: bl.h:217
@ MenuPolicyStandard
Definition: bl.h:218
enum _BL_MENU_POLICY BL_MENU_POLICY

◆ _BL_PARTITION_TYPE

Enumerator
GptPartition 
MbrPartition 
RawPartition 

Definition at line 272 of file bl.h.

273{
@ MbrPartition
Definition: bl.h:275
@ RawPartition
Definition: bl.h:276
@ GptPartition
Definition: bl.h:274
enum _BL_PARTITION_TYPE BL_PARTITION_TYPE

◆ _BL_PATH_TYPE

Enumerator
InternalPath 
EfiPath 

Definition at line 282 of file bl.h.

283{
284 InternalPath = 3,
285 EfiPath = 4
enum _BL_PATH_TYPE BL_PATH_TYPE
@ EfiPath
Definition: bl.h:285
@ InternalPath
Definition: bl.h:284

◆ _BL_TRANSLATION_TYPE

Enumerator
BlNone 
BlVirtual 
BlPae 
BlMax 

Definition at line 228 of file bl.h.

229{
230 BlNone,
231 BlVirtual,
232 BlPae,
233 BlMax
@ BlMax
Definition: bl.h:233
@ BlVirtual
Definition: bl.h:231
@ BlPae
Definition: bl.h:232
@ BlNone
Definition: bl.h:230
enum _BL_TRANSLATION_TYPE BL_TRANSLATION_TYPE

Function Documentation

◆ Archx86TransferTo32BitApplicationAsm()

VOID Archx86TransferTo32BitApplicationAsm ( VOID  )

Definition at line 51 of file arch.c.

52{
53 EfiPrintf(L" Archx86TransferTo32BitApplicationAsm NOT IMPLEMENTED for this platform\r\n");
54}
VOID EfiPrintf(_In_ PWCHAR Format,...)
Definition: firmware.c:126
#define L(x)
Definition: ntvdm.h:50

Referenced by ImgArchEfiStartBootApplication().

◆ BcInitialize()

NTSTATUS BcInitialize ( VOID  )

Definition at line 73 of file blkcache.c.

76{
78
80 if (!NT_SUCCESS(Status))
81 {
82 goto Quickie;
83 }
84
87 {
89 goto Quickie;
90 }
91
93 if (Status >= 0)
94 {
95 return Status;
96 }
97
98Quickie:
99 EfiPrintf(L"Failure path not yet implemented\r\n");
100#if 0
101 if (BcpHashTableId != -1)
102 {
103 BlHtDestroy(BcpHashTableId);
104 }
105 if (BcpBlockAllocatorHandle != -1)
106 {
108 }
109#endif
110 return Status;
111}
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS BlHtCreate(_In_ ULONG Size, _In_ PBL_HASH_TABLE_HASH_FUNCTION HashFunction, _In_ PBL_HASH_TABLE_COMPARE_FUNCTION CompareFunction, _Out_ PULONG Id)
Definition: util.c:504
NTSTATUS BlpMmCreateBlockAllocator(VOID)
Definition: blkalloc.c:213
NTSTATUS BlpIoRegisterDestroyRoutine(_In_ PBL_IO_DESTROY_ROUTINE DestroyRoutine)
Definition: io.c:21
NTSTATUS BlpMmDeleteBlockAllocator(_In_ ULONG BlockId)
Definition: blkalloc.c:88
ULONG BcpHashTableId
Definition: blkcache.c:16
ULONG BcpHashFunction(_In_ PBL_HASH_ENTRY Entry, _In_ ULONG TableSize)
Definition: blkcache.c:45
ULONG BcpBlockAllocatorHandle
Definition: blkcache.c:15
BOOLEAN BcpCompareKey(_In_ PBL_HASH_ENTRY Entry1, _In_ PBL_HASH_ENTRY Entry2)
Definition: blkcache.c:32
NTSTATUS BcpDestroy(VOID)
Definition: blkcache.c:21
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:25
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

Referenced by BlockIopInitialize().

◆ BfClearScreen()

NTSTATUS BfClearScreen ( _In_ PBL_GRAPHICS_CONSOLE  Console)

Definition at line 158 of file font.c.

161{
163
164 /* Reset the cursor position */
165 Console->TextConsole.State.XPos = 0;
166 Console->TextConsole.State.YPos = 0;
167
168 /* Fill the screen with the background color */
170 Console->TextConsole.State.BgColor);
171 if (!NT_SUCCESS(Status))
172 {
173 return Status;
174 }
175
176 /* Check if the cursor should be visible */
177 if (Console->TextConsole.State.CursorVisible)
178 {
179 /* Load any fonts at this time */
181 {
183 }
184
185 /* Switch the cursor to visible */
187 }
188 else
189 {
190 /* Nothing left to do */
192 }
193
194 /* Return cursor flip result, if any */
195 return Status;
196}
CConsole Console
NTSTATUS ConsoleGraphicalClearPixels(_In_ PBL_GRAPHICS_CONSOLE Console, _In_ ULONG Color)
Definition: guicons.c:275
NTSTATUS BfLoadDeferredFontFiles(VOID)
Definition: font.c:99
NTSTATUS BfiFlipCursorCharacter(_In_ PBL_GRAPHICS_CONSOLE Console, _In_ BOOLEAN Visible)
Definition: font.c:139
LIST_ENTRY BfiDeferredListHead
Definition: font.c:15
#define TRUE
Definition: types.h:120
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by ConsoleGraphicalClearText().

◆ BfClearToEndOfLine()

NTSTATUS BfClearToEndOfLine ( _In_ PBL_GRAPHICS_CONSOLE  Console)

Definition at line 149 of file font.c.

152{
153 /* not implemented */
155}
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239

Referenced by ConsoleGraphicalClearText().

◆ BfiFreeDeferredFontFile()

VOID BfiFreeDeferredFontFile ( _In_ PBL_DEFERRED_FONT_FILE  DeferredFontFile)

Definition at line 30 of file font.c.

33{
34 /* Free the device copy if there was one */
35 if (DeferredFontFile->Device)
36 {
37 BlMmFreeHeap(DeferredFontFile->Device);
38 }
39
40 /* Free the path copy if there was one */
41 if (DeferredFontFile->FontPath)
42 {
43 BlMmFreeHeap(DeferredFontFile->FontPath);
44 }
45
46 /* Free the whole thing */
47 BlMmFreeHeap(DeferredFontFile);
48}
NTSTATUS BlMmFreeHeap(_In_ PVOID Buffer)
Definition: heapalloc.c:663

Referenced by BfLoadDeferredFontFiles(), BfLoadFontFile(), and BlpDisplayRegisterLocale().

◆ BfLoadDeferredFontFiles()

NTSTATUS BfLoadDeferredFontFiles ( VOID  )

Definition at line 99 of file font.c.

102{
103 PLIST_ENTRY NextEntry;
104 PBL_DEFERRED_FONT_FILE DeferredFont;
105 NTSTATUS Status, LoadStatus;
106
107 /* Assume empty list */
109
110 /* Parse the list */
111 NextEntry = BfiDeferredListHead.Flink;
112 while (NextEntry != &BfiDeferredListHead)
113 {
114 /* Get the font */
115 DeferredFont = CONTAINING_RECORD(NextEntry, BL_DEFERRED_FONT_FILE, ListEntry);
116
117 /* Move to the next entry and remove this one */
118 NextEntry = NextEntry->Flink;
119 RemoveEntryList(&DeferredFont->ListEntry);
120
121 /* Load the font */
122 LoadStatus = BfiLoadFontFile(DeferredFont->Device,
123 DeferredFont->FontPath);
124 if (!NT_SUCCESS(LoadStatus))
125 {
126 /* Remember the load failure if there was one */
127 Status = LoadStatus;
128 }
129
130 /* Free the deferred font */
131 BfiFreeDeferredFontFile(DeferredFont);
132 }
133
134 /* Return load status */
135 return Status;
136}
NTSTATUS BfiLoadFontFile(_In_ PBL_DEVICE_DESCRIPTOR FontDevice, _In_ PWCHAR FontPath)
Definition: font.c:20
VOID BfiFreeDeferredFontFile(_In_ PBL_DEFERRED_FONT_FILE DeferredFontFile)
Definition: font.c:30
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
PBL_DEVICE_DESCRIPTOR Device
Definition: bl.h:1301
LIST_ENTRY ListEntry
Definition: bl.h:1299
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by BfClearScreen(), and BlResourceFindMessage().

◆ BfLoadFontFile()

NTSTATUS BfLoadFontFile ( _In_ PBL_DEVICE_DESCRIPTOR  Device,
_In_ PWCHAR  FontPath 
)

Definition at line 51 of file font.c.

55{
56 PBL_DEFERRED_FONT_FILE DeferredFont;
57 SIZE_T FontPathSize;
58
59 /* Allocate the deferred font structure */
60 DeferredFont = (PBL_DEFERRED_FONT_FILE)BlMmAllocateHeap(sizeof(*DeferredFont));
61 if (!DeferredFont)
62 {
63 return STATUS_NO_MEMORY;
64 }
65
66 /* Zero it out */
67 RtlZeroMemory(DeferredFont, sizeof(*DeferredFont));
68
69 /* Allocate a copy for the file path */
70 FontPathSize = sizeof(WCHAR) * wcslen(FontPath) + sizeof(UNICODE_NULL);
71 DeferredFont->FontPath = (PWCHAR)BlMmAllocateHeap(FontPathSize);
72 if (!DeferredFont->FontPath)
73 {
74 BfiFreeDeferredFontFile(DeferredFont);
75 return STATUS_NO_MEMORY;
76 }
77
78 /* Allocate a copy for the device */
79 DeferredFont->Device = BlMmAllocateHeap(Device->Size);
80 if (!DeferredFont->Device)
81 {
82 BfiFreeDeferredFontFile(DeferredFont);
83 return STATUS_NO_MEMORY;
84 }
85
86 /* Copy the path and device */
87 RtlCopyMemory(DeferredFont->FontPath, FontPath, FontPathSize);
88 RtlCopyMemory(DeferredFont->Device,Device, Device->Size);
89
90 /* Set pending flag? */
91 DeferredFont->Flags = 1;
92
93 /* Insert it into the list */
95 return STATUS_SUCCESS;
96}
PVOID BlMmAllocateHeap(_In_ SIZE_T Size)
Definition: heapalloc.c:569
struct _BL_DEFERRED_FONT_FILE * PBL_DEFERRED_FONT_FILE
#define InsertTailList(ListHead, Entry)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define UNICODE_NULL
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint16_t * PWCHAR
Definition: typedefs.h:56
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by DsppLoadFontFile().

◆ BiCloseKey()

VOID BiCloseKey ( _In_ HANDLE  KeyHandle)

Definition at line 141 of file bootreg.c.

144{
145 PBI_KEY_HIVE KeyHive;
146 PBI_KEY_OBJECT KeyObject;
147
148 /* Get the key object and hive */
149 KeyObject = (PBI_KEY_OBJECT)KeyHandle;
150 KeyHive = KeyObject->KeyHive;
151
152 /* Check if we have a hive, or name, or key node */
153 if ((KeyHive) || (KeyObject->KeyNode) || (KeyObject->KeyName))
154 {
155 /* Drop a reference, see if it's the last one */
157 if (!KeyHive->ReferenceCount)
158 {
159 /* Check if we should flush it */
160 if (KeyHive->Flags & BI_FLUSH_HIVE)
161 {
163 }
164
165 /* Unmap the hive */
167
168 /* Free the hive and hive path */
169 BlMmFreeHeap(KeyHive->FilePath);
170 BlMmFreeHeap(KeyHive);
171 }
172
173 /* Check if a key name is present */
174 if (KeyObject->KeyName)
175 {
176 /* Free it */
177 BlMmFreeHeap(KeyObject->KeyName);
178 }
179 }
180
181 /* Free the object */
182 BlMmFreeHeap(KeyObject);
183}
NTSTATUS MmPapFreePages(_In_ PVOID Address, _In_ ULONG WhichList)
Definition: pagealloc.c:1196
VOID BiDereferenceHive(_In_ HANDLE KeyHandle)
Definition: bootreg.c:117
VOID BiFlushHive(_In_ HANDLE KeyHandle)
Definition: bootreg.c:131
#define BI_FLUSH_HIVE
Definition: bootreg.c:16
struct _BI_KEY_OBJECT * PBI_KEY_OBJECT
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
PBL_FILE_PATH_DESCRIPTOR FilePath
Definition: bootreg.c:25
LONG ReferenceCount
Definition: bootreg.c:27
ULONG Flags
Definition: bootreg.c:28
PHBASE_BLOCK BaseBlock
Definition: bootreg.c:23
PBI_KEY_HIVE KeyHive
Definition: bootreg.c:34
PWCHAR KeyName
Definition: bootreg.c:37
PCM_KEY_NODE KeyNode
Definition: bootreg.c:35

Referenced by BcdDeleteElement(), BcdOpenObject(), BiAddStoreFromFile(), BiDeleteKey(), BiEnumerateElements(), BiEnumerateSubElements(), BiGetObjectDescription(), BmCloseDataStore(), BmGetEntryDescription(), BmGetOptionList(), and BmPurgeOption().

◆ BiDeleteKey()

NTSTATUS BiDeleteKey ( _In_ HANDLE  KeyHandle)

Definition at line 892 of file bootreg.c.

895{
897 PBI_KEY_OBJECT KeyObject;
898 PHHIVE Hive;
899 ULONG SubKeyCount, i;
900 PWCHAR* SubKeyList;
902
903 /* Get the key object and hive */
904 KeyObject = (PBI_KEY_OBJECT)KeyHandle;
905 Hive = &KeyObject->KeyHive->Hive.Hive;
906
907 /* Make sure the hive is writeable */
908 if (!(KeyObject->KeyHive->Flags & BI_HIVE_WRITEABLE))
909 {
911 }
912
913 /* Enumerate all of the subkeys */
914 Status = BiEnumerateSubKeys(KeyHandle, &SubKeyList, &SubKeyCount);
915 if ((NT_SUCCESS(Status)) && (SubKeyCount > 0))
916 {
917 /* Loop through each one */
918 for (i = 0; i < SubKeyCount; i++)
919 {
920 /* Open a handle to it */
921 Status = BiOpenKey(KeyHandle, SubKeyList[i], &SubKeyHandle);
922 if (NT_SUCCESS(Status))
923 {
924 /* Recursively call us to delete it */
926 if (Status != STATUS_SUCCESS)
927 {
928 /* Close the key on failure */
930 }
931 }
932 }
933 }
934
935 /* Check if we had a list of subkeys */
936 if (SubKeyList)
937 {
938 /* Free it */
939 BlMmFreeHeap(SubKeyList);
940 }
941
942 /* Delete this key cell */
943 Status = CmpFreeKeyByCell(Hive, KeyObject->KeyCell, TRUE);
944 if (NT_SUCCESS(Status))
945 {
946 /* Mark the hive as requiring a flush */
947 KeyObject->KeyHive->Flags |= BI_FLUSH_HIVE;
949 }
950
951 /* All done */
952 return Status;
953}
NTSTATUS BiOpenKey(_In_ HANDLE ParentHandle, _In_ PWCHAR KeyName, _Out_ PHANDLE Handle)
Definition: bootreg.c:186
#define BI_HIVE_WRITEABLE
Definition: bootreg.c:17
VOID BiCloseKey(_In_ HANDLE KeyHandle)
Definition: bootreg.c:141
NTSTATUS BiDeleteKey(_In_ HANDLE KeyHandle)
Definition: bootreg.c:892
NTSTATUS BiEnumerateSubKeys(_In_ HANDLE KeyHandle, _Out_ PWCHAR **SubKeyList, _Out_ PULONG SubKeyCount)
Definition: bootreg.c:723
NTSTATUS NTAPI CmpFreeKeyByCell(IN PHHIVE Hive, IN HCELL_INDEX Cell, IN BOOLEAN Unlink)
Definition: cmkeydel.c:159
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ PNDIS_STRING _Out_ PNDIS_HANDLE SubKeyHandle
Definition: ndis.h:4726
CMHIVE Hive
Definition: bootreg.c:26
HCELL_INDEX KeyCell
Definition: bootreg.c:36
HHIVE Hive
Definition: cmlib.h:317
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_MEDIA_WRITE_PROTECTED
Definition: udferr_usr.h:161

Referenced by BcdDeleteElement(), and BiDeleteKey().

◆ BiDereferenceHive()

VOID BiDereferenceHive ( _In_ HANDLE  KeyHandle)

Definition at line 117 of file bootreg.c.

120{
121 PBI_KEY_OBJECT KeyObject;
122
123 /* Get the key object */
124 KeyObject = (PBI_KEY_OBJECT)KeyHandle;
125
126 /* Drop a reference on the parent hive */
127 --KeyObject->KeyHive->ReferenceCount;
128}

Referenced by BiAddStoreFromFile(), BiCloseKey(), and BmCloseDataStore().

◆ BiEnumerateSubKeys()

NTSTATUS BiEnumerateSubKeys ( _In_ HANDLE  KeyHandle,
_Out_ PWCHAR **  SubKeyList,
_Out_ PULONG  SubKeyCount 
)

Definition at line 723 of file bootreg.c.

728{
729 PCM_KEY_NODE KeyNode, Node;
730 PBI_KEY_OBJECT KeyObject;
731 ULONG KeyCount;
732 ULONG NameLength, NewTotalNameLength, FinalLength, TotalNameLength;
733 PHHIVE Hive;
734 PWCHAR KeyName, NameEnd;
735 HCELL_INDEX CellIndex;
736 PWCHAR* SubKeys;
738 ULONG i;
739
740 /* Get the key object, node, and hive */
741 KeyObject = (PBI_KEY_OBJECT)KeyHandle;
742 KeyNode = KeyObject->KeyNode;
743 Hive = &KeyObject->KeyHive->Hive.Hive;
744
745 /* Assume it's empty */
746 *SubKeyList = 0;
747 *SubKeyCount = 0;
748
749 /* Initialize locals */
750 KeyCount = 0;
751 SubKeys = 0;
752 TotalNameLength = 0;
753
754 /* Find the first subkey cell index */
755 CellIndex = CmpFindSubKeyByNumber(Hive, KeyNode, KeyCount);
756 while (CellIndex != HCELL_NIL)
757 {
758 /* Move to the next one */
759 KeyCount++;
760
761 /* Get the cell data for it */
762 Node = (PCM_KEY_NODE)HvGetCell(Hive, CellIndex);
763 if (!Node)
764 {
766 }
767
768 /* Check if the value is compressed */
769 if (Node->Flags & KEY_COMP_NAME)
770 {
771 /* Get the compressed name size */
772 NameLength = CmpCompressedNameSize(Node->Name, Node->NameLength);
773 }
774 else
775 {
776 /* Get the real size */
777 NameLength = Node->NameLength;
778 }
779
780 /* Add up the new length, protecting against overflow */
781 NewTotalNameLength = TotalNameLength + NameLength + sizeof(UNICODE_NULL);
782 if (NewTotalNameLength < TotalNameLength)
783 {
785 goto Quickie;
786 }
787
788 /* We're good, use the new length */
789 TotalNameLength = NewTotalNameLength;
790
791 /* Find the next subkey cell index */
792 CellIndex = CmpFindSubKeyByNumber(Hive, KeyNode, KeyCount);
793 }
794
795 /* Were there no keys? We're done, if so */
796 if (!KeyCount)
797 {
798 return STATUS_SUCCESS;
799 }
800
801 /* Safely compute the size of the array needed */
802 Status = RtlULongLongToULong(sizeof(PWCHAR) * KeyCount, &FinalLength);
803 if (!NT_SUCCESS(Status))
804 {
805 goto Quickie;
806 }
807
808 /* Safely add that to the name length */
809 Status = RtlULongAdd(TotalNameLength, FinalLength, &FinalLength);
810 if (!NT_SUCCESS(Status))
811 {
812 goto Quickie;
813 }
814
815 /* Allocate an array big enough for the names and pointers */
816 SubKeys = BlMmAllocateHeap(FinalLength);
817 if (!SubKeys)
818 {
820 goto Quickie;
821 }
822
823 /* Go over each key again */
824 NameEnd = (PWCHAR)&SubKeys[KeyCount];
825 for (i = 0; i < KeyCount; i++)
826 {
827 /* Get the cell index for this subkey */
828 CellIndex = CmpFindSubKeyByNumber(Hive, KeyNode, i);
829 if (CellIndex == HCELL_NIL)
830 {
831 break;
832 }
833
834 /* Get the cell data for it */
835 Node = (PCM_KEY_NODE)HvGetCell(Hive, CellIndex);
836 if (!Node)
837 {
839 goto Quickie;
840 }
841
842 /* Check if the value is compressed */
843 KeyName = Node->Name;
844 if (Node->Flags & KEY_COMP_NAME)
845 {
846 /* Get the compressed name size */
847 NameLength = CmpCompressedNameSize(KeyName, Node->NameLength);
848 CmpCopyCompressedName(NameEnd, NameLength, KeyName, Node->NameLength);
849 }
850 else
851 {
852 /* Get the real size */
853 NameLength = Node->NameLength;
854 RtlCopyMemory(NameEnd, KeyName, NameLength);
855 }
856
857 /* Move the name buffer to the next spot, and NULL-terminate */
858 SubKeys[i] = NameEnd;
859 NameEnd += (NameLength / sizeof(WCHAR));
860 *NameEnd = UNICODE_NULL;
861
862 /* Keep going */
863 NameEnd++;
864 }
865
866 /* Check if the subkeys were empty */
867 if (i == 0)
868 {
869 /* They disappeared in the middle of enumeration */
871 goto Quickie;
872 }
873
874 /* Return the count and the array of names */
875 *SubKeyList = SubKeys;
876 *SubKeyCount = i;
877 SubKeys = NULL;
879
880Quickie:
881 /* On the failure path, free the subkeys if any exist */
882 if (SubKeys)
883 {
884 BlMmFreeHeap(SubKeys);
885 }
886
887 /* All done, return the result */
888 return Status;
889}
struct _CM_KEY_NODE * PCM_KEY_NODE
#define KEY_COMP_NAME
Definition: cmdata.h:35
HCELL_INDEX NTAPI CmpFindSubKeyByNumber(IN PHHIVE Hive, IN PCM_KEY_NODE Node, IN ULONG Number)
Definition: cmindex.c:600
VOID NTAPI CmpCopyCompressedName(OUT PWCHAR Destination, IN ULONG DestinationLength, IN PWCHAR Source, IN ULONG SourceLength)
Definition: cmname.c:56
USHORT NTAPI CmpCompressedNameSize(IN PWCHAR Name, IN ULONG Length)
Definition: cmname.c:95
#define HvGetCell(Hive, Cell)
Definition: cmlib.h:452
#define NULL
Definition: types.h:112
union node Node
Definition: types.h:1255
#define HCELL_NIL
Definition: hivedata.h:110
ULONG HCELL_INDEX
Definition: hivedata.h:105
#define STATUS_REGISTRY_CORRUPT
Definition: ntstatus.h:568
#define STATUS_NAME_TOO_LONG
Definition: ntstatus.h:498
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
Definition: dlist.c:348
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699

Referenced by BiDeleteKey(), and BiEnumerateElements().

◆ BiGetRegistryValue()

NTSTATUS BiGetRegistryValue ( _In_ HANDLE  KeyHandle,
_In_ PWCHAR  ValueName,
_In_ ULONG  Type,
_Out_ PVOID Buffer,
_Out_ PULONG  ValueLength 
)

Definition at line 657 of file bootreg.c.

664{
665 PCM_KEY_NODE KeyNode;
666 PHHIVE KeyHive;
667 UNICODE_STRING ValueString;
668 PBI_KEY_OBJECT KeyObject;
669 PCM_KEY_VALUE KeyValue;
670 PVOID ValueCopy;
671 ULONG Size;
672 HCELL_INDEX CellIndex;
674
675 /* Get the key object, node,and hive */
676 KeyObject = (PBI_KEY_OBJECT)KeyHandle;
677 KeyNode = KeyObject->KeyNode;
678 KeyHive = &KeyObject->KeyHive->Hive.Hive;
679
680 /* Find the value cell index in the list of values */
681 RtlInitUnicodeString(&ValueString, ValueName);
682 CmpFindNameInList(KeyHive,
683 &KeyNode->ValueList,
684 &ValueString,
685 NULL,
686 &CellIndex);
687 if (CellIndex == HCELL_NIL)
688 {
690 }
691
692 /* Get the cell data for it */
693 KeyValue = (PCM_KEY_VALUE)HvGetCell(KeyHive, CellIndex);
694 if (!KeyValue)
695 {
697 }
698
699 /* Make sure the type matches */
700 if (KeyValue->Type != Type)
701 {
703 }
704
705 /* Now get the data cell */
706 ValueData = CmpValueToData(KeyHive, KeyValue, &Size);
707
708 /* Make a copy of it */
709 ValueCopy = BlMmAllocateHeap(Size);
710 if (!ValueCopy)
711 {
712 return STATUS_NO_MEMORY;
713 }
714
715 /* Copy it in the buffer, and return it and its size */
716 RtlCopyMemory(ValueCopy, ValueData, Size);
717 *Buffer = ValueCopy;
718 *ValueLength = Size;
719 return STATUS_SUCCESS;
720}
Type
Definition: Type.h:7
Definition: bufpool.h:45
struct _CM_KEY_VALUE * PCM_KEY_VALUE
PCELL_DATA NTAPI CmpValueToData(IN PHHIVE Hive, IN PCM_KEY_VALUE Value, OUT PULONG Length)
Definition: cmvalue.c:167
BOOLEAN NTAPI CmpFindNameInList(IN PHHIVE Hive, IN PCHILD_LIST ChildList, IN PCUNICODE_STRING Name, OUT PULONG ChildIndex OPTIONAL, OUT PHCELL_INDEX CellIndex)
Definition: cmname.c:149
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:312
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define STATUS_OBJECT_TYPE_MISMATCH
Definition: ntstatus.h:273
CHILD_LIST ValueList
Definition: cmdata.h:103
ULONG Type
Definition: cmdata.h:128
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG ValueLength
Definition: wdfregistry.h:275

Referenced by BiEnumerateElements(), and BiGetObjectDescription().

◆ BiLoadHive()

NTSTATUS BiLoadHive ( _In_ PBL_FILE_PATH_DESCRIPTOR  FilePath,
_Out_ PHANDLE  HiveHandle 
)

Definition at line 369 of file bootreg.c.

373{
374 ULONG DeviceId;
375 PHBASE_BLOCK BaseBlock, NewBaseBlock;
376 PBI_KEY_OBJECT KeyObject;
378 PBL_DEVICE_DESCRIPTOR BcdDevice;
379 ULONG PathLength, DeviceLength, HiveSize, HiveLength, NewHiveSize;
380 PWCHAR HiveName, LogName;
381 BOOLEAN HaveWriteAccess;
383 PVOID LogData;
384 PHHIVE Hive;
385 UNICODE_STRING KeyString;
387 HCELL_INDEX CellIndex;
388
389 /* Initialize variables */
390 DeviceId = -1;
391 BaseBlock = NULL;
392 BcdHive = NULL;
393 KeyObject = NULL;
394 LogData = NULL;
395 LogName = NULL;
396
397 /* Initialize the crypto seed */
399 {
400 HvSymcryptSeed = 0x82EF4D887A4E55C5;
402 }
403
404 /* Extract and validate the input path */
405 BcdDevice = (PBL_DEVICE_DESCRIPTOR)&FilePath->Path;
406 PathLength = FilePath->Length;
407 DeviceLength = BcdDevice->Size;
408 HiveName = (PWCHAR)((ULONG_PTR)BcdDevice + BcdDevice->Size);
409 if (PathLength <= DeviceLength)
410 {
411 /* Doesn't make sense, bail out */
413 goto Quickie;
414 }
415
416 /* Attempt to open the underlying device for RW access */
417 HaveWriteAccess = TRUE;
418 Status = BlpDeviceOpen(BcdDevice,
420 0,
421 &DeviceId);
422 if (!NT_SUCCESS(Status))
423 {
424 /* Try for RO access instead */
425 HaveWriteAccess = FALSE;
426 Status = BlpDeviceOpen(BcdDevice, BL_DEVICE_READ_ACCESS, 0, &DeviceId);
427 if (!NT_SUCCESS(Status))
428 {
429 /* No access at all -- bail out */
430 goto Quickie;
431 }
432 }
433
434 /* Now try to load the hive on disk */
437 HiveName,
438 (PVOID*)&BaseBlock,
439 &HiveSize,
440 0,
441 FALSE,
442 NULL,
443 NULL);
444 if (!NT_SUCCESS(Status))
445 {
446 EfiPrintf(L"Hive read failure: % lx\r\n", Status);
447 goto Quickie;
448 }
449
450 /* Allocate a hive structure */
451 BcdHive = BlMmAllocateHeap(sizeof(*BcdHive));
452 if (!BcdHive)
453 {
455 goto Quickie;
456 }
457
458 /* Initialize it */
459 RtlZeroMemory(BcdHive, sizeof(*BcdHive));
460 BcdHive->BaseBlock = BaseBlock;
461 BcdHive->HiveSize = HiveSize;
462 if (HaveWriteAccess)
463 {
465 }
466
467 /* Make sure the hive was at least one bin long */
468 if (HiveSize < sizeof(*BaseBlock))
469 {
471 goto Quickie;
472 }
473
474 /* Make sure the hive contents are at least one bin long */
475 HiveLength = BaseBlock->Length;
476 if (BaseBlock->Length < sizeof(*BaseBlock))
477 {
479 goto Quickie;
480 }
481
482 /* Validate the initial bin (the base block) */
483 if (!HvIsInPlaceBaseBlockValid(BaseBlock))
484 {
485 EfiPrintf(L"Recovery not implemented\r\n");
487 goto Quickie;
488 }
489
490 /* Check if there's log recovery that needs to happen */
491 if (BaseBlock->Sequence1 != BaseBlock->Sequence2)
492 {
493 EfiPrintf(L"Log fix not implemented: %lx %lx\r\n");
495 goto Quickie;
496 }
497
498 /*
499 * Check if the whole hive doesn't fit in the buffer.
500 * Note: HiveLength does not include the size of the baseblock itself
501 */
502 if (HiveSize < (HiveLength + sizeof(*BaseBlock)))
503 {
504 EfiPrintf(L"Need bigger hive buffer path\r\n");
505
506 /* Allocate a slightly bigger buffer */
507 NewHiveSize = HiveLength + sizeof(*BaseBlock);
508 Status = MmPapAllocatePagesInRange((PVOID*)&NewBaseBlock,
510 NewHiveSize >> PAGE_SHIFT,
511 0,
512 0,
513 NULL,
514 0);
515 if (!NT_SUCCESS(Status))
516 {
517 goto Quickie;
518 }
519
520 /* Copy the current data in there */
521 RtlCopyMemory(NewBaseBlock, BaseBlock, HiveSize);
522
523 /* Free the old data */
525
526 /* Update our pointers */
527 BaseBlock = NewBaseBlock;
528 HiveSize = NewHiveSize;
529 BcdHive->BaseBlock = BaseBlock;
530 BcdHive->HiveSize = HiveSize;
531 }
532
533 /* Check if any log stuff needs to happen */
534 if (LogData)
535 {
536 EfiPrintf(L"Log fix not implemented: %lx %lx\r\n");
538 goto Quickie;
539 }
540
541 /* Call Hv to setup the hive library */
543 if (!NT_SUCCESS(Status))
544 {
545 goto Quickie;
546 }
547
548 /* Now get the root node */
549 Hive = &BcdHive->Hive.Hive;
551 if (!RootNode)
552 {
554 goto Quickie;
555 }
556
557 /* Find the Objects subkey under it to see if it's a real BCD hive */
558 RtlInitUnicodeString(&KeyString, L"Objects");
559 CellIndex = CmpFindSubKeyByName(Hive, RootNode, &KeyString);
560 if (CellIndex == HCELL_NIL)
561 {
562 EfiPrintf(L"No OBJECTS subkey found!\r\n");
564 goto Quickie;
565 }
566
567 /* This is a valid BCD hive, store its root node here */
568 BcdHive->RootNode = RootNode;
569
570 /* Allocate a copy of the file path */
571 BcdHive->FilePath = BlMmAllocateHeap(FilePath->Length);
572 if (!BcdHive->FilePath)
573 {
575 goto Quickie;
576 }
577
578 /* Make a copy of it */
579 RtlCopyMemory(BcdHive->FilePath, FilePath, FilePath->Length);
580
581 /* Create a key object to describe the rot */
582 KeyObject = BlMmAllocateHeap(sizeof(*KeyObject));
583 if (!KeyObject)
584 {
586 goto Quickie;
587 }
588
589 /* Fill out the details */
590 KeyObject->KeyNode = RootNode;
591 KeyObject->KeyHive = BcdHive;
592 KeyObject->KeyName = NULL;
593 KeyObject->KeyCell = Hive->BaseBlock->RootCell;
594
595 /* One reference for the key object, plus one lifetime reference */
596 BcdHive->ReferenceCount = 2;
597
598 /* This is the hive handle */
599 *HiveHandle = KeyObject;
600
601 /* We're all good */
603
604Quickie:
605 /* If we had a log name, free it */
606 if (LogName)
607 {
608 BlMmFreeHeap(LogName);
609 }
610
611 /* If we had logging data, free it */
612 if (LogData)
613 {
615 }
616
617 /* Check if this is the failure path */
618 if (!NT_SUCCESS(Status))
619 {
620 /* If we mapped the hive, free it */
621 if (BaseBlock)
622 {
624 }
625
626 /* If we opened the device, close it */
627 if (DeviceId != -1)
628 {
629 BlDeviceClose(DeviceId);
630 }
631
632 /* Did we create a hive object? */
633 if (BcdHive)
634 {
635 /* Free the file path if we made a copy of it */
636 if (BcdHive->FilePath)
637 {
638 BlMmFreeHeap(BcdHive->FilePath);
639 }
640
641 /* Free the hive itself */
643 }
644
645 /* Finally, free the root key object if we created one */
646 if (KeyObject)
647 {
648 BlMmFreeHeap(KeyObject);
649 }
650 }
651
652 /* Return the final status */
653 return Status;
654}
static USHORT PathLength
PCWSTR FilePath
unsigned char BOOLEAN
#define BL_DEVICE_READ_ACCESS
Definition: bl.h:152
struct _BL_DEVICE_DESCRIPTOR * PBL_DEVICE_DESCRIPTOR
#define BL_DEVICE_WRITE_ACCESS
Definition: bl.h:153
NTSTATUS MmPapAllocatePagesInRange(_Inout_ PVOID *PhysicalAddress, _In_ BL_MEMORY_TYPE MemoryType, _In_ ULONGLONG Pages, _In_ ULONG Attributes, _In_ ULONG Alignment, _In_opt_ PBL_ADDRESS_RANGE Range, _In_ ULONG Type)
Definition: pagealloc.c:707
NTSTATUS BlpDeviceOpen(_In_ PBL_DEVICE_DESCRIPTOR Device, _In_ ULONG Flags, _In_ ULONG Unknown, _Out_ PULONG DeviceId)
Definition: device.c:2111
NTSTATUS BlDeviceClose(_In_ ULONG DeviceId)
Definition: device.c:2073
NTSTATUS BlImgLoadImageWithProgress2(_In_ ULONG DeviceId, _In_ BL_MEMORY_TYPE MemoryType, _In_ PWCHAR FileName, _Inout_ PVOID *MappedBase, _Inout_ PULONG MappedSize, _In_ ULONG ImageFlags, _In_ BOOLEAN ShowProgress, _Out_opt_ PUCHAR *HashBuffer, _Out_opt_ PULONG HashSize)
Definition: image.c:358
NTSTATUS BiInitializeAndValidateHive(_In_ PBI_KEY_HIVE Hive)
Definition: bootreg.c:316
ULONGLONG HvSymcryptSeed
Definition: bootreg.c:43
BOOLEAN BiHiveHashLibraryInitialized
Definition: bootreg.c:42
BOOLEAN HvIsInPlaceBaseBlockValid(_In_ PHBASE_BLOCK BaseBlock)
Definition: bootreg.c:48
HCELL_INDEX NTAPI CmpFindSubKeyByName(IN PHHIVE Hive, IN PCM_KEY_NODE Parent, IN PCUNICODE_STRING SearchName)
Definition: cmindex.c:683
#define FALSE
Definition: types.h:117
#define ULONG_PTR
Definition: config.h:101
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
PCONFIGURATION_COMPONENT_DATA RootNode
Definition: macharm.c:19
static CMHIVE BcdHive
Definition: registry.c:62
ULONG Flags
Definition: cmlib.h:354
ULONG Length
Definition: hivedata.h:171
HCELL_INDEX RootCell
Definition: hivedata.h:168
ULONG Sequence1
Definition: hivedata.h:147
ULONG Sequence2
Definition: hivedata.h:148
PHBASE_BLOCK BaseBlock
Definition: hivedata.h:328
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

Referenced by BiAddStoreFromFile().

◆ BiOpenKey()

NTSTATUS BiOpenKey ( _In_ HANDLE  ParentHandle,
_In_ PWCHAR  KeyName,
_Out_ PHANDLE  Handle 
)

Definition at line 186 of file bootreg.c.

191{
193 PBI_KEY_HIVE ParentHive;
195 SIZE_T NameLength, SubNameLength, NameBytes;
196 PWCHAR NameStart, NameBuffer;
197 UNICODE_STRING KeyString;
198 HCELL_INDEX KeyCell;
199 PHHIVE Hive;
200 PCM_KEY_NODE ParentNode;
201
202 /* Convert from a handle to our key object */
203 ParentKey = (PBI_KEY_OBJECT)ParentHandle;
204
205 /* Extract the hive and node information */
206 ParentHive = ParentKey->KeyHive;
207 ParentNode = ParentKey->KeyNode;
208 Hive = &ParentKey->KeyHive->Hive.Hive;
209
210 /* Initialize variables */
211 KeyCell = HCELL_NIL;
213 NameBuffer = NULL;
214
215 /* Loop as long as there's still portions of the key name in play */
216 NameLength = wcslen(KeyName);
217 while (NameLength)
218 {
219 /* Find the first path separator */
221 if (NameStart)
222 {
223 /* Look only at the key before the separator */
224 SubNameLength = NameStart - KeyName;
225 ++NameStart;
226 }
227 else
228 {
229 /* No path separator, this is the final leaf key */
230 SubNameLength = NameLength;
231 }
232
233 /* Free the name buffer from the previous pass if needed */
234 if (NameBuffer)
235 {
236 BlMmFreeHeap(NameBuffer);
237 }
238
239 /* Allocate a buffer to hold the name of this specific subkey only */
240 NameBytes = SubNameLength * sizeof(WCHAR);
241 NameBuffer = BlMmAllocateHeap(NameBytes + sizeof(UNICODE_NULL));
242 if (!NameBuffer)
243 {
245 goto Quickie;
246 }
247
248 /* Copy and null-terminate the name of the subkey */
249 RtlCopyMemory(NameBuffer, KeyName, NameBytes);
250 NameBuffer[SubNameLength] = UNICODE_NULL;
251
252 /* Convert it into a UNICODE_STRING and try to find it */
253 RtlInitUnicodeString(&KeyString, NameBuffer);
254 KeyCell = CmpFindSubKeyByName(Hive, ParentNode, &KeyString);
255 if (KeyCell == HCELL_NIL)
256 {
258 goto Quickie;
259 }
260
261 /* We found it -- get the key node out of it */
262 ParentNode = (PCM_KEY_NODE)HvGetCell(Hive, KeyCell);
263 if (!ParentNode)
264 {
266 goto Quickie;
267 }
268
269 /* Update the key name to the next remaining path element */
270 KeyName = NameStart;
271 if (NameStart)
272 {
273 /* Update the length to the remainder of the path */
274 NameLength += -1 - SubNameLength;
275 }
276 else
277 {
278 /* There's nothing left, this was the leaf key */
279 NameLength = 0;
280 }
281 }
282
283 /* Allocate a key object */
284 NewKey = BlMmAllocateHeap(sizeof(*NewKey));
285 if (!NewKey)
286 {
287 /* Bail out if we had no memory for it */
289 goto Quickie;
290 }
291
292 /* Fill out the key object data */
293 NewKey->KeyNode = ParentNode;
294 NewKey->KeyHive = ParentHive;
295 NewKey->KeyName = NameBuffer;
296 NewKey->KeyCell = KeyCell;
297
298 /* Add a reference to the hive */
299 ++ParentHive->ReferenceCount;
300
301 /* Return the object back to the caller */
302 *Handle = NewKey;
303
304Quickie:
305 /* If we had a name buffer, free it */
306 if (NameBuffer)
307 {
308 BlMmFreeHeap(NameBuffer);
309 }
310
311 /* Return status of the open operation */
312 return Status;
313}
#define OBJ_NAME_PATH_SEPARATOR
Definition: arcname_tests.c:25
#define wcschr
Definition: compat.h:17
ULONG Handle
Definition: gdb_input.c:15
_Must_inspect_result_ _In_opt_ WDFKEY ParentKey
Definition: wdfregistry.h:69

Referenced by BcdDeleteElement(), BcdOpenObject(), BiAddStoreFromFile(), BiDeleteKey(), BiEnumerateElements(), and BiGetObjectDescription().

◆ BlAppendBootOptionBoolean()

NTSTATUS BlAppendBootOptionBoolean ( _In_ PBL_LOADED_APPLICATION_ENTRY  AppEntry,
_In_ ULONG  OptionId,
_In_ BOOLEAN  Value 
)

Definition at line 625 of file bcdopt.c.

630{
632 PBL_BCD_OPTION Option;
633
634 /* Allocate space for the entry -- remember BOOLEANs are USHORTs in BCD */
635 Option = BlMmAllocateHeap(sizeof(*Option) + sizeof(USHORT));
636 if (!Option)
637 {
638 return STATUS_NO_MEMORY;
639 }
640
641 /* Initialize it and set the boolean to TRUE */
642 RtlZeroMemory(Option, sizeof(*Option) + sizeof(USHORT));
643 Option->DataSize = sizeof(USHORT);
644 Option->Type = OptionId;
645 Option->DataOffset = sizeof(*Option);
646 *(PBOOLEAN)(Option + 1) = Value;
647
648 /* Append it */
649 Status = BlAppendBootOptions(AppEntry, Option);
650
651 /* We're all done, free our initial option */
652 BlMmFreeHeap(Option);
653 return Status;
654}
NTSTATUS BlAppendBootOptions(_In_ PBL_LOADED_APPLICATION_ENTRY AppEntry, _In_ PBL_BCD_OPTION Options)
Definition: bcdopt.c:737
unsigned short USHORT
Definition: pedump.c:61
ULONG DataSize
Definition: bl.h:848
ULONG Type
Definition: bl.h:846
ULONG DataOffset
Definition: bl.h:847
unsigned char * PBOOLEAN
Definition: typedefs.h:53
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by BmpLaunchBootEntry(), and OslPrepareTarget().

◆ BlAppendBootOptionInteger()

NTSTATUS BlAppendBootOptionInteger ( _In_ PBL_LOADED_APPLICATION_ENTRY  AppEntry,
_In_ ULONG  OptionId,
_In_ ULONGLONG  Value 
)

Definition at line 657 of file bcdopt.c.

662{
664 PBL_BCD_OPTION Option;
665
666 /* Allocate space for the entry */
667 Option = BlMmAllocateHeap(sizeof(*Option) + sizeof(Value));
668 if (!Option)
669 {
670 return STATUS_NO_MEMORY;
671 }
672
673 /* Initialize it and set the integer to the given value */
674 RtlZeroMemory(Option, sizeof(*Option) + sizeof(Value));
675 Option->DataSize = sizeof(Value);
676 Option->Type = OptionId;
677 Option->DataOffset = sizeof(*Option);
678 *(PULONGLONG)(Option + 1) = Value;
679
680 /* Append it */
681 Status = BlAppendBootOptions(AppEntry, Option);
682
683 /* We're all done, free our initial option */
684 BlMmFreeHeap(Option);
685 return Status;
686}
__GNU_EXTENSION typedef unsigned __int64 * PULONGLONG
Definition: ntbasedef.h:383

Referenced by BlImgLoadBootApplication(), and BmLaunchRecoverySequence().

◆ BlAppendBootOptions()

NTSTATUS BlAppendBootOptions ( _In_ PBL_LOADED_APPLICATION_ENTRY  AppEntry,
_In_ PBL_BCD_OPTION  Options 
)

Definition at line 737 of file bcdopt.c.

741{
742 ULONG OptionsSize, CurrentSize;
743 PBL_BCD_OPTION NewOptions, CurrentOptions, NextOption;
745 ULONG CurrentOffset;
746
747 /* Get the current options */
748 CurrentOptions = AppEntry->BcdData;
749
750 /* Calculate the size of the current, and the appended options */
751 CurrentSize = BlGetBootOptionListSize(CurrentOptions);
752 OptionsSize = BlGetBootOptionListSize(Options);
753
754 /* Allocate a buffer for the concatenated (new) options */
755 NewOptions = BlMmAllocateHeap(CurrentSize + OptionsSize);
756 if (!NewOptions)
757 {
758 return STATUS_NO_MEMORY;
759 }
760
761 /* Copy the old options, and the ones to be added */
762 RtlCopyMemory(NewOptions, CurrentOptions, CurrentSize);
763 RtlCopyMemory((PVOID)((ULONG_PTR)NewOptions + CurrentSize),
764 Options,
765 OptionsSize);
766
767 /* We made it! */
769
770 /* Scan through to the last option in the list */
771 CurrentOffset = 0;
772 do
773 {
774 NextOption = (PBL_BCD_OPTION)((ULONG_PTR)NewOptions + CurrentOffset);
775 CurrentOffset = NextOption->NextEntryOffset;
776 } while (CurrentOffset);
777
778 /* Every other option now has to have its offset adjusted */
779 do
780 {
781 NextOption->NextEntryOffset += CurrentSize;
782 NextOption = (PBL_BCD_OPTION)((ULONG_PTR)NewOptions + NextOption->NextEntryOffset);
783 } while (NextOption->NextEntryOffset);
784
785 /* If we already had internal options, free them */
786 if (AppEntry->Flags & BL_APPLICATION_ENTRY_BCD_OPTIONS_INTERNAL)
787 {
788 BlMmFreeHeap(AppEntry->BcdData);
789 }
790
791 /* Write the new pointer */
792 AppEntry->BcdData = NewOptions;
793
794 /* Options are now internal, not external */
795 AppEntry->Flags &= ~BL_APPLICATION_ENTRY_BCD_OPTIONS_EXTERNAL;
797 return Status;
798}
ULONG BlGetBootOptionListSize(_In_ PBL_BCD_OPTION BcdOption)
Definition: bcdopt.c:79
struct _BL_BCD_OPTION * PBL_BCD_OPTION
#define BL_APPLICATION_ENTRY_BCD_OPTIONS_INTERNAL
Definition: bl.h:69
static char * NextOption(const char *const ostr)
Definition: getopt.c:31
uint32_t ULONG_PTR
Definition: typedefs.h:65
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
Definition: wdfdevice.h:3534

Referenced by BlAppendBootOptionBoolean(), BlAppendBootOptionInteger(), BlAppendBootOptionString(), and BmpUpdateApplicationOptions().

◆ BlAppendBootOptionString()

NTSTATUS BlAppendBootOptionString ( _In_ PBL_LOADED_APPLICATION_ENTRY  AppEntry,
_In_ ULONG  OptionId,
_In_ PWCHAR  OptionString 
)

Definition at line 689 of file bcdopt.c.

694{
696 ULONG StringSize;
697 PBL_BCD_OPTION Option;
698
699 /* Get the length in bytes */
700 Status = RtlULongLongToULong(wcslen(OptionString) * sizeof(WCHAR),
701 &StringSize);
702 if (!NT_SUCCESS(Status))
703 {
704 return Status;
705 }
706
707 /* Add a NULL-terminator */
708 Status = RtlULongAdd(StringSize, sizeof(UNICODE_NULL), &StringSize);
709 if (!NT_SUCCESS(Status))
710 {
711 return Status;
712 }
713
714 /* Allocate space for the entry */
715 Option = BlMmAllocateHeap(sizeof(*Option) + StringSize);
716 if (!Option)
717 {
718 return STATUS_NO_MEMORY;
719 }
720
721 /* Initialize it and copy the string value */
722 RtlZeroMemory(Option, sizeof(*Option) + StringSize);
723 Option->DataSize = StringSize;
724 Option->Type = OptionId;
725 Option->DataOffset = sizeof(*Option);
726 wcsncpy((PWCHAR)Option + 1, OptionString, StringSize / sizeof(WCHAR));
727
728 /* Append it */
729 Status = BlAppendBootOptions(AppEntry, Option);
730
731 /* We're all done, free our initial option */
732 BlMmFreeHeap(Option);
733 return Status;
734}
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)

Referenced by BmpPopulateBootEntryList(), and OslpRemoveInternalApplicationOptions().

◆ BlArchCpuId()

VOID BlArchCpuId ( _In_ ULONG  Function,
_In_ ULONG  SubFunction,
_Out_ PCPU_INFO  Result 
)

Definition at line 924 of file util.c.

929{
930#if defined(_M_IX86) || defined(_M_X64)
931 /* Use the intrinsic */
932 __cpuidex((INT*)Result->AsUINT32, Function, SubFunction);
933#endif
934}
_In_ CDROM_SCAN_FOR_SPECIAL_INFO _In_ PCDROM_SCAN_FOR_SPECIAL_HANDLER Function
Definition: cdrom.h:1156
__INTRIN_INLINE void __cpuidex(int CPUInfo[4], int InfoType, int ECXValue)
Definition: intrin_x86.h:1649
int32_t INT
Definition: typedefs.h:58
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by BlArchGetCpuVendor(), BlArchGetPerformanceCounter(), MmArchInitialize(), OslMain(), and OslpMain().

◆ BlArchGetCpuVendor()

CPU_VENDORS BlArchGetCpuVendor ( VOID  )

Definition at line 937 of file util.c.

940{
941 CPU_INFO CpuInfo;
942 INT Temp;
943
944 /* Get the CPU Vendor */
945 BlArchCpuId(0, 0, &CpuInfo);
946#if defined(_M_IX86) || defined(_M_X64)
947 Temp = CpuInfo.Ecx;
948 CpuInfo.Ecx = CpuInfo.Edx;
949 CpuInfo.Edx = Temp;
950
951 /* Check against supported values */
952 if (!strncmp((PCHAR)&CpuInfo.Ebx, "GenuineIntel", 12))
953 {
954 return CPU_INTEL;
955 }
956 if (!strncmp((PCHAR)&CpuInfo.Ebx, "AuthenticAMD", 12))
957 {
958 return CPU_AMD;
959 }
960 if (!strncmp((PCHAR)&CpuInfo.Ebx, "CentaurHauls", 12))
961 {
962 return CPU_VIA;
963 }
964#ifdef _M_IX86
965 if (!strncmp((PCHAR)&CpuInfo.Ebx, "CyrixInstead", 12))
966 {
967 return CPU_CYRIX;
968 }
969 if (!strncmp((PCHAR)&CpuInfo.Ebx, "GenuineTMx86", 12))
970 {
971 return CPU_TRANSMETA;
972 }
973 if (!strncmp((PCHAR)&CpuInfo.Ebx, "RiseRiseRise", 12))
974 {
975 return CPU_RISE;
976 }
977#endif // _M_IX86
978#else // defined(_M_IX86) || defined(_M_X64)
979 EfiPrintf(L"BlArchGetCpuVendor not implemented for this platform.\r\n");
980#endif
981 /* Other */
982 return CPU_UNKNOWN;
983}
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
VOID BlArchCpuId(_In_ ULONG Function, _In_ ULONG SubFunction, _Out_ PCPU_INFO Result)
Definition: util.c:924
@ CPU_VIA
Definition: ketypes.h:107
@ CPU_INTEL
Definition: ketypes.h:106
@ CPU_UNKNOWN
Definition: ketypes.h:104
@ CPU_AMD
Definition: ketypes.h:105
@ CPU_RISE
Definition: ketypes.h:96
@ CPU_CYRIX
Definition: ketypes.h:92
@ CPU_TRANSMETA
Definition: ketypes.h:93
char * PCHAR
Definition: typedefs.h:51
ULONG Ebx
Definition: ketypes.h:367
ULONG Ecx
Definition: ketypes.h:368
ULONG Edx
Definition: ketypes.h:369

Referenced by OslpMain().

◆ BlArchGetPerformanceCounter()

ULONGLONG BlArchGetPerformanceCounter ( VOID  )

Definition at line 902 of file util.c.

905{
906#if defined(_M_IX86) || defined(_M_X64)
907 CPU_INFO CpuInfo;
908
909 /* Serialize with CPUID, if it exists */
910 if (Archx86IsCpuidSupported())
911 {
912 BlArchCpuId(0, 0, &CpuInfo);
913 }
914
915 /* Read the TSC */
916 return __rdtsc();
917#else
918 EfiPrintf(L"BlArchGetPerformanceCounter not implemented for this platform.\r\n");
919 return 0;
920#endif
921}
PPC_QUAL unsigned long long __rdtsc(void)
Definition: intrin_ppc.h:688

Referenced by MmArchInitialize(), and OslPrepareTarget().

◆ BlArchIsCpuIdFunctionSupported()

BOOLEAN BlArchIsCpuIdFunctionSupported ( _In_ ULONG  Function)

Definition at line 856 of file util.c.

859{
860#if defined(_M_IX86) || defined(_M_X64)
862 INT CpuInfo[4];
863
864 /* Check if the CPU supports this instruction */
865 Supported = Archx86IsCpuidSupported();
866 if (!Supported)
867 {
868 return FALSE;
869 }
870
871 /* Check if it's the extended function */
872 if (Function >= 0x80000000)
873 {
874 /* Check if extended functions are supported */
875 __cpuid(CpuInfo, 0x80000000);
876 if ((CpuInfo[0] & 0xFFFFFF00) != 0x80000000)
877 {
878 /* Nope */
879 return FALSE;
880 }
881 }
882 else
883 {
884 /* It's a regular function, get the maximum one supported */
885 __cpuid(CpuInfo, 0);
886 }
887
888 /* Check if our function is within bounds */
889 if (Function <= CpuInfo[0])
890 {
891 return TRUE;
892 }
893#else
894 EfiPrintf(L"BlArchIsCpuIdFunctionSupported not implemented for this platform.\r\n");
895#endif
896
897 /* Nope */
898 return FALSE;
899}
@ Supported
Definition: classpnp.h:733
PPC_QUAL void __cpuid(int CPUInfo[], const int InfoType)
Definition: intrin_ppc.h:682

Referenced by MmArchInitialize(), and OslMain().

◆ BlBdDebuggerEnabled()

BOOLEAN BlBdDebuggerEnabled ( VOID  )

Definition at line 53 of file debug.c.

56{
58
59 /* Check if the debugger is initialized */
61
62 /* Check if it's currently active */
63 Enabled = FALSE;
65 {
66 /* Yep! */
67 Enabled = TRUE;
68 }
69
70 /* Return enabled state */
71 return Enabled;
72}
BOOLEAN BdDebuggerInitialized(VOID)
Definition: debug.c:25
BOOLEAN BdDebuggerNotPresent
Definition: debug.c:16
@ Enabled
Definition: mountmgr.h:159
@ Initialized
Definition: ketypes.h:388

Referenced by BlBdPullRemoteFile(), BlImgLoadBootApplication(), BlStatusError(), BlStatusPrint(), and MmHapReportHeapCorruption().

◆ BlBdPullRemoteFile()

NTSTATUS BlBdPullRemoteFile ( _In_ PWCHAR  FilePath,
_Out_ PVOID  BaseAddress,
_Out_ PULONGLONG  FileSize 
)

Definition at line 34 of file debug.c.

39{
40 /* Is the boot debugger enabled? */
42 {
43 /* Nothing to pull */
45 }
46
47 /* TODO */
48 EfiPrintf(L"Todo\r\n");
50}
BOOLEAN BlBdDebuggerEnabled(VOID)
Definition: debug.c:53
#define STATUS_DEBUGGER_INACTIVE
Definition: debugger.c:30

Referenced by ImgpOpenFile().

◆ BlCopyBootOptions()

NTSTATUS BlCopyBootOptions ( _In_ PBL_BCD_OPTION  OptionList,
_Out_ PBL_BCD_OPTION CopiedOptions 
)

Definition at line 597 of file bcdopt.c.

601{
603 ULONG OptionSize;
605
606 /* Assume no options */
608 *CopiedOptions = NULL;
609
610 /* Get the size of the list and allocate a copy for it */
612 Options = BlMmAllocateHeap(OptionSize);
613 if (!Options)
614 {
615 return STATUS_NO_MEMORY;
616 }
617
618 /* Make the copy and return it to the caller */
619 RtlCopyMemory(Options, OptionList, OptionSize);
620 *CopiedOptions = Options;
621 return Status;
622}
static PCWSTR OptionList[]
Definition: tasklist.c:12

Referenced by BmMain().

◆ BlDestroyBootEntry()

VOID BlDestroyBootEntry ( _In_ PBL_LOADED_APPLICATION_ENTRY  AppEntry)

Definition at line 442 of file bootlib.c.

445{
446 /* Check if we had allocated BCD options */
447 if (AppEntry->Flags & BL_APPLICATION_ENTRY_BCD_OPTIONS_INTERNAL)
448 {
449 BlMmFreeHeap(AppEntry->BcdData);
450 }
451
452 /* Free the entry itself */
453 BlMmFreeHeap(AppEntry);
454}

Referenced by BmLaunchRecoverySequence(), BmMain(), BmpGetSelectedBootEntry(), and BmpPopulateBootEntryList().

◆ BlDestroyLibrary()

VOID BlDestroyLibrary ( VOID  )

Definition at line 405 of file bootlib.c.

408{
409 EfiPrintf(L"Destroy not yet implemented\r\n");
410 return;
411}

Referenced by BmMain(), and OslMain().

◆ BlDeviceClose()

NTSTATUS BlDeviceClose ( _In_ ULONG  DeviceId)

Definition at line 2073 of file device.c.

2076{
2077 PBL_DEVICE_ENTRY DeviceEntry;
2078
2079 /* Validate the device ID */
2080 if (DmTableEntries <= DeviceId)
2081 {
2083 }
2084
2085 /* Make sure there's a device there */
2086 DeviceEntry = DmDeviceTable[DeviceId];
2087 if (DeviceEntry == NULL)
2088 {
2090 }
2091
2092 /* Make sure the device is active */
2093 if (!(DeviceEntry->Flags & BL_DEVICE_ENTRY_OPENED))
2094 {
2096 }
2097
2098 /* Drop a reference and check if it's the last one */
2099 DeviceEntry->ReferenceCount--;
2100 if (!DeviceEntry->ReferenceCount)
2101 {
2102 /* Mark the device as inactive */
2103 DeviceEntry->Flags = ~BL_DEVICE_ENTRY_OPENED;
2104 }
2105
2106 /* We're good */
2107 return STATUS_SUCCESS;
2108}
#define BL_DEVICE_ENTRY_OPENED
Definition: bl.h:155
PVOID * DmDeviceTable
Definition: device.c:24
ULONG DmTableEntries
Definition: device.c:22
Definition: bl.h:1261
ULONG Flags
Definition: bl.h:1263
ULONG ReferenceCount
Definition: bl.h:1265

Referenced by BiLoadHive(), BlBsdInitializeLog(), BlImgLoadBootApplication(), and BmFwInitializeBootDirectoryPath().

◆ BlDeviceGetInformation()

NTSTATUS BlDeviceGetInformation ( _In_ ULONG  DeviceId,
_Out_ PBL_DEVICE_INFORMATION  DeviceInformation 
)

Definition at line 682 of file device.c.

686{
687 PBL_DEVICE_ENTRY DeviceEntry;
688
689 /* This parameter is not optional */
690 if (!DeviceInformation)
691 {
693 }
694
695 /* Make sure the device ID is valid */
696 if (DmTableEntries <= DeviceId)
697 {
699 }
700
701 /* Get the device entry */
702 DeviceEntry = DmDeviceTable[DeviceId];
703 if (!DeviceEntry)
704 {
706 }
707
708 /* Make sure the device is open */
709 if (!(DeviceEntry->Flags & BL_DEVICE_ENTRY_OPENED))
710 {
712 }
713
714 /* Return the device information */
715 DeviceInformation->DeviceType = DeviceEntry->DeviceDescriptor->DeviceType;
716 return DeviceEntry->Callbacks.GetInformation(DeviceEntry, DeviceInformation);
717}
PBL_DEVICE_GET_INFORMATION GetInformation
Definition: bl.h:1253
DEVICE_TYPE DeviceType
Definition: bl.h:950
PBL_DEVICE_DESCRIPTOR DeviceDescriptor
Definition: bl.h:1268
BL_DEVICE_CALLBACKS Callbacks
Definition: bl.h:1266

Referenced by BlDeviceReadAtOffset(), BlFileOpen(), BlFileReadEx(), EtfspCheckEtfs(), and FatMount().

◆ BlDeviceIsVirtualPartitionDevice()

BOOLEAN BlDeviceIsVirtualPartitionDevice ( _In_ PBL_DEVICE_DESCRIPTOR  InputDevice,
_Outptr_ PBL_DEVICE_DESCRIPTOR VirtualDevice 
)

Definition at line 612 of file device.c.

616{
617 BOOLEAN IsVirtual;
618 PBL_LOCAL_DEVICE ParentDisk;
619
620 /* Assume it isn't */
621 IsVirtual = FALSE;
622
623 /* Check if this is a partition device */
624 if ((InputDevice->DeviceType == LegacyPartitionDevice) ||
625 (InputDevice->DeviceType == PartitionDevice))
626 {
627 /* Check if the parent disk is a VHD */
628 ParentDisk = &InputDevice->Partition.Disk;
629 if (ParentDisk->Type == VirtualDiskDevice)
630 {
631 /* This is a virtual partition device -- does the caller want it? */
632 IsVirtual = TRUE;
633 if (VirtualDevice)
634 {
635 *VirtualDevice = (PBL_DEVICE_DESCRIPTOR)(&ParentDisk->VirtualHardDisk + 1);
636 }
637 }
638 }
639
640 /* Return */
641 return IsVirtual;
642}
BL_HARDDISK_DEVICE VirtualHardDisk
Definition: bl.h:935
BL_LOCAL_DEVICE_TYPE Type
Definition: bl.h:925

Referenced by OslPrepareTarget().

◆ BlDeviceReadAtOffset()

NTSTATUS BlDeviceReadAtOffset ( _In_ ULONG  DeviceId,
_In_ ULONG  Size,
_In_ ULONGLONG  Offset,
_In_ PVOID  Buffer,
_Out_ PULONG  BytesRead 
)

Definition at line 773 of file device.c.

780{
783
784 /* Get the current block and offset */
786 if (!NT_SUCCESS(Status))
787 {
788 return Status;
789 }
790
791 /* Get the block and block-offset based on the new raw offset */
792 DeviceInfo.BlockDeviceInfo.Block = Offset / DeviceInfo.BlockDeviceInfo.BlockSize;
793 DeviceInfo.BlockDeviceInfo.Offset = Offset % DeviceInfo.BlockDeviceInfo.BlockSize;
794
795 /* Update the block and offset */
797 if (NT_SUCCESS(Status))
798 {
799 /* Now issue a read, with this block and offset configured */
800 Status = BlDeviceRead(DeviceId, Buffer, Size, BytesRead);
801 }
802
803 /* All good, return the caller */
804 return Status;
805}
NTSTATUS BlDeviceGetInformation(_In_ ULONG DeviceId, _Out_ PBL_DEVICE_INFORMATION DeviceInformation)
Definition: device.c:682
NTSTATUS BlDeviceRead(_In_ ULONG DeviceId, _In_ PVOID Buffer, _In_ ULONG Size, _Out_opt_ PULONG BytesRead)
Definition: device.c:720
NTSTATUS BlDeviceSetInformation(_In_ ULONG DeviceId, _Out_ PBL_DEVICE_INFORMATION DeviceInformation)
Definition: device.c:645
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870

Referenced by EtfspCheckEtfs(), EtfspGetDirent(), EtfsRead(), and FatMount().

◆ BlDeviceSetInformation()

NTSTATUS BlDeviceSetInformation ( _In_ ULONG  DeviceId,
_In_ PBL_DEVICE_INFORMATION  DeviceInformation 
)

◆ BlDisplayClearScreen()

NTSTATUS BlDisplayClearScreen ( VOID  )

Definition at line 943 of file display.c.

946{
948 PBL_TEXT_CONSOLE TextConsole;
949
950 /* Nothing to do if there's no text console */
952 TextConsole = DspTextConsole;
953 if (TextConsole)
954 {
955 /* Otherwise, clear the whole screen */
956 Status = TextConsole->Callbacks->ClearText(TextConsole, FALSE);
957 if (NT_SUCCESS(Status))
958 {
959 /* Invalidate the OEM bitmap at this point */
961 }
962 }
963
964 /* All done */
965 return Status;
966};
PVOID DspTextConsole
Definition: display.c:36
VOID BlDisplayInvalidateOemBitmap(VOID)
Definition: display.c:723
PCONSOLE_CLEAR_TEXT ClearText
Definition: bl.h:1092
PBL_TEXT_CONSOLE_VTABLE Callbacks
Definition: bl.h:1110

Referenced by BmMain(), and OslDrawLogo().

◆ BlDisplayGetOemBitmap()

PBITMAP BlDisplayGetOemBitmap ( _Out_ PCOORD  Offset,
_Out_opt_ PULONG  Flags 
)

◆ BlDisplayGetScreenResolution()

NTSTATUS BlDisplayGetScreenResolution ( _Out_ PULONG  HRes,
_Out_ PULONG  Vres 
)

Definition at line 680 of file display.c.

684{
687 PBL_GRAPHICS_CONSOLE GraphicsConsole;
688
689 /* Assume failure if no consoles are active */
691
692 /* Do we have a text console? */
693 if (DspTextConsole)
694 {
695 /* Do we have an active graphics console? */
696 GraphicsConsole = DspGraphicalConsole;
697 if ((GraphicsConsole) &&
698 (((PBL_GRAPHICS_CONSOLE_VTABLE)GraphicsConsole->TextConsole.Callbacks)->IsEnabled(GraphicsConsole)))
699 {
700 /* Get the resolution */
701 Status = ((PBL_GRAPHICS_CONSOLE_VTABLE)GraphicsConsole->TextConsole.Callbacks)->GetGraphicalResolution(GraphicsConsole, &Resolution);
702 if (NT_SUCCESS(Status))
703 {
704 /* Return it back to the caller */
705 *HRes = Resolution.HRes;
706 *VRes = Resolution.VRes;
707 }
708 }
709 else
710 {
711 /* Return defaults */
712 *HRes = 640;
713 *VRes = 200;
715 }
716 }
717
718 /* Return if we got a valid resolution back */
719 return Status;
720}
struct _BL_GRAPHICS_CONSOLE_VTABLE * PBL_GRAPHICS_CONSOLE_VTABLE
PVOID DspGraphicalConsole
Definition: display.c:37
BL_TEXT_CONSOLE TextConsole
Definition: bl.h:1146
static BYTE Resolution
Definition: mouse.c:35

Referenced by BlDisplayValidOemBitmap(), and BlpResourceInitialize().

◆ BlDisplayGetTextCellResolution()

VOID BlDisplayGetTextCellResolution ( _Out_ PULONG  TextWidth,
_Out_ PULONG  TextHeight 
)

Definition at line 603 of file display.c.

607{
609 PBL_GRAPHICS_CONSOLE GraphicsConsole;
610
611 /* If the caller doesn't want anything, bail out */
612 if (!(TextWidth) || !(TextHeight))
613 {
614 return;
615 }
616
617 /* Do we have a text console? */
619 if (DspTextConsole)
620 {
621 /* Do we have a graphics console? */
622 GraphicsConsole = DspGraphicalConsole;
623 if (GraphicsConsole)
624 {
625 /* Is it currently active? */
626 if (((PBL_GRAPHICS_CONSOLE_VTABLE)GraphicsConsole->TextConsole.Callbacks)->IsEnabled(GraphicsConsole))
627 {
628 /* Yep -- query it */
629 EfiPrintf(L"GFX active, not supported query\r\n");
631 //Status = ((PBL_GRAPHICS_CONSOLE_VTABLE)GraphicsConsole->TextConsole.Callbacks)->GetTextCellResolution(GraphicsConsole);
632 }
633 }
634 }
635
636 /* Check if we failed to get it from the graphics console */
637 if (!NT_SUCCESS(Status))
638 {
639 /* Set default text size */
640 *TextWidth = 8;
641 *TextHeight = 8;
642 }
643}

Referenced by ConsoleEfiTextGetStateFromMode(), ConsoleFirmwareTextClear(), and ConsoleFirmwareTextSetState().

◆ BlDisplayInvalidateOemBitmap()

VOID BlDisplayInvalidateOemBitmap ( VOID  )

Definition at line 723 of file display.c.

726{
727 PBGRT_TABLE BgrtTable;
729
730 /* Search for the BGRT */
732 if (NT_SUCCESS(Status))
733 {
734 /* Mark the bitmap as invalid */
735 BgrtTable->Status &= ~BGRT_STATUS_IMAGE_VALID;
736
737 /* Unmap the table */
738 BlMmUnmapVirtualAddressEx(BgrtTable, BgrtTable->Header.Length);
739 }
740}
NTSTATUS BlMmUnmapVirtualAddressEx(_In_ PVOID VirtualAddress, _In_ ULONGLONG Size)
Definition: mm.c:487
NTSTATUS BlUtlGetAcpiTable(_Out_ PVOID *TableAddress, _In_ ULONG Signature)
Definition: util.c:34
#define BGRT_SIGNATURE
Definition: acpi.h:43
DESCRIPTION_HEADER Header
Definition: acpi.h:243
UCHAR Status
Definition: acpi.h:245
ULONG Length
Definition: acpi.h:97

Referenced by BlDisplayClearScreen(), ConsoleEfiGopClose(), and ConsoleEfiGopEnable().

◆ BlDisplaySetCursorType()

NTSTATUS BlDisplaySetCursorType ( _In_ ULONG  Type)

Definition at line 969 of file display.c.

972{
974 PBL_TEXT_CONSOLE TextConsole;
976
977 /* Nothing to do if there's no text console */
979 TextConsole = DspTextConsole;
980 if (TextConsole)
981 {
982 /* Write visibility state and call the function to change it */
983 State.CursorVisible = Type;
984 Status = TextConsole->Callbacks->SetTextState(TextConsole, 8, &State);
985 }
986
987 /* All done */
988 return Status;
989}
PCONSOLE_SET_TEXT_STATE SetTextState
Definition: bl.h:1089

Referenced by BlXmiInitialize().

◆ BlDisplaySetScreenResolution()

NTSTATUS BlDisplaySetScreenResolution ( VOID  )

Definition at line 646 of file display.c.

649{
652
653 /* Assume success */
655
656 /* Do we have a graphics console? */
658 if (Console)
659 {
660 /* Is it currently active? */
661 if (((PBL_GRAPHICS_CONSOLE_VTABLE)Console->TextConsole.Callbacks)->IsEnabled(Console))
662 {
663 /* If so, disable it */
664 return ((PBL_GRAPHICS_CONSOLE_VTABLE)Console->TextConsole.Callbacks)->Enable(Console, FALSE);
665 }
666 }
667
668 /* We should've now fallen back to text mode */
669 if (!DspTextConsole)
670 {
671 /* Then fail, as no display appears active */
673 }
674
675 /* Return back to the caller */
676 return Status;
677}

Referenced by BlResourceFindMessage(), and ResSelectLocale().

◆ BlDisplayValidOemBitmap()

BOOLEAN BlDisplayValidOemBitmap ( VOID  )

Definition at line 880 of file display.c.

883{
885 ULONG HRes, VRes, Height, Width, Flags;
886 COORD Offsets;
889
890 /* First check if mobile graphics are enabled */
893 &Result);
894 if ((NT_SUCCESS(Status)) && (Result))
895 {
896 /* Yes, so use the firmware image */
897 return TRUE;
898 }
899
900 /* Nope, so we'll check the ACPI OEM bitmap */
901 Result = FALSE;
902 Bitmap = BlDisplayGetOemBitmap(&Offsets, &Flags);
903
904 /* Is there one? */
905 if (Bitmap)
906 {
907 /* Is it valid? */
909 {
910 /* Get the current screen resolution */
911 Status = BlDisplayGetScreenResolution(&HRes, &VRes);
912 if (NT_SUCCESS(Status))
913 {
914 /* Is there a valid width? */
915 Width = Bitmap->DibHeader.Width;
916 if (Width)
917 {
918 /* Is there a valid height? */
919 Height = Bitmap->DibHeader.Height;
920 if (Height)
921 {
922 /* Will if fit on this screen? */
923 if (((Width + Offsets.X) <= HRes) &&
924 ((Height + Offsets.Y) <= VRes))
925 {
926 /* Then it's all good! */
927 Result = TRUE;
928 }
929 }
930 }
931 }
932 }
933
934 /* Unmap the bitmap for now, it will be drawn later */
935 BlMmUnmapVirtualAddressEx(Bitmap, Bitmap->BmpHeader.Size);
936 }
937
938 /* Return that a valid OEM bitmap exists */
939 return Result;
940}
@ BcdLibraryBoolean_MobileGraphics
Definition: bcd.h:105
NTSTATUS BlGetBootOptionBoolean(_In_ PBL_BCD_OPTION List, _In_ ULONG Type, _Out_ PBOOLEAN Value)
Definition: bcdopt.c:504
BL_LOADED_APPLICATION_ENTRY BlpApplicationEntry
Definition: bootlib.c:19
NTSTATUS BlDisplayGetScreenResolution(_Out_ PULONG HRes, _Out_ PULONG VRes)
Definition: display.c:680
PBITMAP BlDisplayGetOemBitmap(_In_opt_ PCOORD Offsets, _Out_opt_ PULONG Flags)
Definition: display.c:743
#define BGRT_STATUS_IMAGE_VALID
Definition: acpi.h:53
Definition: bl.h:1331
PBL_BCD_OPTION BcdData
Definition: bl.h:867
Definition: bl.h:1338
ULONG Y
Definition: bl.h:1340
ULONG X
Definition: bl.h:1339
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by BmMain().

◆ BlFileClose()

NTSTATUS BlFileClose ( _In_ ULONG  FileId)

Definition at line 220 of file file.c.

223{
224 PBL_FILE_ENTRY FileEntry;
225
226 /* Validate the file ID */
227 if (FileEntries <= FileId)
228 {
230 }
231
232 /* Make sure a file entry actually exists */
233 FileEntry = FileTable[FileId];
234 if (!FileEntry)
235 {
237 }
238
239 /* And that it's actually open */
240 if (!(FileEntry->Flags & BL_FILE_ENTRY_OPENED))
241 {
243 }
244
245 /* Drop a reference, check if this was the last one */
246 --FileEntry->ReferenceCount;
247 if (!FileEntry->ReferenceCount)
248 {
249 /* File is no longer open */
250 FileEntry->Flags &= ~BL_FILE_ENTRY_OPENED;
251 }
252
253 /* All good */
254 return STATUS_SUCCESS;
255}
#define BL_FILE_ENTRY_OPENED
Definition: bl.h:159
ULONG FileEntries
Definition: file.c:16
PVOID * FileTable
Definition: file.c:15
Definition: bl.h:1038
ULONG ReferenceCount
Definition: bl.h:1043
ULONG Flags
Definition: bl.h:1042

Referenced by BlBsdInitializeLog(), BmFwInitializeBootDirectoryPath(), FileIoOpen(), and ImgpCloseFile().

◆ BlFileGetInformation()

NTSTATUS BlFileGetInformation ( _In_ ULONG  FileId,
_In_ PBL_FILE_INFORMATION  FileInfo 
)

Definition at line 564 of file file.c.

568{
569 PBL_FILE_ENTRY FileEntry;
570
571 /* Make sure caller passed this in */
572 if (!FileInfo)
573 {
575 }
576
577 /* Validate file ID */
578 if (FileId > FileEntries)
579 {
581 }
582
583 /* Make sure an opened file exits with this ID */
584 FileEntry = FileTable[FileId];
585 if (!(FileEntry) || !(FileEntry->Flags & BL_FILE_ENTRY_OPENED))
586 {
588 }
589
590 /* Do the I/O operation */
591 return FileEntry->Callbacks.GetInfo(FileEntry, FileInfo);
592}
PBL_FILE_GET_INFO GetInfo
Definition: bl.h:1033
BL_FILE_CALLBACKS Callbacks
Definition: bl.h:1047

Referenced by BlFileReadAtOffsetEx(), BlFileReadEx(), and ImgpGetFileSize().

◆ BlFileOpen()

NTSTATUS BlFileOpen ( _In_ ULONG  DeviceId,
_In_ PWCHAR  FileName,
_In_ ULONG  Flags,
_Out_ PULONG  FileId 
)

Definition at line 477 of file file.c.

483{
485 PBL_FILE_ENTRY FileEntry;
486 BL_DEVICE_INFORMATION DeviceInformation;
487
488 /* Make sure we have a valid file name, access flags and parameters */
489 if (!(FileName) ||
491 !(FileId) ||
493 {
494 EfiPrintf(L"Invalid file options\r\n");
496 }
497
498 /* Get information on the underlying device */
499 Status = BlDeviceGetInformation(DeviceId, &DeviceInformation);
500 if (!NT_SUCCESS(Status))
501 {
502 EfiPrintf(L"Get device info failed: %lx\r\n", Status);
503 return Status;
504 }
505
506 /* Make sure it's a device that can host files */
507 if ((DeviceInformation.DeviceType != DiskDevice) &&
508 (DeviceInformation.DeviceType != LegacyPartitionDevice) &&
509 (DeviceInformation.DeviceType != UdpDevice))
510 {
511 EfiPrintf(L"Invalid device type\r\n");
513 }
514
515 /* Open a file on this device, creating one if needed */
516 Status = FileIoOpen(DeviceId,
517 FileName,
518 Flags,
519 0,
521 &FileEntry);
522 if (NT_SUCCESS(Status))
523 {
524 /* Return the file ID back to the caller */
525 *FileId = FileEntry->FileId;
526 }
527
528 /* All good */
529 return Status;
530}
NTSTATUS BlDeviceGetInformation(_In_ ULONG DeviceId, _Out_ PBL_DEVICE_INFORMATION DeviceInformation)
Definition: device.c:682
#define BL_FILE_WRITE_ACCESS
Definition: bl.h:148
#define BL_FILE_READ_ACCESS
Definition: bl.h:147
BOOLEAN FileTableCompareWithSameAttributes(_In_ PVOID Entry, _In_ PVOID Argument1, _In_ PVOID Argument2, _In_ PVOID Argument3, _In_ PVOID Argument4)
Definition: file.c:138
NTSTATUS FileIoOpen(_In_ ULONG DeviceId, _In_ PWCHAR FileName, _In_ ULONG Flags, _In_ ULONG Unknown, _In_ PBL_TBL_LOOKUP_ROUTINE CompareRoutine, _Out_opt_ PBL_FILE_ENTRY *NewFileEntry)
Definition: file.c:258
BL_DEVICE_TYPE DeviceType
Definition: bl.h:1225
ULONG FileId
Definition: bl.h:1041

Referenced by BlBsdInitializeLog(), BmFwInitializeBootDirectoryPath(), and ImgpOpenFile().

◆ BlFileReadAtOffsetEx()

NTSTATUS BlFileReadAtOffsetEx ( _In_ ULONG  FileId,
_In_ ULONG  Size,
_In_ ULONGLONG  ByteOffset,
_In_ PVOID  Buffer,
_Out_ PULONG  BytesReturned,
_In_ ULONG  Flags 
)

Definition at line 788 of file file.c.

796{
801
802 /* Get information on the specified file */
804 if (!NT_SUCCESS(Status))
805 {
806 return Status;
807 }
808
809 /* Save the current offset, and overwrite it with the one we want */
810 FileOffset = FileInfo.Offset;
811 FileInfo.Offset = ByteOffset;
812
813 /* Check the validity of the read and the actual size to read */
816 FALSE,
819 &RequiredSize);
820 if (!NT_SUCCESS(Status))
821 {
822 /* Bail out if the read is invalid */
823 EfiPrintf(L"File info check failure: %lx\r\n", Status);
824 return Status;
825 }
826
827 /* Check if the offset we're requesting is not the current offset */
828 if (FileInfo.Offset != FileOffset)
829 {
830 /* Set the new offset to use */
832 if (!NT_SUCCESS(Status))
833 {
834 /* Can't do much if that failed */
835 return Status;
836 }
837 }
838
839 /* Do the read at the required offset now */
840 Status = BlFileReadEx(FileId,
841 Buffer,
844 Flags);
845 if (!NT_SUCCESS(Status))
846 {
847 /* The read failed -- had we modified the offset? */
848 if (FileInfo.Offset != FileOffset)
849 {
850 /* Restore the offset back to its original value */
851 FileInfo.Offset = FileOffset;
853 }
854 }
855
856 /* Return the status of the read */
857 return Status;
858}
NTSTATUS BlFileSetInformation(_In_ ULONG FileId, _Out_ PBL_FILE_INFORMATION FileInfo)
Definition: file.c:533
NTSTATUS BlFileGetInformation(_In_ ULONG FileId, _In_ PBL_FILE_INFORMATION FileInfo)
Definition: file.c:564
NTSTATUS FileInformationCheck(_In_ PBL_FILE_INFORMATION FileInformation, _In_ BOOLEAN Write, _In_opt_ PULONG InputSize, _In_opt_ PULONG BytesReturned, _Out_opt_ PULONG RequiredSize)
Definition: file.c:595
NTSTATUS BlFileReadEx(_In_ ULONG FileId, _Out_ PVOID Buffer, _In_ ULONG Size, _Out_ PULONG BytesReturned, _In_ ULONG Flags)
Definition: file.c:655
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:160
IN PDCB IN PCCB IN VBO IN OUT PULONG OUT PDIRENT OUT PBCB OUT PVBO ByteOffset
Definition: fatprocs.h:731
uint64_t ULONGLONG
Definition: typedefs.h:67
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4439
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_ ULONG _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesReturned
Definition: wdfiotarget.h:1052

Referenced by ImgpReadAtFileOffset().

◆ BlFwEnumerateDevice()

NTSTATUS BlFwEnumerateDevice ( _In_ PBL_DEVICE_DESCRIPTOR  Device)

Definition at line 2375 of file firmware.c.

2378{
2380 ULONG PathProtocols, BlockProtocols;
2381 EFI_HANDLE* PathArray;
2382 EFI_HANDLE* BlockArray;
2383
2384 /* Initialize locals */
2385 BlockArray = NULL;
2386 PathArray = NULL;
2387 PathProtocols = 0;
2388 BlockProtocols = 0;
2389
2390 /* Enumeration only makes sense on disks or partitions */
2391 if ((Device->DeviceType != DiskDevice) &&
2392 (Device->DeviceType != LegacyPartitionDevice) &&
2393 (Device->DeviceType != PartitionDevice))
2394 {
2395 return STATUS_NOT_SUPPORTED;
2396 }
2397
2398 /* Enumerate the list of device paths */
2401 &PathProtocols,
2402 &PathArray);
2403 if (NT_SUCCESS(Status))
2404 {
2405 /* Loop through each one */
2407 while (PathProtocols)
2408 {
2409 /* Attempt to connect the driver for this device epath */
2410 Status = EfiConnectController(PathArray[--PathProtocols]);
2411 if (NT_SUCCESS(Status))
2412 {
2413 /* Now enumerate any block I/O devices the driver added */
2416 &BlockProtocols,
2417 &BlockArray);
2418 if (!NT_SUCCESS(Status))
2419 {
2420 break;
2421 }
2422
2423 /* Loop through each one */
2424 while (BlockProtocols)
2425 {
2426 /* Check if one of the new devices is the one we want */
2428 BlockArray[--BlockProtocols]);
2429 if (NT_SUCCESS(Status))
2430 {
2431 /* Yep, all done */
2432 goto Quickie;
2433 }
2434 }
2435
2436 /* Move on to the next device path */
2437 BlMmFreeHeap(BlockArray);
2438 BlockArray = NULL;
2439 }
2440 }
2441 }
2442
2443Quickie:
2444 /* We're done -- free the array of device path protocols, if any */
2445 if (PathArray)
2446 {
2447 BlMmFreeHeap(PathArray);
2448 }
2449
2450 /* We're done -- free the array of block I/O protocols, if any */
2451 if (BlockArray)
2452 {
2453 BlMmFreeHeap(BlockArray);
2454 }
2455
2456 /* Return if we found the device or not */
2457 return Status;
2458}
@ ByProtocol
Definition: UefiSpec.h:1428
NTSTATUS BlockIoEfiCompareDevice(_In_ PBL_DEVICE_DESCRIPTOR Device, _In_ EFI_HANDLE Handle)
Definition: device.c:1268
EFI_GUID EfiDevicePathProtocol
Definition: firmware.c:31
EFI_GUID EfiBlockIoProtocol
Definition: firmware.c:33
NTSTATUS EfiConnectController(_In_ EFI_HANDLE ControllerHandle)
Definition: firmware.c:1530
NTSTATUS EfiLocateHandleBuffer(_In_ EFI_LOCATE_SEARCH_TYPE SearchType, _In_ EFI_GUID *Protocol, _Inout_ PULONG HandleCount, _Inout_ EFI_HANDLE **Buffer)
Definition: firmware.c:1399
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
#define STATUS_NOT_FOUND
Definition: shellext.h:72

Referenced by BmpTransferExecution().

◆ BlFwGetParameters()

NTSTATUS BlFwGetParameters ( _In_ PBL_FIRMWARE_DESCRIPTOR  Parameters)

Definition at line 2359 of file firmware.c.

2362{
2363 /* Make sure we got an argument */
2364 if (!Parameters)
2365 {
2367 }
2368
2369 /* Copy the static data */
2371 return STATUS_SUCCESS;
2372}
PBL_FIRMWARE_DESCRIPTOR EfiFirmwareParameters
Definition: firmware.c:15
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869

Referenced by ImgpInitializeBootApplicationParameters().

◆ BlFwReboot()

VOID BlFwReboot ( VOID  )

Definition at line 14 of file fwutil.c.

17{
18#ifdef BL_KD_SUPPORTED
19 /* Stop the boot debugger*/
20 BlBdStop();
21#endif
22
23 /* Reset the machine */
25}
@ EfiResetCold
Definition: UefiSpec.h:975
VOID EfiResetSystem(_In_ EFI_RESET_TYPE ResetType)
Definition: firmware.c:1509

Referenced by BmMain().

◆ BlGetApplicationBaseAndSize()

NTSTATUS BlGetApplicationBaseAndSize ( _Out_ PVOID ImageBase,
_Out_ PULONG  ImageSize 
)

Definition at line 424 of file bootlib.c.

428{
429 /* Fail if output parameters are missing */
430 if (!ImageBase || !ImageSize)
431 {
433 }
434
435 /* Return the requested data */
438 return STATUS_SUCCESS;
439}
PBOOT_APPLICATION_PARAMETER_BLOCK BlpApplicationParameters
Definition: bootlib.c:18
void * PVOID
Definition: typedefs.h:50

Referenced by BlpResourceInitialize(), and Mmx86InitializeMemoryMap().

◆ BlGetApplicationIdentifier()

PGUID BlGetApplicationIdentifier ( VOID  )

Definition at line 414 of file bootlib.c.

417{
418 /* Return the GUID, if one was present */
421}
#define BL_APPLICATION_ENTRY_FLAG_NO_GUID
Definition: bl.h:68
BL_LOADED_APPLICATION_ENTRY BlpApplicationEntry
Definition: bootlib.c:19
ULONG Flags
Definition: bl.h:865
GUID Guid
Definition: bl.h:866

Referenced by BlGetBootOptionBoolean(), BlGetBootOptionDevice(), BlGetBootOptionInteger(), BlGetBootOptionString(), BmMain(), and OslPrepareTarget().

◆ BlGetBootOptionBoolean()

NTSTATUS BlGetBootOptionBoolean ( _In_ PBL_BCD_OPTION  List,
_In_ ULONG  Type,
_Out_ PBOOLEAN  Value 
)

Definition at line 504 of file bcdopt.c.

509{
511 PBL_BCD_OPTION Option;
512 //PGUID AppIdentifier;
513 BcdElementType ElementType;
514
515 /* Make sure this is a BCD_TYPE_BOOLEAN */
516 ElementType.PackedValue = Type;
517 if (ElementType.Format != BCD_TYPE_BOOLEAN)
518 {
520 }
521
522 /* Return the data */
523 Option = MiscGetBootOption(List, Type);
524 if (Option)
525 {
526 *Value = *(PBOOLEAN)((ULONG_PTR)Option + Option->DataOffset);
527 }
528
529#ifdef _SECURE_BOOT_
530 /* Filter out SecureBoot Options */
531 AppIdentifier = BlGetApplicationIdentifier();
532 Status = BlpBootOptionCallbackBoolean(AppIdentifier, Type, Value);
533#else
534 /* Option found */
536#endif
537 return Status;
538}
#define BCD_TYPE_BOOLEAN
Definition: bcd.h:26
PBL_BCD_OPTION MiscGetBootOption(_In_ PBL_BCD_OPTION List, _In_ ULONG Type)
Definition: bcdopt.c:17
PGUID BlGetApplicationIdentifier(VOID)
Definition: bootlib.c:414
ULONG PackedValue
Definition: bcd.h:234
ULONG Format
Definition: bcd.h:238
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550

Referenced by BlDisplayValidOemBitmap(), BlImgQueryCodeIntegrityBootOptions(), BlMmRemoveBadMemory(), BmDisplayDumpError(), BmFatalErrorEx(), BmGetBootMenuPolicy(), BmMain(), BmpGetSelectedBootEntry(), BmpInitializeBootStatusDataLog(), BmpLaunchBootEntry(), BmpPopulateBootEntryList(), BmpTransferExecution(), BmResumeFromHibernate(), DsppGraphicsDisabledByBcd(), DsppInitialize(), and DsppReinitialize().

◆ BlGetBootOptionDevice()

NTSTATUS BlGetBootOptionDevice ( _In_ PBL_BCD_OPTION  List,
_In_ ULONG  Type,
_Out_ PBL_DEVICE_DESCRIPTOR Value,
_In_opt_ PBL_BCD_OPTION ExtraOptions 
)

Definition at line 321 of file bcdopt.c.

327{
329 PBL_BCD_OPTION Option, ListData, ListCopy, SecureListData;
330 PBCD_DEVICE_OPTION BcdDevice;
331 ULONG DeviceSize, ListOffset, ListSize;
332 PBL_DEVICE_DESCRIPTOR DeviceDescriptor, SecureDescriptor;
333 //PGUID AppIdentifier;
334 BcdElementType ElementType;
335
336 /* Make sure this is a BCD_TYPE_DEVICE */
337 ElementType.PackedValue = Type;
338 if (ElementType.Format != BCD_TYPE_DEVICE)
339 {
341 }
342
343 /* Return the data */
344 Option = MiscGetBootOption(List, Type);
345 if (!Option)
346 {
347 /* Set failure if no data exists */
349 }
350 else
351 {
352 /* Otherwise, read the size of the BCD device encoded */
353 BcdDevice = (PBCD_DEVICE_OPTION)((ULONG_PTR)Option + Option->DataOffset);
354 DeviceSize = BcdDevice->DeviceDescriptor.Size;
355
356 /* Allocate a buffer to copy it into */
358 if (!DeviceDescriptor)
359 {
360 return STATUS_NO_MEMORY;
361 }
362
363 /* Copy it into that buffer */
364 RtlCopyMemory(DeviceDescriptor, &BcdDevice->DeviceDescriptor, DeviceSize);
366 }
367
368 /* Check if extra options were requested */
369 if (ExtraOptions)
370 {
371 /* See where they are */
372 ListOffset = Option->ListOffset;
373 if (ListOffset)
374 {
375 /* See how big they are */
376 ListData = (PBL_BCD_OPTION)((ULONG_PTR)Option + ListOffset);
377 ListSize = BlGetBootOptionListSize(ListData);
378
379 /* Allocate a buffer to hold them into */
380 ListCopy = BlMmAllocateHeap(ListSize);
381 if (!ListCopy)
382 {
384 goto Quickie;
385 }
386
387 /* Copy them in there */
388 RtlCopyMemory(ListCopy, ListData, ListSize);
389 }
390 }
391
392#ifdef _SECURE_BOOT_
393 /* Filter out SecureBoot Options */
394 AppIdentifier = BlGetApplicationIdentifier();
395 if (BlpBootOptionCallbacks)
396 {
397 DeviceCallback = BlpBootOptionCallbacks->Device;
398 if (DeviceCallback)
399 {
400 Status = DeviceCallback(BlpBootOptionCallbackCookie,
401 Status,
402 0,
403 AppIdentifier,
404 Type,
405 &SecureDescriptor,
406 PtrOptionData);
407 }
408 }
409#else
410 /* No secure boot, so the secure descriptors are the standard ones */
411 SecureDescriptor = DeviceDescriptor;
412 SecureListData = ListCopy;
413#endif
414
415 /* Check if the data was read correctly */
416 if (NT_SUCCESS(Status))
417 {
418 /* Check if we had a new descriptor after filtering */
419 if (SecureDescriptor != DeviceDescriptor)
420 {
421 /* Yep -- if we had an old one, free it */
423 {
425 }
426 }
427
428 /* Check if we had a new list after filtering */
429 if (SecureListData != ListCopy)
430 {
431 /* Yep -- if we had an old list, free it */
432 if (ListCopy)
433 {
434 BlMmFreeHeap(ListCopy);
435 }
436 }
437
438 /* Finally, check if the caller wanted extra options */
439 if (ExtraOptions)
440 {
441 /* Yep -- so pass the caller our copy */
442 *ExtraOptions = ListCopy;
443 ListCopy = NULL;
444 }
445
446 /* Caller always wants data back, so pass them our copy */
449 }
450
451Quickie:
452 /* On the failure path, if these buffers are active, we should free them */
453 if (ListCopy)
454 {
455 BlMmFreeHeap(ListCopy);
456 }
458 {
460 }
461
462 /* All done */
463 return Status;
464}
struct _BCD_DEVICE_OPTION * PBCD_DEVICE_OPTION
#define BCD_TYPE_DEVICE
Definition: bcd.h:21
PCSTR ExtraOptions
Definition: setupldr.c:336
const KSDEVICE_DESCRIPTOR DeviceDescriptor
Definition: splitter.c:257
BL_DEVICE_DESCRIPTOR DeviceDescriptor
Definition: bcd.h:298
ULONG ListOffset
Definition: bl.h:849

Referenced by BlImgLoadBootApplication(), BmOpenDataStore(), BmpInitializeBootStatusDataLog(), BmpTransferExecution(), DsppLoadFontFile(), and OslPrepareTarget().

◆ BlGetBootOptionGuid()

NTSTATUS BlGetBootOptionGuid ( _In_ PBL_BCD_OPTION  List,
_In_ ULONG  Type,
_Out_ PGUID  Value 
)

Definition at line 228 of file bcdopt.c.

233{
235 PBL_BCD_OPTION Option;
236 PGUID Guid;
237 BcdElementType ElementType;
238
239 /* Make sure this is a BCD_TYPE_OBJECT */
240 ElementType.PackedValue = Type;
241 if (ElementType.Format != BCD_TYPE_OBJECT)
242 {
244 }
245
246 /* Return the data */
247 Option = MiscGetBootOption(List, Type);
248 if (!Option)
249 {
250 /* Set failure if no data exists */
252 }
253 else
254 {
255 /* Copy the GUID */
256 Guid = (PGUID)((ULONG_PTR)Option + Option->DataOffset);
257 RtlCopyMemory(Value, Guid, Option->DataSize);
259 }
260
261 /* All good */
262 return Status;
263}
#define BCD_TYPE_OBJECT
Definition: bcd.h:23
GUID * PGUID
Definition: bdasup.h:12
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
Definition: wdfobject.h:762

Referenced by BmEnumerateBootEntries(), and BmpGetDefaultBootEntry().

◆ BlGetBootOptionGuidList()

NTSTATUS BlGetBootOptionGuidList ( _In_ PBL_BCD_OPTION  List,
_In_ ULONG  Type,
_Out_ PGUID Value,
_In_ PULONG  Count 
)

Definition at line 266 of file bcdopt.c.

272{
274 PBL_BCD_OPTION Option;
275 PGUID GuidCopy, Guid;
276 ULONG GuidCount;
277 BcdElementType ElementType;
278
279 /* Make sure this is a BCD_TYPE_OBJECT_LIST */
280 ElementType.PackedValue = Type;
281 if (ElementType.Format != BCD_TYPE_OBJECT_LIST)
282 {
284 }
285
286 /* Return the data */
287 Option = MiscGetBootOption(List, Type);
288 if (!Option)
289 {
290 /* Set failure if no data exists */
292 }
293 else
294 {
295 /* Get the GUIDs and allocate a copy for them */
296 Guid = (PGUID)((ULONG_PTR)Option + Option->DataOffset);
297 GuidCopy = BlMmAllocateHeap(Option->DataSize);
298 if (GuidCopy)
299 {
300 /* Copy the GUIDs */
301 RtlCopyMemory(GuidCopy, Guid, Option->DataSize);
302
303 /* Return the number of GUIDs and the start of the array */
304 GuidCount = Option->DataSize / sizeof(GUID);
305 *Value = GuidCopy;
306 *Count = GuidCount;
308 }
309 else
310 {
311 /* No memory for the copy */
313 }
314 }
315
316 /* All good */
317 return Status;
318}
#define BCD_TYPE_OBJECT_LIST
Definition: bcd.h:24
int Count
Definition: noreturn.cpp:7

Referenced by BmEnumerateBootEntries(), BmLaunchRecoverySequence(), and BmMain().

◆ BlGetBootOptionInteger()

NTSTATUS BlGetBootOptionInteger ( _In_ PBL_BCD_OPTION  List,
_In_ ULONG  Type,
_Out_ PULONGLONG  Value 
)

Definition at line 467 of file bcdopt.c.

472{
474 PBL_BCD_OPTION Option;
475 //PGUID AppIdentifier;
476 BcdElementType ElementType;
477
478 /* Make sure this is a BCD_TYPE_INTEGER */
479 ElementType.PackedValue = Type;
480 if (ElementType.Format != BCD_TYPE_INTEGER)
481 {
483 }
484
485 /* Return the data */
486 Option = MiscGetBootOption(List, Type);
487 if (Option)
488 {
489 *Value = *(PULONGLONG)((ULONG_PTR)Option + Option->DataOffset);
490 }
491
492#ifdef _SECURE_BOOT_
493 /* Filter out SecureBoot Options */
494 AppIdentifier = BlGetApplicationIdentifier();
495 Status = BlpBootOptionCallbackULongLong(AppIdentifier, Type, Value);
496#else
497 /* Option found */
499#endif
500 return Status;
501}
#define BCD_TYPE_INTEGER
Definition: bcd.h:25

Referenced by BlpMmInitializeConstraints(), BmGetBootMenuPolicy(), BmpGetSelectedBootEntry(), DsppInitialize(), DsppReinitialize(), InitializeLibrary(), MmArchInitialize(), OslGetBootStatusData(), and OslpCheckForcedFailure().

◆ BlGetBootOptionListSize()

ULONG BlGetBootOptionListSize ( _In_ PBL_BCD_OPTION  BcdOption)

Definition at line 79 of file bcdopt.c.

82{
83 ULONG Size = 0, NextOffset = 0;
85
86 /* Loop all the options*/
87 do
88 {
89 /* Move to the next one */
90 NextOption = (PBL_BCD_OPTION)((ULONG_PTR)BcdOption + NextOffset);
91
92 /* Compute the size of the next one */
94
95 /* Update the offset */
96 NextOffset = NextOption->NextEntryOffset;
97 } while (NextOffset);
98
99 /* Return final computed size */
100 return Size;
101}
ULONG BlGetBootOptionSize(_In_ PBL_BCD_OPTION BcdOption)
Definition: bcdopt.c:115

Referenced by BlAppendBootOptions(), BlCopyBootOptions(), BlGetBootOptionDevice(), BlGetBootOptionSize(), BlImgLoadBootApplication(), BlReplaceBootOptions(), BmGetOptionList(), BmpPopulateBootEntryList(), and ImgpInitializeBootApplicationParameters().

◆ BlGetBootOptionSize()

ULONG BlGetBootOptionSize ( _In_ PBL_BCD_OPTION  BcdOption)

Definition at line 115 of file bcdopt.c.

118{
120
121 /* Check if there's any data */
122 if (BcdOption->DataOffset)
123 {
124 /* Add the size of the data */
125 Size = BcdOption->DataOffset + BcdOption->DataSize;
126 }
127 else
128 {
129 /* No data, just the structure itself */
130 Size = sizeof(*BcdOption);
131 }
132
133 /* Any associated options? */
134 Offset = BcdOption->ListOffset;
135 if (Offset)
136 {
137 /* Go get those too */
139 }
140
141 /* Return the final size */
142 return Size;
143}

Referenced by BlGetBootOptionListSize(), BmGetOptionList(), and EfiInitpCreateApplicationEntry().

◆ BlGetBootOptionString()

NTSTATUS BlGetBootOptionString ( _In_ PBL_BCD_OPTION  List,
_In_ ULONG  Type,
_Out_ PWCHAR Value 
)

Definition at line 146 of file bcdopt.c.

151{
153 PBL_BCD_OPTION Option;
154 PWCHAR String, StringCopy;
155 ULONG StringLength;
156 BcdElementType ElementType;
157 //PGUID AppIdentifier;
158
159 /* Make sure this is a BCD_STRING */
160 ElementType.PackedValue = Type;
161 if (ElementType.Format != BCD_TYPE_STRING)
162 {
164 }
165
166 /* Return the data */
167 Option = MiscGetBootOption(List, Type);
168 if (Option)
169 {
170 /* Extract the string */
171 String = (PWCHAR)((ULONG_PTR)Option + Option->DataOffset);
173 }
174 else
175 {
176 /* No string is present */
177 String = NULL;
179 }
180
181 /* Compute the data size */
182 StringLength = Option->DataSize / sizeof(WCHAR);
183
184#ifdef _SECURE_BOOT_
185 /* Filter out SecureBoot Options */
186 AppIdentifier = BlGetApplicationIdentifier();
187 Status = BlpBootOptionCallbackString(AppIdentifier, Type, String, StringLength, &String, &StringLength);
188#else
189#endif
190
191 /* Make sure we have a valid, non-filtered string */
192 if (NT_SUCCESS(Status))
193 {
194 /* Check if we have space for one more character */
195 Status = RtlULongAdd(StringLength, 1, &StringLength);
196 if (NT_SUCCESS(Status))
197 {
198 /* Check if it's safe to multiply by two */
199 Status = RtlULongMult(StringLength, sizeof(WCHAR), &StringLength);
200 if (NT_SUCCESS(Status))
201 {
202 /* Allocate a copy for the string */
203 StringCopy = BlMmAllocateHeap(StringLength);
204 if (StringCopy)
205 {
206 /* NULL-terminate it */
207 RtlCopyMemory(StringCopy,
208 String,
209 StringLength - sizeof(UNICODE_NULL));
210 StringCopy[StringLength] = UNICODE_NULL;
211 *Value = StringCopy;
213 }
214 else
215 {
216 /* No memory, fail */
218 }
219 }
220 }
221 }
222
223 /* All done */
224 return Status;
225}
#define BCD_TYPE_STRING
Definition: bcd.h:22
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433

Referenced by BlImgLoadBootApplication(), BmOpenDataStore(), BmpFwGetApplicationDirectoryPath(), BmpInitializeBootStatusDataLog(), BmpTransferExecution(), DsppLoadFontFile(), OslpRemoveInternalApplicationOptions(), and OslPrepareTarget().

◆ BlHtCreate()

NTSTATUS BlHtCreate ( _In_ ULONG  Size,
_In_ PBL_HASH_TABLE_HASH_FUNCTION  HashFunction,
_In_ PBL_HASH_TABLE_COMPARE_FUNCTION  CompareFunction,
_Out_ PULONG  Id 
)

Definition at line 504 of file util.c.

510{
513 ULONG i;
514
515 /* Assume failure */
516 HashTable = NULL;
517
518 /* Can't create a table with no ID */
519 if (!Id)
520 {
522 }
523
524 /* Check if we don't already have a hash table table */
525 if (!HtTableSize)
526 {
527 /* Allocate it and zero it out */
528 HtTableSize = 4;
530 if (!HtTableArray)
531 {
533 goto Quickie;
534 }
536 HtTableEntries = 0;
537 }
538
539 /* Allocate the hash table */
541 if (!HashTable)
542 {
544 goto Quickie;
545 }
546
547 /* Fill it out */
548 HashTable->HashFunction = HashFunction ? HashFunction : DefaultHashFunction;
549 HashTable->CompareFunction = CompareFunction ? CompareFunction : HtpCompareKeys;
550 HashTable->Size = Size ? Size : 13;
551
552 /* Allocate the hash links, one for each bucket */
553 HashTable->HashLinks = BlMmAllocateHeap(sizeof(LIST_ENTRY) * HashTable->Size);
554 if (!HashTable->HashLinks)
555 {
557 goto Quickie;
558 }
559
560 /* Initialize the hash links */
561 for (i = 0; i < HashTable->Size; i++)
562 {
563 InitializeListHead(&HashTable->HashLinks[i]);
564 }
565
566 /* Save us in the table of hash tables */
568 &Size,
569 HashTable,
570 Id,
572 if (NT_SUCCESS(Status))
573 {
574 /* One more -- we're done */
576 return Status;
577 }
578
579Quickie:
580 /* Check if we just allocated the table array now */
581 if (!(HtTableEntries) && (HtTableArray))
582 {
583 /* Free it */
586 HtTableSize = 0;
587 }
588
589 /* Check if we allocated a hash table*/
590 if (HashTable)
591 {
592 /* With links? */
593 if (HashTable->HashLinks)
594 {
595 /* Free them */
596 BlMmFreeHeap(HashTable->HashLinks);
597 }
598
599 /* Free the table*/
601 }
602
603 /* We're done */
604 return Status;
605}
DWORD Id
ULONG HtTableEntries
Definition: util.c:439
ULONG DefaultHashFunction(_In_ PBL_HASH_ENTRY Entry, _In_ ULONG TableSize)
Definition: util.c:442
PBL_HASH_TABLE * HtTableArray
Definition: util.c:438
BOOLEAN HtpCompareKeys(_In_ PBL_HASH_ENTRY Entry1, _In_ PBL_HASH_ENTRY Entry2)
Definition: util.c:464
ULONG HtTableSize
Definition: util.c:437
NTSTATUS TblDoNotPurgeEntry(_In_ PVOID Entry)
Definition: util.c:495
NTSTATUS BlTblSetEntry(_Inout_ PVOID **Table, _Inout_ PULONG Count, _In_ PVOID Entry, _Out_ PULONG EntryIndex, _In_ PBL_TBL_SET_ROUTINE Callback)
Definition: util.c:321
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
Definition: hash.c:67

Referenced by BcInitialize(), BlockIopInitialize(), and EfiVmOpenProtocol().

◆ BlHtDelete()

NTSTATUS BlHtDelete ( _In_ ULONG  TableId,
_In_ PBL_HASH_ENTRY  Entry 
)

Definition at line 722 of file util.c.

726{
730 PLIST_ENTRY HashLinkHead, HashLink;
731 PBL_HASH_NODE HashNode;
732
733 /* Check if the table ID is invalid, or we have no entry, or it's malformed */
734 if ((HtTableSize <= TableId) ||
735 !(Entry) ||
736 !(Entry->Size) ||
737 !(Entry->Value) ||
738 ((Entry->Flags & BL_HT_VALUE_IS_INLINE) && (Entry->Size != sizeof(ULONG))))
739 {
740 /* Fail */
742 }
743 else
744 {
745 /* Otherwise, get the hash table for this index */
746 HashTable = HtTableArray[TableId];
747
748 /* Get the hash bucket */
749 HashValue = HashTable->HashFunction(Entry, HashTable->Size);
750
751 /* Start iterating each entry in the bucket, assuming failure */
753 HashLinkHead = &HashTable->HashLinks[HashValue];
754 HashLink = HashLinkHead->Flink;
755 while (HashLink != HashLinkHead)
756 {
757 /* Get a node in this bucket, and compare the value */
758 HashNode = CONTAINING_RECORD(HashLink, BL_HASH_NODE, ListEntry);
759 if (HashTable->CompareFunction(&HashNode->Entry, Entry))
760 {
761 /* Remove it from the list and free it */
762 RemoveEntryList(&HashNode->ListEntry);
763 BlMmFreeHeap(HashNode);
764 return STATUS_SUCCESS;
765 }
766
767 /* Try the next node */
768 HashLink = HashLink->Flink;
769 }
770 }
771
772 /* Return back to the caller */
773 return Status;
774}
#define BL_HT_VALUE_IS_INLINE
Definition: bl.h:137
base of all file and directory entries
Definition: entries.h:83
LIST_ENTRY ListEntry
Definition: bl.h:1191
BL_HASH_ENTRY Entry
Definition: bl.h:1192
_In_ BOOLEAN _In_ ULONG _Out_ PULONG HashValue
Definition: rtlfuncs.h:2039

Referenced by BlockIoFirmwareOpen(), and EfiVmpFreeInterfaceEntry().

◆ BlHtLookup()

NTSTATUS BlHtLookup ( _In_ ULONG  TableId,
_In_ PBL_HASH_ENTRY  Entry,
_Out_ PBL_HASH_VALUE Value 
)

◆ BlHtStore()

NTSTATUS BlHtStore ( _In_ ULONG  TableId,
_In_ PBL_HASH_ENTRY  Entry,
_In_ PVOID  Data,
_In_ ULONG  DataSize 
)

Definition at line 668 of file util.c.

674{
675 PBL_HASH_NODE HashNode;
677 PLIST_ENTRY HashLinkHead;
679
680 /* Check for invalid table ID, missing arguments, or malformed entry */
681 if ((HtTableSize <= TableId) ||
682 !(Entry) ||
683 !(Data) ||
684 !(Entry->Size) ||
685 !(Entry->Value) ||
686 !(DataSize) ||
687 ((Entry->Flags & BL_HT_VALUE_IS_INLINE) && (Entry->Size != sizeof(ULONG))))
688 {
689 /* Fail the call */
691 goto Quickie;
692 }
693
694 /* Get the hash table for this ID */
695 HashTable = HtTableArray[TableId];
696
697 /* Allocate a hash node */
698 HashNode = BlMmAllocateHeap(sizeof(*HashNode));
699 if (!HashNode)
700 {
702 goto Quickie;
703 }
704
705 /* Capture all the data*/
706 HashNode->Entry.Size = Entry->Size;
707 HashNode->Entry.Flags = Entry->Flags;
708 HashNode->Entry.Value = Entry->Value;
709 HashNode->Value.DataSize = DataSize;
710 HashNode->Value.Data = Data;
711
712 /* Insert it into the bucket list and return success */
713 HashLinkHead = &HashTable->HashLinks[HashTable->HashFunction(Entry, HashTable->Size)];
714 InsertTailList(HashLinkHead, &HashNode->ListEntry);
716
717Quickie:
718 return Status;
719}
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4755
ULONG Flags
Definition: bl.h:1179
ULONG Size
Definition: bl.h:1178
PVOID Value
Definition: bl.h:1180
BL_HASH_VALUE Value
Definition: bl.h:1193
PVOID Data
Definition: bl.h:1186
ULONG DataSize
Definition: bl.h:1185

Referenced by BlockIoFirmwareOpen(), and EfiVmOpenProtocol().

◆ BlImgFindSection()

PIMAGE_SECTION_HEADER BlImgFindSection ( _In_ PVOID  ImageBase,
_In_ ULONG  ImageSize 
)

Definition at line 611 of file image.c.

615{
616 PIMAGE_SECTION_HEADER FoundSection;
617 ULONG i;
618 PIMAGE_SECTION_HEADER SectionHeader;
619 PIMAGE_NT_HEADERS NtHeader;
621
622 /* Assume failure */
623 FoundSection = NULL;
624
625 /* Make sure the image is valid */
626 Status = RtlImageNtHeaderEx(0, ImageBase, ImageSize, &NtHeader);
627 if (NT_SUCCESS(Status))
628 {
629 /* Get the first section and loop through them all */
630 SectionHeader = IMAGE_FIRST_SECTION(NtHeader);
631 for (i = 0; i < NtHeader->FileHeader.NumberOfSections; i++)
632 {
633 /* Check if this is the resource section */
634 if (!_stricmp((PCCH)SectionHeader->Name, ".rsrc"))
635 {
636 /* Yep, we're done */
637 FoundSection = SectionHeader;
638 break;
639 }
640
641 /* Nope, keep going */
642 SectionHeader++;
643 }
644 }
645
646 /* Return the matching section */
647 return FoundSection;
648}
NTSTATUS NTAPI RtlImageNtHeaderEx(_In_ ULONG Flags, _In_ PVOID Base, _In_ ULONG64 Size, _Out_ PIMAGE_NT_HEADERS *OutHeaders)
Definition: libsupp.c:32
#define _stricmp
Definition: cat.c:22
CONST CHAR * PCCH
Definition: ntbasedef.h:392
#define IMAGE_FIRST_SECTION(NtHeader)
Definition: ntimage.h:427
IMAGE_FILE_HEADER FileHeader
Definition: ntddk_ex.h:183
BYTE Name[IMAGE_SIZEOF_SHORT_NAME]
Definition: pedump.c:281

Referenced by BlpResourceInitialize(), and ResFindDataEntryFromImage().

◆ BlImgLoadBootApplication()

NTSTATUS BlImgLoadBootApplication ( _In_ PBL_LOADED_APPLICATION_ENTRY  BootEntry,
_Out_ PULONG  AppHandle 
)

Definition at line 1324 of file image.c.

1328{
1330 PULONGLONG AllowedList;
1331 ULONGLONG AllowedCount;
1332 ULONG i, DeviceId, ImageSize, Flags, ListSize;
1334 PVOID UnlockCode, ImageBase;
1335 PBL_DEVICE_DESCRIPTOR Device, BitLockerDevice;
1336 PWCHAR Path;
1337 PBL_APPLICATION_ENTRY AppEntry;
1339 BOOLEAN DisableIntegrity, TestSigning;
1340 UCHAR Hash[64];
1341 PBL_IMAGE_APPLICATION_ENTRY ImageAppEntry;
1342
1343 /* Initialize all locals */
1344 BitLockerDevice = NULL;
1345 UnlockCode = NULL;
1346 ImageFile = NULL;
1347 DeviceId = -1;
1348 Device = NULL;
1349 ImageAppEntry = NULL;
1350 AppEntry = NULL;
1351 Path = NULL;
1352 ImageSize = 0;
1353 ImageBase = NULL;
1354
1355 /* Check for "allowed in-memory settings" */
1356 Status = BlpGetBootOptionIntegerList(BootEntry->BcdData,
1358 &AllowedList,
1359 &AllowedCount,
1360 TRUE);
1361 if (Status == STATUS_SUCCESS)
1362 {
1363 /* Loop through the list of allowed setting */
1364 for (i = 0; i < AllowedCount; i++)
1365 {
1366 /* Find the super undocumented one */
1367 if (AllowedList[i] == BcdLibraryInteger_UndocumentedMagic)
1368 {
1369 /* If it's present, append the current perf frequence to it */
1371 BlAppendBootOptionInteger(BootEntry,
1374 }
1375 }
1376 }
1377
1378#if BL_BITLOCKER_SUPPORT
1379 /* Do bitlocker stuff */
1380 Status = BlFveSecureBootUnlockBootDevice(BootEntry, &BitLockerDevice, &UnlockCode);
1381 if (!NT_SUCCESS(Status))
1382 {
1383 goto Quickie;
1384 }
1385#endif
1386
1387 /* Get the device on which this application is on*/
1388 Status = BlGetBootOptionDevice(BootEntry->BcdData,
1390 &Device,
1391 NULL);
1392 if (!NT_SUCCESS(Status))
1393 {
1394 goto Quickie;
1395 }
1396
1397 /* Get the path of the application */
1398 Status = BlGetBootOptionString(BootEntry->BcdData,
1400 &Path);
1401 if (!NT_SUCCESS(Status))
1402 {
1403 goto Quickie;
1404 }
1405
1406 /* Open the device */
1409 0,
1410 &DeviceId);
1411 if (!NT_SUCCESS(Status))
1412 {
1413 goto Quickie;
1414 }
1415
1416 /* Check for integrity BCD options */
1418 &DisableIntegrity,
1419 &TestSigning);
1420
1421#if BL_TPM_SUPPORT
1422 RtlZeroMemory(&Context, sizeof(Context);
1423 Context.BootEntry = BootEntry;
1424 BlEnNotifyEvent(0x10000003, &Context);
1425#endif
1426
1427 /* Enable signing and hashing checks if integrity is enabled */
1428 Flags = 0;
1429 if (!DisableIntegrity)
1430 {
1431 Flags = 0x8070;
1432 }
1433
1434 /* Now call the PE loader to load the image */
1435 Status = BlImgLoadPEImageEx(DeviceId,
1437 Path,
1438 &ImageBase,
1439 &ImageSize,
1440 Hash,
1441 Flags);
1442 if (!NT_SUCCESS(Status))
1443 {
1444 goto Quickie;
1445 }
1446
1447#if BL_KD_SUPPORT
1448 /* Check if we should notify the debugger of load */
1449 if (BdDebugTransitions)
1450 {
1451 /* Initialize it */
1452 BdForceDebug = 1;
1453 Status = BlBdInitialize();
1454 if (NT_SUCCESS(Status))
1455 {
1456 /* Check if it's enabled */
1457 if (BlBdDebuggerEnabled())
1458 {
1459 /* Send it an image load notification */
1461 RtlInitUnicodeString(&PathString, Path);
1462 BlBdLoadImageSymbols(&PathString, ImageBase);
1463 }
1464 }
1465 }
1466#endif
1467
1468#if BL_BITLOCKER_SUPPORT
1469 /* Do bitlocker stuff */
1470 Status = BlSecureBootCheckPolicyOnFveDevice(BitLockerDevice);
1471 if (!NT_SUCCESS(Status))
1472 {
1473 goto Quickie;
1474 }
1475#endif
1476
1477#if BL_BITLOCKER_SUPPORT
1478 /* Do bitlocker stuff */
1479 Status = BlFveSecureBootCheckpointBootApp(BootEntry, BitLockerDevice, Hash, UnlockCode);
1480 if (!NT_SUCCESS(Status))
1481 {
1482 goto Quickie;
1483 }
1484#endif
1485
1486 /* Get the BCD option size */
1487 ListSize = BlGetBootOptionListSize(BootEntry->BcdData);
1488
1489 /* Allocate an entry with all the BCD options */
1490 AppEntry = BlMmAllocateHeap(ListSize + sizeof(*AppEntry));
1491 if (!AppEntry)
1492 {
1494 goto Quickie;
1495 }
1496
1497 /* Zero it out */
1498 RtlZeroMemory(AppEntry, sizeof(*AppEntry));
1499
1500 /* Initialize it */
1501 strcpy(AppEntry->Signature, "BTAPENT");
1502 AppEntry->Guid = BootEntry->Guid;
1503 AppEntry->Flags = BootEntry->Flags;
1504
1505 /* Copy the BCD options */
1506 RtlCopyMemory(&AppEntry->BcdData, BootEntry->BcdData, ListSize);
1507
1508 /* Allocate the image entry */
1509 ImageAppEntry = BlMmAllocateHeap(sizeof(*ImageAppEntry));
1510 if (!ImageAppEntry)
1511 {
1513 goto Quickie;
1514 }
1515
1516 /* Initialize it */
1517 ImageAppEntry->ImageBase = ImageBase;
1518 ImageAppEntry->ImageSize = ImageSize;
1519 ImageAppEntry->AppEntry = AppEntry;
1520
1521 /* Check if this is the first entry */
1522 if (!IapTableEntries)
1523 {
1524 /* Allocate two entries */
1526 IapTableEntries = 2;
1528 if (!IapImageTable)
1529 {
1531 goto Quickie;
1532 }
1533
1534 /* Zero out the entries for now */
1536 }
1537
1538 /* Set this entry into the table */
1541 ImageAppEntry,
1542 AppHandle,
1544
1545Quickie:
1546 /* Is the device open? Close it if so */
1547 if (DeviceId != 1)
1548 {
1549 BlDeviceClose(DeviceId);
1550 }
1551
1552 /* Is there an allocated device? Free it */
1553 if (Device)
1554 {
1556 }
1557
1558 /* Is there an allocated path? Free it */
1559 if (Path)
1560 {
1562 }
1563
1564 /* Is there a bitlocker device? Free it */
1565 if (BitLockerDevice)
1566 {
1567 BlMmFreeHeap(BitLockerDevice);
1568 }
1569
1570 /* Is there a bitlocker unlock code? Free it */
1571 if (UnlockCode)
1572 {
1573 BlMmFreeHeap(UnlockCode);
1574 }
1575
1576 /* Did we succeed in creating an entry? */
1577 if (NT_SUCCESS(Status))
1578 {
1579 /* Remember there's one more in the table */
1581
1582 /* Return success */
1583 return Status;
1584 }
1585
1586 /* Did we load an image after all? */
1587 if (ImageBase)
1588 {
1589 /* Unload it */
1590 BlImgUnLoadImage(ImageBase, ImageSize, 0);
1591 }
1592
1593 /* Did we allocate an app entry? Free it */
1594 if (AppEntry)
1595 {
1596 BlMmFreeHeap(AppEntry);
1597 }
1598
1599 /* Do we have an image file entry? Free it */
1600 if (ImageFile)
1601 {
1603 }
1604
1605 /* Do we no longer have a single entry in the table? */
1607 {
1608 /* Free and destroy the table */
1610 IapTableEntries = 0;
1612 }
1613
1614 /* Return the failure code */
1615 return Status;
1616}
PRTL_UNICODE_STRING_BUFFER Path
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
@ BcdLibraryInteger_UndocumentedMagic
Definition: bcd.h:97
@ BcdLibraryDevice_ApplicationDevice
Definition: bcd.h:50
@ BcdLibraryIntegerList_AllowedInMemorySettings
Definition: bcd.h:103
@ BcdLibraryString_ApplicationPath
Definition: bcd.h:51
ULONGLONG BlTimeQueryPerformanceCounter(_Out_opt_ PLARGE_INTEGER Frequency)
Definition: time.c:101
NTSTATUS BlGetBootOptionDevice(_In_ PBL_BCD_OPTION List, _In_ ULONG Type, _Out_ PBL_DEVICE_DESCRIPTOR *Value, _In_opt_ PBL_BCD_OPTION *ExtraOptions)
Definition: bcdopt.c:321
NTSTATUS BlAppendBootOptionInteger(_In_ PBL_LOADED_APPLICATION_ENTRY AppEntry, _In_ ULONG OptionId, _In_ ULONGLONG Value)
Definition: bcdopt.c:657
NTSTATUS TblDoNotPurgeEntry(_In_ PVOID Entry)
Definition: util.c:495
NTSTATUS BlTblSetEntry(_Inout_ PVOID **Table, _Inout_ PULONG Count, _In_ PVOID Entry, _Out_ PULONG EntryIndex, _In_ PBL_TBL_SET_ROUTINE Callback)
Definition: util.c:321
NTSTATUS BlpGetBootOptionIntegerList(_In_ PBL_BCD_OPTION List, _In_ ULONG Type, _Out_ PULONGLONG *Value, _Out_ PULONGLONG Count, _In_ BOOLEAN NoCopy)
Definition: bcdopt.c:541
NTSTATUS BlGetBootOptionString(_In_ PBL_BCD_OPTION List, _In_ ULONG Type, _Out_ PWCHAR *Value)
Definition: bcdopt.c:146
BOOLEAN BlBdDebuggerEnabled(VOID)
Definition: debug.c:53
ULONG BlGetBootOptionListSize(_In_ PBL_BCD_OPTION BcdOption)
Definition: bcdopt.c:79
VOID BlImgQueryCodeIntegrityBootOptions(_In_ PBL_LOADED_APPLICATION_ENTRY ApplicationEntry, _Out_ PBOOLEAN IntegrityChecksDisabled, _Out_ PBOOLEAN TestSigning)
Definition: image.c:651
ULONG IapAllocatedTableEntries
Definition: image.c:16
NTSTATUS BlImgLoadPEImageEx(_In_ ULONG DeviceId, _In_ BL_MEMORY_TYPE MemoryType, _In_ PWCHAR Path, _Out_ PVOID *ImageBase, _Out_ PULONG ImageSize, _Out_ PVOID Hash, _In_ ULONG Flags)
Definition: image.c:1276
NTSTATUS BlImgUnLoadImage(_In_ PVOID ImageBase, _In_ ULONG ImageSize, _In_ ULONG ImageFlags)
Definition: image.c:675
ULONG IapTableEntries
Definition: image.c:17
PVOID * IapImageTable
Definition: image.c:18
static int Hash(const char *)
Definition: reader.c:2257
static PWSTR ImageFile
Definition: imagefile.c:10
Definition: bl.h:855
ULONG Flags
Definition: bl.h:857
CHAR Signature[8]
Definition: bl.h:856
GUID Guid
Definition: bl.h:858
BL_BCD_OPTION BcdData
Definition: bl.h:860
Definition: bl.h:1284
PBL_APPLICATION_ENTRY AppEntry
Definition: bl.h:1285
ULONG ImageSize
Definition: bl.h:1287
PVOID ImageBase
Definition: bl.h:1286
static LARGE_INTEGER Frequency
Definition: clock.c:41
LONGLONG QuadPart
Definition: typedefs.h:114
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by BmpTransferExecution().

◆ BlImgLoadImageWithProgress2()

NTSTATUS BlImgLoadImageWithProgress2 ( _In_ ULONG  DeviceId,
_In_ BL_MEMORY_TYPE  MemoryType,
_In_ PWCHAR  FileName,
_Inout_ PVOID MappedBase,
_Inout_ PULONG  MappedSize,
_In_ ULONG  ImageFlags,
_In_ BOOLEAN  ShowProgress,
_Out_opt_ PUCHAR HashBuffer,
_Out_opt_ PULONG  HashSize 
)

Definition at line 358 of file image.c.

369{
372 ULONG RemainingLength, CurrentSize, ImageSize, ReadSize;
373 BOOLEAN ComputeSignature, ComputeHash, Completed;
377
378 /* Initialize variables */
379 BaseAddress = 0;
380 ImageSize = 0;
381 Completed = FALSE;
383
384 /* Check for missing parameters */
385 if (!MappedBase)
386 {
388 goto Quickie;
389 }
390 if (!FileName)
391 {
393 goto Quickie;
394 }
395 if (!MappedSize)
396 {
398 goto Quickie;
399 }
400
401 /* Check if the image buffer is being provided */
403 {
404 /* An existing base must already exist */
405 if (!(*MappedBase))
406 {
408 goto Quickie;
409 }
410 }
411
412 /* Check of a hash is being requested */
414 {
415 /* Make sure we can return the hash */
416 if (!HashBuffer)
417 {
419 goto Quickie;
420 }
421 if (!HashSize)
422 {
424 goto Quickie;
425 }
426 }
427
428 /* Check for invalid combination of parameters */
430 {
432 goto Quickie;
433 }
434
435 /* Initialize hash if requested by caller */
436 if (HashBuffer)
437 {
438 *HashBuffer = 0;
439 }
440
441 /* Do the same for the hash size */
442 if (HashSize)
443 {
444 *HashSize = 0;
445 }
446
447 /* Open the image file */
448 Status = ImgpOpenFile(DeviceId, FileName, DeviceId, &FileHandle);
449 if (!NT_SUCCESS(Status))
450 {
451 EfiPrintf(L"Error opening file: %lx\r\n", Status);
452 goto Quickie;
453 }
454
455 /* Get the size of the image */
456 Status = ImgpGetFileSize(&FileHandle, &ImageSize);
457 if (!NT_SUCCESS(Status))
458 {
459 EfiPrintf(L"Error getting file size: %lx\r\n", Status);
460 goto Quickie;
461 }
462
463 /* Read the current base address */
466 {
467 /* Check if the current buffer is too small */
468 if (*MappedSize < ImageSize)
469 {
470 /* Return the required size of the buffer */
471 *MappedSize = ImageSize;
473 }
474 }
475 else
476 {
477 /* A buffer was not provided, allocate one ourselves */
479 MemoryType,
480 ImageSize,
481 ImageFlags);
482 }
483
484 /* Bail out if allocation failed */
485 if (!NT_SUCCESS(Status))
486 {
487 goto Quickie;
488 }
489
490 /* Set the initial byte offset and length to read */
491 RemainingLength = ImageSize;
492 ByteOffset = 0;
494
495 /* Update the initial progress */
496 Completed = FALSE;
497 if (ShowProgress)
498 {
499 BlUtlUpdateProgress(0, &Completed);
500 ShowProgress &= (Completed != 0) - 1;
501 }
502
503 /* Set the chunk size for each read */
504 ReadSize = 0x100000;
505 if (ReadSize > ImageSize)
506 {
507 ReadSize = ImageSize;
508 }
509
510 /* Check if we should compute hash and/or signatures */
511 ComputeSignature = ImageFlags & BL_LOAD_IMG_COMPUTE_SIGNATURE;
512 ComputeHash = FALSE;
513 if ((ComputeSignature) || (ImageFlags & BL_LOAD_IMG_COMPUTE_HASH))
514 {
515 ComputeHash = TRUE;
516 // todo: crypto is hard
517 }
518
519 /* Begin the read loop */
520 while (RemainingLength)
521 {
522 /* Check if we've got more than a chunk left to read */
523 if (RemainingLength > ReadSize)
524 {
525 /* Read a chunk*/
526 CurrentSize = ReadSize;
527 }
528 else
529 {
530 /* Read only what's left */
531 CurrentSize = RemainingLength;
532 }
533
534 /* Read the chunk */
536 CurrentSize,
538 Buffer,
539 0);
540 if (!NT_SUCCESS(Status))
541 {
542 goto Quickie;
543 }
544
545 /* Check if we need to compute the hash of this chunk */
546 if (ComputeHash)
547 {
548 // todo: crypto is hard
549 }
550
551 /* Update our position and read information */
552 Buffer = (PVOID)((ULONG_PTR)Buffer + CurrentSize);
553 RemainingLength -= CurrentSize;
554 ByteOffset += CurrentSize;
555
556 /* Check if we should update the progress bar */
557 if (ShowProgress)
558 {
559 /* Compute new percentage completed, check if we're done */
560 BlUtlUpdateProgress(100 - 100 * RemainingLength / ImageSize,
561 &Completed);
562 ShowProgress &= (Completed != 0) - 1;
563 }
564 }
565
566 /* Is the read fully complete? We need to finalize the hash if requested */
567 if (ComputeHash)
568 {
569 // todo: CRYPTO IS HARD
570 }
571
572 /* Success path, return back the buffer and the size of the image */
574 *MappedSize = ImageSize;
575
576Quickie:
577 /* Close the file handle */
579
580 /* Check if we failed and had allocated a buffer */
581 if (!(NT_SUCCESS(Status)) &&
582 (BaseAddress) &&
584 {
585 /* Check what kind of buffer we had allocated */
587 {
588 /* Unmap and free the virtual buffer */
592 }
593 else
594 {
595 /* Free the physical buffer */
597 }
598 }
599
600 /* If we hadn't gotten to 100% yet, do it now */
601 if (ShowProgress)
602 {
603 BlUtlUpdateProgress(100, &Completed);
604 }
605
606 /* Return the final status */
607 return Status;
608}
NTSTATUS BlMmFreePhysicalPages(_In_ PHYSICAL_ADDRESS Address)
Definition: pagealloc.c:1187
#define BL_LOAD_IMG_VIRTUAL_BUFFER
Definition: bl.h:171
#define BL_LOAD_IMG_COMPUTE_SIGNATURE
Definition: bl.h:174
#define BL_LOAD_IMG_EXISTING_BUFFER
Definition: bl.h:172
#define BL_LOAD_IMG_COMPUTE_HASH
Definition: bl.h:175
VOID BlUtlUpdateProgress(_In_ ULONG Percentage, _Out_opt_ PBOOLEAN Completed)
Definition: util.c:181
NTSTATUS BlImgAllocateImageBuffer(_Inout_ PVOID *ImageBuffer, _In_ ULONG MemoryType, _In_ ULONGLONG ImageSize, _In_ ULONG Flags)
Definition: image.c:248
NTSTATUS ImgpReadAtFileOffset(_In_ PBL_IMG_FILE File, _In_ ULONG Size, _In_ ULONGLONG ByteOffset, _In_ PVOID Buffer, _Out_ PULONG BytesReturned)
Definition: image.c:72
NTSTATUS ImgpCloseFile(_In_ PBL_IMG_FILE File)
Definition: image.c:178
NTSTATUS ImgpOpenFile(_In_ ULONG DeviceId, _In_ PWCHAR FileName, _In_ ULONG Flags, _Out_ PBL_IMG_FILE NewFile)
Definition: image.c:124
NTSTATUS ImgpGetFileSize(_In_ PBL_IMG_FILE File, _Out_ PULONG FileSize)
Definition: image.c:33
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
ImageFlags
Definition: gdiplusenums.h:332
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1098
_Must_inspect_result_ _Outptr_result_bytebuffer_ ViewSize PVOID * MappedBase
Definition: mmfuncs.h:492

Referenced by BiLoadHive().

◆ BlImgQueryCodeIntegrityBootOptions()

VOID BlImgQueryCodeIntegrityBootOptions ( _In_ PBL_LOADED_APPLICATION_ENTRY  ApplicationEntry,
_Out_ PBOOLEAN  IntegrityChecksDisabled,
_Out_ PBOOLEAN  TestSigning 
)

Definition at line 651 of file image.c.

656{
657
660
661 /* Check if /DISABLEINTEGRITYCHECKS is on */
662 Status = BlGetBootOptionBoolean(ApplicationEntry->BcdData,
664 &Value);
665 *IntegrityChecksDisabled = NT_SUCCESS(Status) && (Value);
666
667 /* Check if /TESTSIGNING is on */
668 Status = BlGetBootOptionBoolean(ApplicationEntry->BcdData,
670 &Value);
671 *TestSigning = NT_SUCCESS(Status) && (Value);
672}
@ BcdLibraryBoolean_DisableIntegrityChecks
Definition: bcd.h:88
@ BcdLibraryBoolean_AllowPrereleaseSignatures
Definition: bcd.h:89

Referenced by BlImgLoadBootApplication(), and BmMain().

◆ BlImgStartBootApplication()

NTSTATUS BlImgStartBootApplication ( _In_ ULONG  AppHandle,
_Inout_ PBL_RETURN_ARGUMENTS  ReturnArguments 
)

Referenced by BmpTransferExecution().

◆ BlImgUnloadBootApplication()

NTSTATUS BlImgUnloadBootApplication ( _In_ ULONG  AppHandle)

Definition at line 2021 of file image.c.

2024{
2025 PBL_IMAGE_APPLICATION_ENTRY ImageAppEntry;
2027
2028 /* Make sure the handle index is valid */
2029 if (IapTableEntries <= AppHandle)
2030 {
2032 }
2033
2034 /* Get the entry for this handle, making sure it exists */
2035 ImageAppEntry = IapImageTable[AppHandle];
2036 if (!ImageAppEntry)
2037 {
2039 }
2040
2041 /* Unload the image */
2042 Status = BlImgUnLoadImage(ImageAppEntry->ImageBase,
2043 ImageAppEntry->ImageSize,
2044 0);
2045 if (NT_SUCCESS(Status))
2046 {
2047 /* Normalize the success code */
2049 }
2050 else
2051 {
2052 /* Normalize the failure code */
2054 }
2055
2056 /* Free the entry and the image entry as well */
2057 BlMmFreeHeap(ImageAppEntry->AppEntry);
2058 BlMmFreeHeap(ImageAppEntry);
2059
2060 /* Clear the handle */
2061 IapImageTable[AppHandle] = NULL;
2062
2063 /* Free one entry */
2064 if (!(--IapAllocatedTableEntries))
2065 {
2066 /* There are no more, so get rid of the table itself */
2069 IapTableEntries = 0;
2070 }
2071
2072 /* All good */
2073 return Status;
2074}
#define STATUS_MEMORY_NOT_ALLOCATED
Definition: ntstatus.h:396

Referenced by BmpTransferExecution().

◆ BlInitializeLibrary()

NTSTATUS BlInitializeLibrary ( _In_ PBOOT_APPLICATION_PARAMETER_BLOCK  BootAppParameters,
_In_ PBL_LIBRARY_PARAMETERS  LibraryParameters 
)

Definition at line 355 of file bootlib.c.

359{
361
362 /* Are we re-initializing the library? */
363 if (LibraryParameters->LibraryFlags & BL_LIBRARY_FLAG_REINITIALIZE)
364 {
365 /* From scratch? */
366 BlpLibraryParameters = *LibraryParameters;
367 if (LibraryParameters->LibraryFlags & BL_LIBRARY_FLAG_REINITIALIZE_ALL)
368 {
369#ifdef BL_TPM_SUPPORT
370 /* Reinitialize the TPM security enclave as BCD hash changed */
371 BlpSiInitialize(1);
372#endif
373#ifdef BL_KD_SUPPORT
374 /* Reinitialize the boot debugger as BCD debug options changed */
375 BlBdInitialize();
376#endif
377
378 /* Reparse the bad page list now that the BCD has been reloaded */
380
381 /* Reparse the low/high physical address limits as well */
383
384 /* Redraw the graphics console as needed */
385 BlpDisplayInitialize(LibraryParameters->LibraryFlags);
386
387 /* Reinitialize resources (language may have changed) */
389 }
390
391 /* Nothing to do, we're done */
393 }
394 else
395 {
396 /* Nope, this is first time initialization */
397 Status = InitializeLibrary(BootAppParameters, LibraryParameters);
398 }
399
400 /* Return initialization status */
401 return Status;
402}
NTSTATUS BlpDisplayInitialize(_In_ ULONG Flags)
Definition: display.c:575
#define BL_LIBRARY_FLAG_REINITIALIZE
Definition: bl.h:128
NTSTATUS BlMmRemoveBadMemory(VOID)
Definition: mm.c:155
NTSTATUS BlpResourceInitialize(VOID)
Definition: resource.c:478
#define BL_LIBRARY_FLAG_REINITIALIZE_ALL
Definition: bl.h:129
NTSTATUS BlpMmInitializeConstraints(VOID)
Definition: pagealloc.c:106
BL_LIBRARY_PARAMETERS BlpLibraryParameters
Definition: bootlib.c:15
NTSTATUS InitializeLibrary(_In_ PBOOT_APPLICATION_PARAMETER_BLOCK BootAppParameters, _In_ PBL_LIBRARY_PARAMETERS LibraryParameters)
Definition: bootlib.c:44

Referenced by BmMain(), and OslMain().

◆ BlMmAllocateHeap()

PVOID BlMmAllocateHeap ( _In_ SIZE_T  Size)

Definition at line 569 of file heapalloc.c.

572{
575 PBL_BUSY_HEAP_ENTRY BusyEntry, FreeEntry, NextEntry;
576
577 /* Ignore heap allocation if the heap allocator isn't ready yet */
579 {
580 return NULL;
581 }
582
583 /* Align the buffer size to the minimum size required */
586
587 /* Watch out for overflow */
588 if (BufferSize <= Size)
589 {
590 return NULL;
591 }
592
593 /* Make sure it's at least big enough to hold a free entry later on */
594 if (BufferSize < sizeof(BL_FREE_HEAP_ENTRY))
595 {
597 }
598
599 /* Loop while we try to allocate memory */
600 while (1)
601 {
602 /* Find a free buffer for this allocation */
604 if (BusyEntry)
605 {
606 break;
607 }
608
609 /* We couldn't find a free buffer. Do we have any heaps? */
611 {
612 /* Get the current heap */
615 ListEntry);
616
617 /* Check if we have space in the heap page for this allocation? */
618 FreeEntry = Heap->HeapStart;
619 NextEntry = (PBL_BUSY_HEAP_ENTRY)((ULONG_PTR)FreeEntry + BufferSize);
620
621 if ((NextEntry >= FreeEntry) &&
622 ((ULONG_PTR)NextEntry <=
624 {
625 /* Update the heap top pointer past this allocation */
626 Heap->HeapStart = NextEntry;
627
628 /* Make this allocation point to the slot */
629 FreeEntry->BufferNext.P = Heap->HeapStart;
630
631 /* And make the free heap entry point back to us */
632 Heap->HeapStart->BufferPrevious.P = FreeEntry;
633
634 /* Mark the heap entry as being free and on the heap */
637
638 /* The previously freed entry on the heap page is now ours */
639 BusyEntry = FreeEntry;
640 break;
641 }
642 }
643
644 /* We have no heaps or space on any heap -- extend the heap and retry */
646 {
647 EfiPrintf(L"Heap extension failed!\r\n");
648 return NULL;
649 }
650
651 EfiPrintf(L"Heap extended -- trying again\r\n");
652 }
653
654 /* Clear all the bits, marking this entry as allocated */
655 BusyEntry->BufferNext.P = MmHapDecodeLink(BusyEntry->BufferNext);
656
657 /* Return the entry's data buffer */
658 //EfiPrintf(L"Returning buffer at 0x%p\r\n", &BusyEntry->Buffer);
659 return &BusyEntry->Buffer;
660}
#define ALIGN_UP_BY(size, align)
#define BufferSize
Definition: mmc.h:75
struct _BL_BUSY_HEAP_ENTRY * PBL_BUSY_HEAP_ENTRY
LIST_ENTRY MmHeapBoundaries
Definition: heapalloc.c:57
struct _BL_FREE_HEAP_ENTRY BL_FREE_HEAP_ENTRY
PBL_BUSY_HEAP_ENTRY MmHapFindBufferInFreeList(_In_ ULONG Size)
Definition: heapalloc.c:450
FORCEINLINE PBL_FREE_HEAP_ENTRY MmHapDecodeLink(_In_ BL_HEAP_POINTER Link)
Definition: heapalloc.c:66
NTSTATUS MmHapHeapAllocatorExtend(_In_ ULONG ExtendSize)
Definition: heapalloc.c:102
ULONG HapInitializationStatus
Definition: heapalloc.c:56
Definition: heapalloc.c:41
UCHAR Buffer[ANYSIZE_ARRAY]
Definition: heapalloc.c:44
BL_HEAP_POINTER BufferNext
Definition: heapalloc.c:42
BL_HEAP_POINTER BufferPrevious
Definition: heapalloc.c:43
Definition: heapalloc.c:33
PBL_BUSY_HEAP_ENTRY HeapStart
Definition: heapalloc.c:53
ULONG_PTR HeapLimit
Definition: heapalloc.c:51
ULONG_PTR BufferFree
Definition: heapalloc.c:23
ULONG_PTR BufferOnHeap
Definition: heapalloc.c:24
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

Referenced by BcdEnumerateAndUnpackElements(), BcdOpenStoreFromFile(), BfLoadFontFile(), BiEnumerateElements(), BiEnumerateSubKeys(), BiGetRegistryValue(), BiLoadHive(), BiOpenKey(), BlAppendBootOptionBoolean(), BlAppendBootOptionInteger(), BlAppendBootOptions(), BlAppendBootOptionString(), BlCopyBootOptions(), BlGetBootOptionDevice(), BlGetBootOptionGuidList(), BlGetBootOptionString(), BlHtCreate(), BlHtStore(), BlImgLoadBootApplication(), BlMmGetMemoryMap(), BlockIoEfiCreateDeviceEntry(), BlockIoOpen(), BlockIopInitialize(), BlpDeviceInitialize(), BlpDeviceOpen(), BlpFileInitialize(), BlpFileRegisterFileSystem(), BlpGetBootOptionIntegerList(), BlpIoInitialize(), BlpMmCreateBlockAllocator(), BlReplaceBootOptions(), BlTblSetEntry(), BmEnumerateBootEntries(), BmFwInitializeBootDirectoryPath(), BmGetBootSequence(), BmGetOptionList(), BmOpenDataStore(), BmpFwGetApplicationDirectoryPath(), BmpFwGetFullPath(), BmpGetSelectedBootEntry(), BmpPopulateBootEntryList(), CmpAllocate(), ConsoleCreateLocalInputConsole(), ConsoleCreateRemoteConsole(), ConsoleEfiTextFindModeFromAllowed(), ConsoleInputBaseConstruct(), ConsolepClearBuffer(), ConvertBmpToGopBlt(), DsppInitialize(), DsppLoadFontFile(), EfiLocateHandleBuffer(), EfiVmOpenProtocol(), EtfsInitialize(), EtfsMount(), EtfsOpen(), EtfspCreateContext(), FatInitialize(), FileIoCopyFileName(), FileIoCopyParentDirectoryPath(), ImgpInitializeBootApplicationParameters(), MmBaInitialize(), MmMdFreeGlobalDescriptors(), OslPrepareTarget(), and RtlpAllocateMemory().

◆ BlMmAllocatePhysicalPages()

NTSTATUS BlMmAllocatePhysicalPages ( _Inout_ PPHYSICAL_ADDRESS  Address,
_In_ BL_MEMORY_TYPE  MemoryType,
_In_ ULONGLONG  PageCount,
_In_ ULONG  Attributes,
_In_ ULONG  Alignment 
)

Referenced by BlImgAllocateImageBuffer(), and BmMain().

◆ BlMmFreeHeap()

NTSTATUS BlMmFreeHeap ( _In_ PVOID  Buffer)

Definition at line 663 of file heapalloc.c.

666{
667 PBL_BUSY_HEAP_ENTRY BusyEntry;
669 PLIST_ENTRY NextEntry;
670
671 /* If the heap is not initialized, fail */
673 {
674 return STATUS_UNSUCCESSFUL;
675 }
676
677 /* Get the heap header */
678 //EfiPrintf(L"Freeing entry at: %p\r\n", Buffer);
679 if (Buffer)
680 {
681 /* Don't free heap until we discover the corruption */
682 return STATUS_SUCCESS;
683 }
684
686
687 /* Loop all the heaps */
688 NextEntry = MmHeapBoundaries.Flink;
689 while (NextEntry != &MmHeapBoundaries)
690 {
691 /* Get the current heap in the list */
692 Heap = CONTAINING_RECORD(NextEntry, BL_HEAP_BOUNDARIES, ListEntry);
693
694 /* Is this entry part of this heap? */
695 if (((ULONG_PTR)Heap->HeapBase <= (ULONG_PTR)BusyEntry) &&
696 ((ULONG_PTR)BusyEntry < (ULONG_PTR)Heap->HeapStart))
697 {
698 /* Ignore double-free */
699 if (BusyEntry->BufferNext.BufferFree)
700 {
702 }
703
704 /* It is -- add it to the free list */
705 MmHapAddToFreeList(BusyEntry, 0);
706 return STATUS_SUCCESS;
707 }
708
709 /* It isn't, move to the next heap */
710 NextEntry = NextEntry->Flink;
711 }
712
713 /* The entry is not on any valid heap */
715}
PBL_FREE_HEAP_ENTRY MmHapAddToFreeList(_In_ PBL_BUSY_HEAP_ENTRY Entry, _In_ ULONG Flags)
Definition: heapalloc.c:393
ULONG_PTR HeapBase
Definition: heapalloc.c:52

Referenced by BcdEnumerateAndUnpackElements(), BcdOpenStoreFromFile(), BfiFreeDeferredFontFile(), BiCloseKey(), BiDeleteKey(), BiEnumerateElements(), BiEnumerateSubKeys(), BiGetObjectDescription(), BiLoadHive(), BiOpenKey(), BlAppendBootOptionBoolean(), BlAppendBootOptionInteger(), BlAppendBootOptions(), BlAppendBootOptionString(), BlDestroyBootEntry(), BlFwEnumerateDevice(), BlGetBootOptionDevice(), BlHtCreate(), BlHtDelete(), BlImgLoadBootApplication(), BlImgUnloadBootApplication(), BlMmGetMemoryMap(), BlockIoDeviceTableDestroy(), BlockIoDeviceTableDestroyEntry(), BlockIoEfiCompareDevice(), BlockIoEfiCreateDeviceEntry(), BlockIoEfiGetChildHandle(), BlockIoFirmwareOpen(), BlockIopDestroy(), BlockIopFreeAllocations(), BlpDeviceOpen(), BlpFileRegisterFileSystem(), BlpMmCreateBlockAllocator(), BlpResourceInitialize(), BlReplaceBootOptions(), BlTblSetEntry(), BmEnumerateBootEntries(), BmErrorPurge(), BmFwInitializeBootDirectoryPath(), BmGetBootSequence(), BmGetOptionList(), BmLaunchRecoverySequence(), BmMain(), BmOpenDataStore(), BmpFwGetApplicationDirectoryPath(), BmpGetSelectedBootEntry(), BmpInitializeBootStatusDataLog(), BmpPopulateBootEntryList(), BmpTransferExecution(), BmpUpdateApplicationOptions(), CmpFree(), ConsoleCreateLocalInputConsole(), ConsoleCreateRemoteConsole(), ConsoleEfiTextFindModeFromAllowed(), ConsoleInputLocalDestruct(), DeviceTableDestroyEntry(), DsppInitialize(), DsppLoadFontFile(), EfiLocateHandleBuffer(), EfiVmOpenProtocol(), EfiVmpFreeInterfaceEntry(), EtfsMount(), EtfsOpen(), EtfspDeviceContextDestroy(), FileIoCopyParentDirectoryPath(), FileIoOpen(), FileTableDestroyEntry(), ImgpInitializeBootApplicationParameters(), MmBapFreeBlockAllocatorTableEntry(), MmMdFreeDescriptor(), OslpRemoveInternalApplicationOptions(), OslPrepareTarget(), and RtlpFreeMemory().

◆ BlMmFreePhysicalPages()

NTSTATUS BlMmFreePhysicalPages ( _In_ PHYSICAL_ADDRESS  Address)

Definition at line 1187 of file pagealloc.c.

1190{
1191 /* Call the physical allocator */
1193}
NTSTATUS MmPapFreePhysicalPages(_In_ ULONG WhichList, _In_ ULONGLONG PageCount, _In_ PHYSICAL_ADDRESS Address)
Definition: pagealloc.c:1017
static WCHAR Address[46]
Definition: ping.c:68

Referenced by BlImgAllocateImageBuffer(), BlImgLoadImageWithProgress2(), BlImgUnallocateImageBuffer(), BmMain(), ImgpLoadPEImage(), and MmDefInitializeTranslation().

◆ BlMmGetMemoryMap()

NTSTATUS BlMmGetMemoryMap ( _In_ PLIST_ENTRY  MemoryMap,
_In_ PBL_BUFFER_DESCRIPTOR  MemoryParameters,
_In_ ULONG  WhichTypes,
_In_ ULONG  Flags 
)

Definition at line 1222 of file pagealloc.c.

1228{
1229 BL_MEMORY_DESCRIPTOR_LIST FirmwareMdList, FullMdList;
1230 BOOLEAN DoFirmware, DoPersistent, DoTruncated, DoBad;
1231 BOOLEAN DoReserved, DoUnmapUnalloc, DoUnmapAlloc;
1232 BOOLEAN DoMapAlloc, DoMapUnalloc, DoFirmware2;
1233 ULONG LoopCount, MdListCount, MdListSize, Used;
1235
1236 /* Initialize the firmware list if we use it */
1237 MmMdInitializeListHead(&FirmwareMdList);
1238
1239 /* Make sure we got our input parameters */
1240 if (!(MemoryMap) || !(MemoryParameters))
1241 {
1243 }
1244
1245 /* Either ask for firmware memory, or don't. Not neither */
1246 if ((WhichTypes & ~BL_MM_INCLUDE_NO_FIRMWARE_MEMORY) &&
1247 (WhichTypes & ~BL_MM_INCLUDE_ONLY_FIRMWARE_MEMORY))
1248 {
1250 }
1251
1252 /* Either ask for firmware memory, or don't. Not both */
1253 if ((WhichTypes & BL_MM_INCLUDE_NO_FIRMWARE_MEMORY) &&
1255 {
1257 }
1258
1259 /* Initialize the memory map list */
1261
1262 /* Check which types of memory to dump */
1263 DoFirmware = WhichTypes & BL_MM_INCLUDE_FIRMWARE_MEMORY;
1264 DoPersistent = WhichTypes & BL_MM_INCLUDE_PERSISTENT_MEMORY;
1265 DoTruncated = WhichTypes & BL_MM_INCLUDE_TRUNCATED_MEMORY;
1266 DoBad = WhichTypes & BL_MM_INCLUDE_BAD_MEMORY;
1267 DoReserved = WhichTypes & BL_MM_INCLUDE_RESERVED_ALLOCATED;
1268 DoUnmapUnalloc = WhichTypes & BL_MM_INCLUDE_UNMAPPED_UNALLOCATED;
1269 DoUnmapAlloc = WhichTypes & BL_MM_INCLUDE_UNMAPPED_ALLOCATED;
1270 DoMapAlloc = WhichTypes & BL_MM_INCLUDE_MAPPED_ALLOCATED;
1271 DoMapUnalloc = WhichTypes & BL_MM_INCLUDE_MAPPED_UNALLOCATED;
1272 DoFirmware2 = WhichTypes & BL_MM_INCLUDE_FIRMWARE_MEMORY_2;
1273
1274 /* Begin the attempt loop */
1275 LoopCount = 0;
1276 while (TRUE)
1277 {
1278 /* Count how many entries we will need */
1279 MdListCount = 0;
1280 if (DoMapAlloc) MdListCount = MmMdCountList(&MmMdlMappedAllocated);
1281 if (DoMapUnalloc) MdListCount += MmMdCountList(&MmMdlMappedUnallocated);
1282 if (DoUnmapAlloc) MdListCount += MmMdCountList(&MmMdlUnmappedAllocated);
1283 if (DoUnmapUnalloc) MdListCount += MmMdCountList(&MmMdlUnmappedUnallocated);
1284 if (DoReserved) MdListCount += MmMdCountList(&MmMdlReservedAllocated);
1285 if (DoBad) MdListCount += MmMdCountList(&MmMdlBadMemory);
1286 if (DoTruncated) MdListCount += MmMdCountList(&MmMdlTruncatedMemory);
1287 if (DoPersistent) MdListCount += MmMdCountList(&MmMdlPersistentMemory);
1288
1289 /* Plus firmware entries */
1290 if (DoFirmware)
1291 {
1292 /* Free the previous entries, if any */
1293 MmMdFreeList(&FirmwareMdList);
1294
1295 /* Get the firmware map, coalesced */
1296 Status = MmFwGetMemoryMap(&FirmwareMdList,
1298 if (!NT_SUCCESS(Status))
1299 {
1300 goto Quickie;
1301 }
1302
1303 /* We overwrite, since this type is exclusive */
1304 MdListCount = MmMdCountList(&FirmwareMdList);
1305 }
1306
1307 /* Plus firmware entries-2 */
1308 if (DoFirmware2)
1309 {
1310 /* Free the previous entries, if any */
1311 MmMdFreeList(&FirmwareMdList);
1312
1313 /* Get the firmware map, uncoalesced */
1314 Status = MmFwGetMemoryMap(&FirmwareMdList, 0);
1315 if (!NT_SUCCESS(Status))
1316 {
1317 goto Quickie;
1318 }
1319
1320 /* We overwrite, since this type is exclusive */
1321 MdListCount = MmMdCountList(&FirmwareMdList);
1322 }
1323
1324 /* If there's no descriptors, we're done */
1325 if (!MdListCount)
1326 {
1328 goto Quickie;
1329 }
1330
1331 /* Check if the buffer we have is big enough */
1332 if (MemoryParameters->BufferSize >=
1333 (sizeof(BL_MEMORY_DESCRIPTOR) * MdListCount))
1334 {
1335 break;
1336 }
1337
1338 /* It's not, allocate it, with a slack of 4 extra descriptors */
1339 MdListSize = sizeof(BL_MEMORY_DESCRIPTOR) * (MdListCount + 4);
1340
1341 /* Except if we weren't asked to */
1343 {
1344 MemoryParameters->BufferSize = MdListSize;
1346 goto Quickie;
1347 }
1348
1349 /* Has it been less than 4 times we've tried this? */
1350 if (++LoopCount <= 4)
1351 {
1352 /* Free the previous attempt, if any */
1353 if (MemoryParameters->BufferSize)
1354 {
1355 BlMmFreeHeap(MemoryParameters->Buffer);
1356 }
1357
1358 /* Allocate a new buffer */
1359 MemoryParameters->BufferSize = MdListSize;
1360 MemoryParameters->Buffer = BlMmAllocateHeap(MdListSize);
1361 if (MemoryParameters->Buffer)
1362 {
1363 /* Try again */
1364 continue;
1365 }
1366 }
1367
1368 /* If we got here, we're out of memory after 4 attempts */
1370 goto Quickie;
1371 }
1372
1373 /* We should have a buffer by now... */
1374 if (MemoryParameters->Buffer)
1375 {
1376 /* Zero it out */
1377 RtlZeroMemory(MemoryParameters->Buffer,
1378 MdListCount * sizeof(BL_MEMORY_DESCRIPTOR));
1379 }
1380
1381 /* Initialize our list of descriptors */
1382 MmMdInitializeList(&FullMdList, 0, MemoryMap);
1383 Used = 0;
1384
1385 /* Handle mapped, allocated */
1386 if (DoMapAlloc)
1387 {
1388 Status = MmMdCopyList(&FullMdList,
1390 MemoryParameters->Buffer,
1391 &Used,
1392 MdListCount,
1393 Flags);
1394 }
1395
1396 /* Handle mapped, unallocated */
1397 if (DoMapUnalloc)
1398 {
1399 Status = MmMdCopyList(&FullMdList,
1401 MemoryParameters->Buffer,
1402 &Used,
1403 MdListCount,
1404 Flags);
1405 }
1406
1407 /* Handle unmapped, allocated */
1408 if (DoUnmapAlloc)
1409 {
1410 Status = MmMdCopyList(&FullMdList,
1412 MemoryParameters->Buffer,
1413 &Used,
1414 MdListCount,
1415 Flags);
1416 }
1417
1418 /* Handle unmapped, unallocated */
1419 if (DoUnmapUnalloc)
1420 {
1421 Status = MmMdCopyList(&FullMdList,
1423 MemoryParameters->Buffer,
1424 &Used,
1425 MdListCount,
1426 Flags);
1427 }
1428
1429 /* Handle reserved, allocated */
1430 if (DoReserved)
1431 {
1432 Status = MmMdCopyList(&FullMdList,
1434 MemoryParameters->Buffer,
1435 &Used,
1436 MdListCount,
1437 Flags);
1438 }
1439
1440 /* Handle bad */
1441 if (DoBad)
1442 {
1443 Status = MmMdCopyList(&FullMdList,
1445 MemoryParameters->Buffer,
1446 &Used,
1447 MdListCount,
1448 Flags);
1449 }
1450
1451 /* Handle truncated */
1452 if (DoTruncated)
1453 {
1454 Status = MmMdCopyList(&FullMdList,
1456 MemoryParameters->Buffer,
1457 &Used,
1458 MdListCount,
1459 Flags);
1460 }
1461
1462 /* Handle persistent */
1463 if (DoPersistent)
1464 {
1465 Status = MmMdCopyList(&FullMdList,
1467 MemoryParameters->Buffer,
1468 &Used,
1469 MdListCount,
1470 Flags);
1471 }
1472
1473 /* Handle firmware */
1474 if (DoFirmware)
1475 {
1476 Status = MmMdCopyList(&FullMdList,
1477 &FirmwareMdList,
1478 MemoryParameters->Buffer,
1479 &Used,
1480 MdListCount,
1481 Flags);
1482 }
1483
1484 /* Handle firmware2 */
1485 if (DoFirmware2)
1486 {
1487 Status = MmMdCopyList(&FullMdList,
1488 &FirmwareMdList,
1489 MemoryParameters->Buffer,
1490 &Used,
1491 MdListCount,
1492 Flags);
1493 }
1494
1495 /* Add up the final size */
1496 Status = RtlULongLongToULong(Used * sizeof(BL_MEMORY_DESCRIPTOR),
1497 &MemoryParameters->ActualSize);
1498
1499Quickie:
1500 MmMdFreeList(&FirmwareMdList);
1501 return Status;
1502}
struct _BL_MEMORY_DESCRIPTOR BL_MEMORY_DESCRIPTOR
ULONG MmMdCountList(_In_ PBL_MEMORY_DESCRIPTOR_LIST MdList)
Definition: descriptor.c:205
FORCEINLINE VOID MmMdInitializeListHead(_In_ PBL_MEMORY_DESCRIPTOR_LIST List)
Definition: bl.h:1376
#define BL_MM_FLAG_REQUEST_COALESCING
Definition: bl.h:87
NTSTATUS MmMdCopyList(_In_ PBL_MEMORY_DESCRIPTOR_LIST DestinationList, _In_ PBL_MEMORY_DESCRIPTOR_LIST SourceList, _In_opt_ PBL_MEMORY_DESCRIPTOR ListDescriptor, _Out_ PULONG ActualCount, _In_ ULONG Count, _In_ ULONG Flags)
Definition: descriptor.c:249
#define BL_MM_INCLUDE_ONLY_FIRMWARE_MEMORY
Definition: bl.h:117
#define BL_MM_ADD_DESCRIPTOR_ALLOCATE_FLAG
Definition: bl.h:93
VOID MmMdFreeList(_In_ PBL_MEMORY_DESCRIPTOR_LIST MdList)
Definition: descriptor.c:356
VOID MmMdInitializeList(_In_ PBL_MEMORY_DESCRIPTOR_LIST DescriptorList, _In_ ULONG Type, _In_ PLIST_ENTRY ListHead)
Definition: descriptor.c:222
#define BL_MM_INCLUDE_NO_FIRMWARE_MEMORY
Definition: bl.h:107
NTSTATUS MmFwGetMemoryMap(_Out_ PBL_MEMORY_DESCRIPTOR_LIST MemoryMap, _In_ ULONG Flags)
Definition: firmware.c:1845
BIOS_MEMORY_MAP MemoryMap[32]
Definition: loader.c:11
BL_MEMORY_DESCRIPTOR_LIST MmMdlMappedUnallocated
Definition: pagealloc.c:36
BL_MEMORY_DESCRIPTOR_LIST MmMdlReservedAllocated
Definition: pagealloc.c:40
BL_MEMORY_DESCRIPTOR_LIST MmMdlBadMemory
Definition: pagealloc.c:41
BL_MEMORY_DESCRIPTOR_LIST MmMdlUnmappedAllocated
Definition: pagealloc.c:38
BL_MEMORY_DESCRIPTOR_LIST MmMdlTruncatedMemory
Definition: pagealloc.c:42
BL_MEMORY_DESCRIPTOR_LIST MmMdlMappedAllocated
Definition: pagealloc.c:35
BL_MEMORY_DESCRIPTOR_LIST MmMdlUnmappedUnallocated
Definition: pagealloc.c:39
BL_MEMORY_DESCRIPTOR_LIST MmMdlPersistentMemory
Definition: pagealloc.c:43

Referenced by ImgpInitializeBootApplicationParameters().

◆ BlMmMapPhysicalAddressEx()

NTSTATUS BlMmMapPhysicalAddressEx ( _In_ PVOID VirtualAddress,
_In_ ULONG  Attributes,
_In_ ULONGLONG  Size,
_In_ PHYSICAL_ADDRESS  PhysicalAddress 
)

Definition at line 192 of file mm.c.

198{
200 PVOID MappingAddress;
201 PHYSICAL_ADDRESS MappedAddress;
203 ULONGLONG MapSize;
204 UCHAR CacheAttributes;
205 ULONGLONG BasePage, EndPage, MappedPage, FoundBasePage;
206 ULONGLONG PageOffset, FoundPageCount;
209 ULONG AddPages;
210
211 /* Increase call depth */
213
214 /* Check if any parameters are missing */
215 if (!(VirtualAddress) || !(Size))
216 {
218 goto Quickie;
219 }
220
221 /* Check for fixed allocation without an actual address */
222 if ((Flags & BlMemoryFixed) &&
223 (PhysicalAddress.QuadPart == -1) &&
224 !(*VirtualAddress))
225 {
227 goto Quickie;
228 }
229
230 /* Check for invalid requirement flag, if one is present */
234 {
236 goto Quickie;
237 }
238
239 /* Check for invalid cache attribute flags */
242 {
244 goto Quickie;
245 }
246
247 /* Select an address to map this at */
248 Status = MmSelectMappingAddress(&MappingAddress,
250 Size,
252 Flags,
254 if (!NT_SUCCESS(Status))
255 {
256 goto Quickie;
257 }
258
259 /* Map the selected address, using the appropriate caching attributes */
260 MappedAddress = PhysicalAddress;
261 MapSize = Size;
262 CacheAttributes = ((Flags & BlMemoryValidCacheAttributeMask) != 0x20) ?
264 Status = MmMapPhysicalAddress(&MappedAddress,
265 &MappingAddress,
266 &MapSize,
267 CacheAttributes);
268 if (!NT_SUCCESS(Status))
269 {
270 goto Quickie;
271 }
272
273 /* Compute the final address where the mapping was made */
274 MappedBase = (PVOID)(ULONG_PTR)((ULONG_PTR)MappingAddress +
276 MappedAddress.QuadPart);
277 MappedAddress.QuadPart = (ULONG_PTR)MappedBase;
278
279 /* Check if we're in physical or virtual mode */
281 {
282 /* We are in physical mode -- just return this address directly */
285 goto Quickie;
286 }
287
288 /* Remove the mapping address from the list of free virtual memory */
291 (ULONG_PTR)MappingAddress >> PAGE_SHIFT,
292 MapSize >> PAGE_SHIFT,
293 NULL);
294 if (NT_SUCCESS(Status))
295 {
296 /* And then add an entry for the fact we mapped it */
298 CacheAttributes,
300 MapSize);
301 }
302
303 /* Abandon if we didn't update the memory map successfully */
304 if (!NT_SUCCESS(Status))
305 {
306 /* Unmap the virtual address so it can be used later */
307 MmUnmapVirtualAddress(MappingAddress, &MapSize);
308 goto Quickie;
309 }
310
311 /* Check if no real mapping into RAM was made */
312 if (PhysicalAddress.QuadPart == -1)
313 {
314 /* Then we're done here */
317 goto Quickie;
318 }
319
320
321 /* Loop over the entire allocation */
322 BasePage = MappedAddress.QuadPart >> PAGE_SHIFT;
323 EndPage = (MappedAddress.QuadPart + MapSize) >> PAGE_SHIFT;
324 MappedPage = (ULONG_PTR)MappingAddress >> PAGE_SHIFT;
325 do
326 {
327 /* Start with the unmapped allocated list */
331 BasePage);
332 if (!Descriptor)
333 {
334 /* Try persistent next */
338 BasePage);
339 }
340 if (!Descriptor)
341 {
342 /* Try unmapped, unallocated, next */
346 BasePage);
347 }
348 if (!Descriptor)
349 {
350 /* Try reserved next */
354 BasePage);
355 }
356
357 /* Check if we have a descriptor */
358 if (Descriptor)
359 {
360 /* Remove it from its list */
362
363 /* Check if it starts before our allocation */
364 FoundBasePage = Descriptor->BasePage;
365 if (FoundBasePage < BasePage)
366 {
367 /* Create a new descriptor to cover the gap before our allocation */
368 PageOffset = BasePage - FoundBasePage;
370 Descriptor->Type,
371 FoundBasePage,
372 0,
373 PageOffset);
374
375 /* Insert it */
377
378 /* Adjust ours to ignore that piece */
379 Descriptor->PageCount -= PageOffset;
380 Descriptor->BasePage = BasePage;
381 }
382
383 /* Check if it goes beyond our allocation */
384 FoundPageCount = Descriptor->PageCount;
385 if (EndPage < (FoundPageCount + Descriptor->BasePage))
386 {
387 /* Create a new descriptor to cover the range after our allocation */
388 PageOffset = EndPage - BasePage;
390 Descriptor->Type,
391 EndPage,
392 0,
393 FoundPageCount -
394 PageOffset);
395
396 /* Insert it */
398
399 /* Adjust ours to ignore that piece */
400 Descriptor->PageCount = PageOffset;
401 }
402
403 /* Update the descriptor to be mapepd at this virtual page */
404 Descriptor->VirtualPage = MappedPage;
405
406 /* Check if this was one of the regular lists */
407 if ((List != &MmMdlReservedAllocated) &&
409 {
410 /* Was it allocated, or unallocated? */
412 {
413 /* In which case use the unallocated mapped list */
415 }
416 else
417 {
418 /* Insert it into the mapped list */
420 }
421 }
422
423 /* Add the descriptor that was removed, into the right list */
425
426 /* Add the pages this descriptor had */
427 AddPages = Descriptor->PageCount;
428 }
429 else
430 {
431 /* Nope, so just add one page */
432 AddPages = 1;
433 }
434
435 /* Increment the number of pages the descriptor had */
436 MappedPage += AddPages;
437 BasePage += AddPages;
438 }
439 while (BasePage < EndPage);
440
441 /* We're done -- returned the address */
444
445Quickie:
446 /* Cleanup descriptors and reduce depth */
449 return Status;
450}
BL_MEMORY_DESCRIPTOR_LIST MmMdlMappedUnallocated
Definition: pagealloc.c:36
NTSTATUS MmMdAddDescriptorToList(_In_ PBL_MEMORY_DESCRIPTOR_LIST MdList, _In_ PBL_MEMORY_DESCRIPTOR MemoryDescriptor, _In_ ULONG Flags)
Definition: descriptor.c:582
NTSTATUS MmMapPhysicalAddress(_Inout_ PPHYSICAL_ADDRESS PhysicalAddress, _Out_ PVOID *VirtualAddress, _Inout_ PULONGLONG Size, _In_ ULONG CacheAttributes)
PBL_MEMORY_DESCRIPTOR MmMdInitByteGranularDescriptor(_In_ ULONG Flags, _In_ BL_MEMORY_TYPE Type, _In_ ULONGLONG BasePage, _In_ ULONGLONG VirtualPage, _In_ ULONGLONG PageCount)
Definition: descriptor.c:377
BL_MEMORY_DESCRIPTOR_LIST MmMdlReservedAllocated
Definition: pagealloc.c:40
VOID MmMdRemoveDescriptorFromList(_In_ PBL_MEMORY_DESCRIPTOR_LIST MdList, _In_ PBL_MEMORY_DESCRIPTOR Entry)
Definition: descriptor.c:338
BL_MEMORY_DESCRIPTOR_LIST MmMdlUnmappedAllocated
Definition: pagealloc.c:38
#define BL_MM_REMOVE_PHYSICAL_REGION_FLAG
Definition: bl.h:124
VOID MmMdFreeGlobalDescriptors(VOID)
Definition: descriptor.c:1332
BL_MEMORY_DESCRIPTOR_LIST MmMdlMappedAllocated
Definition: pagealloc.c:35
BL_MEMORY_DESCRIPTOR_LIST MmMdlFreeVirtual
Definition: pagealloc.c:45
BL_MEMORY_DESCRIPTOR_LIST MmMdlUnmappedUnallocated
Definition: pagealloc.c:39
NTSTATUS MmMdRemoveRegionFromMdlEx(__in PBL_MEMORY_DESCRIPTOR_LIST MdList, __in ULONG Flags, __in ULONGLONG BasePage, __in ULONGLONG PageCount, __in PBL_MEMORY_DESCRIPTOR_LIST NewMdList)
NTSTATUS MmSelectMappingAddress(_Out_ PVOID *MappingAddress, _In_ PVOID PreferredAddress, _In_ ULONGLONG Size, _In_ ULONG AllocationAttributes, _In_ ULONG Flags, _In_ PHYSICAL_ADDRESS PhysicalAddress)
Definition: pagealloc.c:1625
BL_MEMORY_DESCRIPTOR_LIST MmMdlPersistentMemory
Definition: pagealloc.c:43
PBL_MEMORY_DESCRIPTOR MmMdFindDescriptor(_In_ ULONG WhichList, _In_ ULONG Flags, _In_ ULONGLONG Page)
Definition: descriptor.c:1049
#define BL_MM_REMOVE_VIRTUAL_REGION_FLAG
Definition: bl.h:125
BL_TRANSLATION_TYPE MmTranslationType
Definition: mm.c:17
ULONG MmDescriptorCallTreeCount
Definition: mm.c:19
NTSTATUS MmUnmapVirtualAddress(_Inout_ PVOID *VirtualAddress, _Inout_ PULONGLONG Size)
Definition: mm.c:453
NTSTATUS TrpGenerateMappingTracker(_In_ PVOID VirtualAddress, _In_ ULONG Flags, _In_ LARGE_INTEGER PhysicalAddress, _In_ ULONGLONG Size)
Definition: mm.c:24
_Must_inspect_result_ _In_ WDFDMATRANSACTION _In_ PFN_WDF_PROGRAM_DMA _In_ WDF_DMA_DIRECTION _In_ PMDL _In_ PVOID VirtualAddress
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
int WINAPI EndPage(_In_ HDC)
_In_opt_ PSECURITY_DESCRIPTOR _Out_ PSECURITY_DESCRIPTOR * NewDescriptor
Definition: sefuncs.h:30

Referenced by BlDisplayGetOemBitmap(), BlImgAllocateImageBuffer(), BlUtlGetAcpiTable(), ConsoleEfiGopEnable(), EfipGetRsdt(), EfiVmOpenProtocol(), and MmPapPageAllocatorExtend().

◆ BlMmRemoveBadMemory()

NTSTATUS BlMmRemoveBadMemory ( VOID  )

Definition at line 155 of file mm.c.

158{
159 BOOLEAN AllowBad;
161 PULONGLONG BadPages;
162 ULONGLONG BadPageCount;
163
164 /* First check if bad memory access is allowed */
165 AllowBad = FALSE;
168 &AllowBad);
169 if ((NT_SUCCESS(Status)) && (AllowBad))
170 {
171 /* No point checking the list if it is */
172 return STATUS_SUCCESS;
173 }
174
175 /* Otherwise, check if there's a persisted bad page list */
178 &BadPages,
179 &BadPageCount,
180 TRUE);
181 if (NT_SUCCESS(Status))
182 {
183 EfiPrintf(L"Persistent bad page list not supported\r\n");
185 }
186
187 /* All done here */
188 return STATUS_SUCCESS;
189}
@ BcdLibraryIntegerList_BadMemoryList
Definition: bcd.h:58
@ BcdLibraryBoolean_AllowBadMemoryAccess
Definition: bcd.h:59

Referenced by BlInitializeLibrary(), and BlpMmInitialize().

◆ BlMmTranslateVirtualAddress()

BOOLEAN BlMmTranslateVirtualAddress ( _In_ PVOID  VirtualAddress,
_Out_ PPHYSICAL_ADDRESS  PhysicalAddress 
)

Definition at line 525 of file mm.c.

529{
530 /* Make sure arguments are present */
531 if (!(VirtualAddress) || !(PhysicalAddress))
532 {
533 return FALSE;
534 }
535
536 /* Do the architecture-specific translation */
538}
BOOLEAN MmArchTranslateVirtualAddress(_In_ PVOID VirtualAddress, _Out_opt_ PPHYSICAL_ADDRESS PhysicalAddress, _Out_opt_ PULONG CachingFlags)
Definition: mmx86.c:108

Referenced by BlImgUnallocateImageBuffer(), EfiAllocatePages(), EfiConInExSetState(), EfiGetMemoryMap(), EfiGopGetCurrentMode(), EfiGopGetFrameBuffer(), EfiLocateHandleBuffer(), EfiVmOpenProtocol(), ImgpLoadPEImage(), and OslDrawLogo().

◆ BlMmUnmapVirtualAddressEx()

NTSTATUS BlMmUnmapVirtualAddressEx ( _In_ PVOID  VirtualAddress,
_In_ ULONGLONG  Size 
)

Definition at line 487 of file mm.c.

491{
493
494 /* Increment call depth */
496
497 /* Make sure all parameters are there */
498 if ((VirtualAddress) && (Size))
499 {
500 /* Unmap the virtual address */
502
503 /* Check if we actually had a virtual mapping active */
505 {
506 /* We don't support virtual memory yet @TODO */
507 EfiPrintf(L"not yet implemented in %S\r\n", __FUNCTION__);
508 EfiStall(1000000);
510 }
511 }
512 else
513 {
514 /* Fail */
516 }
517
518 /* Cleanup descriptors and reduce depth */
521 return Status;
522}
NTSTATUS EfiStall(_In_ ULONG StallTime)
Definition: firmware.c:1003
#define __FUNCTION__
Definition: types.h:116

Referenced by BlDisplayGetOemBitmap(), BlDisplayInvalidateOemBitmap(), BlDisplayValidOemBitmap(), BlImgLoadImageWithProgress2(), BlImgUnallocateImageBuffer(), BlUtlGetAcpiTable(), ConsoleFirmwareGraphicalDisable(), EfipGetRsdt(), EfiVmOpenProtocol(), EfiVmpFreeInterfaceEntry(), and ImgpLoadPEImage().

◆ BlockIoEfiCompareDevice()

NTSTATUS BlockIoEfiCompareDevice ( _In_ PBL_DEVICE_DESCRIPTOR  Device,
_In_ EFI_HANDLE  Handle 
)

Definition at line 1268 of file device.c.

1272{
1273 PBL_LOCAL_DEVICE LocalDeviceInfo, EfiLocalDeviceInfo;
1274 PBL_DEVICE_ENTRY DeviceEntry;
1275 PBL_DEVICE_DESCRIPTOR EfiDevice;
1277
1278 DeviceEntry = NULL;
1279
1280 /* Check if no device was given */
1281 if (!Device)
1282 {
1283 /* Fail the comparison */
1285 goto Quickie;
1286 }
1287
1288 /* Check if this is a local disk device */
1289 if (Device->DeviceType != DiskDevice)
1290 {
1291 /* Nope -- is it a partition device? */
1292 if ((Device->DeviceType != LegacyPartitionDevice) &&
1293 (Device->DeviceType != PartitionDevice))
1294 {
1295 /* Nope, so we can't compare */
1297 goto Quickie;
1298 }
1299
1300 /* If so, return the device information for the parent disk */
1301 LocalDeviceInfo = &Device->Partition.Disk;
1302 }
1303 else
1304 {
1305 /* Just return the disk information itself */
1306 LocalDeviceInfo = &Device->Local;
1307 }
1308
1309 /* Create an EFI device entry for the EFI device handle */
1310 Status = BlockIoEfiCreateDeviceEntry(&DeviceEntry, Handle);
1311 if (!NT_SUCCESS(Status))
1312 {
1313 goto Quickie;
1314 }
1315
1316 /* Read the descriptor and assume failure for now */
1317 EfiDevice = DeviceEntry->DeviceDescriptor;
1319
1320 /* Check if the EFI device is a disk */
1321 if (EfiDevice->DeviceType != DiskDevice)
1322 {
1323 /* Nope, is it a partition? */
1324 if ((EfiDevice->DeviceType != LegacyPartitionDevice) &&
1325 (EfiDevice->DeviceType != PartitionDevice))
1326 {
1327 /* Neither, invalid handle so bail out */
1329 goto Quickie;
1330 }
1331
1332 /* Yes, so get the information of the parent disk */
1333 EfiLocalDeviceInfo = &EfiDevice->Partition.Disk;
1334 }
1335 else
1336 {
1337 /* It's a disk, so get the disk information itself */
1338 EfiLocalDeviceInfo = &EfiDevice->Local;
1339 }
1340
1341 /* Are the two devices the same type? */
1342 if (EfiLocalDeviceInfo->Type != LocalDeviceInfo->Type)
1343 {
1344 /* Nope, that was easy */
1345 goto Quickie;
1346 }
1347
1348 /* Yes, what kind of device is the EFI side? */
1349 switch (EfiLocalDeviceInfo->Type)
1350 {
1351 case LocalDevice:
1352
1353 /* Local hard drive, compare the signature */
1354 if (RtlCompareMemory(&EfiLocalDeviceInfo->HardDisk,
1355 &LocalDeviceInfo->HardDisk,
1356 sizeof(LocalDeviceInfo->HardDisk)) ==
1357 sizeof(LocalDeviceInfo->HardDisk))
1358 {
1360 }
1361 break;
1362
1363 case FloppyDevice:
1364 case CdRomDevice:
1365
1366 /* Removable floppy or CD, compare the disk number */
1367 if (RtlCompareMemory(&EfiLocalDeviceInfo->FloppyDisk,
1368 &LocalDeviceInfo->FloppyDisk,
1369 sizeof(LocalDeviceInfo->FloppyDisk)) ==
1370 sizeof(LocalDeviceInfo->FloppyDisk))
1371 {
1373 }
1374 break;
1375
1376 case RamDiskDevice:
1377
1378 /* RAM disk, compare the size and base information */
1379 if (RtlCompareMemory(&EfiLocalDeviceInfo->RamDisk,
1380 &LocalDeviceInfo->RamDisk,
1381 sizeof(LocalDeviceInfo->RamDisk)) ==
1382 sizeof(LocalDeviceInfo->RamDisk))
1383 {
1385 }
1386 break;
1387
1388 case FileDevice:
1389
1390 /* File, compare the file identifier */
1391 if (RtlCompareMemory(&EfiLocalDeviceInfo->File,
1392 &LocalDeviceInfo->File,
1393 sizeof(LocalDeviceInfo->File)) ==
1394 sizeof(LocalDeviceInfo->File))
1395 {
1397 }
1398 break;
1399
1400 /* Something else we don't support */
1401 default:
1402 break;
1403 }
1404
1405Quickie:
1406 /* All done, did we have an EFI device entry? */
1407 if (DeviceEntry)
1408 {
1409 /* Free it, since we only needed it locally for comparison */
1410 BlMmFreeHeap(DeviceEntry->DeviceDescriptor);
1412 BlMmFreeHeap(DeviceEntry);
1413 }
1414
1415 /* Return back to the caller */
1416 return Status;
1417}
NTSTATUS BlockIoEfiCreateDeviceEntry(_In_ PBL_DEVICE_ENTRY *DeviceEntry, _Out_ PVOID Handle)
Definition: device.c:1185
NTSTATUS BlockIopFreeAllocations(_In_ PBL_BLOCK_DEVICE BlockDevice)
Definition: device.c:842
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
struct _BL_DEVICE_DESCRIPTOR::@138::@141 Partition
BL_LOCAL_DEVICE Local
Definition: bl.h:956
PVOID DeviceSpecificData
Definition: bl.h:1267
BL_HARDDISK_DEVICE HardDisk
Definition: bl.h:933
struct _BL_LOCAL_DEVICE::@134::@137 RamDisk
ULONG File
Definition: bl.h:944
struct _BL_LOCAL_DEVICE::@134::@136 FloppyDisk

Referenced by BlFwEnumerateDevice().

◆ BlpArchEnableTranslation()

VOID BlpArchEnableTranslation ( VOID  )

Definition at line 189 of file arch.c.

192{
194
195 /* Does the current execution context already have paging enabled? */
197 if (!(Context->ContextFlags & BL_CONTEXT_PAGING_ON))
198 {
199 /* No -- does it have interrupts enabled? */
200 if (Context->ContextFlags & BL_CONTEXT_INTERRUPTS_ON)
201 {
202 /* Disable them */
203 _disable();
204 Context->ContextFlags &= ~BL_CONTEXT_INTERRUPTS_ON;
205 }
206
207 /* Are we enabling PAE? */
208 if (Context->TranslationType == BlPae)
209 {
210 /* Make sure CR4 reflects this */
212 }
213
214 /* Enable paging in the CPU */
216
217 /* Reflect that paging is enabled */
218 Context->ContextFlags |= BL_CONTEXT_PAGING_ON;
219 }
220}
#define BL_CONTEXT_INTERRUPTS_ON
Definition: bl.h:84
#define BL_CONTEXT_PAGING_ON
Definition: bl.h:83
PBL_ARCH_CONTEXT CurrentExecutionContext
Definition: arch.c:17
void __cdecl _disable(void)
Definition: intrin_arm.h:365
__INTRIN_INLINE unsigned long __readcr4(void)
Definition: intrin_x86.h:1825
__INTRIN_INLINE unsigned long __readcr0(void)
Definition: intrin_x86.h:1804
__INTRIN_INLINE void __writecr0(unsigned int Data)
Definition: intrin_x86.h:1789
__INTRIN_INLINE void __writecr4(unsigned int Data)
Definition: intrin_x86.h:1799
#define CR0_PG
Definition: asm.h:255
#define CR4_PAE
Definition: ketypes.h:150

Referenced by MmDefInitializeTranslation().

◆ BlpArchInitialize()

NTSTATUS BlpArchInitialize ( _In_ ULONG  Phase)

Definition at line 235 of file arch.c.

238{
239 KDESCRIPTOR Idtr;
240 USHORT CodeSegment;
242 PKIDTENTRY IdtBase;
243
244 /* Assume success */
246
247 /* Is this phase 1? */
248 if (Phase != 0)
249 {
250 /* Get the IDT */
251 __sidt(&Idtr);
252 IdtBase = (PKIDTENTRY)Idtr.Base;
253
254 /* Get the Code Segment */
255#if defined(__GNUC__)
256 __asm__ __volatile__ ("mov %%cs,%0\n\t" :"=r" (CodeSegment));
257#elif defined (_MSC_VER)
258 _asm { mov CodeSegment, cs };
259#else
260#error wtf are you using
261#endif
262
263 /* Set up INT 3, ASSERT, and SECURITY_ASSERT to be no-op (for Rtl) */
265 IdtBase[3].Selector = CodeSegment;
266 IdtBase[3].Access = 0x8E00u;
267 IdtBase[3].ExtendedOffset = (ULONG_PTR)ArchTrapNoProcess >> 16;
268 IdtBase[0x2C].Offset = (USHORT)(ULONG_PTR)ArchTrapNoProcess;
269 IdtBase[0x2C].Selector = CodeSegment;
270 IdtBase[0x2C].Access = 0x8E00u;
271 IdtBase[0x2C].ExtendedOffset = (ULONG_PTR)ArchTrapNoProcess >> 16;
272 IdtBase[0x2D].Offset = (USHORT)(ULONG_PTR)ArchTrapNoProcess;
273 IdtBase[0x2D].Selector = CodeSegment;
274 IdtBase[0x2D].Access = 0x8E00u;
275 IdtBase[0x2D].ExtendedOffset = (ULONG_PTR)ArchTrapNoProcess >> 16;
276
277 /* Write the IDT back */
278 Idtr.Base = (ULONG)IdtBase;
279 __lidt(&Idtr);
280
281 /* Reset FPU state */
282#if defined(__GNUC__)
283 __asm__ __volatile__ ("fninit");
284#elif defined (_MSC_VER)
285 _asm { fninit };
286#else
287#error wtf are you using
288#endif
289 }
290 else
291 {
292 /* Reset TSC if needed */
293 if ((__readmsr(0x10) >> 32) & 0xFFC00000)
294 {
295 __writemsr(0x10, 0);
296 }
297
298 /* Initialize all the contexts */
300 }
301
302 /* Return initialization state */
303 return Status;
304}
#define __GNUC__
Definition: _icc.h:38
#define cs
Definition: i386-dis.c:442
NTSTATUS ArchInitializeContexts(VOID)
Definition: arch.c:122
VOID DECLSPEC_NORETURN ArchTrapNoProcess(VOID)
Definition: arch.c:23
PPC_QUAL void __writemsr(const unsigned long Value)
Definition: intrin_ppc.h:748
PPC_QUAL unsigned long long __readmsr()
Definition: intrin_ppc.h:741
__INTRIN_INLINE void __lidt(void *Source)
Definition: intrin_x86.h:2018
__INTRIN_INLINE void __sidt(void *Destination)
Definition: intrin_x86.h:2023
#define PKIDTENTRY
Definition: ketypes.h:550
__asm__(".p2align 4, 0x90\n" ".seh_proc __seh2_global_filter_func\n" "__seh2_global_filter_func:\n" "\tpush %rbp\n" "\t.seh_pushreg %rbp\n" "\tsub $32, %rsp\n" "\t.seh_stackalloc 32\n" "\t.seh_endprologue\n" "\tmov %rdx, %rbp\n" "\tjmp *%rax\n" "__seh2_global_filter_func_exit:\n" "\t.p2align 4\n" "\tadd $32, %rsp\n" "\tpop %rbp\n" "\tret\n" "\t.seh_endproc")
PVOID Base
Definition: ketypes.h:556
USHORT Offset
Definition: ketypes.h:440
USHORT Selector
Definition: ketypes.h:441
USHORT Access
Definition: ketypes.h:442
USHORT ExtendedOffset
Definition: ketypes.h:443

Referenced by InitializeLibrary().

◆ BlpArchSwitchContext()

VOID BlpArchSwitchContext ( _In_ BL_ARCH_MODE  NewMode)

Definition at line 166 of file arch.c.

169{
171
172 /* In real mode, use EFI, otherwise, use the application mode */
174 if (NewMode != BlRealMode)
175 {
177 }
178
179 /* Are we in a different mode? */
180 if (CurrentExecutionContext->Mode != NewMode)
181 {
182 /* Switch to the new one */
185 }
186}
VOID ArchSwitchContext(_In_ PBL_ARCH_CONTEXT NewContext, _In_ PBL_ARCH_CONTEXT OldContext)
Definition: arch.c:39
BL_ARCH_CONTEXT ApplicationExecutionContext
Definition: arch.c:16
BL_ARCH_CONTEXT FirmwareExecutionContext
Definition: arch.c:15
BL_ARCH_MODE Mode
Definition: bl.h:999

Referenced by BlockIoFirmwareRead(), ConsoleFirmwareTextClear(), EfiAllocatePages(), EfiCloseProtocol(), EfiConInExReset(), EfiConInExSetState(), EfiConInReset(), EfiConnectController(), EfiConOutEnableCursor(), EfiConOutOutputString(), EfiConOutQueryMode(), EfiConOutReadCurrentMode(), EfiConOutSetAttribute(), EfiConOutSetCursorPosition(), EfiConOutSetMode(), EfiFreePages(), EfiGetMemoryMap(), EfiGetVariable(), EfiGopGetCurrentMode(), EfiGopGetFrameBuffer(), EfiGopSetMode(), EfiLocateHandleBuffer(), EfiOpenProtocol(), EfiPrintf(), EfiSetWatchdogTimer(), EfiStall(), EfiVmOpenProtocol(), EfiVmpCloseProtocol(), MmFwGetMemoryMap(), and OslDrawLogo().

◆ BlpDeviceInitialize()

NTSTATUS BlpDeviceInitialize ( VOID  )

Definition at line 2309 of file device.c.

2312{
2314
2315 /* Initialize the table count and list of devices */
2316 DmTableEntries = 8;
2318
2319 /* Initialize device information */
2322
2323 /* Allocate the device table */
2325 if (DmDeviceTable)
2326 {
2327 /* Clear it */
2329#if BL_BITLOCKER_SUPPORT
2330 /* Initialize BitLocker support */
2331 Status = FvebInitialize();
2332#else
2334#endif
2335 }
2336 else
2337 {
2338 /* No memory, we'll fail */
2340 }
2341
2342 /* Return initialization state */
2343 return Status;
2344}
BL_DEVICE_IO_INFORMATION DmDeviceIoInformation
Definition: device.c:26
LIST_ENTRY DmRegisteredDevices
Definition: device.c:21
ULONGLONG WriteCount
Definition: device.c:18

Referenced by BlpIoInitialize().

◆ BlpDeviceOpen()

NTSTATUS BlpDeviceOpen ( _In_ PBL_DEVICE_DESCRIPTOR  Device,
_In_ ULONG  Flags,
_In_ ULONG  Unknown,
_Out_ PULONG  DeviceId 
)

Definition at line 2111 of file device.c.

2117{
2119 PBL_DEVICE_ENTRY DeviceEntry;
2120 PBL_DEVICE_DESCRIPTOR LocateDeviceDescriptor;
2121 PBL_REGISTERED_DEVICE RegisteredDevice;
2122 PLIST_ENTRY NextEntry, ListHead;
2123
2124 DeviceEntry = NULL;
2125
2126 /* Check for missing parameters */
2127 if (!(Device) || !(DeviceId) || !(Device->Size))
2128 {
2129 /* Bail out */
2131 goto Quickie;
2132 }
2133
2134 /* Make sure both read and write access are set */
2136 {
2137 /* Bail out */
2139 goto Quickie;
2140 }
2141
2142 /* Check if the boot device is being opened */
2143 if (Device->DeviceType == BootDevice)
2144 {
2145 /* Select it */
2147 }
2148
2149 /* Check if the 'locate' device is being opened */
2150 if (Device->DeviceType == LocateDevice)
2151 {
2152 /* Go find it */
2153 Status = BlpDeviceResolveLocate(Device, &LocateDeviceDescriptor);
2154 if (!NT_SUCCESS(Status))
2155 {
2156 /* Not found, bail out */
2157 goto Quickie;
2158 }
2159
2160 /* Select it */
2161 Device = LocateDeviceDescriptor;
2162 }
2163
2164 /* Check if the device isn't ready yet */
2165 if (Device->Flags & 1)
2166 {
2167 /* Return a failure */
2169 goto Quickie;
2170 }
2171
2172 /* Check if we already have an entry for the device */
2173 DeviceEntry = BlTblFindEntry(DmDeviceTable,
2175 DeviceId,
2177 Device,
2178 &Flags,
2179 &Unknown,
2180 NULL);
2181 if (DeviceEntry)
2182 {
2183 /* Return it, taking a reference on it */
2184 *DeviceId = DeviceEntry->DeviceId;
2185 ++DeviceEntry->ReferenceCount;
2186 DeviceEntry->Flags |= BL_DEVICE_ENTRY_OPENED;
2187 return STATUS_SUCCESS;
2188 }
2189
2190 /* We don't, allocate one */
2191 DeviceEntry = BlMmAllocateHeap(sizeof(*DeviceEntry));
2192 if (!DeviceEntry)
2193 {
2195 goto Quickie;
2196 }
2197
2198 /* Fill it out */
2199 RtlZeroMemory(DeviceEntry, sizeof(*DeviceEntry));
2200 DeviceEntry->ReferenceCount = 1;
2201 DeviceEntry->Flags |= (BL_DEVICE_ENTRY_OPENED |
2204 DeviceEntry->Unknown = Unknown;
2205
2206 /* Save flag 8 if needed */
2207 if (Flags & 8)
2208 {
2209 DeviceEntry->Flags |= 8;
2210 }
2211
2212 /* Allocate a device descriptor for the device */
2213 DeviceEntry->DeviceDescriptor = BlMmAllocateHeap(Device->Size);
2214 if (!DeviceEntry->DeviceDescriptor)
2215 {
2217 goto Quickie;
2218 }
2219
2220 /* Copy the descriptor that was passed in */
2222
2223 /* Now loop the list of dynamically registered devices */
2224 ListHead = &DmRegisteredDevices;
2225 NextEntry = ListHead->Flink;
2226 while (NextEntry != ListHead)
2227 {
2228 /* Get the device */
2229 RegisteredDevice = CONTAINING_RECORD(NextEntry,
2231 ListEntry);
2232
2233 /* Open the device */
2234 Status = RegisteredDevice->Callbacks.Open(Device, DeviceEntry);
2235 if (NT_SUCCESS(Status))
2236 {
2237 /* The device was opened, so we have the right one */
2238 goto DeviceOpened;
2239 }
2240
2241 /* Nope, keep trying */
2242 NextEntry = NextEntry->Flink;
2243 }
2244
2245 /* Well, it wasn't a dynamic device. Is it a block device? */
2246 if ((Device->DeviceType == PartitionDevice) ||
2247 (Device->DeviceType == DiskDevice) ||
2248 (Device->DeviceType == LegacyPartitionDevice))
2249 {
2250 /* Call the Block I/O handler */
2252 }
2253 else if (Device->DeviceType == SerialDevice)
2254 {
2255 /* It's a serial device, call the serial device handler */
2256 Status = SerialPortFunctionTable.Open(Device, DeviceEntry);
2257 }
2258 else if (Device->DeviceType == UdpDevice)
2259 {
2260 /* It's a network device, call the UDP device handler */
2261 Status = UdpFunctionTable.Open(Device, DeviceEntry);
2262 }
2263 else
2264 {
2265 /* Unsupported type of device */
2267 }
2268
2269 /* Check if the device was opened successfully */
2270 if (NT_SUCCESS(Status))
2271 {
2272DeviceOpened:
2273 /* Save the entry in the device table */
2276 DeviceEntry,
2277 DeviceId,
2279 if (NT_SUCCESS(Status))
2280 {
2281 /* It worked -- return the ID in the table to the caller */
2282 EfiPrintf(L"Device ID: %lx\r\n", *DeviceId);
2283 DeviceEntry->DeviceId = *DeviceId;
2284 return STATUS_SUCCESS;
2285 }
2286 }
2287
2288Quickie:
2289 /* Failure path -- did we allocate a device entry? */
2290 EfiPrintf(L"Block failure: %lx\r\n", Status);
2291 if (DeviceEntry)
2292 {
2293 /* Yep -- did it have a descriptor? */
2294 if (DeviceEntry->DeviceDescriptor)
2295 {
2296 /* Free it */
2297 BlMmFreeHeap(DeviceEntry->DeviceDescriptor);
2298 }
2299
2300 /* Free the entry */
2301 BlMmFreeHeap(DeviceEntry);
2302 }
2303
2304 /* Return the failure */
2305 return Status;
2306}
#define BL_DEVICE_ENTRY_WRITE_ACCESS
Definition: bl.h:157
PVOID BlTblFindEntry(_In_ PVOID *Table, _In_ ULONG Count, _Out_ PULONG EntryIndex, _In_ PBL_TBL_LOOKUP_ROUTINE Callback, _In_ PVOID Argument1, _In_ PVOID Argument2, _In_ PVOID Argument3, _In_ PVOID Argument4)
Definition: util.c:273
PBL_DEVICE_DESCRIPTOR BlpBootDevice
Definition: bootlib.c:16
#define BL_DEVICE_ENTRY_READ_ACCESS
Definition: bl.h:156
BOOLEAN DeviceTableCompare(_In_ PVOID Entry, _In_ PVOID Argument1, _In_ PVOID Argument2, _Inout_ PVOID Argument3, _Inout_ PVOID Argument4)
Definition: device.c:1691
BL_DEVICE_CALLBACKS SerialPortFunctionTable
Definition: device.c:1683
NTSTATUS DeviceTablePurge(_In_ PVOID Entry)
Definition: device.c:1755
BL_DEVICE_CALLBACKS BlockIoDeviceFunctionTable
Definition: device.c:84
BL_DEVICE_CALLBACKS UdpFunctionTable
Definition: device.c:1676
NTSTATUS BlpDeviceResolveLocate(_In_ PBL_DEVICE_DESCRIPTOR InputDevice, _Out_ PBL_DEVICE_DESCRIPTOR *LocateDevice)
Definition: device.c:2063
@ Unknown
Definition: i8042prt.h:114
#define STATUS_DEVICE_NOT_READY
Definition: shellext.h:70
PBL_DEVICE_OPEN Open
Definition: bl.h:1249
ULONG Unknown
Definition: bl.h:1264
ULONG DeviceId
Definition: bl.h:1262
BL_DEVICE_CALLBACKS Callbacks
Definition: device.c:33

Referenced by BiLoadHive(), BlBsdInitializeLog(), BlImgLoadBootApplication(), BmFwInitializeBootDirectoryPath(), and OslPrepareTarget().

◆ BlpDisplayInitialize()

NTSTATUS BlpDisplayInitialize ( _In_ ULONG  Flags)

Definition at line 575 of file display.c.

578{
580
581 /* Are we resetting or initializing? */
583 {
584 /* This is a reset */
586 if (NT_SUCCESS(Status))
587 {
588 /* Re-initialize the class as well */
590 }
591 }
592 else
593 {
594 /* Initialize the display */
596 }
597
598 /* Return display initialization state */
599 return Status;
600}
NTSTATUS BlpDisplayReinitialize(VOID)
Definition: display.c:542
NTSTATUS DsppInitialize(_In_ ULONG Flags)
Definition: display.c:256
NTSTATUS DsppReinitialize(_In_ ULONG Flags)
Definition: display.c:415

Referenced by BlInitializeLibrary(), and InitializeLibrary().

◆ BlpDisplayRegisterLocale()

NTSTATUS BlpDisplayRegisterLocale ( _In_ PWCHAR  Locale)

Definition at line 177 of file display.c.

180{
181 BOOLEAN StandardLocale;
183 PWCHAR FontFileName;
184 PBL_DEFERRED_FONT_FILE DeferredFont;
185 PLIST_ENTRY NextEntry;
186 WCHAR Prefix[3];
187
188 /* Assume custom locale */
189 StandardLocale = FALSE;
190
191 /* Bail out if the locale string seems invalid */
192 if (wcslen(Locale) < 2)
193 {
195 }
196
197 /* Check the prefix first, then traditional vs. simplified */
198 Prefix[0] = Locale[0];
199 Prefix[1] = Locale[1];
200 Prefix[2] = UNICODE_NULL;
201 if (!_wcsicmp(Prefix, L"ja"))
202 {
203 FontFileName = L"\\jpn_boot.ttf";
204 }
205 else if (!_wcsicmp(Prefix, L"ko"))
206 {
207 FontFileName = L"\\kor_boot.ttf";
208 }
209 else if (!(_wcsicmp(Locale, L"zh-CN")) ||
210 !(_wcsicmp(Locale, L"zh-CHS")) ||
211 !(_wcsicmp(Locale, L"zh-Hans")))
212 {
213 FontFileName = L"\\chs_boot.ttf";
214 }
215 else if (!(_wcsicmp(Locale, L"zh-TW")) &&
216 !(_wcsicmp(Locale, L"zh-CHT")) &&
217 !(_wcsicmp(Locale, L"zh-HK")) &&
218 !(_wcsicmp(Locale, L"zh-Hant")))
219 {
220 FontFileName = L"\\cht_boot.ttf";
221 }
222 else
223 {
224 StandardLocale = TRUE;
225 FontFileName = L"\\wgl4_boot.ttf";
226 }
227
228 /* Parse all the currently deferred fonts*/
229 NextEntry = BfiDeferredListHead.Flink;
230 while (NextEntry != &BfiDeferredListHead)
231 {
232 /* Grab the font */
233 DeferredFont = CONTAINING_RECORD(NextEntry, BL_DEFERRED_FONT_FILE, ListEntry);
234
235 /* Move to the next entry, and remove this one */
236 NextEntry = NextEntry->Flink;
237 RemoveEntryList(&DeferredFont->ListEntry);
238
239 /* Free the deferred font, we'll be loading a new one */
240 BfiFreeDeferredFontFile(DeferredFont);
241 }
242
243 /* Load the primary font */
244 Status = DsppLoadFontFile(FontFileName);
245 if (NT_SUCCESS(Status) && !(StandardLocale))
246 {
247 /* Also load the standard US one if we loaded a different one */
248 Status = DsppLoadFontFile(L"\\wgl4_boot.ttf");
249 }
250
251 /* Return back to caller */
252 return Status;
253}
VOID BfiFreeDeferredFontFile(_In_ PBL_DEFERRED_FONT_FILE DeferredFontFile)
Definition: font.c:30
NTSTATUS DsppLoadFontFile(_In_ PWCHAR FontFileName)
Definition: display.c:58
LIST_ENTRY BfiDeferredListHead
Definition: display.c:17
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_In_ __drv_aliasesMem PSTRING Prefix
Definition: rtlfuncs.h:1630

Referenced by ResSelectLocale().

◆ BlpDisplayReinitialize()

NTSTATUS BlpDisplayReinitialize ( VOID  )

Definition at line 542 of file display.c.

545{
547 PBL_TEXT_CONSOLE TextConsole;
548 PBL_INPUT_CONSOLE InputConsole;
549
550 /* Do we have a local console? */
551 InputConsole = DspLocalInputConsole;
552 if (InputConsole)
553 {
554 /* Reinitialize it */
555 Status = InputConsole->Callbacks->Reinitialize((PBL_TEXT_CONSOLE)InputConsole);
556 if (!NT_SUCCESS(Status))
557 {
558 return Status;
559 }
560 }
561
562 /* Do we have a text console? */
563 TextConsole = DspTextConsole;
564 if (TextConsole)
565 {
566 /* Reinitialize it */
567 Status = TextConsole->Callbacks->Reinitialize(TextConsole);
568 }
569
570 /* Return status */
571 return Status;
572}
PVOID DspLocalInputConsole
Definition: display.c:38
PCONSOLE_REINITIALIZE Reinitialize
Definition: bl.h:1122
PBL_INPUT_CONSOLE_VTABLE Callbacks
Definition: bl.h:1131
PCONSOLE_REINITIALIZE Reinitialize
Definition: bl.h:1087

Referenced by BlImgStartBootApplication(), and BlpDisplayInitialize().

◆ BlPdQueryData()

NTSTATUS BlPdQueryData ( _In_ const GUID DataGuid,
_In_ PVOID  Unknown,
_Inout_ PBL_PD_DATA_BLOB  DataBlob 
)

Definition at line 457 of file bootlib.c.

462{
463 /* Check for invalid or missing parameters */
464 if (!(DataBlob) ||
465 !(DataGuid) ||
466 ((DataBlob->BlobSize) && !(DataBlob->Data)))
467 {
469 }
470
471 /* Check if there's no persistent data blobs */
473 {
474 return STATUS_NOT_FOUND;
475 }
476
477 /* Not yet handled, TODO */
478 EfiPrintf(L"Boot persistent data not yet implemented\r\n");
480}
LIST_ENTRY BlpPdListHead
Definition: bootlib.c:24

Referenced by BmpProcessBadMemory().

◆ BlpFileInitialize()

NTSTATUS BlpFileInitialize ( VOID  )

Definition at line 908 of file file.c.

911{
913
914 /* Allocate the file table */
915 FileEntries = 16;
917 if (!FileTable)
918 {
920 }
921
922 /* Initialize it */
925
926#if 0
927 /* Initialize the network file system */
928 Status = BlpFileRegisterFileSystem(NetRegisterFunctionTable.Init,
929 NetRegisterFunctionTable.Destroy,
930 NetRegisterFunctionTable.Mount,
931 NetRegisterFunctionTable.Purge,
932 1);
933 if (NT_SUCCESS(Status))
934 {
935 /* Initialize NTFS */
936 Status = BlpFileRegisterFileSystem(NtfsRegisterFunctionTable.Init,
937 NtfsRegisterFunctionTable.Destroy,
938 NtfsRegisterFunctionTable.Mount,
939 NtfsRegisterFunctionTable.Purge,
940 0);
941 }
942
943 if (NT_SUCCESS(Status))
944#endif
945 {
946 /* Initialize FAT */
951 0);
952 }
953
954#if 0
955 if (NT_SUCCESS(Status))
956 {
957 /* Initialize EXFAT (FatPlus) */
958 Status = BlpFileRegisterFileSystem(FppRegisterFunctionTable.Init,
959 FppRegisterFunctionTable.Destroy,
960 FppRegisterFunctionTable.Mount,
961 FppRegisterFunctionTable.Purge,
962 0);
963 }
964
965 if (NT_SUCCESS(Status))
966 {
967 /* Initialize WIM */
968 Status = BlpFileRegisterFileSystem(WimRegisterFunctionTable.Init,
969 WimRegisterFunctionTable.Destroy,
970 WimRegisterFunctionTable.Mount,
971 WimRegisterFunctionTable.Purge,
972 0);
973 }
974
975 if (NT_SUCCESS(Status))
976 {
977 /* Initialize UDFS */
978 Status = BlpFileRegisterFileSystem(UdfsRegisterFunctionTable.Init,
979 UdfsRegisterFunctionTable.Destroy,
980 UdfsRegisterFunctionTable.Mount,
981 UdfsRegisterFunctionTable.Purge,
982 0);
983 }
984#endif
985 if (NT_SUCCESS(Status))
986 {
987 /* Initialize El-Torito CDFS */
992 0);
993 }
994
995 /* Destroy the file manager if any of the file systems didn't initialize */
996 if (!NT_SUCCESS(Status))
997 {
998 if (FileTable)
999 {
1000 //BlpFileDestroy();
1001 }
1002 }
1003 return Status;
1004}
BL_FILE_SYSTEM_REGISTRATION_TABLE FatRegisterFunctionTable
Definition: file.c:19
BL_FILE_SYSTEM_REGISTRATION_TABLE EtfsRegisterFunctionTable
Definition: file.c:26
LIST_ENTRY RegisteredFileSystems
Definition: file.c:18
NTSTATUS BlpFileRegisterFileSystem(_In_ PBL_FS_INIT_CALLBACK InitCallback, _In_ PBL_FS_DESTROY_CALLBACK DestroyCallback, _In_ PBL_FS_MOUNT_CALLBACK MountCallback, _In_ PBL_FS_PURGE_CALLBACK PurgeCallback, _In_ ULONG Flags)
Definition: file.c:861
PBL_FS_PURGE_CALLBACK Purge
Definition: bl.h:1065
PBL_FS_MOUNT_CALLBACK Mount
Definition: bl.h:1064
PBL_FS_DESTROY_CALLBACK Destroy
Definition: bl.h:1063
PBL_FS_INIT_CALLBACK Init
Definition: bl.h:1062

Referenced by BlpIoInitialize().

◆ BlpFwInitialize()

NTSTATUS BlpFwInitialize ( _In_ ULONG  Phase,
_In_ PBL_FIRMWARE_DESCRIPTOR  FirmwareParameters 
)

Definition at line 2290 of file firmware.c.

2294{
2296 EFI_KEY_TOGGLE_STATE KeyToggleState;
2297
2298 /* Check if we have valid firmware data */
2299 if (!(FirmwareData) || !(FirmwareData->Version))
2300 {
2302 }
2303
2304 /* Check which boot phase we're in */
2305 if (Phase != 0)
2306 {
2307 /* Memory manager is ready, open the extended input protocol */
2310 (PVOID*)&EfiConInEx);
2311 if (NT_SUCCESS(Status))
2312 {
2313 /* Set the initial key toggle state */
2314 KeyToggleState = EFI_TOGGLE_STATE_VALID | 40;
2315 EfiConInExSetState(EfiConInEx, &KeyToggleState);
2316 }
2317
2318 /* Setup the watchdog timer */
2320 }
2321 else
2322 {
2323 /* Make a copy of the parameters */
2325
2326 /* Check which version we received */
2327 if (FirmwareData->Version == 1)
2328 {
2329 /* FIXME: Not supported */
2331 }
2332 else if (FirmwareData->Version >= BL_FIRMWARE_DESCRIPTOR_VERSION)
2333 {
2334 /* Version 2 -- save the data */
2335 EfiFirmwareData = *FirmwareData;
2336 EfiSystemTable = FirmwareData->SystemTable;
2337 EfiImageHandle = FirmwareData->ImageHandle;
2338
2339 /* Set the EDK-II style variables as well */
2345 EfiConInEx = NULL;
2346 }
2347 else
2348 {
2349 /* Unknown version */
2351 }
2352 }
2353
2354 /* Return the initialization state */
2355 return Status;
2356}
UINT8 EFI_KEY_TOGGLE_STATE
#define EFI_TOGGLE_STATE_VALID
#define BL_FIRMWARE_DESCRIPTOR_VERSION
Definition: bl.h:64
BL_FIRMWARE_DESCRIPTOR EfiFirmwareData
Definition: firmware.c:16
EFI_BOOT_SERVICES * EfiBS
Definition: firmware.c:21
EFI_HANDLE EfiImageHandle
Definition: firmware.c:17
EFI_SYSTEM_TABLE * EfiSystemTable
Definition: firmware.c:18
EFI_SYSTEM_TABLE * EfiST
Definition: firmware.c:20
NTSTATUS EfiOpenProtocol(_In_ EFI_HANDLE Handle, _In_ EFI_GUID *Protocol, _Outptr_ PVOID *Interface)
Definition: firmware.c:369
EFI_GUID EfiSimpleTextInputExProtocol
Definition: firmware.c:32
EFI_RUNTIME_SERVICES * EfiRT
Definition: firmware.c:22
EFI_SIMPLE_TEXT_INPUT_PROTOCOL * EfiConIn
Definition: firmware.c:24
NTSTATUS EfiConInExSetState(_In_ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *ConInEx, _In_ EFI_KEY_TOGGLE_STATE *KeyToggleState)
Definition: firmware.c:856
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL * EfiConInEx
Definition: firmware.c:25
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * EfiConOut
Definition: firmware.c:23
NTSTATUS EfiSetWatchdogTimer(VOID)
Definition: firmware.c:893
EFI_BOOT_SERVICES * BootServices
Definition: UefiSpec.h:1959
EFI_HANDLE ConsoleInHandle
Definition: UefiSpec.h:1927
EFI_RUNTIME_SERVICES * RuntimeServices
Definition: UefiSpec.h:1955
EFI_SIMPLE_TEXT_INPUT_PROTOCOL * ConIn
Definition: UefiSpec.h:1932
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut
Definition: UefiSpec.h:1941

Referenced by InitializeLibrary().

◆ BlpGetBootOptionIntegerList()

NTSTATUS BlpGetBootOptionIntegerList ( _In_ PBL_BCD_OPTION  List,
_In_ ULONG  Type,
_Out_ PULONGLONG Value,
_Out_ PULONGLONG  Count,
_In_ BOOLEAN  NoCopy 
)

Definition at line 541 of file bcdopt.c.

548{
549 PBL_BCD_OPTION Option;
550 BcdElementType ElementType;
551 PULONGLONG ValueCopy;
552
553 /* Make sure this is a BCD_TYPE_INTEGER_LIST */
554 ElementType.PackedValue = Type;
555 if (ElementType.Format != BCD_TYPE_INTEGER_LIST)
556 {
558 }
559
560 /* Return the data */
561 Option = MiscGetBootOption(List, Type);
562 if (!Option)
563 {
564 return STATUS_NOT_FOUND;
565 }
566
567 /* Check if a copy should be made of it */
568 if (NoCopy)
569 {
570 /* Nope, return the raw value */
571 *Value = (PULONGLONG)((ULONG_PTR)Option + Option->DataOffset);
572 }
573 else
574 {
575 /* Allocate a buffer for the copy */
576 ValueCopy = BlMmAllocateHeap(Option->DataSize);
577 if (!ValueCopy)
578 {
579 return STATUS_NO_MEMORY;
580 }
581
582 /* Copy the data in */
583 RtlCopyMemory(ValueCopy,
584 (PVOID)((ULONG_PTR)Option + Option->DataOffset),
585 Option->DataSize);
586
587 /* Return our copy */
588 *Value = ValueCopy;
589 }
590
591 /* Return count and success */
592 *Count = Option->DataSize / sizeof(ULONGLONG);
593 return STATUS_SUCCESS;
594}
#define BCD_TYPE_INTEGER_LIST
Definition: bcd.h:27

Referenced by BlImgLoadBootApplication(), and BlMmRemoveBadMemory().

◆ BlpIoInitialize()

NTSTATUS BlpIoInitialize ( VOID  )

Definition at line 35 of file io.c.

38{
40 ULONG Size;
41
42 /* Allocate the I/O table */
44 Size = IoMgrRoutineEntries * sizeof(PVOID);
47 {
48 /* Zero it out */
50
51 /* Initialize the device manager */
53
54 /* Initialize the file manager */
55 if (NT_SUCCESS(Status))
56 {
58 }
59 }
60 else
61 {
62 /* No memory */
64 }
65
66 /* Return initialization status */
67 return Status;
68}
NTSTATUS BlpDeviceInitialize(VOID)
Definition: device.c:2309
NTSTATUS BlpFileInitialize(VOID)
Definition: file.c:908
PVOID * IoMgrDestroyRoutineTable
Definition: io.c:16
ULONG IoMgrRoutineEntries
Definition: io.c:15

Referenced by InitializeLibrary().

◆ BlpIoRegisterDestroyRoutine()

NTSTATUS BlpIoRegisterDestroyRoutine ( _In_ PBL_IO_DESTROY_ROUTINE  DestroyRoutine)

Definition at line 21 of file io.c.

24{
25 ULONG Id;
26
29 DestroyRoutine,
30 &Id,
32}

Referenced by BcInitialize(), and BlockIopInitialize().

◆ BlpMmCreateBlockAllocator()

NTSTATUS BlpMmCreateBlockAllocator ( VOID  )

Definition at line 213 of file blkalloc.c.

216{
217 PBL_BLOCK_DESCRIPTOR BlockInfo;
218 ULONG BlockId;
220
221 /* If the block allocator isn't initialized, bail out */
222 BlockId = -1;
224 {
225 goto Quickie;
226 }
227
228 /* Allocate a block descriptor and zero it out */
229 BlockInfo = BlMmAllocateHeap(sizeof(*BlockInfo));
230 if (!BlockInfo)
231 {
232 goto Quickie;
233 }
234 RtlZeroMemory(BlockInfo, sizeof(*BlockInfo));
235
236 /* Setup the block descriptor */
237 BlockInfo->Attributes = 0;
238 BlockInfo->Type = BlLoaderBlockMemory;
239 BlockInfo->Unknown = 1;
240 BlockInfo->Unknown2 = 1;
241 BlockInfo->Size = PAGE_SIZE;
242 BlockInfo->Count = 128;
243 BlockInfo->Count2 = 128;
244 InitializeListHead(&BlockInfo->ListHead);
245
246 /* Add it to the list of block descriptors */
249 BlockInfo,
250 &BlockId,
252 if (NT_SUCCESS(Status))
253 {
254 /* Add the initial reference and store the block ID */
255 BlockInfo->ReferenceCount = 1;
256 BlockInfo->BlockId = BlockId;
257 }
258
259Quickie:
260 /* On failure, free the block descriptor */
261 if (BlockId == -1)
262 {
263 BlMmFreeHeap(BlockInfo);
264 }
265
266 /* Return the block descriptor ID, or -1 on failure */
267 return BlockId;
268}
NTSTATUS MmBapPurgeBlockAllocatorTableEntry(_In_ PVOID Entry)
Definition: blkalloc.c:188
BOOLEAN MmBlockAllocatorInitialized
Definition: blkalloc.c:17
ULONG MmBlockAllocatorTableEntries
Definition: blkalloc.c:16
PVOID * MmBlockAllocatorTable
Definition: blkalloc.c:15
#define PAGE_SIZE
Definition: env_spec_w32.h:49
LIST_ENTRY ListHead
Definition: blkalloc.c:21
BL_MEMORY_TYPE Type
Definition: blkalloc.c:23

Referenced by BcInitialize().

◆ BlpMmInitialize()

NTSTATUS BlpMmInitialize ( _In_ PBL_MEMORY_DATA  MemoryData,
_In_ BL_TRANSLATION_TYPE  TranslationType,
_In_ PBL_LIBRARY_PARAMETERS  LibraryParameters 
)

Definition at line 541 of file mm.c.

546{
548
549 /* Take a reference */
551
552 /* Only support valid translation types */
553 if ((TranslationType > BlPae) || (LibraryParameters->TranslationType > BlPae))
554 {
555 /* Bail out */
556 EfiPrintf(L"Invalid translation types present\r\n");
558 goto Quickie;
559 }
560
561 /* Initialize memory descriptors */
562 MmMdInitialize(0, LibraryParameters);
563
564 /* Remember the page type we came in with */
565 MmOriginalTranslationType = TranslationType;
566
567 /* Initialize the physical page allocator */
568 Status = MmPaInitialize(MemoryData,
569 LibraryParameters->MinimumAllocationCount);
570 if (!NT_SUCCESS(Status))
571 {
572 goto Quickie;
573 }
574
575 /* Initialize the memory tracker */
577 if (!NT_SUCCESS(Status))
578 {
579 EfiPrintf(L"TR Mm init failed: %lx\r\n", Status);
580 //MmArchDestroy();
581 //MmPaDestroy(1);
582 goto Quickie;
583 }
584
585 /* Initialize paging, large pages, self-mapping, PAE, if needed */
587 MemoryData,
588 TranslationType,
589 LibraryParameters->TranslationType);
590 if (NT_SUCCESS(Status))
591 {
592 /* Save the newly active transation type */
593 MmTranslationType = LibraryParameters->TranslationType;
594
595 /* Initialize the heap allocator now */
596 Status = MmHaInitialize(LibraryParameters->MinimumHeapSize,
597 LibraryParameters->HeapAllocationAttributes);
598 }
599
600 /* If Phase 1 init failed, bail out */
601 if (!NT_SUCCESS(Status))
602 {
603 /* Kill everything set setup so far */
604 EfiPrintf(L"Phase 1 Mm init failed: %lx\r\n", Status);
605 //MmPaDestroy(0);
606 //MmTrDestroy();
607 //MmArchDestroy();
608 //MmPaDestroy(1);
609 goto Quickie;
610 }
611
612 /* Do we have too many descriptors? */
613 if (LibraryParameters->DescriptorCount > 512)
614 {
615 /* Switch to using a dynamic buffer instead */
616 EfiPrintf(L"Warning: too many descriptors\r\n");
618 goto Quickie;
619 //MmMdpSwitchToDynamicDescriptors(LibraryParameters->DescriptorCount);
620 }
621
622 /* Remove memory that the BCD says is bad */
624
625 /* Now map all the memory regions as needed */
627 MemoryData,
628 TranslationType,
629 LibraryParameters->TranslationType);
630 if (NT_SUCCESS(Status))
631 {
632 /* Initialize the block allocator */
634 }
635
636 /* Check if anything in phase 2 failed */
637 if (!NT_SUCCESS(Status))
638 {
639 /* Go back to static descriptors and kill the heap */
640 EfiPrintf(L"Phase 2 Mm init failed: %lx\r\n", Status);
641 //MmMdpSwitchToStaticDescriptors();
642 //HapInitializationStatus = 0;
643 //++MmDescriptorCallTreeCount;
644
645 /* Destroy the Phase 1 initialization */
646 //MmPaDestroy(0);
647 //MmTrDestroy();
648 //MmArchDestroy();
649 //MmPaDestroy(1);
650 }
651
652Quickie:
653 /* Free the memory descriptors and return the initialization state */
656 return Status;
657}
NTSTATUS MmPaInitialize(_In_ PBL_MEMORY_DATA MemoryData, _In_ ULONG MinimumPages)
NTSTATUS MmArchInitialize(_In_ ULONG Phase, _In_ PBL_MEMORY_DATA MemoryData, _In_ BL_TRANSLATION_TYPE TranslationType, _In_ BL_TRANSLATION_TYPE LibraryTranslationType)
Definition: mmx86.c:1028
NTSTATUS MmHaInitialize(_In_ ULONG HeapSize, _In_ ULONG HeapAttributes)
Definition: heapalloc.c:538
VOID MmMdInitialize(_In_ ULONG Phase, _In_ PBL_LIBRARY_PARAMETERS LibraryParameters)
Definition: descriptor.c:1384
NTSTATUS MmBaInitialize(VOID)
Definition: blkalloc.c:271
NTSTATUS BlMmRemoveBadMemory(VOID)
Definition: mm.c:155
NTSTATUS MmTrInitialize(VOID)
Definition: mm.c:84
BL_TRANSLATION_TYPE MmOriginalTranslationType
Definition: mm.c:18

Referenced by InitializeLibrary().

◆ BlpMmInitializeConstraints()

NTSTATUS BlpMmInitializeConstraints ( VOID  )

Definition at line 106 of file pagealloc.c.

109{
110 NTSTATUS Status, ReturnStatus;
111 ULONGLONG LowestAddressValid, HighestAddressValid;
112 ULONGLONG LowestPage, HighestPage;
113
114 /* Assume success */
115 ReturnStatus = STATUS_SUCCESS;
116
117 /* Check for LOWMEM */
120 &LowestAddressValid);
121 if (NT_SUCCESS(Status))
122 {
123 /* Align the address */
124 LowestAddressValid = (ULONG_PTR)PAGE_ALIGN(LowestAddressValid);
125 LowestPage = LowestAddressValid >> PAGE_SHIFT;
126
127 /* Make sure it's below 4GB */
128 if (LowestPage <= 0x100000)
129 {
130 PapMinimumPhysicalPage = LowestPage;
131 }
132 }
133
134 /* Check for MAXMEM */
137 &HighestAddressValid);
138 if (NT_SUCCESS(Status))
139 {
140 /* Get the page */
141 HighestPage = HighestAddressValid >> PAGE_SHIFT;
142
143 /* Truncate memory above this page */
144 ReturnStatus = MmPaTruncateMemory(HighestPage);
145 }
146
147 /* Return back to the caller */
148 return ReturnStatus;
149}
@ BcdLibraryInteger_AvoidLowPhysicalMemory
Definition: bcd.h:62
@ BcdLibraryInteger_TruncatePhysicalMemory
Definition: bcd.h:55
NTSTATUS BlGetBootOptionInteger(_In_ PBL_BCD_OPTION List, _In_ ULONG Type, _Out_ PULONGLONG Value)
Definition: bcdopt.c:467
ULONGLONG PapMinimumPhysicalPage
Definition: pagealloc.c:29
NTSTATUS MmPaTruncateMemory(_In_ ULONGLONG BasePage)
Definition: pagealloc.c:51
#define PAGE_ALIGN(Va)

Referenced by BlInitializeLibrary(), and MmPaInitialize().

◆ BlpResourceInitialize()

NTSTATUS BlpResourceInitialize ( VOID  )

Definition at line 478 of file resource.c.

481{
483 PIMAGE_SECTION_HEADER ResourceSection;
484 PVOID ImageBase;
485 ULONG ImageSize, VRes, HRes;
486 BOOLEAN UsePrimary;
487
488 /* Default to using fallback */
489 UsePrimary = FALSE;
490
491 /* Initialize all globals */
492 ResMuiImageBase = 0;
493 ResMuiImageSize = 0;
504 ResPeImageBase = 0;
505 ResPeImageEnd = 0;
507
508 /* Check if we had allocated a locale already */
509 if (ResLocale)
510 {
511 /* Free it and reset */
513 ResLocale = 0;
514 }
515
516 /* Get our base address and size*/
517 Status = BlGetApplicationBaseAndSize(&ImageBase, &ImageSize);
518 if (!NT_SUCCESS(Status))
519 {
520 return Status;
521 }
522
523 /* Find our resource section */
524 ResourceSection = BlImgFindSection(ImageBase, ImageSize);
525 if (ResourceSection)
526 {
527 /* The resource section will be our fallback. Save down its details */
529 ResPeImageBaseFallback = ImageBase;
530 ResPeImageEndFallback = (PVOID)((ULONG_PTR)ImageBase + ImageSize);
533 }
534
535 /* Get the current screen resolution and check if we're in graphics mode */
536 Status = BlDisplayGetScreenResolution(&HRes, &VRes);
537 if ((NT_SUCCESS(Status)) && ((HRes != 640) || (VRes != 200)))
538 {
539 /* We are... we should load MUI data */
540 Status = STATUS_NOT_IMPLEMENTED;//ResInitializeMuiResources();
541 if (NT_SUCCESS(Status))
542 {
543 /* And not rely on the fallback */
544 UsePrimary = TRUE;
545 }
546 }
547
548 /* Load the locale resources */
549 return ResSelectLocale(UsePrimary);
550}
NTSTATUS BlDisplayGetScreenResolution(_Out_ PULONG HRes, _Out_ PULONG Vres)
Definition: display.c:680
PIMAGE_SECTION_HEADER BlImgFindSection(_In_ PVOID ImageBase, _In_ ULONG ImageSize)
Definition: image.c:611
NTSTATUS BlGetApplicationBaseAndSize(_Out_ PVOID *ImageBase, _Out_ PULONG ImageSize)
Definition: bootlib.c:424
ULONG_PTR ResRootDirectoryFallbackOffset
Definition: resource.c:24
PVOID ResPeImageBase
Definition: resource.c:15
PWCHAR ResLocale
Definition: resource.c:33
ULONG_PTR ResRootDirectoryOffset
Definition: resource.c:23
PVOID ResMuiImageBase
Definition: resource.c:30
NTSTATUS ResSelectLocale(_In_ BOOLEAN Primary)
Definition: resource.c:38
PVOID ResRootDirectoryFallback
Definition: resource.c:27
ULONG_PTR ResRootDirectoryPrimaryOffset
Definition: resource.c:22
PVOID ResPeImageEndFallback
Definition: resource.c:26
PVOID ResRootDirectory
Definition: resource.c:17
BOOLEAN ResLoadedFontFiles
Definition: resource.c:29
PVOID ResPeImageEnd
Definition: resource.c:16
PVOID ResPeImageBasePrimary
Definition: resource.c:19
PVOID ResPeImageBaseFallback
Definition: resource.c:25
ULONG_PTR ResMuiImageSize
Definition: resource.c:31
PVOID ResRootDirectoryPrimary
Definition: resource.c:21
PVOID ResPeImageEndPrimary
Definition: resource.c:20
struct _IMAGE_RESOURCE_DIRECTORY * PIMAGE_RESOURCE_DIRECTORY

Referenced by BlInitializeLibrary(), and InitializeLibrary().

◆ BlpSecureBootEFIIsEnabled()

NTSTATUS BlpSecureBootEFIIsEnabled ( VOID  )

Definition at line 687 of file firmware.c.

690{
692 BOOLEAN SetupMode, SecureBoot;
694
695 /* Assume setup mode enabled, and no secure boot */
696 SecureBoot = FALSE;
697 SetupMode = TRUE;
698
699 /* Get the SetupMode variable */
700 DataSize = sizeof(SetupMode);
701 Status = EfiGetVariable(L"SetupMode",
703 NULL,
704 &DataSize,
705 &SetupMode);
706 if (NT_SUCCESS(Status))
707 {
708 /* If it worked, get the SecureBoot variable */
709 DataSize = sizeof(SecureBoot);
710 Status = EfiGetVariable(L"SecureBoot",
712 NULL,
713 &DataSize,
714 &SecureBoot);
715 if (NT_SUCCESS(Status))
716 {
717 /* In setup mode or without secureboot turned on, return failure */
718 if ((SecureBoot != TRUE) || (SetupMode))
719 {
721 }
722
723 // BlpSbdiStateFlags |= 8u;
724 }
725 }
726
727 /* Return secureboot status */
728 return Status;
729}
NTSTATUS EfiGetVariable(_In_ PWCHAR VariableName, _In_ EFI_GUID *VendorGuid, _Out_opt_ PULONG Attributes, _Inout_ PULONG DataSize, _Out_ PVOID Data)
Definition: firmware.c:639
EFI_GUID EfiGlobalVariable
Definition: firmware.c:36
#define STATUS_INVALID_SIGNATURE
Definition: ntstatus.h:1172

Referenced by BlSecureBootIsEnabled().

◆ BlpTimeCalibratePerformanceCounter()

NTSTATUS BlpTimeCalibratePerformanceCounter ( VOID  )

Definition at line 62 of file time.c.

65{
66#if defined(_M_IX86) || defined(_M_X64)
67 INT CpuInfo[4];
68
69 /* Check if the ISVM bit it set, meaning we're in a hypervisor */
70 __cpuid(CpuInfo, 1);
71 if (CpuInfo[2] & 0x80000000)
72 {
73 /* Get the Hypervisor Identification Leaf */
74 __cpuid(CpuInfo, 0x40000001);
75
76 /* Is this Hyper-V? */
77 if (CpuInfo[0] == '1#vH')
78 {
79 /* Get the Hypervisor Feature Identification Leaf */
80 __cpuid(CpuInfo, 0x40000003);
81
82 /* Check if HV_X64_MSR_REFERENCE_TSC is present */
83 if (CpuInfo[3] & 0x100)
84 {
85 /* Read the TSC frequency from the MSR */
87 return STATUS_SUCCESS;
88 }
89 }
90 }
91
92 /* On other systems, compute it */
94#else
95 EfiPrintf(L"BlpTimeCalibratePerformanceCounter not implemented for this platform.\r\n");
97#endif
98}
ULONGLONG BlpTimePerformanceFrequency
Definition: time.c:15
NTSTATUS BlpTimeMeasureTscFrequency(VOID)
Definition: time.c:20

Referenced by InitializeLibrary().

◆ BlRemoveBootOption()

VOID BlRemoveBootOption ( _In_ PBL_BCD_OPTION  List,
_In_ ULONG  Type 
)

Definition at line 801 of file bcdopt.c.

805{
806 PBL_BCD_OPTION Option;
807
808 /* Keep going until the option is gone */
809 while (1)
810 {
811 /* Get the BCD option */
812 Option = MiscGetBootOption(List, Type);
813 if (!Option)
814 {
815 break;
816 }
817
818 /* Pretend it's empty */
819 Option->Empty = TRUE;
820 }
821}
ULONG Empty
Definition: bl.h:851

Referenced by BmLaunchRecoverySequence(), BmMain(), BmpGetSelectedBootEntry(), BmpLaunchBootEntry(), and OslpRemoveInternalApplicationOptions().

◆ BlReplaceBootOptions()

NTSTATUS BlReplaceBootOptions ( _In_ PBL_LOADED_APPLICATION_ENTRY  AppEntry,
_In_ PBL_BCD_OPTION  NewOptions 
)

Definition at line 824 of file bcdopt.c.

828{
830 ULONG OptionSize;
831 PBL_BCD_OPTION NewOptions;
832
833 /* Make sure there's something to replace with */
834 if (!OldOptions)
835 {
837 }
838
839 /* Check if we already had allocated internal options */
840 if (AppEntry->Flags & BL_APPLICATION_ENTRY_BCD_OPTIONS_INTERNAL)
841 {
842 /* Free them */
843 BlMmFreeHeap(AppEntry->BcdData);
844 }
845
846 /* Reset option flags */
847 AppEntry->Flags &= ~(BL_APPLICATION_ENTRY_BCD_OPTIONS_INTERNAL |
849
850 /* Reset the options and set success for now */
852 AppEntry->BcdData = NULL;
853
854 /* Get the size of the new list of options */
855 OptionSize = BlGetBootOptionListSize(OldOptions);
856
857 /* Allocate a copy of the new list */
858 NewOptions = BlMmAllocateHeap(OptionSize);
859 if (!NewOptions)
860 {
861 return STATUS_NO_MEMORY;
862 }
863
864 /* Copy it in */
865 RtlCopyMemory(NewOptions, OldOptions, OptionSize);
866
867 /* Set it as the new set of options and return */
869 AppEntry->BcdData = NewOptions;
870 return Status;
871}
#define BL_APPLICATION_ENTRY_BCD_OPTIONS_EXTERNAL
Definition: bl.h:74

Referenced by BmMain().

◆ BlResourceFindHtml()

PWCHAR BlResourceFindHtml ( VOID  )

Definition at line 305 of file resource.c.

308{
310 PIMAGE_RESOURCE_DATA_ENTRY HtmlDataEntry;
311 PWCHAR Stylesheet;
312
313 /* Assume failure */
314 Stylesheet = NULL;
315
316 /* Look for an RT_HTML resource called BOOTMGR.XSL */
318 0,
319 23,
320 NULL,
321 L"BOOTMGR.XSL",
322 &HtmlDataEntry,
323 (PVOID*)&Stylesheet);
324 if (!NT_SUCCESS(Status))
325 {
326 return Stylesheet;
327 }
328
329 /* Check for Unicode BOM */
330 if (*Stylesheet == 0xFEFF)
331 {
332 /* Overwrite it, and NULL-terminate */
333 RtlMoveMemory(Stylesheet,
334 Stylesheet + 1,
335 HtmlDataEntry->Size - sizeof(WCHAR));
336 Stylesheet[(HtmlDataEntry->Size / sizeof(WCHAR)) - 1] = UNICODE_NULL;
337 }
338 else if (Stylesheet[(HtmlDataEntry->Size / sizeof(WCHAR)) - 1] != UNICODE_NULL)
339 {
340 /* If it's not NULL-terminated, fail */
341 Stylesheet = NULL;
342 }
343
344 /* Return it back */
345 return Stylesheet;
346}
NTSTATUS ResFindDataEntryFromImage(_In_opt_ PVOID ImageBase, _In_opt_ ULONG ImageSize, _In_ USHORT DirectoryId, _In_ PUSHORT EntryId, _In_ PWCHAR Name, _Out_ PIMAGE_RESOURCE_DATA_ENTRY *DataEntryOut, _Out_ PVOID *ResourceOut)
Definition: resource.c:154
Definition: pedump.c:458
DWORD Size
Definition: pedump.c:460
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264

Referenced by BmMain().

◆ BlResourceFindMessage()

PWCHAR BlResourceFindMessage ( _In_ ULONG  MsgId)

Definition at line 349 of file resource.c.

352{
354 PIMAGE_RESOURCE_DIRECTORY ResourceDir;
358 ULONG i, j;
359 USHORT Id;
360 PVOID MsgEnd;
362
363 /* Bail out if there's no resource directory */
364 Message = NULL;
365 if (!ResRootDirectory)
366 {
367 return Message;
368 }
369
370 /* Check if we've loaded fonts already */
372 {
373 /* Nope, load them now */
375 if (!NT_SUCCESS(Status))
376 {
377 /* We failed to load fonts, fallback to fallback locale */
379 if (NT_SUCCESS(Status))
380 {
381 /* Try fonts now */
383 if (!NT_SUCCESS(Status))
384 {
385 /* Still didn't work -- fallback to text mode */
386 EfiPrintf(L"Font loading failed, falling back to text mode\r\n");
388 if (!NT_SUCCESS(Status))
389 {
390 /* That didn't work either. F*ck it. */
391 return Message;
392 }
393 }
394 }
395 }
396
397 /* Now we have a resource directory, and fonts are loaded */
400 }
401
402 /* Go look for RT_MESSAGETABLE */
403 Id = 11;
405 &Id,
406 NULL,
408 if (!ResourceDir)
409 {
410 return Message;
411 }
412
413 /* Go look for the first directory in the table */
414 Id = 1;
415 ResourceDir = (PIMAGE_RESOURCE_DIRECTORY)ResFindDirectoryEntry(ResourceDir,
416 &Id,
417 NULL,
419 if (!ResourceDir)
420 {
421 return Message;
422 }
423
424 /* Go look for any language entry in the table */
425 Id = -1;
426 DataEntry = (PIMAGE_RESOURCE_DATA_ENTRY)ResFindDirectoryEntry(ResourceDir,
427 &Id,
428 NULL,
430 if (!DataEntry)
431 {
432 return Message;
433 }
434
435 /* Get the message data*/
437 DataEntry->OffsetToData -
439
440 /* Loop through the message blocks */
441 for (j = 0; j < MsgData->NumberOfBlocks; j++)
442 {
443 /* Check if the ID is within this range */
444 if ((MsgId >= MsgData->Blocks[j].LowId) &&
445 (MsgId <= MsgData->Blocks[j].HighId))
446 {
447 /* Get the first entry */
448 MsgEntry = (PMESSAGE_RESOURCE_ENTRY)((ULONG_PTR)MsgData +
449 MsgData->Blocks[j].OffsetToEntries);
450
451 /* Loop till we find the right one */
452 for (i = MsgId - MsgData->Blocks[j].LowId; i; --i)
453 {
454 MsgEntry = (PMESSAGE_RESOURCE_ENTRY)((ULONG_PTR)MsgEntry +
455 MsgEntry->Length);
456 }
457
458 /* Find where this message ends */
459 MsgEnd = (PVOID)((ULONG_PTR)MsgEntry + MsgEntry->Length);
460
461 /* Now make sure that the message is within bounds */
462 if ((MsgEnd >= (PVOID)MsgEntry) &&
463 ((PVOID)MsgEntry >= ResPeImageBase) &&
464 (MsgEnd <= ResPeImageEnd))
465 {
466 /* If so, read the text associated with it */
467 Message = (PWCHAR)MsgEntry->Text;
468 break;
469 }
470 }
471 }
472
473 /* Return the text, if one was found */
474 return Message;
475}
NTSTATUS BfLoadDeferredFontFiles(VOID)
Definition: font.c:99
NTSTATUS BlDisplaySetScreenResolution(VOID)
Definition: display.c:646
PIMAGE_RESOURCE_DIRECTORY_ENTRY ResFindDirectoryEntry(_In_ PIMAGE_RESOURCE_DIRECTORY Directory, _In_opt_ PUSHORT Id, _In_opt_ PWCHAR Name, _In_ ULONG_PTR SectionStart)
Definition: resource.c:81
static const WCHAR Message[]
Definition: register.c:74
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
struct _MESSAGE_RESOURCE_DATA * PMESSAGE_RESOURCE_DATA
struct _MESSAGE_RESOURCE_ENTRY * PMESSAGE_RESOURCE_ENTRY
struct _IMAGE_RESOURCE_DATA_ENTRY * PIMAGE_RESOURCE_DATA_ENTRY
DWORD OffsetToData
Definition: pedump.c:459
MESSAGE_RESOURCE_BLOCK Blocks[ANYSIZE_ARRAY]
Definition: rtltypes.h:1912
Definition: rtltypes.h:1896
UCHAR Text[ANYSIZE_ARRAY]
Definition: rtltypes.h:1899
USHORT Length
Definition: rtltypes.h:1897
#define NT_ASSERT
Definition: rtlfuncs.h:3310

Referenced by BmpErrorLog().

◆ BlSecureBootCheckForFactoryReset()

NTSTATUS BlSecureBootCheckForFactoryReset ( VOID  )

Definition at line 759 of file firmware.c.

762{
763 BOOLEAN SecureBootEnabled;
766
767 /* Initialize locals */
768 DataSize = 0;
769 SecureBootEnabled = FALSE;
770
771 /* Check if secureboot is enabled */
772 Status = BlSecureBootIsEnabled(&SecureBootEnabled);
773 if (!(NT_SUCCESS(Status)) || !(SecureBootEnabled))
774 {
775 /* It's not. Check if there's a revocation list */
776 Status = EfiGetVariable(L"RevocationList",
778 NULL,
779 &DataSize,
780 NULL);
782 {
783 /* We don't support this yet */
784 EfiPrintf(L"Not yet supported\r\n");
786 }
787 }
788
789 /* Return back to the caller */
790 return Status;
791}
NTSTATUS BlSecureBootIsEnabled(_Out_ PBOOLEAN SecureBootEnabled)
Definition: firmware.c:732
VOID EfiPrintf(_In_ PWCHAR Format,...)
Definition: firmware.c:126
EFI_GUID BlpEfiSecureBootPrivateNamespace
Definition: firmware.c:37

Referenced by BmMain().

◆ BlSecureBootIsEnabled()

NTSTATUS BlSecureBootIsEnabled ( _Out_ PBOOLEAN  SecureBootEnabled)

Definition at line 732 of file firmware.c.

735{
737
738 /* Have we checked before ? */
740 {
741 /* First time checking */
744 {
745 /* Yep, it's on */
747 }
748
749 /* Don't check again */
751 }
752
753 /* Return the firmware result */
754 *SecureBootEnabled = BlpFirmwareEnabled;
755 return STATUS_SUCCESS;
756}
BOOLEAN BlpFirmwareEnabled
Definition: firmware.c:42
BOOLEAN BlpFirmwareChecked
Definition: firmware.c:41
NTSTATUS BlpSecureBootEFIIsEnabled(VOID)
Definition: firmware.c:687

Referenced by BlSecureBootCheckForFactoryReset(), and BmFwRegisterRevocationList().

◆ BlSetupDefaultParameters()

FORCEINLINE VOID BlSetupDefaultParameters ( _Out_ PBL_LIBRARY_PARAMETERS  LibraryParameters)

Definition at line 1354 of file bl.h.

1357{
1358 BL_LIBRARY_PARAMETERS DefaultParameters =
1359 {
1360 0x20,
1361 BlVirtual,
1362 1024,
1363 2 * 1024 * 1024,
1364 0,
1365 NULL,
1366 0,
1367 NULL
1368 };
1369
1370 /* Copy the defaults */
1371 RtlCopyMemory(LibraryParameters, &DefaultParameters, sizeof(*LibraryParameters));
1372}

Referenced by BmMain(), and OslMain().

◆ BlStatusError()

VOID BlStatusError ( _In_ ULONG  ErrorCode,
_In_ ULONG  Parameter1,
_In_ ULONG_PTR  Parameter2,
_In_ ULONG_PTR  Parameter3,
_In_ ULONG_PTR  Parameter4 
)

Definition at line 121 of file debug.c.

128{
130
131 /* Is this a non-boot error? */
132 if (ErrorCode != 1)
133 {
134 /* Is one already ongoing? */
136 {
137 /* Do we have a custom error handler registered? */
139 {
140 /* Call it, making sure to avoid recursion */
143 Parameter1,
144 Parameter2,
145 Parameter3,
146 Parameter4);
148
149 /* If the error handler consumed the error, we're done */
150 if (NT_SUCCESS(Status))
151 {
152 return;
153 }
154 }
155 }
156 }
157
158 /* Check if the boot debugger is enabled */
160 {
161 /* Print out the fatal error */
162 BlStatusPrint(L"\n"
163 L"*** Fatal Error 0x%08x :\n"
164 L" (0x%p, 0x%p, 0x%p, 0x%p)\n"
165 L"\n",
166 ErrorCode,
167 Parameter1,
168 Parameter2,
169 Parameter3,
170 Parameter4);
171
172 /* Issue a breakpoint */
173 __debugbreak();
174 }
175}
BOOLEAN BlpStatusErrorInProgress
Definition: debug.c:19
PBL_STATUS_ERROR_HANDLER BlpStatusErrorHandler
Definition: debug.c:20
VOID BlStatusPrint(_In_ PCWCH Format,...)
Definition: debug.c:75
void __cdecl __debugbreak(void)
Definition: intrin_ppc.h:698
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436

Referenced by BmFatalErrorEx().

◆ BlStatusPrint()

VOID BlStatusPrint ( _In_ PCWCH  Format,
  ... 
)

Definition at line 75 of file debug.c.

79{
82 va_list va;
84
85 va_start(va, Format);
86
87 /* Check if the boot debugger is enabled */
89#if DBG
90 || TRUE
91#endif
92 )
93 {
94 /* Print the string out into a buffer */
95 if (vswprintf(BlScratchBuffer, Format, va) > 0)
96 {
97#if DBG
99 EfiPrintf(L"\r\n");
100#endif
101 /* Make it a UNICODE_STRING */
103
104 /* Then convert it into an ANSI_STRING */
105 AnsiString.Length = 0;
106 AnsiString.MaximumLength = sizeof(AnsiBuffer);
107 AnsiString.Buffer = AnsiBuffer;
109 if (NT_SUCCESS(Status))
110 {
111 /* Print it out to the debugger if that worked */
112 DbgPrint(AnsiString.Buffer);
113 }
114 }
115 }
116
117 va_end(va);
118}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
WCHAR BlScratchBuffer[8192]
Definition: firmware.c:39
CHAR AnsiBuffer[1024]
Definition: debug.c:15
@ AnsiString
Definition: dnslib.h:19
#define DbgPrint
Definition: hal.h:12
static _Check_return_opt_ int __cdecl vswprintf(_Out_writes_z_(_SizeInWords) wchar_t *_DstBuf, _In_ size_t _SizeInWords, _In_z_ _Printf_format_string_ const wchar_t *_Format, va_list _ArgList)
Definition: stdio.h:977
#define DBG(x)
Definition: moztest.c:12
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)

Referenced by BiEnumerateSubObjectElements(), BlStatusError(), BmFatalErrorEx(), BmFwMemoryInitialize(), MmHapReportHeapCorruption(), OslAbortBoot(), and OslFatalErrorEx().

◆ BlTblFindEntry()

PVOID BlTblFindEntry ( _In_ PVOID Table,
_In_ ULONG  Count,
_Out_ PULONG  EntryIndex,
_In_ PBL_TBL_LOOKUP_ROUTINE  Callback,
_In_ PVOID  Argument1,
_In_ PVOID  Argument2,
_In_ PVOID  Argument3,
_In_ PVOID  Argument4 
)

Definition at line 273 of file util.c.

283{
284 PVOID Entry = NULL;
285 ULONG Index;
287
288 /* Check for invalid parameters */
289 if (!(Table) || !(EntryIndex))
290 {
291 return Entry;
292 }
293
294 /* Loop each entry in the table */
295 for (Index = 0; Index < Count; Index++)
296 {
297 /* Check if this entry is filled out */
298 if (Table[Index])
299 {
300 /* Call the comparison function */
302 Argument1,
303 Argument2,
304 Argument3,
305 Argument4);
306 if (Result)
307 {
308 /* Entry found return it */
309 *EntryIndex = Index;
310 Entry = Table[Index];
311 break;
312 }
313 }
314 }
315
316 /* Return the entry that was (or wasn't) found */
317 return Entry;
318}
_In_ PVOID Argument2
Definition: classpnp.h:721
InternalIoctlParams Argument4
ASMGENDATA Table[]
Definition: genincdata.c:61
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:458
_IRQL_requires_same_ _In_opt_ PVOID Argument1
Definition: cmtypes.h:696

Referenced by BlockIoOpen(), BlpDeviceOpen(), FileIoOpen(), and MmBapFindBlockInformation().

◆ BlTblMap()

NTSTATUS BlTblMap ( _In_ PVOID Table,
_In_ ULONG  Count,
_In_ PBL_TBL_MAP_ROUTINE  MapCallback 
)

Definition at line 399 of file util.c.

404{
405 NTSTATUS Status, LocalStatus;
406 PVOID Entry;
407 ULONG Index;
408
409 /* Bail out if there's no table */
410 if (!Table)
411 {
413 }
414
415 /* Assume success and loop each index */
417 for (Index = 0; Index < Count; Index++)
418 {
419 /* See if an entry exists at this index */
420 Entry = Table[Index];
421 if (Entry)
422 {
423 /* Call the map routine for this entry */
424 LocalStatus = MapCallback(Entry, Index);
425 if (!NT_SUCCESS(LocalStatus))
426 {
427 /* Propagate failure only */
428 Status = LocalStatus;
429 }
430 }
431 }
432
433 /* Return status to caller */
434 return Status;
435}

Referenced by BlockIoDeviceTableDestroy().

◆ BlTblSetEntry()

NTSTATUS BlTblSetEntry ( _Inout_ PVOID **  Table,
_Inout_ PULONG  Count,
_In_ PVOID  Entry,
_Out_ PULONG  EntryIndex,
_In_ PBL_TBL_SET_ROUTINE  Callback 
)

Definition at line 321 of file util.c.

328{
329 ULONG NewCount;
331 ULONG Index = 0;
332 PVOID* NewTable;
333
334 /* Make sure all the parameters were specified */
335 if (!(Table) || !(*Table) || !(Count) || !(Callback))
336 {
338 }
339
340 /* Read the current table */
341 NewTable = *Table;
342 NewCount = *Count;
343
344 /* Iterate over it */
345 while (Index < NewCount)
346 {
347 /* Look for a free index */
348 if (!NewTable[Index])
349 {
350 goto SetIndex;
351 }
352
353 /* No free index yet, keep going */
354 ++Index;
355 }
356
357 /* No free index was found, try to purge some entries */
358 Index = 0;
359 while (Index < NewCount)
360 {
361 /* Call each purge callback, trying to make space */
362 Status = Callback(NewTable[Index]);
363 if (NT_SUCCESS(Status))
364 {
365 /* We should have this slot available now */
366 goto SetIndex;
367 }
368
369 /* Keep trying to purge more */
370 ++Index;
371 }
372
373 /* Double the table */
374 NewTable = BlMmAllocateHeap(2 * sizeof(PVOID) * NewCount);
375 if (!NewTable)
376 {
377 return STATUS_NO_MEMORY;
378 }
379
380 /* Clear the new table, and copy the old entries */
381 RtlZeroMemory(&NewTable[NewCount], sizeof(PVOID) * NewCount);
382 RtlCopyMemory(NewTable, *Table, sizeof(PVOID) * NewCount);
383
384 /* Free the old table */
386
387 /* Return the new table and count */
388 *Count = 2 * NewCount;
389 *Table = NewTable;
390
391SetIndex:
392 /* Set the index and return */
393 NewTable[Index] = Entry;
394 *EntryIndex = Index;
395 return Status;
396}

Referenced by BlHtCreate(), BlImgLoadBootApplication(), BlockIoFirmwareOpen(), BlpDeviceOpen(), BlpIoRegisterDestroyRoutine(), BlpMmCreateBlockAllocator(), EtfsMount(), and FileIoOpen().

◆ BlTimeQueryPerformanceCounter()

ULONGLONG BlTimeQueryPerformanceCounter ( _Out_opt_ PLARGE_INTEGER  Frequency)

Definition at line 101 of file time.c.

104{
105#if defined(_M_IX86) || defined(_M_X64)
106 /* Check if caller wants frequency */
107 if (Frequency)
108 {
109 /* Return it */
111 }
112
113 /* Return the TSC value */
114 return __rdtsc();
115#else
116 EfiPrintf(L"BlTimeQueryPerformanceCounter not implemented for this platform.\r\n");
117 return 0;
118#endif
119};

Referenced by BlImgLoadBootApplication().

◆ BlUtlCheckSum()

ULONG BlUtlCheckSum ( _In_ ULONG  PartialSum,
_In_ PUCHAR  Buffer,
_In_ ULONG  Length,
_In_ ULONG  Flags 
)

Definition at line 777 of file util.c.

783{
784 ULONG i;
785
787 {
788 EfiPrintf(L"Not supported\r\n");
789 return 0;
790 }
792 {
793 PartialSum = (unsigned __int16)PartialSum;
794 Length &= ~1;
795
796 for (i = 0; i < Length; i += 2)
797 {
798 PartialSum += *(unsigned __int16 *)&Buffer[i];
800 {
801 PartialSum = (unsigned __int16)((PartialSum >> 16) + PartialSum);
802 }
803 }
804
805 if (i != Length)
806 {
807 PartialSum += (unsigned __int8)Buffer[Length];
809 {
810 PartialSum = (unsigned __int16)((PartialSum >> 16) + PartialSum);
811 }
812 }
813
815 {
816 return ~PartialSum;
817 }
818
819 PartialSum = (unsigned __int16)PartialSum;
820 }
821 else
822 {
823 /* Invalid mode */
824 return 0;
825 }
826
828 {
829 return ~PartialSum;
830 }
831
832 return PartialSum;
833}
#define __int8
Definition: basetyps.h:25
#define __int16
Definition: basetyps.h:22
#define BL_UTL_CHECKSUM_USHORT_BUFFER
Definition: bl.h:191
#define BL_UTL_CHECKSUM_COMPLEMENT
Definition: bl.h:187
#define BL_UTL_CHECKSUM_UCHAR_BUFFER
Definition: bl.h:190
#define BL_UTL_CHECKSUM_NEGATE
Definition: bl.h:189
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102

Referenced by ImgpLoadPEImage().

◆ BlUtlGetAcpiTable()

NTSTATUS BlUtlGetAcpiTable ( _Out_ PVOID TableAddress,
_In_ ULONG  Signature 
)

Definition at line 34 of file util.c.

38{
39 ULONG i, TableCount, HeaderLength;
41 PRSDT Rsdt;
42 PXSDT Xsdt;
45
46 Header = 0;
47
48 /* Make sure there's an output parameter */
49 if (!TableAddress)
50 {
52 }
53
54 /* Get the currently known RSDT and XSDT */
55 Rsdt = (PRSDT)UtlRsdt;
56 Xsdt = (PXSDT)UtlXsdt;
57
58 /* Is there an RSDT? */
59 if (!Rsdt)
60 {
61 /* No -- is there an XSDT? */
62 if (!Xsdt)
63 {
64 /* No. Look up the RSDT */
66 if (!NT_SUCCESS(Status))
67 {
68 EfiPrintf(L"no rsdp found\r\n");
69 return Status;
70 }
71
72 /* Map the header */
74 0,
75 sizeof(*Header),
77 if (!NT_SUCCESS(Status))
78 {
79 return Status;
80 }
81
82 /* Unmap the header */
84
85 /* Map the whole table */
87 0,
88 Header->Length,
90 if (!NT_SUCCESS(Status))
91 {
92 return Status;
93 }
94
95 /* Check if its an XSDT or an RSDT */
96 if (Header->Signature == XSDT_SIGNATURE)
97 {
98 /* It's an XSDT */
99 Xsdt = (PXSDT)Header;
100 UtlXsdt = Xsdt;
101 }
102 else
103 {
104 /* It's an RSDT */
105 Rsdt = (PRSDT)Header;
106 UtlRsdt = Rsdt;
107 }
108 }
109 }
110
111 /* OK, so do we have an XSDT after all? */
112 if (Xsdt)
113 {
114 /* Yes... how big is it? */
115 HeaderLength = Xsdt->Header.Length;
116 if (HeaderLength >= sizeof(*Header))
117 {
118 HeaderLength = sizeof(*Header);
119 }
120
121 /* Based on that, how many tables are there? */
122 TableCount = (Xsdt->Header.Length - HeaderLength) / sizeof(PHYSICAL_ADDRESS);
123 }
124 else
125 {
126 /* Nope, we have an RSDT. How big is it? */
127 HeaderLength = Rsdt->Header.Length;
128 if (HeaderLength >= sizeof(*Header))
129 {
130 HeaderLength = sizeof(*Header);
131 }
132
133 /* Based on that, how many tables are there? */
134 TableCount = (Rsdt->Header.Length - HeaderLength) / sizeof(ULONG);
135 }
136
137 /* Loop through the ACPI tables */
138 for (i = 0; i < TableCount; i++)
139 {
140 /* For an XSDT, read the 64-bit address directly */
141 if (Xsdt)
142 {
143 PhysicalAddress = Xsdt->Tables[i];
144 }
145 else
146 {
147 /* For RSDT, cast it */
149 }
150
151 /* Map the header */
153 0,
154 sizeof(*Header),
156 if (!NT_SUCCESS(Status))
157 {
158 return Status;
159 }
160
161 /* Is it the right one? */
162 if (Header->Signature == Signature)
163 {
164 /* Unmap the header */
166
167 /* Map the whole table */
168 return BlMmMapPhysicalAddressEx(TableAddress,
169 0,
170 Header->Length,
172 }
173 }
174
175 /* Requested table does not exist */
176 return STATUS_NOT_FOUND;
177}
NTSTATUS BlMmMapPhysicalAddressEx(_In_ PVOID *VirtualAddress, _In_ ULONG Attributes, _In_ ULONGLONG Size, _In_ PHYSICAL_ADDRESS PhysicalAddress)
Definition: mm.c:192
NTSTATUS EfipGetRsdt(_Out_ PPHYSICAL_ADDRESS FoundRsdt)
Definition: firmware.c:1635
PRSDT UtlRsdt
Definition: util.c:15
PXSDT UtlXsdt
Definition: util.c:16
Definition: Header.h:9
static const WCHAR Signature[]
Definition: parser.c:141
RSDT * PRSDT
Definition: acpi.h:191
#define XSDT_SIGNATURE
Definition: acpi.h:39
XSDT * PXSDT
Definition: acpi.h:198
Definition: acpi.h:187
ULONG Tables[ANYSIZE_ARRAY]
Definition: acpi.h:189
DESCRIPTION_HEADER Header
Definition: acpi.h:188
Definition: acpi.h:194
PHYSICAL_ADDRESS Tables[ANYSIZE_ARRAY]
Definition: acpi.h:196
DESCRIPTION_HEADER Header
Definition: acpi.h:195

Referenced by BlDisplayGetOemBitmap(), and BlDisplayInvalidateOemBitmap().

◆ BlUtlInitialize()

NTSTATUS BlUtlInitialize ( VOID  )

Definition at line 197 of file util.c.

200{
201 UtlRsdt = 0;
202 UtlXsdt = 0;
203
204 UtlMcContext = 0;
207
215 UtlProgressInfo = 0;
216
217 return STATUS_SUCCESS;
218}
ULONG UtlProgressGranularity
Definition: util.c:25
PVOID UtlMcContext
Definition: util.c:18
PVOID UtlProgressInfo
Definition: util.c:29
ULONG UtlNextUpdatePercentage
Definition: util.c:27
PVOID UtlProgressInfoRoutine
Definition: util.c:24
ULONG UtlCurrentPercentComplete
Definition: util.c:26
PVOID UtlMcUpdateMessageRoutine
Definition: util.c:20
PVOID UtlMcDisplayMessageRoutine
Definition: util.c:19
BOOLEAN UtlProgressNeedsInfoUpdate
Definition: util.c:28
PVOID UtlProgressRoutine
Definition: util.c:22
PVOID UtlProgressContext
Definition: util.c:23

Referenced by InitializeLibrary().

◆ BlUtlRegisterProgressRoutine()

NTSTATUS BlUtlRegisterProgressRoutine ( VOID  )

Definition at line 244 of file util.c.

247{
248 /* One shouldn't already exist */
250 {
251 return STATUS_UNSUCCESSFUL;
252 }
253
254 /* Set the routine, and no context */
257
258 /* Progress increases by one */
260
261 /* Set progress to zero for now */
264
265 /* Set the info routine if there is one */
267
268 /* All good */
269 return STATUS_SUCCESS;
270}
VOID BmUpdateProgress(_In_ PVOID Unknown, _In_ ULONG Percent, _Out_ PBOOLEAN Completed)
Definition: util.c:230
VOID BmUpdateProgressInfo(_In_ PVOID Unknown, _In_ PWCHAR ProgressInfo)
Definition: util.c:221

Referenced by BmMain().

◆ BlUtlUpdateProgress()

VOID BlUtlUpdateProgress ( _In_ ULONG  Percentage,
_Out_opt_ PBOOLEAN  Completed 
)

Definition at line 181 of file util.c.

185{
187 {
188 EfiPrintf(L"Unimplemented\r\n");
189 }
190 else if (*Completed)
191 {
192 *Completed = TRUE;
193 }
194}

Referenced by BlImgLoadImageWithProgress2().

◆ C_ASSERT() [1/2]

C_ASSERT ( BL_MM_INCLUDE_NO_FIRMWARE_MEMORY  = =0x1BF)

◆ C_ASSERT() [2/2]

C_ASSERT ( BL_MM_INCLUDE_ONLY_FIRMWARE_MEMORY  = =0x240)

◆ ConsoleCreateLocalInputCnsole()

NTSTATUS ConsoleCreateLocalInputCnsole ( VOID  )

◆ ConsoleCreateLocalInputConsole()

NTSTATUS ConsoleCreateLocalInputConsole ( VOID  )

Definition at line 243 of file textcons.c.

246{
247 PBL_INPUT_CONSOLE InputConsole;
249
250 /* Allocate the input console */
251 InputConsole = BlMmAllocateHeap(sizeof(*InputConsole));
252 if (!InputConsole)
253 {
255 }
256
257 /* Construct it */
258 Status = ConsoleInputBaseConstruct(InputConsole);
259 if (!NT_SUCCESS(Status))
260 {
261 /* Tear down on failure */
262 BlMmFreeHeap(InputConsole);
263 return Status;
264 }
265
266 /* Set the callback table, and set us as the local input console */
267 InputConsole->Callbacks = &ConsoleInputLocalVtbl;
268 DspLocalInputConsole = InputConsole;
269 return STATUS_SUCCESS;
270}
PVOID DspLocalInputConsole
Definition: display.c:38
BL_INPUT_CONSOLE_VTABLE ConsoleInputLocalVtbl
Definition: textcons.c:187
NTSTATUS ConsoleInputBaseConstruct(_In_ PBL_INPUT_CONSOLE Console)
Definition: textcons.c:204
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158

Referenced by DsppInitialize(), and DsppReinitialize().

◆ ConsoleCreateRemoteConsole()

NTSTATUS ConsoleCreateRemoteConsole ( _In_ PBL_TEXT_CONSOLE TextConsole)

Definition at line 31 of file emscons.c.

34{
35 PBL_REMOTE_CONSOLE RemoteConsole;
37
38 /* Allocate the remote console */
39 RemoteConsole = BlMmAllocateHeap(sizeof(*RemoteConsole));
40 if (!RemoteConsole)
41 {
43 }
44
45 /* Construct it */
46 Status = ConsoleRemoteConstruct(RemoteConsole);
47 if (!NT_SUCCESS(Status))
48 {
49 /* Failed to construct it, delete it */
50 BlMmFreeHeap(RemoteConsole);
51 return Status;
52 }
53
54 /* Save the global pointer and return a pointer to the text console */
55 DspRemoteInputConsole = RemoteConsole;
56 *TextConsole = &RemoteConsole->TextConsole;
57 return STATUS_SUCCESS;
58}
PVOID DspRemoteInputConsole
Definition: display.c:35
NTSTATUS ConsoleRemoteConstruct(_In_ PBL_REMOTE_CONSOLE RemoteConsole)
Definition: emscons.c:18
BL_TEXT_CONSOLE TextConsole
Definition: bl.h:1165

Referenced by DsppInitialize(), and DsppReinitialize().

◆ ConsoleEfiGopClose()

VOID ConsoleEfiGopClose ( _In_ PBL_GRAPHICS_CONSOLE  GraphicsConsole)

Definition at line 177 of file gop.c.

180{
181 ULONG OldMode;
182
183 /* Did we switch modes when we turned on the console? */
184 OldMode = GraphicsConsole->OldMode;
185 if (GraphicsConsole->Mode != OldMode)
186 {
187 /* Restore the old mode and reset the OEM bitmap in ACPI */
188 EfiGopSetMode(GraphicsConsole->Protocol, OldMode);
190 }
191
192 /* Close the GOP protocol */
193 EfiCloseProtocol(GraphicsConsole->Handle,
195}
EFI_GUID EfiGraphicsOutputProtocol
Definition: firmware.c:28
NTSTATUS EfiCloseProtocol(_In_ EFI_HANDLE Handle, _In_ EFI_GUID *Protocol)
Definition: firmware.c:581
VOID BlDisplayInvalidateOemBitmap(VOID)
Definition: display.c:723
NTSTATUS EfiGopSetMode(_In_ EFI_GRAPHICS_OUTPUT_PROTOCOL *GopInterface, _In_ ULONG Mode)
Definition: firmware.c:1349

Referenced by ConsoleFirmwareGraphicalClose().

◆ ConsoleEfiGopEnable()

NTSTATUS ConsoleEfiGopEnable ( _In_ PBL_GRAPHICS_CONSOLE  GraphicsConsole)

Definition at line 88 of file gop.c.

91{
93 UINTN CurrentMode, Dummy;
94 ULONG Mode, PixelDepth;
99 PHYSICAL_ADDRESS FrameBufferPhysical;
100
101 /* Capture the current mode and protocol */
102 Mode = GraphicsConsole->Mode;
103 Protocol = GraphicsConsole->Protocol;
104
105 /* Get the current mode and its information */
106 Status = EfiGopGetCurrentMode(Protocol, &CurrentMode, &ModeInformation);
107 if (!NT_SUCCESS(Status))
108 {
109 return Status;
110 }
111
112 /* Check if we're not in the mode we should be */
113 if (CurrentMode != Mode)
114 {
115 /* Switch modes */
117 if (!NT_SUCCESS(Status))
118 {
119 return Status;
120 }
121
122 /* Reset the OEM bitmap and get the new more information */
124 EfiGopGetCurrentMode(Protocol, &Dummy, &ModeInformation);
125 }
126
127 /* Get the pixel depth for this mode */
128 Status = ConsoleEfiGopGetGraphicalFormat(&ModeInformation, &PixelDepth);
129 if (NT_SUCCESS(Status))
130 {
131 /* Get the framebuffer for this mode */
132 EfiGopGetFrameBuffer(Protocol, &FrameBufferPhysical, &FrameBufferSize);
133
134 /* Map the framebuffer, try as writeback first */
139 FrameBufferPhysical);
140 if (!NT_SUCCESS(Status))
141 {
142 /* That didn't work, so try uncached next */
146 FrameBufferPhysical);
147 }
148 }
149
150 /* Check if getting all the required information worked out */
151 if (NT_SUCCESS(Status))
152 {
153 /* Capture the resolution, depth, and framebuffer information */
154 GraphicsConsole->DisplayMode.HRes = ModeInformation.HorizontalResolution;
155 GraphicsConsole->DisplayMode.VRes = ModeInformation.VerticalResolution;
156 GraphicsConsole->DisplayMode.HRes2 = ModeInformation.PixelsPerScanLine;
157 GraphicsConsole->PixelDepth = PixelDepth;
158 GraphicsConsole->FrameBuffer = FrameBuffer;
159 GraphicsConsole->FrameBufferSize = FrameBufferSize;
160 GraphicsConsole->PixelsPerScanLine = ModeInformation.PixelsPerScanLine;
161
162 /* All good */
164 }
165 else if (CurrentMode != GraphicsConsole->Mode)
166 {
167 /* We failed somewhere, reset the mode and the OEM bitmap back */
168 EfiGopSetMode(Protocol, CurrentMode);
170 }
171
172 /* Return back to caller */
173 return Status;
174}
UINT32 UINTN
NTSTATUS EfiGopGetCurrentMode(_In_ EFI_GRAPHICS_OUTPUT_PROTOCOL *GopInterface, _Out_ UINTN *Mode, _Out_ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Information)
Definition: firmware.c:1296
VOID EfiGopGetFrameBuffer(_In_ EFI_GRAPHICS_OUTPUT_PROTOCOL *GopInterface, _Out_ PHYSICAL_ADDRESS *FrameBuffer, _Out_ UINTN *FrameBufferSize)
Definition: firmware.c:1255
NTSTATUS ConsoleEfiGopGetGraphicalFormat(_In_ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *ModeInfo, _Out_ PULONG PixelDepth)
Definition: gop.c:18
_In_ ULONG Mode
Definition: hubbusif.h:303
ULONG FrameBufferSize
Definition: xboxvideo.c:29
PVOID FrameBuffer
Definition: xboxvideo.c:28

Referenced by ConsoleFirmwareGraphicalEnable().

◆ ConsoleEfiGopOpen()

NTSTATUS ConsoleEfiGopOpen ( _In_ PBL_GRAPHICS_CONSOLE  GraphicsConsole)

Definition at line 198 of file gop.c.

201{
203 EFI_GRAPHICS_OUTPUT_PROTOCOL *GopProtocol;
204 ULONG Mode, PixelDepth;
205 UINTN CurrentMode;
207 BOOLEAN CurrentModeOk;
208
209 /* Open a handle to GOP */
210 Status = EfiOpenProtocol(GraphicsConsole->Handle,
212 (PVOID*)&GopProtocol);
213 if (!NT_SUCCESS(Status))
214 {
215 EfiPrintf(L"GOP OPEN failed: %lx\r\n", Status);
217 }
218
219 /* Get the current mode */
220 Status = EfiGopGetCurrentMode(GopProtocol, &CurrentMode, &ModeInformation);
221 if (!NT_SUCCESS(Status))
222 {
223 EfiPrintf(L"GOP mode failed: %lx\r\n", Status);
224 goto Quickie;
225 }
226
227 Mode = CurrentMode;
228
229 /* Check if any custom BCD options were provided */
233 {
234 /* We'll have to find a mode */
235 CurrentModeOk = FALSE;
236 }
237 else
238 {
239 /* Then we should be in the default mode, check if the pixel format is OK */
240 CurrentModeOk = ConsoleEfiGopIsPixelFormatSupported(&ModeInformation);
241 }
242
243 /* Is the mode/format OK? */
244 if (!CurrentModeOk)
245 {
246 /* Nope -- we'll have to go find one */
250 &Mode);
251 if (!NT_SUCCESS(Status))
252 {
253 goto Quickie;
254 }
255 }
256
257 /* Store mode information */
258 GraphicsConsole->Protocol = GopProtocol;
259 GraphicsConsole->Mode = Mode;
260 GraphicsConsole->OldMode = CurrentMode;
261
262 /* Get format information */
263 Status = ConsoleEfiGopGetGraphicalFormat(&ModeInformation, &PixelDepth);
264 if (NT_SUCCESS(Status))
265 {
266 /* Store it */
267 GraphicsConsole->OldDisplayMode.HRes = ModeInformation.HorizontalResolution;
268 GraphicsConsole->OldDisplayMode.VRes = ModeInformation.VerticalResolution;
269 GraphicsConsole->OldDisplayMode.HRes2 = ModeInformation.PixelsPerScanLine;
270 GraphicsConsole->PixelDepth = PixelDepth;
271 return STATUS_SUCCESS;
272 }
273
274Quickie:
275 /* We failed, close the protocol and return the failure code */
276 EfiPrintf(L"Get format failed: %lx\r\n", Status);
277 EfiCloseProtocol(GraphicsConsole->Handle, &EfiGraphicsOutputProtocol);
278 return Status;
279}
BL_DISPLAY_MODE ConsoleGraphicalResolutionList[]
Definition: display.c:22
NTSTATUS EfiOpenProtocol(_In_ EFI_HANDLE Handle, _In_ EFI_GUID *Protocol, _Out_ PVOID *Interface)
ULONG ConsoleGraphicalResolutionListSize
Definition: display.c:28
#define BL_DISPLAY_GRAPHICS_FORCED_HIGH_RES_MODE_FLAG
Definition: bl.h:135
#define BL_DISPLAY_GRAPHICS_FORCED_VIDEO_MODE_FLAG
Definition: bl.h:134
ULONG ConsoleGraphicalResolutionListFlags
Definition: display.c:21
NTSTATUS ConsoleEfiGopFindModeFromAllowed(_In_ EFI_GRAPHICS_OUTPUT_PROTOCOL *GopProtocol, _In_ PBL_DISPLAY_MODE SupportedModes, _In_ ULONG MaximumIndex, _Out_ PULONG SupportedMode)
Definition: gop.c:77
BOOLEAN ConsoleEfiGopIsPixelFormatSupported(_In_ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Mode)
Definition: gop.c:38
EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE * Mode

Referenced by ConsoleEfiGraphicalOpenProtocol().

◆ ConsoleEfiGraphicalOpenProtocol()

NTSTATUS ConsoleEfiGraphicalOpenProtocol ( _In_ PBL_GRAPHICS_CONSOLE  GraphicsConsole,
_In_ BL_GRAPHICS_CONSOLE_TYPE  Type 
)

Definition at line 34 of file guicons.c.

38{
39 ULONG HandleIndex, HandleCount;
40 EFI_HANDLE* HandleArray;
44
45 /* Find a device handle that implements either GOP or UGA */
46 HandleCount = 0;
47 HandleArray = NULL;
49 (Type == BlGopConsole) ?
52 &HandleCount,
53 &HandleArray);
54 if (!NT_SUCCESS(Status))
55 {
56 /* Nothing supports this (no video card?) */
57 EfiPrintf(L"Status: %lx Count: %d\r\n", Status, HandleCount);
59 }
60
61 /* Scan through the handles we received */
62 for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++)
63 {
64 /* Try to open each one */
65 GraphicsConsole->Handle = HandleArray[HandleIndex];
66 Handle = HandleArray[HandleIndex];
68 if (NT_SUCCESS(Status))
69 {
70 /* Test worked, close the protocol */
72
73 /* Now open the real protocol we want, either UGA or GOP */
74 Status = Type ? ConsoleEfiUgaOpen(GraphicsConsole) :
75 ConsoleEfiGopOpen(GraphicsConsole);
76 if (NT_SUCCESS(Status))
77 {
78 /* It worked -- store the type of console this is */
79 GraphicsConsole->Type = Type;
80 return STATUS_SUCCESS;
81 }
82 }
83 }
84
85 /* We failed to find a working GOP/UGA protocol provider */
87}
EFI_GUID EfiDevicePathProtocol
Definition: firmware.c:31
NTSTATUS ConsoleEfiGopOpen(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: gop.c:198
EFI_GUID EfiUgaDrawProtocol
Definition: firmware.c:29
NTSTATUS ConsoleEfiUgaOpen(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: uga.c:18
NTSTATUS EfiLocateHandleBuffer(_In_ EFI_LOCATE_SEARCH_TYPE SearchType, _In_ EFI_GUID *Protocol, _Inout_ PULONG HandleCount, _Inout_ EFI_HANDLE **Buffer)
Definition: firmware.c:1399
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465

Referenced by ConsoleGraphicalConstruct().

◆ ConsoleEfiUgaClose()

VOID ConsoleEfiUgaClose ( _In_ PBL_GRAPHICS_CONSOLE  GraphicsConsole)

Definition at line 27 of file uga.c.

30{
31 return;
32}

Referenced by ConsoleFirmwareGraphicalClose().

◆ ConsoleEfiUgaOpen()

NTSTATUS ConsoleEfiUgaOpen ( _In_ PBL_GRAPHICS_CONSOLE  GraphicsConsole)

Definition at line 18 of file uga.c.

21{
22 EfiPrintf(L"UGA not implemented\r\n");
24}

Referenced by ConsoleEfiGraphicalOpenProtocol().

◆ ConsoleEfiUgaSetResolution()

NTSTATUS ConsoleEfiUgaSetResolution ( _In_ PBL_GRAPHICS_CONSOLE  GraphicsConsole,
_In_ PBL_DISPLAY_MODE  DisplayMode,
_In_ ULONG  DisplayModeCount 
)

Definition at line 35 of file uga.c.

40{
42}

Referenced by ConsoleFirmwareGraphicalEnable().

◆ ConsoleFirmwareGraphicalClear()

NTSTATUS ConsoleFirmwareGraphicalClear ( _In_ PBL_GRAPHICS_CONSOLE  Console,
_In_ ULONG  Color 
)

Definition at line 90 of file guicons.c.

94{
96 UCHAR Pixel[4] = { 0 };
97
98 /* Convert the standard color to a firmware pixel color */
100 if (!NT_SUCCESS(Status))
101 {
102 return Status;
103 }
104
105 /* Check if this is GOP or UGA */
106 if (Console->Type == BlUgaConsole)
107 {
108 EfiPrintf(L"Uga not supported\r\n");
110 }
111 else
112 {
113 /* For GOP, just fill the screen */
114 ConsolepClearBuffer(Console->FrameBuffer,
115 Console->DisplayMode.HRes,
116 Pixel,
117 Console->DisplayMode.VRes,
118 Console->PixelsPerScanLine,
119 Console->PixelDepth);
121 }
122
123 /* All clear */
124 return Status;
125}
NTSTATUS ConsolepConvertColorToPixel(_In_ BL_COLOR Color, _Out_ PUCHAR Pixel)
Definition: guicons.c:174
VOID ConsolepClearBuffer(_In_ PUCHAR FrameBuffer, _In_ ULONG Width, _In_ PUCHAR FillColor, _In_ ULONG Height, _In_ ULONG ScanlineWidth, _In_ ULONG PixelDepth)
Definition: guicons.c:109

Referenced by ConsoleGraphicalClearPixels().

◆ ConsoleFirmwareGraphicalClose()

VOID ConsoleFirmwareGraphicalClose ( _In_ PBL_GRAPHICS_CONSOLE  GraphicsConsole)

Definition at line 18 of file guicons.c.

21{
22 /* Call the correct close routine based on the console mode */
23 if (GraphicsConsole->Type == BlUgaConsole)
24 {
25 ConsoleEfiUgaClose(GraphicsConsole);
26 }
27 else
28 {
29 ConsoleEfiGopClose(GraphicsConsole);
30 }
31}
VOID ConsoleEfiUgaClose(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: uga.c:27
VOID ConsoleEfiGopClose(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: gop.c:177

Referenced by ConsoleGraphicalConstruct(), and ConsoleGraphicalDestruct().

◆ ConsoleFirmwareGraphicalDisable()

VOID ConsoleFirmwareGraphicalDisable ( _In_ PBL_GRAPHICS_CONSOLE  GraphicsConsole)

Definition at line 153 of file guicons.c.

156{
157 /* Is this a GOP console? */
158 if (GraphicsConsole->Type == BlGopConsole)
159 {
160 /* Did we map a framebuffer? */
161 if (GraphicsConsole->FrameBuffer)
162 {
163 /* Unmap it */
164 BlMmUnmapVirtualAddressEx(GraphicsConsole->FrameBuffer,
165 GraphicsConsole->FrameBufferSize);
166 }
167 }
168}

Referenced by ConsoleGraphicalDestruct(), ConsoleGraphicalEnable(), and ConsoleGraphicalReinitialize().

◆ ConsoleFirmwareGraphicalEnable()

NTSTATUS ConsoleFirmwareGraphicalEnable ( _In_ PBL_GRAPHICS_CONSOLE  GraphicsConsole)

Definition at line 128 of file guicons.c.

131{
133
134 /* Check what type of console this is */
135 if (GraphicsConsole->Type == BlUgaConsole)
136 {
137 /* Handle UGA */
138 Status = ConsoleEfiUgaSetResolution(GraphicsConsole,
139 &GraphicsConsole->DisplayMode,
140 1);
141 }
142 else
143 {
144 /* Handle GOP */
145 Status = ConsoleEfiGopEnable(GraphicsConsole);
146 }
147
148 /* Return back to caller */
149 return Status;
150}
NTSTATUS ConsoleEfiUgaSetResolution(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole, _In_ PBL_DISPLAY_MODE DisplayMode, _In_ ULONG DisplayModeCount)
Definition: uga.c:35
NTSTATUS ConsoleEfiGopEnable(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: gop.c:88

Referenced by ConsoleGraphicalConstruct(), ConsoleGraphicalEnable(), and ConsoleGraphicalReinitialize().

◆ ConsoleFirmwareTextClear()

NTSTATUS ConsoleFirmwareTextClear ( _In_ PBL_TEXT_CONSOLE  Console,
_In_ BOOLEAN  LineOnly 
)

Definition at line 557 of file textcons.c.

561{
562 BL_ARCH_MODE OldMode;
563 EFI_STATUS EfiStatus;
565 ULONG i, Column, Row, TextWidth, TextHeight;
566
567 /* Get the text resolution */
568 BlDisplayGetTextCellResolution(&TextWidth, &TextHeight);
569
570 /* Are we just clearing a line? */
571 if (LineOnly)
572 {
573 /* Get the current column and row */
574 Column = Console->State.XPos / TextWidth;
575 Row = Console->State.YPos / TextHeight;
576
577 /* Loop over every remaining character */
578 for (i = 0; i < Console->DisplayMode.HRes - Column - 1; i++)
579 {
580 /* Write a space on top of it */
581 Status = EfiConOutOutputString(Console->Protocol, L" ");
582 if (!NT_SUCCESS(Status))
583 {
584 break;
585 }
586 }
587
588 /* And reset the cursor back at the initial position */
590 Column,
591 Row);
592 }
593 else
594 {
595 /* Are we in protected mode? */
596 OldMode = CurrentExecutionContext->Mode;
597 if (OldMode != BlRealMode)
598 {
599 /* FIXME: Not yet implemented */
601 }
602
603 /* Clear the screen */
604 EfiStatus = Console->Protocol->ClearScreen(Console->Protocol);
605
606 /* Switch back to protected mode if we came from there */
607 if (OldMode != BlRealMode)
608 {
609 BlpArchSwitchContext(OldMode);
610 }
611
612 /* Conver to NT status -- did that work? */
613 Status = EfiGetNtStatusCode(EfiStatus);
614 if (NT_SUCCESS(Status))
615 {
616 /* Reset current positions */
617 Console->State.XPos = 0;
618 Console->State.YPos = 0;
619 }
620 }
621
622 /* All done */
623 return Status;
624}
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:31
NTSTATUS EfiGetNtStatusCode(_In_ EFI_STATUS EfiStatus)
Definition: firmware.c:2539
VOID BlDisplayGetTextCellResolution(_Out_ PULONG TextWidth, _Out_ PULONG TextHeight)
Definition: display.c:603
VOID BlpArchSwitchContext(_In_ BL_ARCH_MODE NewMode)
Definition: arch.c:166
PBL_ARCH_CONTEXT CurrentExecutionContext
Definition: arch.c:17
NTSTATUS EfiConOutSetCursorPosition(_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface, _In_ ULONG Column, _In_ ULONG Row)
Definition: firmware.c:1130
NTSTATUS EfiConOutOutputString(_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface, _In_ PWCHAR String)
Definition: firmware.c:1195

Referenced by ConsoleGraphicalClearText(), and ConsoleTextLocalClearText().

◆ ConsoleFirmwareTextClose()

VOID ConsoleFirmwareTextClose ( _In_ PBL_TEXT_CONSOLE  TextConsole)

Definition at line 398 of file textcons.c.

401{
402 ULONG Mode;
403 BL_DISPLAY_STATE DisplayState;
404
405 /* Read the original mode, and see if it's different than the one now */
406 Mode = TextConsole->OldMode.Mode;
407 if (Mode != TextConsole->Mode)
408 {
409 /* Restore to the original mode */
410 EfiConOutSetMode(TextConsole->Protocol, Mode);
411 }
412
413 /* Read the EFI settings for the original mode */
414 ConsoleEfiTextGetStateFromMode(&TextConsole->OldMode, &DisplayState);
415
416 /* Set the original settings */
417 ConsoleFirmwareTextSetState(TextConsole, 0xF, &DisplayState);
418}
NTSTATUS EfiConOutSetMode(_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface, _In_ ULONG Mode)
Definition: firmware.c:1066
VOID ConsoleEfiTextGetStateFromMode(_In_ EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode, _Out_ PBL_DISPLAY_STATE State)
Definition: textcons.c:181
NTSTATUS ConsoleFirmwareTextSetState(_In_ PBL_TEXT_CONSOLE TextConsole, _In_ UCHAR Mask, _In_ PBL_DISPLAY_STATE State)
Definition: textcons.c:198

Referenced by ConsoleGraphicalEnable(), and ConsoleTextLocalConstruct().

◆ ConsoleFirmwareTextOpen()

NTSTATUS ConsoleFirmwareTextOpen ( _In_ PBL_TEXT_CONSOLE  TextConsole)

Definition at line 421 of file textcons.c.

424{
426 EFI_SIMPLE_TEXT_OUTPUT_MODE CurrentMode, NewMode;
427 UINTN HRes, VRes;
428 ULONG Mode;
430
431 /* Read the current mode and its settings */
432 EfiConOutReadCurrentMode(EfiConOut, &CurrentMode);
433 Status = EfiConOutQueryMode(EfiConOut, CurrentMode.Mode, &HRes, &VRes);
434 if (!NT_SUCCESS(Status))
435 {
436 return Status;
437 }
438
439 /* Save the current mode and its settings */
440 NewMode = CurrentMode;
441 DisplayMode.VRes = VRes;
442 DisplayMode.HRes = HRes;
443 DisplayMode.HRes2 = HRes;
444
445 /* Check if the current mode is compatible with one of our modes */
447 {
448 /* It isn't -- find a matching EFI mode for what we need */
449 EfiPrintf(L"In incorrect mode, scanning for right one\r\n");
452 1,
453 &Mode);
454 if (!NT_SUCCESS(Status))
455 {
456 EfiPrintf(L"Failed to find mode: %lx\r\n", Status);
457 return Status;
458 }
459
460 /* Set the new EFI mode */
461 EfiPrintf(L"Setting new mode: %d\r\n", Mode);
463 if (!NT_SUCCESS(Status))
464 {
465 return Status;
466 }
467
468 /* Read the current mode and its settings */
470 Status = EfiConOutQueryMode(EfiConOut, Mode, &HRes, &VRes);
471 if (!NT_SUCCESS(Status))
472 {
473 EfiConOutSetMode(EfiConOut, CurrentMode.Mode);
474 return Status;
475 }
476
477 /* Save the current mode and its settings */
478 DisplayMode.HRes = HRes;
479 DisplayMode.VRes = VRes;
480 DisplayMode.HRes2 = HRes;
481 }
482
483 /* Capture all the current settings */
484 ConsoleEfiTextGetStateFromMode(&NewMode, &TextConsole->State);
485 TextConsole->Mode = NewMode.Mode;
486 TextConsole->DisplayMode = DisplayMode;
487 TextConsole->Protocol = EfiConOut;
488 TextConsole->OldMode = CurrentMode;
489 return STATUS_SUCCESS;
490}
NTSTATUS EfiConOutQueryMode(_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface, _In_ ULONG Mode, _In_ UINTN *Columns, _In_ UINTN *Rows)
Definition: firmware.c:1032
VOID EfiConOutReadCurrentMode(_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface, _Out_ EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode)
Definition: firmware.c:1227
BL_DISPLAY_MODE ConsoleTextResolutionList[]
Definition: display.c:30
BOOLEAN ConsolepFindResolution(_In_ PBL_DISPLAY_MODE Mode, _In_ PBL_DISPLAY_MODE List, _In_ ULONG MaxIndex)
Definition: textcons.c:159
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * EfiConOut
Definition: firmware.c:23
NTSTATUS ConsoleEfiTextFindModeFromAllowed(_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextProtocol, _In_ PBL_DISPLAY_MODE SupportedModes, _In_ ULONG MaxIndex, _Out_ PULONG SupportedMode)
Definition: textcons.c:318
static VIDEODISPLAYMODE DisplayMode
Definition: pcvideo.c:117

Referenced by ConsoleGraphicalEnable(), and ConsoleTextLocalConstruct().

◆ ConsoleFirmwareTextSetState()

NTSTATUS ConsoleFirmwareTextSetState ( _In_ PBL_TEXT_CONSOLE  TextConsole,
_In_ UCHAR  Mask,
_In_ PBL_DISPLAY_STATE  State 
)

Definition at line 198 of file textcons.c.

203{
205 ULONG FgColor, BgColor, Attribute, XPos, YPos, TextHeight, TextWidth;
206 BOOLEAN Visible;
207
208 /* Check if foreground state is being set */
209 if (Mask & 1)
210 {
211 /* Check if there's a difference from current */
212 FgColor = State->FgColor;
213 if (TextConsole->State.FgColor != FgColor)
214 {
215 /* Ignore invalid color */
216 if (FgColor > White)
217 {
219 }
220
221 /* Convert from NT/CGA format to EFI, and then set the attribute */
222 Attribute = ConsoleEfiTextGetAttribute(TextConsole->State.BgColor,
223 FgColor);
224 Status = EfiConOutSetAttribute(TextConsole->Protocol, Attribute);
225 if (!NT_SUCCESS(Status))
226 {
227 return Status;
228 }
229
230 /* Update cached state */
231 TextConsole->State.FgColor = FgColor;
232 }
233 }
234
235 /* Check if background state is being set */
236 if (Mask & 2)
237 {
238 /* Check if there's a difference from current */
239 BgColor = State->BgColor;
240 if (TextConsole->State.BgColor != BgColor)
241 {
242 /* Ignore invalid color */
243 if (BgColor > White)
244 {
246 }
247
248 /* Convert from NT/CGA format to EFI, and then set the attribute */
249 Attribute = ConsoleEfiTextGetAttribute(BgColor,
250 TextConsole->State.FgColor);
251 Status = EfiConOutSetAttribute(TextConsole->Protocol, Attribute);
252
253 if (!NT_SUCCESS(Status))
254 {
255 return Status;
256 }
257
258 /* Update cached state */
259 TextConsole->State.BgColor = BgColor;
260 }
261 }
262
263 /* Check if position state is being set */
264 if (Mask & 4)
265 {
266 /* Check if there's a difference from current */
267 XPos = State->XPos;
268 YPos = State->YPos;
269 if ((TextConsole->State.XPos != XPos) ||
270 (TextConsole->State.YPos != YPos))
271 {
272 /* Set the new cursor position */
273 BlDisplayGetTextCellResolution(&TextWidth, &TextHeight);
274 Status = EfiConOutSetCursorPosition(TextConsole->Protocol,
275 XPos/ TextWidth,
276 YPos / TextHeight);
277 if (!NT_SUCCESS(Status))
278 {
279 return Status;
280 }
281
282 /* Update cached state */
283 TextConsole->State.XPos = XPos;
284 TextConsole->State.YPos = YPos;
285 }
286 }
287
288 /* Check if cursor state is being set */
289 if (Mask & 8)
290 {
291 /* Check if there's a difference from current */
292 Visible = State->CursorVisible;
293 if (TextConsole->State.CursorVisible != Visible)
294 {
295 /* Ignore invalid state */
296 if (Visible >= 3)
297 {
299 }
300
301 /* Set the new cursor state */
302 Status = EfiConOutEnableCursor(TextConsole->Protocol, Visible);
303 if (!NT_SUCCESS(Status))
304 {
305 return Status;
306 }
307
308 /* Update cached status */
309 TextConsole->State.CursorVisible = Visible;
310 }
311 }
312
313 /* Return success */
314 return STATUS_SUCCESS;
315}
NTSTATUS EfiConOutSetAttribute(_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface, _In_ ULONG Attribute)
Definition: firmware.c:1098
NTSTATUS EfiConOutEnableCursor(_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface, _In_ BOOLEAN Visible)
Definition: firmware.c:1163
ULONG ConsoleEfiTextGetAttribute(BL_COLOR BgColor, BL_COLOR FgColor)
Definition: textcons.c:170
unsigned int Mask
Definition: fpcontrol.c:82

Referenced by ConsoleFirmwareTextClose(), ConsoleGraphicalSetTextState(), ConsoleTextLocalConstruct(), and ConsoleTextLocalSetTextState().

◆ ConsoleGraphicalClearPixels()

NTSTATUS ConsoleGraphicalClearPixels ( _In_ PBL_GRAPHICS_CONSOLE  Console,
_In_ ULONG  Color 
)

Definition at line 275 of file guicons.c.

279{
281
282 /* Check if the text console is active */
283 if (Console->TextConsole.Active)
284 {
285 /* We shouldn't be here */
287 }
288 else
289 {
290 /* Clear it in graphics mode */
292 }
293
294 /* All good */
295 return Status;
296}
NTSTATUS ConsoleFirmwareGraphicalClear(_In_ PBL_GRAPHICS_CONSOLE Console, _In_ ULONG Color)
Definition: guicons.c:90

Referenced by BfClearScreen().

◆ ConsoleGraphicalClearText()

NTSTATUS ConsoleGraphicalClearText ( _In_ PBL_GRAPHICS_CONSOLE  Console,
_In_ BOOLEAN  LineOnly 
)

Definition at line 299 of file guicons.c.

303{
304 /* Is the text console active? */
305 if (Console->TextConsole.Active)
306 {
307 /* Let firmware clear do it */
308 return ConsoleFirmwareTextClear(&Console->TextConsole, LineOnly);
309 }
310
311 /* Are we clearing a line only? */
312 if (LineOnly)
313 {
315 }
316
317 /* Nope -- the whole screen */
318 return BfClearScreen(Console);
319}
NTSTATUS BfClearScreen(_In_ PBL_GRAPHICS_CONSOLE Console)
Definition: font.c:158
NTSTATUS BfClearToEndOfLine(_In_ PBL_GRAPHICS_CONSOLE Console)
Definition: font.c:149
NTSTATUS ConsoleFirmwareTextClear(_In_ PBL_TEXT_CONSOLE Console, _In_ BOOLEAN LineOnly)
Definition: textcons.c:557

◆ ConsoleGraphicalConstruct()

NTSTATUS ConsoleGraphicalConstruct ( _In_ PBL_GRAPHICS_CONSOLE  GraphicsConsole)

Definition at line 58 of file guicons.c.

61{
63
64 /* Create a text console */
65 Status = ConsoleTextLocalConstruct(&GraphicsConsole->TextConsole, FALSE);
66 if (!NT_SUCCESS(Status))
67 {
68 EfiPrintf(L"Text failed: %lx\r\n", Status);
69 return Status;
70 }
71
72 /* But overwrite its callbacks with ours */
73 GraphicsConsole->TextConsole.Callbacks = &ConsoleGraphicalVtbl.Text;
74
75 /* Try to create a GOP console */
77 if (!NT_SUCCESS(Status))
78 {
79 /* That failed, try an older EFI 1.02 UGA console */
80 EfiPrintf(L"GOP open failed!\r\n", Status);
82 if (!NT_SUCCESS(Status))
83 {
84 /* That failed too, give up */
85 EfiPrintf(L"UGA failed!\r\n", Status);
86 ConsoleTextLocalDestruct(&GraphicsConsole->TextConsole);
88 }
89 }
90
91 /* Enable the console */
92 Status = ConsoleFirmwareGraphicalEnable(GraphicsConsole);
93 if (!NT_SUCCESS(Status))
94 {
95 /* Failed to enable it, undo everything */
96 EfiPrintf(L"Enable failed\r\n");
97 ConsoleFirmwareGraphicalClose(GraphicsConsole);
98 ConsoleTextLocalDestruct(&GraphicsConsole->TextConsole);
100 }
101
102 /* Save the graphics text color from the text mode text color */
103 GraphicsConsole->FgColor = GraphicsConsole->TextConsole.State.FgColor;
104 GraphicsConsole->BgColor = GraphicsConsole->TextConsole.State.BgColor;
105 return STATUS_SUCCESS;
106}
VOID ConsoleTextLocalDestruct(_In_ struct _BL_TEXT_CONSOLE *Console)
Definition: textcons.c:30
NTSTATUS ConsoleFirmwareGraphicalEnable(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: guicons.c:128
NTSTATUS ConsoleEfiGraphicalOpenProtocol(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole, _In_ BL_GRAPHICS_CONSOLE_TYPE Type)
Definition: guicons.c:34
VOID ConsoleFirmwareGraphicalClose(_In_ PBL_GRAPHICS_CONSOLE GraphicsConsole)
Definition: guicons.c:18
NTSTATUS ConsoleTextLocalConstruct(_In_ PBL_TEXT_CONSOLE TextConsole, _In_ BOOLEAN Activate)
Definition: textcons.c:104
BL_GRAPHICS_CONSOLE_VTABLE ConsoleGraphicalVtbl
Definition: guicons.c:15
BL_TEXT_CONSOLE_VTABLE Text
Definition: bl.h:1098

Referenced by DsppInitialize().

◆ ConsoleGraphicalDestruct()

VOID ConsoleGraphicalDestruct ( _In_ struct _BL_GRAPHICS_CONSOLE Console)

◆ ConsoleGraphicalEnable()

NTSTATUS ConsoleGraphicalEnable ( _In_ struct _BL_GRAPHICS_CONSOLE Console,
_In_ BOOLEAN  Enable 
)

◆ ConsoleGraphicalGetGraphicalResolution()

NTSTATUS ConsoleGraphicalGetGraphicalResolution ( _In_ struct _BL_GRAPHICS_CONSOLE Console,
_In_ PBL_DISPLAY_MODE  DisplayMode 
)

◆ ConsoleGraphicalGetOriginalResolution()

NTSTATUS ConsoleGraphicalGetOriginalResolution ( _In_ struct _BL_GRAPHICS_CONSOLE Console,
_In_ PBL_DISPLAY_MODE  DisplayMode 
)

◆ ConsoleGraphicalIsEnabled()

BOOLEAN ConsoleGraphicalIsEnabled ( _In_ struct _BL_GRAPHICS_CONSOLE Console)

◆ ConsoleGraphicalReinitialize()

NTSTATUS ConsoleGraphicalReinitialize ( _In_ struct _BL_GRAPHICS_CONSOLE Console)

◆ ConsoleGraphicalSetTextState()

NTSTATUS ConsoleGraphicalSetTextState ( _In_ PBL_GRAPHICS_CONSOLE  Console,
_In_ ULONG  Mask,
_In_ PBL_DISPLAY_STATE  TextState 
)

Definition at line 37 of file guicons.c.

42{
43 /* Is the text console active? */
44 if (Console->TextConsole.Active)
45 {
46 /* Let it handle that */
47 return ConsoleFirmwareTextSetState(&Console->TextConsole,
48 Mask,
49 TextState);
50 }
51
52 /* Not yet */
53 EfiPrintf(L"FFX set not implemented\r\n");
55}
NTSTATUS ConsoleFirmwareTextSetState(_In_ PBL_TEXT_CONSOLE TextConsole, _In_ UCHAR Mask, _In_ PBL_DISPLAY_STATE State)
Definition: textcons.c:198

◆ ConsoleInputBaseReinitialize()

NTSTATUS ConsoleInputBaseReinitialize ( _In_ struct _BL_INPUT_CONSOLE Console)

◆ ConsoleInputLocalDestruct()

VOID ConsoleInputLocalDestruct ( _In_ struct _BL_INPUT_CONSOLE Console)

◆ ConsoleInputLocalEraseBuffer()

NTSTATUS ConsoleInputLocalEraseBuffer ( _In_ PBL_INPUT_CONSOLE  Console,
_In_opt_ PULONG  ValueToFill 
)

Definition at line 527 of file textcons.c.

531{
532 NTSTATUS Status, EfiStatus;
533
534 /* Erase the software buffer */
536
537 /* Reset the hardware console */
538 EfiStatus = EfiConInEx ? EfiConInExReset() : EfiConInReset();
539 if (!NT_SUCCESS(EfiStatus))
540 {
541 /* Normalize the failure code */
542 EfiStatus = STATUS_UNSUCCESSFUL;
543 }
544
545 /* Check if software reset worked */
546 if (NT_SUCCESS(Status))
547 {
548 /* Then return the firmware code */
549 Status = EfiStatus;
550 }
551
552 /* All done */
553 return Status;
554}
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL * EfiConInEx
Definition: firmware.c:25
NTSTATUS EfiConInExReset(VOID)
Definition: firmware.c:825
NTSTATUS EfiConInReset(VOID)
Definition: firmware.c:794
NTSTATUS ConsoleInputBaseEraseBuffer(_In_ PBL_INPUT_CONSOLE Console, _In_opt_ PULONG FillValue)
Definition: textcons.c:493

Referenced by ConsoleInputLocalDestruct().

◆ ConsolepClearBuffer()

VOID ConsolepClearBuffer ( _In_ PUCHAR  FrameBuffer,
_In_ ULONG  Width,
_In_ PUCHAR  FillColor,
_In_ ULONG  Height,
_In_ ULONG  ScanlineWidth,
_In_ ULONG  PixelDepth 
)

Definition at line 109 of file guicons.c.

117{
118 PUCHAR Scanline, Current, FrameBufferEnd, LineEnd;
119 ULONG LineBytes, WidthBytes, BytesPerPixel;
120
121 /* Get the BPP */
122 BytesPerPixel = PixelDepth / 8;
123
124 /* Using that, calculate the size of a scan line */
125 LineBytes = ScanlineWidth * BytesPerPixel;
126
127 /* And the size of line we'll have to clear */
128 WidthBytes = Width * BytesPerPixel;
129
130 /* Allocate a scanline */
131 Scanline = BlMmAllocateHeap(WidthBytes);
132 if (Scanline)
133 {
134 /* For each remaining pixel on the scanline */
135 Current = Scanline;
136 while (Width--)
137 {
138 /* Copy in the fill color */
139 RtlCopyMemory(Current, FillColor, BytesPerPixel);
140 Current += BytesPerPixel;
141 }
142
143 /* For each scanline in the frame buffer */
144 while (Height--)
145 {
146 /* Copy our constructed scanline */
147 RtlCopyMemory(FrameBuffer, Scanline, WidthBytes);
148 FrameBuffer += LineBytes;
149 }
150 }
151 else
152 {
153 FrameBufferEnd = FrameBuffer + Height * LineBytes;
154 ScanlineWidth = BytesPerPixel * (ScanlineWidth - Width);
155 while (FrameBuffer != FrameBufferEnd)
156 {
157 if (FrameBuffer != (FrameBuffer + WidthBytes))
158 {
159 LineEnd = FrameBuffer + WidthBytes;
160 do
161 {
164 }
165 while (FrameBuffer != LineEnd);
166 }
167
168 FrameBuffer += ScanlineWidth;
169 }
170 }
171}
unsigned char * PUCHAR
Definition: typedefs.h:53
static ULONG BytesPerPixel
Definition: xboxvideo.c:32

Referenced by ConsoleFirmwareGraphicalClear().

◆ ConsolepConvertColorToPixel()

NTSTATUS ConsolepConvertColorToPixel ( _In_ BL_COLOR  Color,
_Out_ PUCHAR  Pixel 
)

Definition at line 174 of file guicons.c.

178{
180
181 /* Assume success */
183
184 /* Convert the color to a pixel value */
185 switch (Color)
186 {
187 case Black:
188 Pixel[1] = 0;
189 Pixel[2] = 0;
190 Pixel[0] = 0;
191 break;
192 case Blue:
193 Pixel[1] = 0;
194 Pixel[2] = 0;
195 Pixel[0] = 0x7F;
196 break;
197 case Green:
198 Pixel[1] = 0x7F;
199 Pixel[2] = 0;
200 Pixel[0] = 0;
201 break;
202 case Cyan:
203 Pixel[1] = 0x7F;
204 Pixel[2] = 0;
205 Pixel[0] = 0x7F;
206 break;
207 case Red:
208 Pixel[1] = 0;
209 Pixel[2] = 0x7F;
210 Pixel[0] = 0x7F;
211 break;
212 case Magenta:
213 Pixel[1] = 0;
214 Pixel[2] = 0x7F;
215 Pixel[0] = 0x7F;
216 break;
217 case Brown:
218 Pixel[1] = 0x3F;
219 Pixel[2] = 0x7F;
220 Pixel[0] = 0;
221 break;
222 case LtGray:
223 Pixel[1] = 0xBFu;
224 Pixel[2] = 0xBFu;
225 *Pixel = 0xBFu;
226 break;
227 case Gray:
228 Pixel[1] = 0x7F;
229 Pixel[2] = 0x7F;
230 Pixel[0] = 0x7F;
231 break;
232 case LtBlue:
233 Pixel[1] = 0;
234 Pixel[2] = 0;
235 Pixel[0] = 0xFF;
236 break;
237 case LtGreen:
238 Pixel[1] = 0xFF;
239 Pixel[2] = 0;
240 Pixel[0] = 0;
241 break;
242 case LtCyan:
243 Pixel[1] = 0xFF;
244 Pixel[2] = 0;
245 Pixel[0] = 0xFF;
246 break;
247 case LtRed:
248 Pixel[1] = 0;
249 Pixel[2] = 0xFF;
250 Pixel[0] = 0;
251 break;
252 case LtMagenta:
253 Pixel[1] = 0;
254 Pixel[2] = 0xFF;
255 Pixel[0] = 0xFF;
256 break;
257 case Yellow:
258 Pixel[1] = 0xFF;
259 Pixel[2] = 0xFF;
260 Pixel[0] = 0;
261 break;
262 case White:
263 Pixel[1] = 0xFF;
264 Pixel[2] = 0xFF;
265 Pixel[0] = 0xFF;
266 break;
267 default:
269 break;
270 }
271 return Status;
272}

Referenced by ConsoleFirmwareGraphicalClear().

◆ ConsolepFindResolution()

BOOLEAN ConsolepFindResolution ( _In_ PBL_DISPLAY_MODE  Mode,
_In_ PBL_DISPLAY_MODE  List,
_In_ ULONG  MaxIndex 
)

Definition at line 159 of file textcons.c.

164{
166
167 /* Loop until we hit the maximum supported list index */
168 ListEnd = &List[MaxIndex];
169 while (List != ListEnd)
170 {
171 /* Does this resolution match? */
172 if ((Mode->HRes == List->HRes) && (Mode->VRes == List->VRes))
173 {
174 /* Yep -- we got a match */
175 return TRUE;
176
177 }
178
179 /* Try another one*/
180 List++;
181 }
182
183 /* No matches were found */
184 return FALSE;
185}
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY ListEnd
Definition: exfuncs.h:1224

Referenced by ConsoleFirmwareTextOpen().

◆ ConsoleTextBaseGetTextResolution()

NTSTATUS ConsoleTextBaseGetTextResolution ( _In_ struct _BL_TEXT_CONSOLE Console,
_Out_ PULONG  TextResolution 
)

Definition at line 66 of file textcons.c.

70{
72}

◆ ConsoleTextBaseGetTextState()

NTSTATUS ConsoleTextBaseGetTextState ( _In_ struct _BL_TEXT_CONSOLE Console,
_Out_ PBL_DISPLAY_STATE  TextState 
)

Definition at line 47 of file textcons.c.

51{
53}

◆ ConsoleTextLocalClearText()

NTSTATUS ConsoleTextLocalClearText ( _In_ struct _BL_TEXT_CONSOLE Console,
_In_ BOOLEAN  LineOnly 
)

Definition at line 85 of file textcons.c.

89{
90 return ConsoleFirmwareTextClear(Console, LineOnly);
91}

◆ ConsoleTextLocalConstruct()

NTSTATUS ConsoleTextLocalConstruct ( _In_ PBL_TEXT_CONSOLE  TextConsole,
_In_ BOOLEAN  Activate 
)

Definition at line 104 of file textcons.c.

108{
110 BL_DISPLAY_STATE TextState;
111
112 /* Set our callbacks */
113 TextConsole->Callbacks = &ConsoleTextLocalVtbl;
114
115 /* Are we activating this console? */
116 if (Activate)
117 {
118 /* Call firmware to activate it */
119 Status = ConsoleFirmwareTextOpen(TextConsole);
120 if (!NT_SUCCESS(Status))
121 {
122 EfiPrintf(L"Failed to activate console: %lx\r\n", Status);
123 return Status;
124 }
125 }
126
127 /* Set default text state */
128 TextState.BgColor = 0;
129 TextState.XPos = 0;
130 TextState.YPos = 0;
131 TextState.CursorVisible = FALSE;
132 TextState.FgColor = White;
133
134 /* Are we activating? */
135 if (Activate)
136 {
137 /* Call firmware to set it */
138 Status = ConsoleFirmwareTextSetState(TextConsole, 0xF, &TextState);
139 if (!NT_SUCCESS(Status))
140 {
141 /* We failed, back down */
142 EfiPrintf(L"Failed to set console state: %lx\r\n", Status);
143 ConsoleFirmwareTextClose(TextConsole);
144 return Status;
145 }
146 }
147 else
148 {
149 /* Just save the state for now, someone else can activate later */
150 TextConsole->State = TextState;
151 }
152
153 /* Remember if we activated it */
154 TextConsole->Active = Activate;
155 return STATUS_SUCCESS;
156}
NTSTATUS ConsoleFirmwareTextOpen(_In_ PBL_TEXT_CONSOLE TextConsole)
Definition: textcons.c:421
VOID ConsoleFirmwareTextClose(_In_ PBL_TEXT_CONSOLE TextConsole)
Definition: textcons.c:398
ULONG YPos
Definition: bl.h:1073
ULONG FgColor
Definition: bl.h:1071
ULONG BgColor
Definition: bl.h:1070
ULONG CursorVisible
Definition: bl.h:1074
ULONG XPos
Definition: bl.h:1072
BL_TEXT_CONSOLE_VTABLE ConsoleTextLocalVtbl
Definition: textcons.c:15

Referenced by ConsoleGraphicalConstruct(), and DsppInitialize().

◆ ConsoleTextLocalDestruct()

VOID ConsoleTextLocalDestruct ( _In_ struct _BL_TEXT_CONSOLE Console)

Definition at line 30 of file textcons.c.

33{
34
35}

Referenced by ConsoleGraphicalConstruct(), and ConsoleGraphicalDestruct().

◆ ConsoleTextLocalReinitialize()

NTSTATUS ConsoleTextLocalReinitialize ( _In_ struct _BL_TEXT_CONSOLE Console)

Definition at line 38 of file textcons.c.

41{
42 EfiPrintf(L"Not active yet!\r\n");
44}

Referenced by ConsoleGraphicalReinitialize().

◆ ConsoleTextLocalSetTextResolution()

NTSTATUS ConsoleTextLocalSetTextResolution ( _In_ struct _BL_TEXT_CONSOLE Console,
_In_ ULONG  NewTextResolution,
_Out_ PULONG  OldTextResolution 
)

Definition at line 75 of file textcons.c.

80{
82}

◆ ConsoleTextLocalSetTextState()

NTSTATUS ConsoleTextLocalSetTextState ( _In_ struct _BL_TEXT_CONSOLE Console,
_In_ ULONG  Flags,
_In_ PBL_DISPLAY_STATE  TextState 
)

Definition at line 56 of file textcons.c.

61{
62 return ConsoleFirmwareTextSetState(Console, Mask, TextState);
63}

◆ ConsoleTextLocalWriteText()

NTSTATUS ConsoleTextLocalWriteText ( _In_ struct _BL_TEXT_CONSOLE Console,
_In_ PCHAR  Text,
_In_ ULONG  Attribute 
)

Definition at line 94 of file textcons.c.

99{
101}

◆ DEFINE_GUID()

DEFINE_GUID ( BadMemoryGuid  ,
0x54B8275B  ,
0xD431  ,
0x473F  ,
0xAC  ,
0xFB  ,
0xE5  ,
0x36  ,
0xA0  ,
0x84  ,
0x94  ,
0xA3   
)

◆ EfiAllocatePages()

NTSTATUS EfiAllocatePages ( _In_ ULONG  Type,
_In_ ULONG  Pages,
_Inout_ EFI_PHYSICAL_ADDRESS Memory 
)

Definition at line 1568 of file firmware.c.

1573{
1574 BL_ARCH_MODE OldMode;
1575 EFI_STATUS EfiStatus;
1576 PHYSICAL_ADDRESS MemoryPhysical;
1577
1578 /* Are we in protected mode? */
1579 OldMode = CurrentExecutionContext->Mode;
1580 if (OldMode != BlRealMode)
1581 {
1582 /* Translate output address */
1583 BlMmTranslateVirtualAddress(Memory, &MemoryPhysical);
1585
1586 /* Switch to real mode */
1588 }
1589
1590 /* Make the EFI call */
1591 EfiStatus = EfiBS->AllocatePages(Type, EfiLoaderData, Pages, Memory);
1592
1593 /* Switch back to protected mode if we came from there */
1594 if (OldMode != BlRealMode)
1595 {
1596 BlpArchSwitchContext(OldMode);
1597 }
1598
1599 /* Convert the error to an NTSTATUS */
1600 return EfiGetNtStatusCode(EfiStatus);
1601}
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:52
@ EfiLoaderData
FORCEINLINE PVOID PhysicalAddressToPtr(_In_ PHYSICAL_ADDRESS PhysicalAddress)
Definition: bl.h:1389
BOOLEAN BlMmTranslateVirtualAddress(_In_ PVOID VirtualAddress, _Out_ PPHYSICAL_ADDRESS PhysicalAddress)
Definition: mm.c:525
NTSTATUS EfiGetNtStatusCode(_In_ EFI_STATUS EfiStatus)
Definition: firmware.c:2539
EFI_ALLOCATE_PAGES AllocatePages
Definition: UefiSpec.h:1810
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _In_ _Strict_type_match_ POOL_TYPE _In_opt_ ULONG _In_ _Out_ WDFMEMORY * Memory
Definition: wdfmemory.h:169

Referenced by MmFwGetMemoryMap(), and MmPapAllocateRegionFromMdl().

◆ EfiCloseProtocol()

NTSTATUS EfiCloseProtocol ( _In_ EFI_HANDLE  Handle,
_In_ EFI_GUID Protocol 
)

Definition at line 581 of file firmware.c.

585{
586 EFI_STATUS EfiStatus;
588 BL_ARCH_MODE OldMode;
589
590 /* Are we using virtual memory/ */
592 {
593 /* We need complex tracking to make this work */
595 }
596 else
597 {
598 /* Are we on legacy 1.02? */
600 {
601 /* Nothing to close */
602 EfiStatus = EFI_SUCCESS;
603 }
604 else
605 {
606 /* Are we in protected mode? */
607 OldMode = CurrentExecutionContext->Mode;
608 if (OldMode != BlRealMode)
609 {
610 /* Switch to real mode */
612 }
613
614 /* Use the UEFI version */
616
617 /* Switch back to protected mode if we came from there */
618 if (OldMode != BlRealMode)
619 {
620 BlpArchSwitchContext(OldMode);
621 }
622
623 /* Normalize not found as success */
624 if (EfiStatus == EFI_NOT_FOUND)
625 {
626 EfiStatus = EFI_SUCCESS;
627 }
628 }
629
630 /* Convert the error to an NTSTATUS */
631 Status = EfiGetNtStatusCode(EfiStatus);
632 }
633
634 /* All done */
635 return Status;
636}
#define EFI_NOT_FOUND
Definition: UefiBaseType.h:134
#define EFI_SUCCESS
Definition: UefiBaseType.h:120
#define EFI_1_02_SYSTEM_TABLE_REVISION
Definition: UefiSpec.h:1734
BL_TRANSLATION_TYPE MmTranslationType
Definition: mm.c:17
NTSTATUS EfiVmCloseProtocol(_In_ EFI_HANDLE Handle, _In_ EFI_GUID *Protocol)
Definition: firmware.c:522
EFI_CLOSE_PROTOCOL CloseProtocol
Definition: UefiSpec.h:1865
UINT32 FirmwareRevision
Definition: UefiSpec.h:1922

Referenced by BlockIoEfiGetChildHandle(), BlockIoEfiGetDeviceInformation(), BlockIoFirmwareRead(), ConsoleEfiGopClose(), ConsoleEfiGopOpen(), ConsoleEfiGraphicalOpenProtocol(), and DiskClose().

◆ EfiConInExReset()

NTSTATUS EfiConInExReset ( VOID  )

Definition at line 825 of file firmware.c.

828{
829 BL_ARCH_MODE OldMode;
830 EFI_STATUS EfiStatus;
831
832 /* Are we in protected mode? */
833 OldMode = CurrentExecutionContext->Mode;
834 if (OldMode != BlRealMode)
835 {
836 /* FIXME: Not yet implemented */
837 EfiPrintf(L"conreset vm path\r\n");
838 EfiStall(10000000);
840 }
841
842 /* Make the EFI call */
843 EfiStatus = EfiConInEx->Reset(EfiConInEx, FALSE);
844
845 /* Switch back to protected mode if we came from there */
846 if (OldMode != BlRealMode)
847 {
848 BlpArchSwitchContext(OldMode);
849 }
850
851 /* Convert the error to an NTSTATUS */
852 return EfiGetNtStatusCode(EfiStatus);
853}
NTSTATUS EfiStall(_In_ ULONG StallTime)
Definition: firmware.c:1003

Referenced by ConsoleInputLocalEraseBuffer().

◆ EfiConInReset()

NTSTATUS EfiConInReset ( VOID  )

Definition at line 794 of file firmware.c.

797{
798 BL_ARCH_MODE OldMode;
799 EFI_STATUS EfiStatus;
800
801 /* Are we in protected mode? */
802 OldMode = CurrentExecutionContext->Mode;
803 if (OldMode != BlRealMode)
804 {
805 /* FIXME: Not yet implemented */
806 EfiPrintf(L"coninreset vm path\r\n");
807 EfiStall(10000000);
809 }
810
811 /* Make the EFI call */
812 EfiStatus = EfiConIn->Reset(EfiConIn, FALSE);
813
814 /* Switch back to protected mode if we came from there */
815 if (OldMode != BlRealMode)
816 {
817 BlpArchSwitchContext(OldMode);
818 }
819
820 /* Convert the error to an NTSTATUS */
821 return EfiGetNtStatusCode(EfiStatus);
822}

Referenced by ConsoleInputLocalEraseBuffer().

◆ EfiConOutEnableCursor()

NTSTATUS EfiConOutEnableCursor ( _In_ SIMPLE_TEXT_OUTPUT_INTERFACE TextInterface,
_In_ BOOLEAN  Visible 
)

Definition at line 1163 of file firmware.c.

1167{
1168 BL_ARCH_MODE OldMode;
1169 EFI_STATUS EfiStatus;
1170
1171 /* Are we in protected mode? */
1172 OldMode = CurrentExecutionContext->Mode;
1173 if (OldMode != BlRealMode)
1174 {
1175 /* FIXME: Not yet implemented */
1176 EfiPrintf(L"enablecurso vm path\r\n");
1177 EfiStall(10000000);
1179 }
1180
1181 /* Make the EFI call */
1182 EfiStatus = TextInterface->EnableCursor(TextInterface, Visible);
1183
1184 /* Switch back to protected mode if we came from there */
1185 if (OldMode != BlRealMode)
1186 {
1187 BlpArchSwitchContext(OldMode);
1188 }
1189
1190 /* Convert the error to an NTSTATUS */
1191 return EfiGetNtStatusCode(EfiStatus);
1192}

Referenced by ConsoleFirmwareTextSetState().

◆ EfiConOutOutputString()

NTSTATUS EfiConOutOutputString ( _In_ SIMPLE_TEXT_OUTPUT_INTERFACE TextInterface,
_In_ PWCHAR  String 
)

Definition at line 1195 of file firmware.c.

1199{
1200 BL_ARCH_MODE OldMode;
1201 EFI_STATUS EfiStatus;
1202
1203 /* Are we in protected mode? */
1204 OldMode = CurrentExecutionContext->Mode;
1205 if (OldMode != BlRealMode)
1206 {
1207 /* FIXME: Not yet implemented */
1208 EfiPrintf(L"output string vm path\r\n");
1209 EfiStall(10000000);
1211 }
1212
1213 /* Make the EFI call */
1214 EfiStatus = TextInterface->OutputString(TextInterface, String);
1215
1216 /* Switch back to protected mode if we came from there */
1217 if (OldMode != BlRealMode)
1218 {
1219 BlpArchSwitchContext(OldMode);
1220 }
1221
1222 /* Convert the error to an NTSTATUS */
1223 return EfiGetNtStatusCode(EfiStatus);
1224}

Referenced by ConsoleFirmwareTextClear().

◆ EfiConOutQueryMode()

NTSTATUS EfiConOutQueryMode ( _In_ SIMPLE_TEXT_OUTPUT_INTERFACE TextInterface,
_In_ ULONG  Mode,
_In_ UINTN Columns,
_In_ UINTN Rows 
)

Definition at line 1032 of file firmware.c.

1038{
1039 BL_ARCH_MODE OldMode;
1040 EFI_STATUS EfiStatus;
1041
1042 /* Are we in protected mode? */
1043 OldMode = CurrentExecutionContext->Mode;
1044 if (OldMode != BlRealMode)
1045 {
1046 /* FIXME: Not yet implemented */
1047 EfiPrintf(L"conqmode vm path\r\n");
1048 EfiStall(10000000);
1050 }
1051
1052 /* Make the EFI call */
1053 EfiStatus = TextInterface->QueryMode(TextInterface, Mode, Columns, Rows);
1054
1055 /* Switch back to protected mode if we came from there */
1056 if (OldMode != BlRealMode)
1057 {
1058 BlpArchSwitchContext(OldMode);
1059 }
1060
1061 /* Convert the error to an NTSTATUS */
1062 return EfiGetNtStatusCode(EfiStatus);
1063}
static const COLUMN_LIST Columns[]
Definition: listview.c:19
_In_ ULONG Rows
Definition: haltypes.h:7

Referenced by ConsoleEfiTextFindModeFromAllowed(), and ConsoleFirmwareTextOpen().

◆ EfiConOutReadCurrentMode()

VOID EfiConOutReadCurrentMode ( _In_ SIMPLE_TEXT_OUTPUT_INTERFACE TextInterface,
_Out_ EFI_SIMPLE_TEXT_OUTPUT_MODE Mode 
)

Definition at line 1227 of file firmware.c.

1231{
1232 BL_ARCH_MODE OldMode;
1233
1234 /* Are we in protected mode? */
1235 OldMode = CurrentExecutionContext->Mode;
1236 if (OldMode != BlRealMode)
1237 {
1238 /* FIXME: Not yet implemented */
1239 EfiPrintf(L"readmode vm path\r\n");
1240 EfiStall(10000000);
1241 return;
1242 }
1243
1244 /* Make the EFI call */
1245 RtlCopyMemory(Mode, TextInterface->Mode, sizeof(*Mode));
1246
1247 /* Switch back to protected mode if we came from there */
1248 if (OldMode != BlRealMode)
1249 {
1250 BlpArchSwitchContext(OldMode);
1251 }
1252}

Referenced by ConsoleEfiTextFindModeFromAllowed(), and ConsoleFirmwareTextOpen().

◆ EfiConOutSetAttribute()

NTSTATUS EfiConOutSetAttribute ( _In_ SIMPLE_TEXT_OUTPUT_INTERFACE TextInterface,
_In_ ULONG  Attribute 
)

Definition at line 1098 of file firmware.c.

1102{
1103 BL_ARCH_MODE OldMode;
1104 EFI_STATUS EfiStatus;
1105
1106 /* Are we in protected mode? */
1107 OldMode = CurrentExecutionContext->Mode;
1108 if (OldMode != BlRealMode)
1109 {
1110 /* FIXME: Not yet implemented */
1111 EfiPrintf(L"sattr vm path\r\n");
1112 EfiStall(10000000);
1114 }
1115
1116 /* Make the EFI call */
1117 EfiStatus = TextInterface->SetAttribute(TextInterface, Attribute);
1118
1119 /* Switch back to protected mode if we came from there */
1120 if (OldMode != BlRealMode)
1121 {
1122 BlpArchSwitchContext(OldMode);
1123 }
1124
1125 /* Convert the error to an NTSTATUS */
1126 return EfiGetNtStatusCode(EfiStatus);
1127}

Referenced by ConsoleFirmwareTextSetState().

◆ EfiConOutSetCursorPosition()

NTSTATUS EfiConOutSetCursorPosition ( _In_ SIMPLE_TEXT_OUTPUT_INTERFACE TextInterface,
_In_ ULONG  Column,
_In_ ULONG  Row 
)

Definition at line 1130 of file firmware.c.

1135{
1136 BL_ARCH_MODE OldMode;
1137 EFI_STATUS EfiStatus;
1138
1139 /* Are we in protected mode? */
1140 OldMode = CurrentExecutionContext->Mode;
1141 if (OldMode != BlRealMode)
1142 {
1143 /* FIXME: Not yet implemented */
1144 EfiPrintf(L"setcursor vm path\r\n");
1145 EfiStall(10000000);
1147 }
1148
1149 /* Make the EFI call */
1150 EfiStatus = TextInterface->SetCursorPosition(TextInterface, Column, Row);
1151
1152 /* Switch back to protected mode if we came from there */
1153 if (OldMode != BlRealMode)
1154 {
1155 BlpArchSwitchContext(OldMode);
1156 }
1157
1158 /* Convert the error to an NTSTATUS */
1159 return EfiGetNtStatusCode(EfiStatus);
1160}

Referenced by ConsoleFirmwareTextClear(), and ConsoleFirmwareTextSetState().

◆ EfiConOutSetMode()

NTSTATUS EfiConOutSetMode ( _In_ SIMPLE_TEXT_OUTPUT_INTERFACE TextInterface,
_In_ ULONG  Mode 
)

Definition at line 1066 of file firmware.c.

1070{
1071 BL_ARCH_MODE OldMode;
1072 EFI_STATUS EfiStatus;
1073
1074 /* Are we in protected mode? */
1075 OldMode = CurrentExecutionContext->Mode;
1076 if (OldMode != BlRealMode)
1077 {
1078 /* FIXME: Not yet implemented */
1079 EfiPrintf(L"setmode vm path\r\n");
1080 EfiStall(10000000);
1082 }
1083
1084 /* Make the EFI call */
1085 EfiStatus = TextInterface->SetMode(TextInterface, Mode);
1086
1087 /* Switch back to protected mode if we came from there */
1088 if (OldMode != BlRealMode)
1089 {
1090 BlpArchSwitchContext(OldMode);
1091 }
1092
1093 /* Convert the error to an NTSTATUS */
1094 return EfiGetNtStatusCode(EfiStatus);
1095}

Referenced by ConsoleFirmwareTextClose(), and ConsoleFirmwareTextOpen().

◆ EfiFreePages()

NTSTATUS EfiFreePages ( _In_ ULONG  Pages,
_In_ EFI_PHYSICAL_ADDRESS  PhysicalAddress 
)

Definition at line 973 of file firmware.c.

977{
978 BL_ARCH_MODE OldMode;
979 EFI_STATUS EfiStatus;
980
981 /* Are we in protected mode? */
982 OldMode = CurrentExecutionContext->Mode;
983 if (OldMode != BlRealMode)
984 {
985 /* Switch to real mode */
987 }
988
989 /* Make the EFI call */
990 EfiStatus = EfiBS->FreePages(PhysicalAddress, Pages);
991
992 /* Switch back to protected mode if we came from there */
993 if (OldMode != BlRealMode)
994 {
995 BlpArchSwitchContext(OldMode);
996 }
997
998 /* Convert the error to an NTSTATUS */
999 return EfiGetNtStatusCode(EfiStatus);
1000}
EFI_FREE_PAGES FreePages
Definition: UefiSpec.h:1811

Referenced by MmFwFreePages(), and MmFwGetMemoryMap().

◆ EfiGetEfiStatusCode()

EFI_STATUS EfiGetEfiStatusCode ( _In_ NTSTATUS  Status)

Definition at line 2474 of file firmware.c.

2477{
2478 switch (Status)
2479 {
2481 return EFI_UNSUPPORTED;
2482 case STATUS_DISK_FULL:
2483 return EFI_VOLUME_FULL;
2485 return EFI_OUT_OF_RESOURCES;
2487 return EFI_WRITE_PROTECTED;
2489 return EFI_NOT_STARTED;
2491 return EFI_ALREADY_STARTED;
2493 return EFI_MEDIA_CHANGED;
2495 return EFI_INVALID_PARAMETER;
2497 return EFI_ACCESS_DENIED;
2499 return EFI_BUFFER_TOO_SMALL;
2501 return EFI_VOLUME_CORRUPTED;
2503 return EFI_ABORTED;
2504 case STATUS_NO_MEDIA:
2505 return EFI_NO_MEDIA;
2507 return EFI_DEVICE_ERROR;
2509 return EFI_BAD_BUFFER_SIZE;
2510 case STATUS_NOT_FOUND:
2511 return EFI_NOT_FOUND;
2513 return EFI_LOAD_ERROR;
2514 case STATUS_NO_MATCH:
2515 return EFI_NO_MAPPING;
2516 case STATUS_SUCCESS:
2517 return EFI_SUCCESS;
2518 case STATUS_TIMEOUT:
2519 return EFI_TIMEOUT;
2520 default:
2521 return EFI_NO_MAPPING;
2522 }
2523}
#define EFI_NO_MAPPING
Definition: UefiBaseType.h:137
#define EFI_MEDIA_CHANGED
Definition: UefiBaseType.h:133
#define EFI_VOLUME_FULL
Definition: UefiBaseType.h:131
#define EFI_DEVICE_ERROR
Definition: UefiBaseType.h:127
#define EFI_UNSUPPORTED
Definition: UefiBaseType.h:123
#define EFI_ALREADY_STARTED
Definition: UefiBaseType.h:140
#define EFI_INVALID_PARAMETER
Definition: UefiBaseType.h:122
#define EFI_WRITE_PROTECTED
Definition: UefiBaseType.h:128
#define EFI_NO_MEDIA
Definition: UefiBaseType.h:132
#define EFI_NOT_STARTED
Definition: UefiBaseType.h:139
#define EFI_VOLUME_CORRUPTED
Definition: UefiBaseType.h:130
#define EFI_ACCESS_DENIED
Definition: UefiBaseType.h:135
#define EFI_BAD_BUFFER_SIZE
Definition: UefiBaseType.h:124
#define EFI_TIMEOUT
Definition: UefiBaseType.h:138
#define EFI_BUFFER_TOO_SMALL
Definition: UefiBaseType.h:125
#define EFI_OUT_OF_RESOURCES
Definition: UefiBaseType.h:129
#define EFI_LOAD_ERROR
Definition: UefiBaseType.h:121
#define EFI_ABORTED
Definition: UefiBaseType.h:141
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
#define STATUS_INVALID_BUFFER_SIZE
Definition: ntstatus.h:650
#define STATUS_MEDIA_CHANGED
Definition: ntstatus.h:207
#define STATUS_DEVICE_ALREADY_ATTACHED
Definition: ntstatus.h:292
#define STATUS_NO_MATCH
Definition: ntstatus.h:751
#define STATUS_DRIVER_UNABLE_TO_LOAD
Definition: ntstatus.h:745
#define STATUS_NO_MEDIA
Definition: ntstatus.h:610
#define STATUS_IO_DEVICE_ERROR
Definition: udferr_usr.h:179
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define STATUS_REQUEST_ABORTED
Definition: udferr_usr.h:183
#define STATUS_DISK_CORRUPT_ERROR
Definition: udferr_usr.h:147
#define STATUS_DISK_FULL
Definition: udferr_usr.h:155

Referenced by EfiEntry().

◆ EfiGetLeafNode()

EFI_DEVICE_PATH * EfiGetLeafNode ( _In_ EFI_DEVICE_PATH DevicePath)

Definition at line 102 of file firmware.c.

105{
106 EFI_DEVICE_PATH *NextDevicePath;
107
108 /* Make sure we're not already at the end */
109 if (!IsDevicePathEndType(DevicePath))
110 {
111 /* Grab the next node element, and keep going until the end */
112 for (NextDevicePath = NextDevicePathNode(DevicePath);
113 !IsDevicePathEndType(NextDevicePath);
114 NextDevicePath = NextDevicePathNode(NextDevicePath))
115 {
116 /* Save the current node we're at */
117 DevicePath = NextDevicePath;
118 }
119 }
120
121 /* This now contains the deepest (leaf) node */
122 return DevicePath;
123}
FORCEINLINE EFI_DEVICE_PATH_PROTOCOL * NextDevicePathNode(_In_ PVOID Node)
Definition: DevicePath.h:1189
FORCEINLINE BOOLEAN IsDevicePathEndType(_In_ PVOID Node)
Definition: DevicePath.h:1199

Referenced by BlockIoEfiGetDeviceInformation().

◆ EfiGetNtStatusCode()

NTSTATUS EfiGetNtStatusCode ( _In_ EFI_STATUS  EfiStatus)

Definition at line 2539 of file firmware.c.

2542{
2543 switch (EfiStatus)
2544 {
2545 case EFI_NOT_READY:
2546 case EFI_NOT_FOUND:
2547 return STATUS_NOT_FOUND;
2548 case EFI_NO_MEDIA:
2549 return STATUS_NO_MEDIA;
2550 case EFI_MEDIA_CHANGED:
2551 return STATUS_MEDIA_CHANGED;
2552 case EFI_ACCESS_DENIED:
2554 return STATUS_ACCESS_DENIED;
2555 case EFI_TIMEOUT:
2556 case EFI_NO_RESPONSE:
2557 return STATUS_TIMEOUT;
2558 case EFI_NO_MAPPING:
2559 return STATUS_NO_MATCH;
2560 case EFI_NOT_STARTED:
2564 case EFI_ABORTED:
2566 case EFI_VOLUME_FULL:
2567 return STATUS_DISK_FULL;
2568 case EFI_DEVICE_ERROR:
2572 /* @FIXME: ReactOS Headers don't yet have this */
2573 //case EFI_OUT_OF_RESOURCES:
2574 //return STATUS_INSUFFICIENT_NVRAM_RESOURCES;
2579 case EFI_SUCCESS:
2580 return STATUS_SUCCESS;
2581 case EFI_LOAD_ERROR:
2585 case EFI_UNSUPPORTED:
2586 return STATUS_NOT_SUPPORTED;
2589 default:
2590 return STATUS_UNSUCCESSFUL;
2591 }
2592}
#define EFI_NOT_READY
Definition: UefiBaseType.h:126
#define EFI_SECURITY_VIOLATION
Definition: UefiBaseType.h:146
#define EFI_NO_RESPONSE
Definition: UefiBaseType.h:136

Referenced by BlockIoFirmwareRead(), ConsoleFirmwareTextClear(), EfiAllocatePages(), EfiCloseProtocol(), EfiConInExReset(), EfiConInExSetState(), EfiConInReset(), EfiConnectController(), EfiConOutEnableCursor(), EfiConOutOutputString(), EfiConOutQueryMode(), EfiConOutSetAttribute(), EfiConOutSetCursorPosition(), EfiConOutSetMode(), EfiFreePages(), EfiGetMemoryMap(), EfiGetVariable(), EfiGopSetMode(), EfiLocateHandleBuffer(), EfiOpenProtocol(), EfiSetWatchdogTimer(), EfiStall(), EfiVmOpenProtocol(), EfiVmpCloseProtocol(), and MmFwGetMemoryMap().

◆ EfiGopGetCurrentMode()

NTSTATUS EfiGopGetCurrentMode ( _In_ EFI_GRAPHICS_OUTPUT_PROTOCOL GopInterface,
_Out_ UINTN Mode,
_Out_ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION Information 
)

Definition at line 1296 of file firmware.c.

1301{
1302 BL_ARCH_MODE OldMode;
1303 PHYSICAL_ADDRESS GopInterfacePhys, ModePhys, InformationPhys;
1304
1305 /* Are we in protected mode? */
1306 OldMode = CurrentExecutionContext->Mode;
1307 if (OldMode != BlRealMode)
1308 {
1309 /* Translate pointer to physical */
1310 if (!BlMmTranslateVirtualAddress(GopInterface, &GopInterfacePhys))
1311 {
1312 return STATUS_UNSUCCESSFUL;
1313 }
1314 GopInterface = PhysicalAddressToPtr(GopInterfacePhys);
1315
1316 /* Translate pointer to physical */
1317 if (!BlMmTranslateVirtualAddress(Mode, &ModePhys))
1318 {
1319 return STATUS_UNSUCCESSFUL;
1320 }
1321 Mode = PhysicalAddressToPtr(ModePhys);
1322
1323 /* Translate pointer to physical */
1324 if (!BlMmTranslateVirtualAddress(Information, &InformationPhys))
1325 {
1326 return STATUS_UNSUCCESSFUL;
1327 }
1328 Information = PhysicalAddressToPtr(InformationPhys);
1329
1330 /* Switch to real mode */
1332 }
1333
1334 /* Make the EFI call */
1335 *Mode = GopInterface->Mode->Mode;
1336 RtlCopyMemory(Information, GopInterface->Mode->Info, sizeof(*Information));
1337
1338 /* Switch back to protected mode if we came from there */
1339 if (OldMode != BlRealMode)
1340 {
1341 BlpArchSwitchContext(OldMode);
1342 }
1343
1344 /* Return back */
1345 return STATUS_SUCCESS;
1346}
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049

Referenced by ConsoleEfiGopEnable(), and ConsoleEfiGopOpen().

◆ EfiGopGetFrameBuffer()

VOID EfiGopGetFrameBuffer ( _In_ EFI_GRAPHICS_OUTPUT_PROTOCOL GopInterface,
_Out_ PHYSICAL_ADDRESS FrameBuffer,
_Out_ UINTN FrameBufferSize 
)

Definition at line 1255 of file firmware.c.

1260{
1261 BL_ARCH_MODE OldMode;
1262 PHYSICAL_ADDRESS GopInterfacePhys, FrameBufferPhys, FrameBufferSizePhys;
1263
1264 /* Are we in protected mode? */
1265 OldMode = CurrentExecutionContext->Mode;
1266 if (OldMode != BlRealMode)
1267 {
1268 /* Translate pointer to physical */
1269 BlMmTranslateVirtualAddress(GopInterface, &GopInterfacePhys);
1270 GopInterface = PhysicalAddressToPtr(GopInterfacePhys);
1271
1272 /* Translate pointer to physical */
1273 BlMmTranslateVirtualAddress(FrameBuffer, &FrameBufferPhys);
1274 FrameBuffer = PhysicalAddressToPtr(FrameBufferPhys);
1275
1276 /* Translate pointer to physical */
1277 BlMmTranslateVirtualAddress(FrameBufferSize, &FrameBufferSizePhys);
1278 FrameBufferSize = PhysicalAddressToPtr(FrameBufferSizePhys);
1279
1280 /* Switch to real mode */
1282 }
1283
1284 /* Make the EFI call */
1285 FrameBuffer->QuadPart = GopInterface->Mode->FrameBufferBase;
1286 *FrameBufferSize = GopInterface->Mode->FrameBufferSize;
1287
1288 /* Switch back to protected mode if we came from there */
1289 if (OldMode != BlRealMode)
1290 {
1291 BlpArchSwitchContext(OldMode);
1292 }
1293}

Referenced by ConsoleEfiGopEnable().

◆ EfiGopSetMode()

NTSTATUS EfiGopSetMode ( _In_ EFI_GRAPHICS_OUTPUT_PROTOCOL GopInterface,
_In_ ULONG  Mode 
)

Definition at line 1349 of file firmware.c.

1353{
1354 BL_ARCH_MODE OldMode;
1355 EFI_STATUS EfiStatus;
1358
1359 /* Are we in protected mode? */
1360 OldMode = CurrentExecutionContext->Mode;
1361 if (OldMode != BlRealMode)
1362 {
1363 /* FIXME: Not yet implemented */
1364 EfiPrintf(L"gopsmode vm path\r\n");
1365 EfiStall(10000000);
1367 }
1368
1369 /* Make the EFI call */
1370 if (Mode == GopInterface->Mode->Mode)
1371 {
1372 EfiStatus = EFI_SUCCESS;
1374 }
1375 {
1376 EfiStatus = GopInterface->SetMode(GopInterface, Mode);
1377 ModeChanged = TRUE;
1378 }
1379
1380 /* Switch back to protected mode if we came from there */
1381 if (OldMode != BlRealMode)
1382 {
1383 BlpArchSwitchContext(OldMode);
1384 }
1385
1386 /* Print out to the debugger if the mode was changed */
1387 Status = EfiGetNtStatusCode(EfiStatus);
1388 if ((ModeChanged) && (NT_SUCCESS(Status)))
1389 {
1390 /* FIXME @TODO: Should be BlStatusPrint */
1391 EfiPrintf(L"Console video mode set to 0x%x\r\n", Mode);
1392 }
1393
1394 /* Convert the error to an NTSTATUS */
1395 return Status;
1396}
static BOOLEAN ModeChanged
Definition: svga.c:282

Referenced by ConsoleEfiGopClose(), and ConsoleEfiGopEnable().

◆ EfiIsDevicePathParent()

EFI_DEVICE_PATH * EfiIsDevicePathParent ( _In_ EFI_DEVICE_PATH DevicePath1,
_In_ EFI_DEVICE_PATH DevicePath2 
)

Definition at line 47 of file firmware.c.

51{
52 EFI_DEVICE_PATH* CurrentPath1;
53 EFI_DEVICE_PATH* CurrentPath2;
55
56 /* Start with the current nodes */
57 CurrentPath1 = DevicePath1;
58 CurrentPath2 = DevicePath2;
59
60 /* Loop each element of the device path */
61 while (!(IsDevicePathEndType(CurrentPath1)) &&
62 !(IsDevicePathEndType(CurrentPath2)))
63 {
64 /* Check if the element has a different length */
65 Length1 = DevicePathNodeLength(CurrentPath1);
66 Length2 = DevicePathNodeLength(CurrentPath2);
67 if (Length1 != Length2)
68 {
69 /* Then they're not related */
70 return NULL;
71 }
72
73 /* Check if the rest of the element data matches */
74 if (RtlCompareMemory(CurrentPath1, CurrentPath2, Length1) != Length1)
75 {
76 /* Nope, not related */
77 return NULL;
78 }
79
80 /* Move to the next element */
81 CurrentPath1 = NextDevicePathNode(CurrentPath1);
82 CurrentPath2 = NextDevicePathNode(CurrentPath2);
83 }
84
85 /* If the last element in path 1 is empty, then path 2 is the child (deeper) */
86 if (!IsDevicePathEndType(CurrentPath1))
87 {
88 return DevicePath2;
89 }
90
91 /* If the last element in path 2 is empty, then path 1 is the child (deeper) */
92 if (!IsDevicePathEndType(CurrentPath2))
93 {
94 return DevicePath1;
95 }
96
97 /* They're both the end, so they're identical, so there's no parent */
98 return NULL;
99}
FORCEINLINE UINTN DevicePathNodeLength(_In_ PVOID Node)
Definition: DevicePath.h:1179
INT Length2
Definition: FsRtlDissect.c:16
INT Length1
Definition: FsRtlDissect.c:15

Referenced by BlockIoEfiGetChildHandle().

◆ EfiLocateHandleBuffer()

NTSTATUS EfiLocateHandleBuffer ( _In_ EFI_LOCATE_SEARCH_TYPE  SearchType,
_In_ EFI_GUID Protocol,
_Inout_ PULONG  HandleCount,
_Inout_ EFI_HANDLE **  Buffer 
)

Definition at line 1399 of file firmware.c.

1405{
1406 BL_ARCH_MODE OldMode;
1407 EFI_STATUS EfiStatus;
1410 BOOLEAN TranslateResult;
1411 PHYSICAL_ADDRESS BufferPhys;
1412
1413 /* Bail out if we're missing parameters */
1414 if (!(Buffer) || !(HandleCount))
1415 {
1417 }
1418
1419 /* Check if a buffer was passed in*/
1421 if (InputBuffer)
1422 {
1423 /* Then we should already have a buffer size*/
1424 BufferSize = sizeof(EFI_HANDLE) * *HandleCount;
1425 }
1426 else
1427 {
1428 /* Then no buffer size exists */
1429 BufferSize = 0;
1430 }
1431
1432 /* Are we in protected mode? */
1433 OldMode = CurrentExecutionContext->Mode;
1434 if (OldMode != BlRealMode)
1435 {
1436 /* Translate the input buffer from virtual to physical */
1437 TranslateResult = BlMmTranslateVirtualAddress(InputBuffer, &BufferPhys);
1438 InputBuffer = TranslateResult ? PhysicalAddressToPtr(BufferPhys) : NULL;
1439
1440 /* Switch to real mode */
1442 }
1443
1444 /* Try the first time */
1445 EfiStatus = EfiBS->LocateHandle(SearchType,
1446 Protocol,
1447 NULL,
1448 &BufferSize,
1449 InputBuffer);
1450
1451 /* Switch back to protected mode if we came from there */
1452 if (OldMode != BlRealMode)
1453 {
1454 BlpArchSwitchContext(OldMode);
1455 }
1456
1457 /* Check result of first search */
1458 if (EfiStatus == EFI_BUFFER_TOO_SMALL)
1459 {
1460 /* Did we have an existing buffer? */
1461 if (*Buffer)
1462 {
1463 /* Free it */
1465 }
1466
1467 /* Allocate a new one */
1470 if (!InputBuffer)
1471 {
1472 /* No space, fail */
1473 return STATUS_NO_MEMORY;
1474 }
1475
1476 if (OldMode != BlRealMode)
1477 {
1478 /* Translate the input buffer from virtual to physical */
1479 TranslateResult = BlMmTranslateVirtualAddress(InputBuffer,
1480 &BufferPhys);
1481 InputBuffer = TranslateResult ? PhysicalAddressToPtr(BufferPhys) : NULL;
1482
1483 /* Switch to real mode */
1485 }
1486
1487 /* Try again */
1488 EfiStatus = EfiBS->LocateHandle(SearchType,
1489 Protocol,
1490 NULL,
1491 &BufferSize,
1492 InputBuffer);
1493
1494 /* Switch back to protected mode if we came from there */
1495 if (OldMode != BlRealMode)
1496 {
1497 BlpArchSwitchContext(OldMode);
1498 }
1499 }
1500
1501 /* Return the number of handles */
1502 *HandleCount = BufferSize / sizeof(EFI_HANDLE);
1503
1504 /* Convert the error to an NTSTATUS */
1505 return EfiGetNtStatusCode(EfiStatus);
1506}
VOID * EFI_HANDLE
Definition: UefiBaseType.h:35
EFI_LOCATE_HANDLE LocateHandle
Definition: UefiSpec.h:1835
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR InputBuffer
Definition: wdfiotarget.h:953

Referenced by BlFwEnumerateDevice(), BlockIoEfiGetChildHandle(), BlockIoFirmwareOpen(), and ConsoleEfiGraphicalOpenProtocol().

◆ EfiOpenProtocol()

◆ EfipGetRsdt()

NTSTATUS EfipGetRsdt ( _Out_ PPHYSICAL_ADDRESS  FoundRsdt)

Definition at line 1635 of file firmware.c.

1638{
1640 ULONG Length;
1641 PHYSICAL_ADDRESS RsdpAddress, Rsdt;
1642 PRSDP Rsdp;
1643
1644 /* Assume failure */
1645 Length = 0;
1646 Rsdp = NULL;
1647
1648 /* Check if we already know it */
1649 if (EfiRsdt.QuadPart)
1650 {
1651 /* Return it */
1652 *FoundRsdt = EfiRsdt;
1653 return STATUS_SUCCESS;
1654 }
1655
1656 /* Otherwise, look for the ACPI 2.0 RSDP (XSDT really) */
1658 if (!NT_SUCCESS(Status))
1659 {
1660 /* Didn't fint it, look for the ACPI 1.0 RSDP (RSDT really) */
1662 if (!NT_SUCCESS(Status))
1663 {
1664 return Status;
1665 }
1666 }
1667
1668 /* Map it */
1669 Length = sizeof(*Rsdp);
1671 0,
1672 Length,
1673 RsdpAddress);
1674 if (NT_SUCCESS(Status))
1675 {
1676 /* Check the revision (anything >= 2.0 is XSDT) */
1677 if (Rsdp->Revision)
1678 {
1679 /* Check if the table is bigger than just its header */
1680 if (Rsdp->Length > Length)
1681 {
1682 /* Capture the real length */
1683 Length = Rsdp->Length;
1684
1685 /* Unmap our header mapping */
1686 BlMmUnmapVirtualAddressEx(Rsdp, sizeof(*Rsdp));
1687
1688 /* And map the whole thing now */
1690 0,
1691 Length,
1692 RsdpAddress);
1693 if (!NT_SUCCESS(Status))
1694 {
1695 return Status;
1696 }
1697 }
1698
1699 /* Read the XSDT address from the table*/
1700 Rsdt = Rsdp->XsdtAddress;
1701 }
1702 else
1703 {
1704 /* ACPI 1.0 so just read the RSDT */
1705 Rsdt.QuadPart = Rsdp->RsdtAddress;
1706 }
1707
1708 /* Save it for later */
1709 EfiRsdt = Rsdt;
1710
1711 /* And return it back */
1712 *FoundRsdt = Rsdt;
1713 }
1714
1715 /* Check if we had mapped the RSDP */
1716 if (Rsdp)
1717 {
1718 /* Unmap it */
1720 }
1721
1722 /* Return search result back to caller */
1723 return Status;
1724}
EFI_GUID EfiRootAcpiTable10Guid
Definition: firmware.c:35
EFI_GUID EfiRootAcpiTableGuid
Definition: firmware.c:34
PHYSICAL_ADDRESS EfiRsdt
Definition: firmware.c:26
NTSTATUS EfipGetSystemTable(_In_ EFI_GUID *TableGuid, _Out_ PPHYSICAL_ADDRESS TableAddress)
Definition: firmware.c:1604
Definition: acpi.h:81
ULONG Length
Definition: acpi.h:87
ULONG RsdtAddress
Definition: acpi.h:86
PHYSICAL_ADDRESS XsdtAddress
Definition: acpi.h:88
UCHAR Revision
Definition: acpi.h:85

Referenced by BlUtlGetAcpiTable().

◆ EfiPrintf()

VOID EfiPrintf ( _In_ PWCHAR  Format,
  ... 
)

Definition at line 126 of file firmware.c.

130{
133
134 /* Capture the buffer in our scratch pad, and NULL-terminate */
137
138 /* Check which mode we're in */
140 {
141 /* Call EFI directly */
143 }
144 else
145 {
146 /* Switch to real mode */
148
149 /* Call EFI directly */
150 if (EfiConOut != NULL)
151 {
153 }
154
155 /* Switch back to protected mode */
157 }
158
159 /* All done */
160 va_end(args);
161}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
WCHAR BlScratchBuffer[8192]
Definition: firmware.c:39
__CRT_INLINE int __cdecl vsnwprintf(wchar_t *s, size_t n, const wchar_t *format, va_list arg)
Definition: stdio.h:931
#define args
Definition: format.c:66
Definition: match.c:390

Referenced by Archx86TransferTo32BitApplicationAsm(), BcInitialize(), BcpDestroy(), BfiLoadFontFile(), BiConvertRegistryDataToElement(), BiEnumerateElements(), BiFlushHive(), BiLoadHive(), BiNotifyEnumerationError(), BlArchGetCpuVendor(), BlArchGetPerformanceCounter(), BlArchIsCpuIdFunctionSupported(), BlBdPullRemoteFile(), BlBsdInitializeLog(), BlDestroyLibrary(), BlDisplayGetTextCellResolution(), BlFileOpen(), BlFileReadAtOffsetEx(), BlImgLoadImageWithProgress2(), BlMmAllocateHeap(), BlMmRemoveBadMemory(), BlMmUnmapVirtualAddressEx(), BlockIoEfiCreateDeviceEntry(), BlockIoEfiFlush(), BlockIoEfiGetDeviceInformation(), BlockIoEfiReset(), BlockIoFirmwareOpen(), BlockIoGetGPTDiskSignature(), BlockIopOperation(), BlockIopReadPhysicalDevice(), BlockIopReadUsingPrefetch(), BlockIoSetInformation(), BlpArchInitialize(), BlpDeviceOpen(), BlpDeviceResolveLocate(), BlPdQueryData(), BlpMmInitialize(), BlpPdParseReturnArguments(), BlpTimeCalibratePerformanceCounter(), BlpTimeMeasureTscFrequency(), BlResourceFindMessage(), BlSecureBootCheckForFactoryReset(), BlStatusPrint(), BlTimeQueryPerformanceCounter(), BlUtlCheckSum(), BlUtlGetAcpiTable(), BlUtlUpdateProgress(), BlXmiWrite(), BmCloseDataStore(), BmDisplayDumpError(), BmEnumerateBootEntries(), BmFatalErrorEx(), BmFwInitializeBootDirectoryPath(), BmFwRegisterRevocationList(), BmMain(), BmOpenDataStore(), BmpCreateDevices(), BmpGetSelectedBootEntry(), BmpPopulateBootEntryList(), BmpProcessBadMemory(), BmpProcessBootEntry(), BmProcessCustomAction(), BmpTransferExecution(), BmResumeFromHibernate(), BmUpdateProgress(), BmUpdateProgressInfo(), ConsoleEfiGopOpen(), ConsoleEfiGraphicalOpenProtocol(), ConsoleEfiTextFindModeFromAllowed(), ConsoleEfiUgaOpen(), ConsoleFirmwareGraphicalClear(), ConsoleFirmwareTextOpen(), ConsoleGraphicalConstruct(), ConsoleGraphicalSetTextState(), ConsoleTextLocalConstruct(), ConsoleTextLocalReinitialize(), DbgPrint(), DsppInitialize(), DsppReinitialize(), EfiConInExReset(), EfiConInReset(), EfiConnectController(), EfiConOutEnableCursor(), EfiConOutOutputString(), EfiConOutQueryMode(), EfiConOutReadCurrentMode(), EfiConOutSetAttribute(), EfiConOutSetCursorPosition(), EfiConOutSetMode(), EfiGetVariable(), EfiGopSetMode(), EfiResetSystem(), EtfsMount(), EtfspCheckCdfs(), EtfspCheckEtfs(), EtfspCreateContext(), EtfspGetDirent(), EtfsSetInformation(), FatMount(), FileDeviceOpen(), FileIoOpen(), ImgArchEfiStartBootApplication(), ImgpCopyApplicationBootDevice(), ImgpLoadPEImage(), InitializeLibrary(), MmArchInitialize(), MmArchTranslateVirtualAddress(), MmBapFreeBlockAllocatorDescriptor(), MmDefInitializeTranslation(), MmDefMoveVirtualAddressRange(), MmDefpDestroySelfMap(), MmDefpMapPhysicalAddress(), MmDefpRemapVirtualAddress(), MmDefpTranslateVirtualAddress(), MmDefpUnmapVirtualAddress(), MmDefRelocateSelfMap(), MmDefZeroVirtualAddressRange(), MmFwGetMemoryMap(), MmHapHeapAllocatorExtend(), MmHapReportHeapCorruption(), MmMapPhysicalAddress(), MmMdDbgDumpList(), MmMdInitByteGranularDescriptor(), MmMdpCoalesceDescriptor(), MmMdpSwitchToDynamicDescriptors(), MmMdpTruncateDescriptor(), MmMdTruncateDescriptors(), MmPaAllocatePages(), MmPaInitialize(), MmPapAllocatePagesInRange(), MmPapAllocateRegionFromMdl(), MmPapFreePages(), MmPapFreePhysicalPages(), MmPapPageAllocatorExtend(), MmPaReleaseSelfMapPages(), MmTrInitialize(), MmUnmapVirtualAddress(), OslArchTransferToKernel(), OslDrawLogo(), OslMain(), OslpMain(), OslPrepareTarget(), PartitionOpen(), RdDeviceOpen(), RtlAssert(), SpOpen(), UdpOpen(), and VhdFileDeviceOpen().

◆ EfiResetSystem()

VOID EfiResetSystem ( _In_ EFI_RESET_TYPE  ResetType)

Definition at line 1509 of file firmware.c.

1512{
1513 BL_ARCH_MODE OldMode;
1514
1515 /* Are we in protected mode? */
1516 OldMode = CurrentExecutionContext->Mode;
1517 if (OldMode != BlRealMode)
1518 {
1519 /* FIXME: Not yet implemented */
1520 EfiPrintf(L"reset vm path\r\n");
1521 EfiStall(10000000);
1522 return;
1523 }
1524
1525 /* Call the EFI runtime */
1526 EfiRT->ResetSystem(ResetType, EFI_SUCCESS, 0, NULL);
1527}
EFI_RESET_SYSTEM ResetSystem
Definition: UefiSpec.h:1774

Referenced by BlFwReboot().

◆ EfiStall()

NTSTATUS EfiStall ( _In_ ULONG  StallTime)

Definition at line 1003 of file firmware.c.

1006{
1007 BL_ARCH_MODE OldMode;
1008 EFI_STATUS EfiStatus;
1009
1010 /* Are we in protected mode? */
1011 OldMode = CurrentExecutionContext->Mode;
1012 if (OldMode != BlRealMode)
1013 {
1014 /* Switch to real mode */
1016 }
1017
1018 /* Make the EFI call */
1019 EfiStatus = EfiBS->Stall(StallTime);
1020
1021 /* Switch back to protected mode if we came from there */
1022 if (OldMode != BlRealMode)
1023 {
1024 BlpArchSwitchContext(OldMode);
1025 }
1026
1027 /* Convert the error to an NTSTATUS */
1028 return EfiGetNtStatusCode(EfiStatus);
1029}
EFI_STALL Stall
Definition: UefiSpec.h:1852

Referenced by BiEnumerateElements(), BlMmUnmapVirtualAddressEx(), BlpTimeMeasureTscFrequency(), BmMain(), BmpGetSelectedBootEntry(), EfiConInExReset(), EfiConInReset(), EfiConnectController(), EfiConOutEnableCursor(), EfiConOutOutputString(), EfiConOutQueryMode(), EfiConOutReadCurrentMode(), EfiConOutSetAttribute(), EfiConOutSetCursorPosition(), EfiConOutSetMode(), EfiGetVariable(), EfiGopSetMode(), EfiResetSystem(), ImgArchEfiStartBootApplication(), MmDefpMapPhysicalAddress(), MmHapHeapAllocatorExtend(), MmMapPhysicalAddress(), MmMdInitByteGranularDescriptor(), MmMdpSwitchToDynamicDescriptors(), MmMdpTruncateDescriptor(), MmPaAllocatePages(), MmPapAllocatePagesInRange(), MmPapAllocateRegionFromMdl(), MmPapPageAllocatorExtend(), MmTrInitialize(), MmUnmapVirtualAddress(), and OslDrawLogo().

◆ EtfsInitialize()

NTSTATUS EtfsInitialize ( VOID  )

Definition at line 969 of file etfs.c.

972{
974
975 /* Allocate the device table with 2 entries*/
979 if (EtfsDeviceTable)
980 {
981 /* Zero it out */
985 }
986 else
987 {
988 /* No memory, fail */
990 }
991
992 /* Return back to caller */
993 return Status;
994}
PVOID * EtfsDeviceTable
Definition: etfs.c:49
ULONG EtfsDeviceTableEntries
Definition: etfs.c:48

◆ EtfsMount()

NTSTATUS EtfsMount ( _In_ ULONG  DeviceId,
_In_ ULONG  Unknown,
_Out_ PBL_FILE_ENTRY FileEntry 
)

Definition at line 874 of file etfs.c.

879{
880 PBL_ETFS_DEVICE EtfsDevice = NULL;
881 PBL_FILE_ENTRY RootEntry;
883 PBL_ETFS_FILE EtfsFile;
884
885 EfiPrintf(L"Trying to mount as ETFS...\r\n");
886
887 Status = EtfspCreateContext(DeviceId, &EtfsDevice);
888 if (!NT_SUCCESS(Status))
889 {
890 EfiPrintf(L"ETFS context failed: %lx\r\n");
891 return Status;
892 }
893
896 EtfsDevice,
897 &DeviceId,
899 if (!NT_SUCCESS(Status))
900 {
901 EtfspDeviceContextDestroy(EtfsDevice);
902 return Status;
903 }
904
905 RootEntry = BlMmAllocateHeap(sizeof(*RootEntry));
906 if (!RootEntry)
907 {
909 goto Quickie;
910 }
911
912 RtlZeroMemory(RootEntry, sizeof(*RootEntry));
913
914 RootEntry->FilePath = BlMmAllocateHeap(4);
915 if (!RootEntry->FilePath)
916 {
918 goto Quickie;
919 }
920
921 wcsncpy(RootEntry->FilePath, L"\\", 1);
922
923 RootEntry->DeviceId = DeviceId;
924 RtlCopyMemory(&RootEntry->Callbacks,
926 sizeof(RootEntry->Callbacks));
927
928 EtfsFile = (PBL_ETFS_FILE)BlMmAllocateHeap(sizeof(*EtfsFile));
929 if (!EtfsFile)
930 {
932 goto Quickie;
933 }
934
935 RootEntry->Flags |= 0x10000;
936
937 RtlZeroMemory(EtfsFile, sizeof(*EtfsFile));
938 RootEntry->FsSpecificData = EtfsFile;
939 EtfsFile->DeviceId = DeviceId;
940 EtfsFile->Flags |= 1;
941 EtfsFile->DiskOffset = EtfsDevice->RootDirOffset;
942 EtfsFile->DirOffset = 0;
943 EtfsFile->Size = EtfsDevice->RootDirSize;
944 EtfsFile->FsName = L"cdfs";
945 *FileEntry = RootEntry;
946
947 return STATUS_SUCCESS;
948
949Quickie:
950 if (RootEntry->FilePath)
951 {
952 BlMmFreeHeap(RootEntry->FilePath);
953 }
954 if (RootEntry->FsSpecificData)
955 {
956 BlMmFreeHeap(RootEntry->FsSpecificData);
957 }
958 if (RootEntry)
959 {
960 BlMmFreeHeap(RootEntry);
961 }
962
963 EtfspDeviceTableDestroyEntry(EtfsDevice, DeviceId);
964
965 return Status;
966}
NTSTATUS EtfspCreateContext(_In_ ULONG DeviceId, _Out_ PBL_ETFS_DEVICE *EtfsDevice)
Definition: etfs.c:800
struct _BL_ETFS_FILE * PBL_ETFS_FILE
NTSTATUS EtfspDeviceTableDestroyEntry(_In_ PBL_ETFS_DEVICE EtfsDevice, _In_ ULONG Index)
Definition: etfs.c:862
NTSTATUS EtfspDeviceContextDestroy(_In_ PBL_ETFS_DEVICE EtfsDevice)
Definition: etfs.c:785
BL_FILE_CALLBACKS EtfsFunctionTable
Definition: etfs.c:79
ULONG RootDirSize
Definition: etfs.c:29
ULONG RootDirOffset
Definition: etfs.c:28
ULONG DiskOffset
Definition: etfs.c:39
ULONG DeviceId
Definition: etfs.c:45
ULONG DirOffset
Definition: etfs.c:40
PVOID FsSpecificData
Definition: bl.h:1048
PWCHAR FilePath
Definition: bl.h:1039
ULONG DeviceId
Definition: bl.h:1040

◆ FatInitialize()

NTSTATUS FatInitialize ( VOID  )

Definition at line 81 of file fat.c.

84{
86
87 /* Allocate the device table with 2 entries*/
92 {
93 /* Zero it out */
96
97 /* Allocate a 512 byte buffer for long file name conversion */
100 }
101 else
102 {
103 /* No memory, fail */
105 }
106
107 /* Return back to caller */
108 return Status;
109}
ULONG FatDeviceTableEntries
Definition: fat.c:17
PVOID * FatDeviceTable
Definition: fat.c:16
PWCHAR FatpLongFileName
Definition: fat.c:18

◆ FatMount()

NTSTATUS FatMount ( _In_ ULONG  DeviceId,
_In_ ULONG  Unknown,
_Out_ PBL_FILE_ENTRY FileEntry 
)

Definition at line 23 of file fat.c.

28{
29 BL_DEVICE_INFORMATION DeviceInformation;
30 ULONG UnknownFlag;
32 PACKED_BOOT_SECTOR FatBootSector;
33 BIOS_PARAMETER_BLOCK BiosBlock;
34
35 /* Capture thing */
36 BlDeviceGetInformation(DeviceId, &DeviceInformation);
37 UnknownFlag = DeviceInformation.BlockDeviceInfo.Unknown;
38
39 /* Set thing to 1 */
40 DeviceInformation.BlockDeviceInfo.Unknown |= 1;
41 BlDeviceSetInformation(DeviceId, &DeviceInformation);
42
43 /* Read the boot sector */
45 sizeof(FatBootSector),
46 0,
47 &FatBootSector,
48 NULL);
49
50 /* Restore thing back */
51 DeviceInformation.BlockDeviceInfo.Unknown = UnknownFlag;
52 BlDeviceSetInformation(DeviceId, &DeviceInformation);
53 if (!NT_SUCCESS(Status))
54 {
55 EfiPrintf(L"Failed reading drive: %lx\r\n", Status);
56 return Status;
57 }
58
59 FatUnpackBios(&BiosBlock, &FatBootSector.PackedBpb);
60
61 /* For now, quickly fail if this isn't FAT */
62 if (FatBootSector.Jump[0] != 0xE9)
63 {
65 }
66
67 EfiPrintf(L"Jump: %lx Bytes Per Sector: %d Sectors Per Cluster: %d Reserved: %d Fats: %d Sectors: %d Large Sectors: %d Media: %lx RootEntries: %d\r\n",
68 FatBootSector.Jump[0],
69 BiosBlock.BytesPerSector,
70 BiosBlock.SectorsPerCluster,
71 BiosBlock.ReservedSectors,
72 BiosBlock.Fats,
73 BiosBlock.Sectors,
74 BiosBlock.LargeSectors,
75 BiosBlock.Media,
76 BiosBlock.RootEntries);
78}
NTSTATUS BlDeviceReadAtOffset(_In_ ULONG DeviceId, _In_ ULONG Size, _In_ ULONGLONG Offset, _In_ PVOID Buffer, _Out_ PULONG BytesRead)
Definition: device.c:773
NTSTATUS BlDeviceSetInformation(_In_ ULONG DeviceId, _In_ PBL_DEVICE_INFORMATION DeviceInformation)
#define FatUnpackBios(Bios, Pbios)
Definition: fat.h:136
USHORT ReservedSectors
Definition: fat.h:106
USHORT BytesPerSector
Definition: fat.h:104
USHORT Sectors
Definition: fat.h:109
ULONG32 LargeSectors
Definition: fat.h:115
USHORT RootEntries
Definition: fat.h:108
UCHAR SectorsPerCluster
Definition: fat.h:105
BL_BLOCK_DEVICE_INFORMATION BlockDeviceInfo
Definition: bl.h:1228
UCHAR Jump[3]
Definition: fat.h:163
PACKED_BIOS_PARAMETER_BLOCK PackedBpb
Definition: fat.h:165

Referenced by ArcOpen().

◆ MiscGetBootOption()

PBL_BCD_OPTION MiscGetBootOption ( _In_ PBL_BCD_OPTION  List,
_In_ ULONG  Type 
)

Definition at line 17 of file bcdopt.c.

21{
22 ULONG_PTR NextOption = 0, ListOption;
23 PBL_BCD_OPTION Option, FoundOption;
24
25 /* No options, bail out */
26 if (!List)
27 {
28 return NULL;
29 }
30
31 /* Loop while we find an option */
32 FoundOption = NULL;
33 do
34 {
35 /* Get the next option and see if it matches the type */
37 if ((Option->Type == Type) && !(Option->Empty))
38 {
39 FoundOption = Option;
40 break;
41 }
42
43 /* Store the offset of the next option */
45
46 /* Failed to match. Check for list options */
47 ListOption = Option->ListOffset;
48 if (ListOption)
49 {
50 /* Try to get a match in the associated option */
51 Option = MiscGetBootOption((PBL_BCD_OPTION)((ULONG_PTR)Option +
52 ListOption),
53 Type);
54 if (Option)
55 {
56 /* Return it */
57 FoundOption = Option;
58 break;
59 }
60 }
61 } while (NextOption);
62
63 /* Return the option that was found, if any */
64 return FoundOption;
65}
ULONG NextEntryOffset
Definition: bl.h:850

Referenced by BlGetBootOptionBoolean(), BlGetBootOptionDevice(), BlGetBootOptionGuid(), BlGetBootOptionGuidList(), BlGetBootOptionInteger(), BlGetBootOptionString(), BlpGetBootOptionIntegerList(), BlRemoveBootOption(), BmGetOptionList(), BmpLaunchBootEntry(), BmpPopulateBootEntryList(), BmpTransferExecution(), DsppReinitialize(), and MiscGetBootOption().

◆ MmArchInitialize()

NTSTATUS MmArchInitialize ( _In_ ULONG  Phase,
_In_ PBL_MEMORY_DATA  MemoryData,
_In_ BL_TRANSLATION_TYPE  TranslationType,
_In_ BL_TRANSLATION_TYPE  LibraryTranslationType 
)

Definition at line 1028 of file mmx86.c.

1034{
1036 ULONGLONG IncreaseUserVa, PerfCounter, CpuRandom;
1037 CPU_INFO CpuInfo;
1038
1039 /* For phase 2, just map deferred regions */
1040 if (Phase != 1)
1041 {
1042 return Mmx86pMapMemoryRegions(2, MemoryData);
1043 }
1044
1045 /* What translation type are we switching to? */
1046 switch (RequestedTranslationType)
1047 {
1048 /* Physical memory */
1049 case BlNone:
1050
1051 /* Initialize everything to default/null values */
1053 MmArchKsegBase = 0;
1054 MmArchKsegBias = 0;
1059
1060 /* Set stub functions */
1063
1064 /* Set success */
1066 break;
1067
1068 case BlVirtual:
1069
1070 /* Set the large page size to 1024 pages (4MB) */
1071 MmArchLargePageSize = (4 * 1024 * 1024) / PAGE_SIZE;
1072
1073 /* Check if /USERVA option was used */
1076 &IncreaseUserVa);
1077 if (NT_SUCCESS(Status) && (IncreaseUserVa))
1078 {
1079 /* Yes -- load the kernel at 0xE0000000 instead */
1080 MmArchKsegBase = 0xE0000000;
1081 }
1082 else
1083 {
1084 /* Nope, load at the standard 2GB split */
1085 MmArchKsegBase = 0x80000000;
1086 }
1087
1088 /* Check if CPUID 01h is supported */
1089 CpuRandom = 0;
1091 {
1092 /* Call it */
1093 BlArchCpuId(1, 0, &CpuInfo);
1094
1095 /* Check if RDRAND is supported */
1096 if (CpuInfo.Ecx & 0x40000000)
1097 {
1098 EfiPrintf(L"Your CPU can do RDRAND! Good for you!\r\n");
1099 CpuRandom = 0;
1100 }
1101 }
1102
1103 /* Read the TSC */
1104 PerfCounter = BlArchGetPerformanceCounter();
1105 PerfCounter >>= 4;
1106 _rotl16(PerfCounter, 5);
1107
1108 /* Set the address range */
1111
1112 /* Set the KASLR bias */
1113 MmArchKsegBias = ((PerfCounter ^ CpuRandom) & 0xFFF) << 12;
1114 MmArchKsegBias = 0;
1116
1117 /* Set the kernel range */
1120
1121 /* Set the boot application top maximum */
1122 MmArchTopOfApplicationAddressSpace = 0x70000000 - 1; // Windows bug
1123
1124 /* Initialize virtual address space translation */
1125 Status = MmDefInitializeTranslation(MemoryData, TranslationType);
1126 if (NT_SUCCESS(Status))
1127 {
1128 /* Set stub functions */
1133 }
1134 break;
1135
1136 case BlPae:
1137
1138 /* We don't support PAE */
1140 break;
1141
1142 default:
1143
1144 /* Invalid architecture type*/
1146 break;
1147 }
1148
1149 /* Back to caller */
1150 return Status;
1151}
@ BcdOSLoaderInteger_IncreaseUserVa
Definition: bcd.h:125
VOID BlArchCpuId(_In_ ULONG Function, _In_ ULONG SubFunction, _Out_ PCPU_INFO Result)
Definition: util.c:924
BOOLEAN BlArchIsCpuIdFunctionSupported(_In_ ULONG Function)
Definition: util.c:856
ULONGLONG BlArchGetPerformanceCounter(VOID)
Definition: util.c:902
_Check_return_ unsigned short __cdecl _rotl16(_In_ unsigned short _Value, _In_ unsigned char _Shift)
NTSTATUS MmDefZeroVirtualAddressRange(_In_ PVOID DestinationAddress, _In_ ULONGLONG Size)
Definition: mmx86.c:98
ULONG_PTR MmArchKsegBias
Definition: mmx86.c:27
ULONG_PTR MmArchTopOfApplicationAddressSpace
Definition: mmx86.c:30
VOID MmArchNullFunction(VOID)
Definition: mmx86.c:67
VOID MmDefRelocateSelfMap(VOID)
Definition: mmx86.c:76
PBL_MM_RELOCATE_SELF_MAP BlMmRelocateSelfMap
Definition: mmx86.c:47
PBL_MM_MOVE_VIRTUAL_ADDRESS_RANGE BlMmMoveVirtualAddressRange
Definition: mmx86.c:49
NTSTATUS Mmx86pMapMemoryRegions(_In_ ULONG Phase, _In_ PBL_MEMORY_DATA MemoryData)
Definition: mmx86.c:631
BL_ADDRESS_RANGE MmArchKsegAddressRange
Definition: mmx86.c:29
PBL_MM_FLUSH_TLB BlMmFlushTlb
Definition: mmx86.c:48
NTSTATUS MmDefMoveVirtualAddressRange(_In_ PVOID DestinationAddress, _In_ PVOID SourceAddress, _In_ ULONGLONG Size)
Definition: mmx86.c:87
NTSTATUS MmDefInitializeTranslation(_In_ PBL_MEMORY_DATA MemoryData, _In_ BL_TRANSLATION_TYPE TranslationType)
Definition: mmx86.c:857
PBL_MM_ZERO_VIRTUAL_ADDRESS_RANGE BlMmZeroVirtualAddressRange
Definition: mmx86.c:50
ULONG_PTR MmArchKsegBase
Definition: mmx86.c:26
ULONG MmArchLargePageSize
Definition: mmx86.c:28
PBL_MM_FLUSH_TLB Mmx86FlushTlb
Definition: mmx86.c:43
PHYSICAL_ADDRESS Mmx86SelfMapBase
Definition: mmx86.c:31
ULONGLONG Maximum
Definition: bl.h:1015
ULONGLONG Minimum
Definition: bl.h:1014

Referenced by BlpMmInitialize().

◆ MmArchTranslateVirtualAddress()

BOOLEAN MmArchTranslateVirtualAddress ( _In_ PVOID  VirtualAddress,
_Out_opt_ PPHYSICAL_ADDRESS  PhysicalAddress,
_Out_opt_ PULONG  CachingFlags 
)

Definition at line 108 of file mmx86.c.

113{
115
116 /* Check if paging is on */
119 {
120 /* Yes -- we have to translate this from virtual */
123 CachingFlags);
124 }
125
126 /* Look in all descriptors except truncated and firmware ones */
131
132 /* Return the virtual address as the physical address */
133 if (PhysicalAddress)
134 {
137 }
138
139 /* There's no caching on physical memory */
140 if (CachingFlags)
141 {
142 *CachingFlags = 0;
143 }
144
145 /* Success is if we found a descriptor */
146 return Descriptor != NULL;
147}
PBL_MM_TRANSLATE_VIRTUAL_ADDRESS Mmx86TranslateVirtualAddress
Definition: mmx86.c:39
ULONG ContextFlags
Definition: bl.h:1001
ULONG LowPart
Definition: typedefs.h:106

Referenced by BlMmTranslateVirtualAddress(), and MmMapPhysicalAddress().

◆ MmBaInitialize()

NTSTATUS MmBaInitialize ( VOID  )

Definition at line 271 of file blkalloc.c.

274{
276 ULONG Size;
277
278 /* Allocate 8 table entries */
283 {
284 /* Zero them out -- we're all done */
288 }
289 else
290 {
291 /* Bail out since we're out of memory */
294 }
295
296 /* Return initialization status */
297 return Status;
298}
struct _BL_BLOCK_DESCRIPTOR BL_BLOCK_DESCRIPTOR

Referenced by BlpMmInitialize().

◆ MmFwFreePages()

NTSTATUS MmFwFreePages ( _In_ ULONG  BasePage,
_In_ ULONG  PageCount 
)

Definition at line 28 of file fwutil.c.

32{
33 /* Free the pages */
34 return EfiFreePages(PageCount, BasePage << PAGE_SHIFT);
35}
NTSTATUS EfiFreePages(_In_ ULONG Pages, _In_ EFI_PHYSICAL_ADDRESS PhysicalAddress)
Definition: firmware.c:973

Referenced by MmPapFreePhysicalPages(), MmPapPageAllocatorExtend(), and MmPaReleaseSelfMapPages().

◆ MmFwGetMemoryMap()

NTSTATUS MmFwGetMemoryMap ( _Out_ PBL_MEMORY_DESCRIPTOR_LIST  MemoryMap,
_In_ ULONG  Flags 
)

Definition at line 1845 of file firmware.c.

1849{
1850 BL_LIBRARY_PARAMETERS LibraryParameters = BlpLibraryParameters;
1851 BOOLEAN UseEfiBuffer, HaveRamDisk;
1853 ULONGLONG Pages, StartPage, EndPage, EfiBufferPage;
1854 UINTN EfiMemoryMapSize, MapKey, DescriptorSize, DescriptorVersion;
1855 EFI_PHYSICAL_ADDRESS EfiBuffer = 0;
1857 EFI_STATUS EfiStatus;
1858 BL_ARCH_MODE OldMode;
1859 EFI_MEMORY_DESCRIPTOR EfiDescriptor;
1860 BL_MEMORY_TYPE MemoryType;
1862 BL_MEMORY_ATTR Attribute;
1863 PVOID LibraryBuffer;
1864
1865 /* Initialize EFI memory map attributes */
1866 EfiMemoryMapSize = MapKey = DescriptorSize = DescriptorVersion = 0;
1867 LibraryBuffer = NULL;
1868
1869 /* Increment the nesting depth */
1871
1872 /* Determine if we should use EFI or our own allocator at this point */
1874 if (!(LibraryParameters.LibraryFlags & BL_LIBRARY_FLAG_INITIALIZATION_COMPLETED))
1875 {
1876 UseEfiBuffer = TRUE;
1877 }
1878
1879 /* Bail out if we don't have a list to use */
1880 if (MemoryMap == NULL)
1881 {
1883 goto Quickie;
1884 }
1885
1886 /* Free the current descriptor list */
1888
1889 /* Call into EFI to get the size of the memory map */
1890 Status = EfiGetMemoryMap(&EfiMemoryMapSize,
1891 NULL,
1892 &MapKey,
1894 &DescriptorVersion);
1896 {
1897 /* This should've failed because our buffer was too small, nothing else */
1898 if (NT_SUCCESS(Status))
1899 {
1901 }
1902 goto Quickie;
1903 }
1904
1905 /* Add 4 more descriptors just in case things changed */
1906 EfiMemoryMapSize += (4 * DescriptorSize);
1907 Pages = BYTES_TO_PAGES(EfiMemoryMapSize);
1908
1909 /* Should we use EFI to grab memory? */
1910 if (UseEfiBuffer)
1911 {
1912 /* Yes -- request one more page to align up correctly */
1913 Pages++;
1914
1915 /* Grab the required pages */
1917 Pages,
1918 &EfiBuffer);
1919 if (!NT_SUCCESS(Status))
1920 {
1921 EfiPrintf(L"EFI allocation failed: %lx\r\n", Status);
1922 goto Quickie;
1923 }
1924
1925 /* Free the pages for now */
1926 Status = EfiFreePages(Pages, EfiBuffer);
1927 if (!NT_SUCCESS(Status))
1928 {
1929 EfiBuffer = 0;
1930 goto Quickie;
1931 }
1932
1933 /* Now round to the actual buffer size, removing the extra page */
1934 EfiBuffer = ROUND_TO_PAGES(EfiBuffer);
1935 Pages--;
1937 Pages,
1938 &EfiBuffer);
1939 if (!NT_SUCCESS(Status))
1940 {
1941 EfiBuffer = 0;
1942 goto Quickie;
1943 }
1944
1945 /* Get the final aligned size and proper buffer */
1946 EfiMemoryMapSize = EFI_PAGES_TO_SIZE(Pages);
1948
1949 /* Switch to real mode if not already in it */
1950 OldMode = CurrentExecutionContext->Mode;
1951 if (OldMode != BlRealMode)
1952 {
1954 }
1955
1956 /* Call EFI to get the memory map */
1957 EfiStatus = EfiBS->GetMemoryMap(&EfiMemoryMapSize,
1959 &MapKey,
1961 &DescriptorVersion);
1962
1963 /* Switch back into the previous mode */
1964 if (OldMode != BlRealMode)
1965 {
1966 BlpArchSwitchContext(OldMode);
1967 }
1968
1969 /* Convert the result code */
1970 Status = EfiGetNtStatusCode(EfiStatus);
1971 }
1972 else
1973 {
1974 /* Round the map to pages */
1975 Pages = BYTES_TO_PAGES(EfiMemoryMapSize);
1976
1977 /* Allocate a large enough buffer */
1978 Status = MmPapAllocatePagesInRange(&LibraryBuffer,
1980 Pages,
1981 0,
1982 0,
1983 0,
1984 0);
1985 if (!NT_SUCCESS(Status))
1986 {
1987 EfiPrintf(L"Failed to allocate mapped VM for EFI map: %lx\r\n", Status);
1988 goto Quickie;
1989 }
1990
1991 /* Call EFI to get the memory map */
1992 EfiMemoryMap = LibraryBuffer;
1993 Status = EfiGetMemoryMap(&EfiMemoryMapSize,
1994 LibraryBuffer,
1995 &MapKey,
1997 &DescriptorVersion);
1998 }
1999
2000 /* So far so good? */
2001 if (!NT_SUCCESS(Status))
2002 {
2003 EfiPrintf(L"Failed to get EFI memory map: %lx\r\n", Status);
2004 goto Quickie;
2005 }
2006
2007 /* Did we get correct data from firmware? */
2008 if (((EfiMemoryMapSize % DescriptorSize)) ||
2010 {
2011 EfiPrintf(L"Incorrect descriptor size\r\n");
2013 goto Quickie;
2014 }
2015
2016 /* Did we boot from a RAM disk? */
2019 {
2020 /* We don't handle this yet */
2021 EfiPrintf(L"RAM boot not supported\r\n");
2023 goto Quickie;
2024 }
2025 else
2026 {
2027 /* We didn't, so there won't be any need to find the memory descriptor */
2028 HaveRamDisk = FALSE;
2029 }
2030
2031 /* Loop the EFI memory map */
2032#if 0
2033 EfiPrintf(L"UEFI MEMORY MAP\r\n\r\n");
2034 EfiPrintf(L"TYPE START END ATTRIBUTES\r\n");
2035 EfiPrintf(L"===============================================================\r\n");
2036#endif
2037 while (EfiMemoryMapSize != 0)
2038 {
2039 /* Check if this is an EFI buffer, but we're not in real mode */
2040 if ((UseEfiBuffer) && (OldMode != BlRealMode))
2041 {
2043 }
2044
2045 /* Capture it so we can go back to protected mode (if possible) */
2046 EfiDescriptor = *EfiMemoryMap;
2047
2048 /* Go back to protected mode, if we had switched */
2049 if ((UseEfiBuffer) && (OldMode != BlRealMode))
2050 {
2051 BlpArchSwitchContext(OldMode);
2052 }
2053
2054 /* Convert to OS memory type */
2055 MemoryType = MmFwpGetOsMemoryType(EfiDescriptor.Type);
2056
2057 /* Round up or round down depending on where the memory is coming from */
2058 if (MemoryType == BlConventionalMemory)
2059 {
2060 StartPage = BYTES_TO_PAGES(EfiDescriptor.PhysicalStart);
2061 }
2062 else
2063 {
2064 StartPage = EfiDescriptor.PhysicalStart >> PAGE_SHIFT;
2065 }
2066
2067 /* Calculate the ending page */
2068 EndPage = StartPage + EfiDescriptor.NumberOfPages;
2069
2070 /* If after rounding, we ended up with 0 pages, skip this */
2071 if (StartPage == EndPage)
2072 {
2073 goto LoopAgain;
2074 }
2075#if 0
2076 EfiPrintf(L"%08X 0x%016I64X-0x%016I64X 0x%I64X\r\n",
2077 MemoryType,
2080 EfiDescriptor.Attribute);
2081#endif
2082 /* Check for any range of memory below 1MB */
2083 if (StartPage < 0x100)
2084 {
2085 /* Does this range actually contain NULL? */
2086 if (StartPage == 0)
2087 {
2088 /* Manually create a reserved descriptof for this page */
2089 Attribute = MmFwpGetOsAttributeType(EfiDescriptor.Attribute);
2092 0,
2093 0,
2094 1);
2095 if (!Descriptor)
2096 {
2098 break;
2099 }
2100
2101 /* Add this descriptor into the list */
2103 Descriptor,
2105 if (!NT_SUCCESS(Status))
2106 {
2107 EfiPrintf(L"Failed to add zero page descriptor: %lx\r\n", Status);
2108 break;
2109 }
2110
2111 /* Now handle the rest of the range, unless this was it */
2112 StartPage = 1;
2113 if (EndPage == 1)
2114 {
2115 goto LoopAgain;
2116 }
2117 }
2118
2119 /* Does the range go beyond 1MB? */
2120 if (EndPage > 0x100)
2121 {
2122 /* Then create the descriptor for everything up until the megabyte */
2123 Attribute = MmFwpGetOsAttributeType(EfiDescriptor.Attribute);
2125 MemoryType,
2126 StartPage,
2127 0,
2128 0x100 - StartPage);
2129 if (!Descriptor)
2130 {
2132 break;
2133 }
2134
2135 /* Check if this region is currently free RAM */
2136 if (Descriptor->Type == BlConventionalMemory)
2137 {
2138 /* Set the appropriate flag on the descriptor */
2139 Descriptor->Flags |= BlMemoryBelow1MB;
2140 }
2141
2142 /* Add this descriptor into the list */
2144 Descriptor,
2146 if (!NT_SUCCESS(Status))
2147 {
2148 EfiPrintf(L"Failed to add 1MB descriptor: %lx\r\n", Status);
2149 break;
2150 }
2151
2152 /* Now handle the rest of the range above 1MB */
2153 StartPage = 0x100;
2154 }
2155 }
2156
2157 /* Check if we loaded from a RAM disk */
2158 if (HaveRamDisk)
2159 {
2160 /* We don't handle this yet */
2161 EfiPrintf(L"RAM boot not supported\r\n");
2163 goto Quickie;
2164 }
2165
2166 /* Create a descriptor for the current range */
2167 Attribute = MmFwpGetOsAttributeType(EfiDescriptor.Attribute);
2169 MemoryType,
2170 StartPage,
2171 0,
2172 EndPage - StartPage);
2173 if (!Descriptor)
2174 {
2176 break;
2177 }
2178
2179 /* Check if this region is currently free RAM below 1MB */
2180 if ((Descriptor->Type == BlConventionalMemory) && (EndPage <= 0x100))
2181 {
2182 /* Set the appropriate flag on the descriptor */
2183 Descriptor->Flags |= BlMemoryBelow1MB;
2184 }
2185
2186 /* Add the descriptor to the list, requesting coalescing as asked */
2188 Descriptor,
2192 if (!NT_SUCCESS(Status))
2193 {
2194 EfiPrintf(L"Failed to add full descriptor: %lx\r\n", Status);
2195 break;
2196 }
2197
2198LoopAgain:
2199 /* Consume this descriptor, and move to the next one */
2200 EfiMemoryMapSize -= DescriptorSize;
2202 }
2203
2204 /* Check if we are using the local UEFI buffer */
2205 if (!UseEfiBuffer)
2206 {
2207 goto Quickie;
2208 }
2209
2210 /* Free the EFI buffer */
2211 Status = EfiFreePages(Pages, EfiBuffer);
2212 if (!NT_SUCCESS(Status))
2213 {
2214 /* Keep the pages marked 'in use' and fake success */
2216 goto Quickie;
2217 }
2218
2219 /* Get the base page of the EFI buffer */
2220 EfiBufferPage = EfiBuffer >> PAGE_SHIFT;
2221 Pages = (EfiBufferPage + Pages) - EfiBufferPage;
2222
2223 /* Don't try freeing below */
2224 EfiBuffer = 0;
2225
2226 /* Find the current descriptor for the allocation */
2229 EfiBufferPage);
2230 if (!Descriptor)
2231 {
2233 goto Quickie;
2234 }
2235
2236 /* Convert it to a free descriptor */
2239 EfiBufferPage,
2240 0,
2241 Pages);
2242 if (!Descriptor)
2243 {
2245 goto Quickie;
2246 }
2247
2248 /* Remove the region from the memory map */
2251 EfiBufferPage,
2252 Pages,
2253 NULL);
2254 if (!NT_SUCCESS(Status))
2255 {
2257 goto Quickie;
2258 }
2259
2260 /* Add it back as free memory */
2262 Descriptor,
2264
2265Quickie:
2266 /* Free the EFI buffer, if we had one */
2267 if (EfiBuffer != 0)
2268 {
2269 EfiFreePages(Pages, EfiBuffer);
2270 }
2271
2272 /* Free the library-allocated buffer, if we had one */
2273 if (LibraryBuffer != 0)
2274 {
2276 }
2277
2278 /* On failure, free the memory map if one was passed in */
2279 if (!NT_SUCCESS(Status) && (MemoryMap != NULL))
2280 {
2282 }
2283
2284 /* Decrement the nesting depth and return */
2286 return Status;
2287}
#define EFI_PAGES_TO_SIZE(Pages)
Definition: UefiBaseType.h:217
@ AllocateAddress
Definition: UefiSpec.h:45
@ AllocateAnyPages
Definition: UefiSpec.h:36
PBL_MEMORY_DESCRIPTOR MmMdFindDescriptorFromMdl(_In_ PBL_MEMORY_DESCRIPTOR_LIST MdList, _In_ ULONG Flags, _In_ ULONGLONG Page)
Definition: descriptor.c:960
NTSTATUS MmMdFreeDescriptor(_In_ PBL_MEMORY_DESCRIPTOR MemoryDescriptor)
Definition: descriptor.c:157
#define BL_LIBRARY_FLAG_INITIALIZATION_COMPLETED
Definition: bl.h:131
#define BL_MM_ADD_DESCRIPTOR_COALESCE_FLAG
Definition: bl.h:89
#define BL_MM_ADD_DESCRIPTOR_TRUNCATE_FLAG
Definition: bl.h:90
BL_LIBRARY_PARAMETERS BlpLibraryParameters
Definition: bootlib.c:15
#define BL_MM_FLAG_USE_FIRMWARE_FOR_MEMORY_MAP_BUFFERS
Definition: bl.h:86
ULONG MmDescriptorCallTreeCount
Definition: mm.c:19
BL_MEMORY_TYPE MmFwpGetOsMemoryType(_In_ EFI_MEMORY_TYPE MemoryType)
Definition: firmware.c:1782
NTSTATUS EfiFreePages(_In_ ULONG Pages, _In_ EFI_PHYSICAL_ADDRESS PhysicalAddress)
Definition: firmware.c:973
BL_MEMORY_ATTR MmFwpGetOsAttributeType(_In_ ULONGLONG Attribute)
Definition: firmware.c:1727
NTSTATUS EfiGetMemoryMap(_Out_ UINTN *MemoryMapSize, _Inout_ EFI_MEMORY_DESCRIPTOR *MemoryMap, _Out_ UINTN *MapKey, _Out_ UINTN *DescriptorSize, _Out_ UINTN *DescriptorVersion)
Definition: firmware.c:922
NTSTATUS EfiAllocatePages(_In_ ULONG Type, _In_ ULONG Pages, _Inout_ EFI_PHYSICAL_ADDRESS *Memory)
Definition: firmware.c:1568
EFI_GET_MEMORY_MAP GetMemoryMap
Definition: UefiSpec.h:1812
EFI_PHYSICAL_ADDRESS PhysicalStart
Definition: UefiSpec.h:99
ULONG LibraryFlags
Definition: bl.h:757
_In_ SIZE_T DescriptorSize
Definition: nls.c:40
EFI_MEMORY_DESCRIPTOR * EfiMemoryMap
Definition: uefimem.c:35
int WINAPI StartPage(_In_ HDC)
#define ROUND_TO_PAGES(Size)
#define BYTES_TO_PAGES(Size)

Referenced by BlMmGetMemoryMap(), MmPaInitialize(), and Mmx86pMapMemoryRegions().

◆ MmHaInitialize()

NTSTATUS MmHaInitialize ( _In_ ULONG  HeapSize,
_In_ ULONG  HeapAttributes 
)

Definition at line 538 of file heapalloc.c.

542{
544
545 /* No free list to begin with */
547
548 /* Configure the minimum heap size and allocation attributes */
550 HapAllocationAttributes = HeapAttributes & 0x20000;
551
552 /* Initialize the heap boundary list */
554
555 /* Initialize a heap big enough to handle a one pointer long allocation */
557 if (NT_SUCCESS(Status))
558 {
559 /* The heap is ready! */
562 }
563
564 /* Return initialization status */
565 return Status;
566}
ULONG HapMinimumHeapSize
Definition: heapalloc.c:58
ULONG HapAllocationAttributes
Definition: heapalloc.c:59
PBL_FREE_HEAP_ENTRY * MmFreeList
Definition: heapalloc.c:60
SIZE_T WINAPI HeapSize(HANDLE, DWORD, LPCVOID)

Referenced by BlpMmInitialize().

◆ MmMapPhysicalAddress()

NTSTATUS MmMapPhysicalAddress ( _Inout_ PPHYSICAL_ADDRESS  PhysicalAddress,
_Out_ PVOID VirtualAddress,
_Inout_ PULONGLONG  Size,
_In_ ULONG  CacheAttributes 
)

◆ MmMdAddDescriptorToList()

NTSTATUS MmMdAddDescriptorToList ( _In_ PBL_MEMORY_DESCRIPTOR_LIST  MdList,
_In_ PBL_MEMORY_DESCRIPTOR  MemoryDescriptor,
_In_ ULONG  Flags 
)

Definition at line 582 of file descriptor.c.

587{
588 PLIST_ENTRY ThisEntry, FirstEntry;
589 PBL_MEMORY_DESCRIPTOR ThisDescriptor;
590
591 /* Arguments must be present */
592 if (!(MdList) || !(MemoryDescriptor))
593 {
595 }
596
597 /* Check if coalescing is forcefully disabled */
599 {
600 /* Then we won't be coalescing */
601 Flags &= ~BL_MM_ADD_DESCRIPTOR_COALESCE_FLAG;
602 }
603 else if (MemoryDescriptor->Flags & BlMemoryCoalesced)
604 {
605 /* Coalesce if the descriptor requires it */
607 }
608
609 /* Check if truncation is forcefully disabled */
611 {
612 Flags &= ~BL_MM_ADD_DESCRIPTOR_TRUNCATE_FLAG;
613 }
614
615 /* Update the current list pointer if the descriptor requires it */
616 if (MemoryDescriptor->Flags & BlMemoryUpdate)
617 {
619 }
620
621 /* Get the current descriptor */
622 ThisEntry = MdList->This;
623 ThisDescriptor = CONTAINING_RECORD(ThisEntry, BL_MEMORY_DESCRIPTOR, ListEntry);
624
625 /* Also get the first descriptor */
626 FirstEntry = MdList->First;
627
628 /* Check if there's no current pointer, or if it's higher than the new one */
629 if (!(ThisEntry) ||
630 (MemoryDescriptor->BasePage <= ThisDescriptor->BasePage))
631 {
632 /* Start at the first descriptor instead, since current is past us */
633 ThisEntry = FirstEntry->Flink;
634 }
635
636 /* Loop until we find the right location to insert */
637 while (ThisEntry != FirstEntry)
638 {
639 /* Get the descriptor part of this entry */
640 ThisDescriptor = CONTAINING_RECORD(ThisEntry, BL_MEMORY_DESCRIPTOR, ListEntry);
641
642 /* Is the address smaller, or equal but more important? */
643 if ((MemoryDescriptor->BasePage < ThisDescriptor->BasePage) ||
644 ((MemoryDescriptor->BasePage == ThisDescriptor->BasePage) &&
645 (MmMdpHasPrecedence(MemoryDescriptor->Type, ThisDescriptor->Type))))
646 {
647 /* Then insert right here */
648 InsertTailList(ThisEntry, &MemoryDescriptor->ListEntry);
649 goto Quickie;
650 }
651
652 /* Try the next entry */
653 ThisEntry = ThisEntry->Flink;
654 }
655
656 /* Then we didn't find a good match, so insert it right here */
657 InsertTailList(FirstEntry, &MemoryDescriptor->ListEntry);
658
659Quickie:
660 /* Do we have to truncate? */
662 {
663 /* Do it and then exit */
665 {
666 return STATUS_SUCCESS;
667 }
668 }
669
670 /* Do we have to coalesce? */
672 {
673 /* Do it and then exit */
675 {
676 return STATUS_SUCCESS;
677 }
678 }
679
680 /* Do we have to update the current pointer? */
682 {
683 /* Do it */
685 }
686
687 /* We're done */
688 return STATUS_SUCCESS;
689}
#define BL_MM_ADD_DESCRIPTOR_NEVER_COALESCE_FLAG
Definition: bl.h:91
#define BL_MM_ADD_DESCRIPTOR_NEVER_TRUNCATE_FLAG
Definition: bl.h:92
#define BL_MM_ADD_DESCRIPTOR_UPDATE_LIST_POINTER_FLAG
Definition: bl.h:94
BOOLEAN MmMdpTruncateDescriptor(_In_ PBL_MEMORY_DESCRIPTOR_LIST MdList, _In_ PBL_MEMORY_DESCRIPTOR MemoryDescriptor, _In_ ULONG Flags)
Definition: descriptor.c:486
BOOLEAN MmMdpCoalesceDescriptor(_In_ PBL_MEMORY_DESCRIPTOR_LIST MdList, _In_ PBL_MEMORY_DESCRIPTOR MemoryDescriptor, _In_ ULONG Flags)
Definition: descriptor.c:528
BOOLEAN MmMdpHasPrecedence(_In_ BL_MEMORY_TYPE Type1, _In_ BL_MEMORY_TYPE Type2)
Definition: descriptor.c:64
VOID MmMdpSaveCurrentListPointer(_In_ PBL_MEMORY_DESCRIPTOR_LIST MdList, _In_ PLIST_ENTRY Current)
Definition: descriptor.c:185
ULONGLONG BasePage
Definition: bl.h:830
BL_MEMORY_TYPE Type
Definition: bl.h:841
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _In_ PWDF_USB_CONTROL_SETUP_PACKET _In_opt_ PWDF_MEMORY_DESCRIPTOR MemoryDescriptor
Definition: wdfusb.h:1339

Referenced by BlMmMapPhysicalAddressEx(), MmFwGetMemoryMap(), MmMdCopyList(), MmMdRemoveRegionFromMdlEx(), MmMdTruncateDescriptors(), MmPaInitialize(), MmPapAllocateRegionFromMdl(), MmPapFreePhysicalPages(), MmPapPageAllocatorExtend(), MmPaReleaseSelfMapPages(), and MmTrInitialize().

◆ MmMdCopyList()

NTSTATUS MmMdCopyList ( _In_ PBL_MEMORY_DESCRIPTOR_LIST  DestinationList,
_In_ PBL_MEMORY_DESCRIPTOR_LIST  SourceList,
_In_opt_ PBL_MEMORY_DESCRIPTOR  ListDescriptor,
_Out_ PULONG  ActualCount,
_In_ ULONG  Count,
_In_ ULONG  Flags 
)

Definition at line 249 of file descriptor.c.

257{
259 PULONG Used;
260 PLIST_ENTRY First, NextEntry;
262
263 /* Both parameters must be present */
264 if (!(DestinationList) || !(SourceList))
265 {
267 }
268
269 /* Assume success */
271
272 /* Check if a descriptor is being used to store the list */
273 if (ListDescriptor)
274 {
275 /* See how big it is */
277 Used = ActualCount;
278 }
279 else
280 {
281 /* We are using our internal descriptors instead */
284
285 /* Use as many as are available */
287 ListDescriptor = MmGlobalMemoryDescriptors;
288 }
289
290 /* Never truncate descriptors during a list copy */
292
293 /* Iterate through the list */
294 First = SourceList->First;
295 NextEntry = First->Flink;
296 while ((NextEntry != First) && (NT_SUCCESS(Status)))
297 {
298 /* Make sure there's still space */
299 if (Count <= *Used)
300 {
302 break;
303 }
304
305 /* Get the current descriptor */
306 Descriptor = CONTAINING_RECORD(NextEntry,
308 ListEntry);
309
310 /* Copy it into one of the descriptors we have */
311 RtlCopyMemory(&ListDescriptor[*Used],
313 sizeof(*Descriptor));
314
315 /* Add it to the list we have */
316 Status = MmMdAddDescriptorToList(DestinationList,
317 &ListDescriptor[*Used],
318 Flags);
319 ++*Used;
320
321 /* Move to the next entry */
322 NextEntry = NextEntry->Flink;
323 }
324
325 /* Check if the global descriptors were used */
326 if (ListDescriptor == MmGlobalMemoryDescriptors)
327 {
328 /* Unwind our usage */
331 }
332
333 /* Return back to caller */
334 return Status;
335}
WCHAR First[]
Definition: FormatMessage.c:11
NTSTATUS MmMdAddDescriptorToList(_In_ PBL_MEMORY_DESCRIPTOR_LIST MdList, _In_ PBL_MEMORY_DESCRIPTOR MemoryDescriptor, _In_ ULONG Flags)
Definition: descriptor.c:582
ULONG MmGlobalMemoryDescriptorsUsed
Definition: descriptor.c:18
ULONG MmGlobalMemoryDescriptorCount
Definition: descriptor.c:16
PBL_MEMORY_DESCRIPTOR MmGlobalMemoryDescriptors
Definition: descriptor.c:17
VOID MmMdFreeGlobalDescriptors(VOID)
Definition: descriptor.c:1332
uint32_t * PULONG
Definition: typedefs.h:59
_In_ IN_ADDR _In_ IN_ADDR _Out_ MULTICAST_MODE_TYPE _Inout_ ULONG _Out_writes_ SourceCount IN_ADDR * SourceList
Definition: ws2tcpip.h:622

Referenced by BlMmGetMemoryMap().

◆ MmMdCountList()

ULONG MmMdCountList ( _In_ PBL_MEMORY_DESCRIPTOR_LIST  MdList)

Definition at line 205 of file descriptor.c.

208{
209 PLIST_ENTRY First, NextEntry;
210 ULONG Count;
211
212 /* Iterate the list */
213 for (Count = 0, First = MdList->First, NextEntry = First->Flink;
214 NextEntry != First;
215 NextEntry = NextEntry->Flink, Count++);
216
217 /* Return the count */
218 return Count;
219}

Referenced by BlMmGetMemoryMap().

◆ MmMdDbgDumpList()

VOID MmMdDbgDumpList ( _In_ PBL_MEMORY_DESCRIPTOR_LIST  DescriptorList,
_In_opt_ ULONG  MaxCount 
)

Definition at line 579 of file mmx86.c.

583{
584 ULONGLONG EndPage, VirtualEndPage;
586 PLIST_ENTRY NextEntry;
587
588 /* If no maximum was provided, use essentially infinite */
589 if (MaxCount == 0)
590 {
591 MaxCount = 0xFFFFFFFF;
592 }
593
594 /* Loop the list as long as there's entries and max isn't reached */
595 NextEntry = DescriptorList->First->Flink;
596 while ((NextEntry != DescriptorList->First) && (MaxCount--))
597 {
598 /* Get the descriptor */
601 ListEntry);
602
603 /* Get the descriptor end page, and see if it was virtually mapepd */
604 EndPage = MemoryDescriptor->BasePage + MemoryDescriptor->PageCount;
605 if (MemoryDescriptor->VirtualPage)
606 {
607 /* Get the virtual end page too, then */
608 VirtualEndPage = MemoryDescriptor->VirtualPage +
609 MemoryDescriptor->PageCount;
610 }
611 else
612 {
613 VirtualEndPage = 0;
614 }
615
616 /* Print out the descriptor, physical range, virtual range, and type */
617 EfiPrintf(L"%p - [%08llx-%08llx @ %08llx-%08llx]:%x\r\n",
619 MemoryDescriptor->BasePage << PAGE_SHIFT,
620 (EndPage << PAGE_SHIFT) - 1,
621 MemoryDescriptor->VirtualPage << PAGE_SHIFT,
622 VirtualEndPage ? (VirtualEndPage << PAGE_SHIFT) - 1 : 0,
623 (ULONG)MemoryDescriptor->Type);
624
625 /* Next entry */
626 NextEntry = NextEntry->Flink;
627 }
628}

◆ MmMdFindDescriptor()

PBL_MEMORY_DESCRIPTOR MmMdFindDescriptor ( _In_ ULONG  WhichList,
_In_ ULONG  Flags,
_In_ ULONGLONG  Page 
)

Definition at line 1049 of file descriptor.c.

1054{
1055 PBL_MEMORY_DESCRIPTOR FoundDescriptor;
1056
1057 /* Check if the caller is looking for mapped, allocated memory */
1058 if (WhichList & BL_MM_INCLUDE_MAPPED_ALLOCATED)
1059 {
1060 /* Find a descriptor in that list */
1062 if (FoundDescriptor)
1063 {
1064 /* Got it */
1065 return FoundDescriptor;
1066 }
1067 }
1068
1069 /* Check if the caller is looking for mapped, unallocated memory */
1070 if (WhichList & BL_MM_INCLUDE_MAPPED_UNALLOCATED)
1071 {
1072 /* Find a descriptor in that list */
1074 if (FoundDescriptor)
1075 {
1076 /* Got it */
1077 return FoundDescriptor;
1078 }
1079 }
1080
1081 /* Check if the caller is looking for unmapped, allocated memory */
1082 if (WhichList & BL_MM_INCLUDE_UNMAPPED_ALLOCATED)
1083 {
1084 /* Find a descriptor in that list */
1086 if (FoundDescriptor)
1087 {
1088 /* Got it */
1089 return FoundDescriptor;
1090 }
1091 }
1092
1093 /* Check if the caller is looking for unmapped, unallocated memory */
1094 if (WhichList & BL_MM_INCLUDE_UNMAPPED_UNALLOCATED)
1095 {
1096 /* Find a descriptor in that list */
1098 if (FoundDescriptor)
1099 {
1100 /* Got it */
1101 return FoundDescriptor;
1102 }
1103 }
1104
1105 /* Check if the caller is looking for reserved, allocated memory */
1106 if (WhichList & BL_MM_INCLUDE_RESERVED_ALLOCATED)
1107 {
1108 /* Find a descriptor in that list */
1110 if (FoundDescriptor)
1111 {
1112 /* Got it */
1113 return FoundDescriptor;
1114 }
1115 }
1116
1117 /* Check if the caller is looking for bad memory */
1118 if (WhichList & BL_MM_INCLUDE_BAD_MEMORY)
1119 {
1120 /* Find a descriptor in that list */
1121 FoundDescriptor = MmMdFindDescriptorFromMdl(&MmMdlBadMemory, Flags, Page);
1122 if (FoundDescriptor)
1123 {
1124 /* Got it */
1125 return FoundDescriptor;
1126 }
1127 }
1128
1129 /* Check if the caller is looking for truncated memory */
1130 if (WhichList & BL_MM_INCLUDE_TRUNCATED_MEMORY)
1131 {
1132 /* Find a descriptor in that list */
1134 if (FoundDescriptor)
1135 {
1136 /* Got it */
1137 return FoundDescriptor;
1138 }
1139 }
1140
1141 /* Check if the caller is looking for persistent memory */
1142 if (WhichList & BL_MM_INCLUDE_PERSISTENT_MEMORY)
1143 {
1144 /* Find a descriptor in that list */
1146 if (FoundDescriptor)
1147 {
1148 /* Got it */
1149 return FoundDescriptor;
1150 }
1151 }
1152
1153 /* Nothing if we got here */
1154 return NULL;
1155}
BL_MEMORY_DESCRIPTOR_LIST MmMdlBadMemory
Definition: pagealloc.c:41
BL_MEMORY_DESCRIPTOR_LIST MmMdlTruncatedMemory
Definition: pagealloc.c:42
PBL_MEMORY_DESCRIPTOR MmMdFindDescriptorFromMdl(_In_ PBL_MEMORY_DESCRIPTOR_LIST MdList, _In_ ULONG Flags, _In_ ULONGLONG Page)
Definition: descriptor.c:960
_In_ PVOID _Out_opt_ BOOLEAN _Out_opt_ PPFN_NUMBER Page
Definition: mm.h:1306

Referenced by BlMmMapPhysicalAddressEx(), MmArchTranslateVirtualAddress(), MmPapFreePhysicalPages(), and MmPaReleaseSelfMapPages().

◆ MmMdFindDescriptorFromMdl()

PBL_MEMORY_DESCRIPTOR MmMdFindDescriptorFromMdl ( _In_ PBL_MEMORY_DESCRIPTOR_LIST  MdList,
_In_ ULONG  Flags,
_In_ ULONGLONG  Page 
)

Definition at line 960 of file descriptor.c.

965{
966 BOOLEAN IsVirtual;
967 PLIST_ENTRY NextEntry, ListHead;
968 PBL_MEMORY_DESCRIPTOR Current;
969 ULONGLONG BasePage;
970
971 /* Assume physical */
972 IsVirtual = FALSE;
973
974 /* Check if the caller wants physical memory */
976 {
977 /* Check if this is a virtual memory list */
978 if (MdList->Type == BlMdVirtual)
979 {
980 /* We won't find anything */
981 return NULL;
982 }
983 }
984 else if (MdList->Type == BlMdPhysical)
985 {
986 /* Otherwise, caller wants virtual, but this is a physical list */
987 IsVirtual = TRUE;
988 NextEntry = MdList->First->Flink;
989 }
990
991 /* Check if this is a physical search */
992 if (!IsVirtual)
993 {
994 /* Check if we can use the current pointer */
995 NextEntry = MdList->This;
996 if (!NextEntry)
997 {
998 /* We can't -- start at the beginning */
999 NextEntry = MdList->First->Flink;
1000 }
1001 else
1002 {
1003 /* If the page is below the current pointer, restart */
1004 Current = CONTAINING_RECORD(NextEntry, BL_MEMORY_DESCRIPTOR, ListEntry);
1005 if (Page < Current->BasePage)
1006 {
1007 NextEntry = MdList->First->Flink;
1008 }
1009 }
1010 }
1011
1012 /* Loop the list of descriptors */
1013 ListHead = MdList->First;
1014 while (NextEntry != ListHead)
1015 {
1016 /* Get the current one */
1017 Current = CONTAINING_RECORD(NextEntry, BL_MEMORY_DESCRIPTOR, ListEntry);
1018
1019 /* Check if we are looking for virtual memory */
1020 if (IsVirtual)
1021 {
1022 /* Use the base address */
1023 BasePage = Current->VirtualPage;
1024 }
1025 else
1026 {
1027 /* Use the page */
1028 BasePage = Current->BasePage;
1029 }
1030
1031 /* If this is a virtual descriptor, make sure it has a base address */
1032 if ((!(IsVirtual) || (BasePage)) &&
1033 (BasePage <= Page) &&
1034 (Page < (BasePage + Current->PageCount)))
1035 {
1036 /* The descriptor fits the page being requested */
1037 return Current;
1038 }
1039
1040 /* Try the next one */
1041 NextEntry = NextEntry->Flink;
1042 }
1043
1044 /* Nothing found if we're here */
1045 return NULL;
1046}
ULONGLONG VirtualPage
Definition: bl.h:831
ULONGLONG PageCount
Definition: bl.h:839

Referenced by MmFwGetMemoryMap(), and MmMdFindDescriptor().

◆ MmMdFindSatisfyingRegion()

BOOLEAN MmMdFindSatisfyingRegion ( _In_ PBL_MEMORY_DESCRIPTOR  Descriptor,
_Out_ PBL_MEMORY_DESCRIPTOR  NewDescriptor,
_In_ ULONGLONG  Pages,
_In_ PBL_ADDRESS_RANGE  BaseRange,
_In_ PBL_ADDRESS_RANGE  VirtualRange,
_In_ BOOLEAN  TopDown,
_In_ BL_MEMORY_TYPE  MemoryType,
_In_ ULONG  Flags,
_In_ ULONG  Alignment 
)

Definition at line 1158 of file descriptor.c.

1169{
1170 ULONGLONG BaseMin, BaseMax, AlignedMin;
1171 ULONGLONG VirtualPage, BasePage;
1172 ULONGLONG BaseDelta, AlignedBase;
1173 ULONGLONG VirtualMin, VirtualMax;
1174
1175 /* Extract the minimum and maximum range */
1176 BaseMin = BaseRange->Minimum;
1177 BaseMax = BaseRange->Maximum;
1178
1179 /* Don't go below where the descriptor starts */
1180 if (BaseMin < Descriptor->BasePage)
1181 {
1182 BaseMin = Descriptor->BasePage;
1183 }
1184
1185 /* Don't go beyond where the descriptor ends */
1186 if (BaseMax > (Descriptor->BasePage + Descriptor->PageCount - 1))
1187 {
1188 BaseMax = (Descriptor->BasePage + Descriptor->PageCount - 1);
1189 }
1190
1191 /* Check for start overflow */
1192 if (BaseMin > BaseMax)
1193 {
1194 return FALSE;
1195 }
1196
1197 /* Align the base as required */
1198 if (Alignment != 1)
1199 {
1200 AlignedMin = ALIGN_UP_BY(BaseMin, Alignment);
1201 }
1202 else
1203 {
1204 AlignedMin = BaseMin;
1205 }
1206
1207 /* Check for range overflow */
1208 if (((AlignedMin + Pages - 1) < AlignedMin) || ((AlignedMin + Pages - 1) > BaseMax))
1209 {
1210 return FALSE;
1211 }
1212
1213 /* Check if this was a top-down request */
1214 if (TopDown)
1215 {
1216 /* Then get the highest page possible */
1217 BasePage = BaseMax - Pages + 1;
1218 if (Alignment != 1)
1219 {
1220 /* Align it as needed */
1221 AlignedBase = ALIGN_DOWN_BY(BasePage, Alignment);
1222 }
1223 else
1224 {
1225 AlignedBase = BasePage;
1226 }
1227
1228 /* Calculate the delta between max address and our aligned base */
1229 BaseDelta = BasePage - AlignedBase;
1230 BasePage -= BaseDelta;
1231 }
1232 else
1233 {
1234 /* Otherwise, get the lowest page possible */
1235 BasePage = AlignedMin;
1236 BaseDelta = 0;
1237 }
1238
1239 /* If a virtual address range was passed in, this must be a virtual descriptor */
1240 if (((VirtualRange->Minimum) || (VirtualRange->Maximum)) &&
1241 !(Descriptor->VirtualPage))
1242 {
1243 return FALSE;
1244 }
1245
1246 /* Any mapped page already? */
1247 if (Descriptor->VirtualPage)
1248 {
1249 /* Get virtual min/max */
1250 VirtualMin = VirtualRange->Minimum;
1251 VirtualMax = VirtualRange->Maximum;
1252
1253 /* Don't go below where the descriptor maps */
1254 if (VirtualMin <= Descriptor->VirtualPage)
1255 {
1256 VirtualMin = Descriptor->VirtualPage;
1257 }
1258
1259 /* Don't go above where the descriptor maps */
1260 if (VirtualMax >= (Descriptor->VirtualPage + Descriptor->PageCount - 1))
1261 {
1262 VirtualMax = Descriptor->VirtualPage + Descriptor->PageCount - 1;
1263 }
1264
1265 /* Don't let the base overflow */
1266 if (VirtualMin > VirtualMax)
1267 {
1268 return FALSE;
1269 }
1270
1271 /* Adjust the base by the alignment delta */
1272 VirtualMin += AlignedMin - BaseMin;
1273
1274 /* Check that the bounds don't overflow or underflow */
1275 if (((VirtualMin + Pages - 1) < VirtualMin) ||
1276 ((VirtualMin + Pages - 1) > VirtualMax))
1277 {
1278 return FALSE;
1279 }
1280
1281 /* Finally, pick the correct address based on direction */
1282 if (TopDown)
1283 {
1284 /* Highest possible base address, aligned */
1285 VirtualPage = VirtualMax - Pages + 1 - BaseDelta;
1286 }
1287 else
1288 {
1289 /* Lowest possible base address, aligned */
1290 VirtualPage = VirtualMin;
1291 }
1292 }
1293 else
1294 {
1295 /* Nothing to worry about */
1296 VirtualPage = 0;
1297 }
1298
1299 /* Bail out if the memory type attributes don't match */
1300 if ((((Flags & 0xFF) & (Descriptor->Flags & 0xFF)) != (Flags & 0xFF)) ||
1301 (((Flags & 0xFF00) & (Descriptor->Flags & 0xFF00)) != (Flags & 0xFF00)))
1302 {
1303 //EfiPrintf(L"Incorrect memory attributes\r\n");
1304 return FALSE;
1305 }
1306
1307 /* Bail out if the allocation flags don't match */
1309 {
1310 //EfiPrintf(L"Incorrect memory allocation flags\r\n");
1311 return FALSE;
1312 }
1313
1314 /* Bail out if the type doesn't match */
1315 if (Descriptor->Type != MemoryType)
1316 {
1317 //EfiPrintf(L"Incorrect descriptor type: %lx %lx\r\n", Descriptor->Type, MemoryType);
1318 return FALSE;
1319 }
1320
1321 /* We have a matching region, fill out the descriptor for it */
1322 NewDescriptor->BasePage = BasePage;
1323 NewDescriptor->PageCount = Pages;
1324 NewDescriptor->Type = Descriptor->Type;
1325 NewDescriptor->VirtualPage = VirtualPage;
1326 NewDescriptor->Flags = Descriptor->Flags;
1327 //EfiPrintf(L"Found a matching descriptor: %08I64X with %08I64X pages\r\n", BasePage, Pages);
1328 return TRUE;
1329}
#define ALIGN_DOWN_BY(size, align)

Referenced by MmPapAllocateRegionFromMdl().

◆ MmMdFreeDescriptor()

NTSTATUS MmMdFreeDescriptor ( _In_ PBL_MEMORY_DESCRIPTOR  MemoryDescriptor)

Definition at line 157 of file descriptor.c.

160{
162
163 /* Check if this is a valid static descriptor */
169 {
170 /* It's a global/static descriptor, so just zero it */
173 }
174 else
175 {
176 /* It's a dynamic descriptor, so free it */
178 }
179
180 /* Done */
181 return Status;
182}
ULONG MmDynamicMemoryDescriptorCount
Definition: descriptor.c:20
PBL_MEMORY_DESCRIPTOR MmDynamicMemoryDescriptors
Definition: descriptor.c:19
BL_MEMORY_DESCRIPTOR MmStaticMemoryDescriptors[512]
Definition: descriptor.c:15

Referenced by MmFwGetMemoryMap(), MmMdFreeList(), MmMdRemoveRegionFromMdlEx(), MmPapAllocateRegionFromMdl(), and Mmx86pMapMemoryRegions().

◆ MmMdFreeGlobalDescriptors()

VOID MmMdFreeGlobalDescriptors ( VOID  )

Definition at line 1332 of file descriptor.c.

1335{
1336 PBL_MEMORY_DESCRIPTOR Descriptor, OldDescriptor;
1337 ULONG Index = 0;
1338 PLIST_ENTRY OldFlink, OldBlink;
1339
1340 /* Make sure we're not int middle of a call using a descriptor */
1342 {
1343 return;
1344 }
1345
1346 /* Loop every current global descriptor */
1348 {
1349 /* Does it have any valid pages? */
1350 OldDescriptor = &MmGlobalMemoryDescriptors[Index];
1351 if (OldDescriptor->PageCount)
1352 {
1353 /* Allocate a copy of it */
1355 if (!Descriptor)
1356 {
1357 return;
1358 }
1359
1360 /* Save the links */
1361 OldBlink = OldDescriptor->ListEntry.Blink;
1362 OldFlink = OldDescriptor->ListEntry.Flink;
1363
1364 /* Make the copy */
1365 *Descriptor = *OldDescriptor;
1366
1367 /* Fix the links */
1368 OldBlink->Flink = &Descriptor->ListEntry;
1369 OldFlink->Blink = &Descriptor->ListEntry;
1370
1371 /* Zero the descriptor */
1372 RtlZeroMemory(OldDescriptor, sizeof(*OldDescriptor));
1373 }
1374
1375 /* Keep going */
1376 Index++;
1377 }
1378
1379 /* All global descriptors freed */
1381}
LIST_ENTRY ListEntry
Definition: bl.h:825
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122

Referenced by BlMmMapPhysicalAddressEx(), BlMmUnmapVirtualAddressEx(), BlpMmInitialize(), MmMdCopyList(), MmPapAllocatePagesInRange(), MmPapAllocatePhysicalPagesInRange(), MmPaReserveSelfMapPages(), MmPaTruncateMemory(), and TrpGenerateMappingTracker().

◆ MmMdFreeList()

VOID MmMdFreeList ( _In_ PBL_MEMORY_DESCRIPTOR_LIST  MdList)

Definition at line 356 of file descriptor.c.

359{
360 PLIST_ENTRY FirstEntry, NextEntry;
362
363 /* Go over every descriptor from the top */
364 FirstEntry = MdList->First;
365 NextEntry = FirstEntry->Flink;
366 while (NextEntry != FirstEntry)
367 {
368 /* Remove and free each one */
369 Entry = CONTAINING_RECORD(NextEntry, BL_MEMORY_DESCRIPTOR, ListEntry);
370 NextEntry = NextEntry->Flink;
373 }
374}
NTSTATUS MmMdFreeDescriptor(_In_ PBL_MEMORY_DESCRIPTOR MemoryDescriptor)
Definition: descriptor.c:157
VOID MmMdRemoveDescriptorFromList(_In_ PBL_MEMORY_DESCRIPTOR_LIST MdList, _In_ PBL_MEMORY_DESCRIPTOR Entry)
Definition: descriptor.c:338

Referenced by BlMmGetMemoryMap(), MmFwGetMemoryMap(), and MmMdRemoveRegionFromMdlEx().

◆ MmMdInitByteGranularDescriptor()

PBL_MEMORY_DESCRIPTOR MmMdInitByteGranularDescriptor ( _In_ ULONG  Flags,
_In_ BL_MEMORY_TYPE  Type,
_In_ ULONGLONG  BasePage,
_In_ ULONGLONG  VirtualPage,
_In_ ULONGLONG  PageCount 
)

Definition at line 377 of file descriptor.c.

384{
386
387 /* If we're out of descriptors, bail out */
389 {
390 EfiPrintf(L"Out of descriptors!\r\n");
391 EfiStall(1000000);
392 return NULL;
393 }
394
395 /* Take one of the available descriptors and fill it out */
397 MemoryDescriptor->BasePage = BasePage;
398 MemoryDescriptor->VirtualPage = VirtualPage;
399 MemoryDescriptor->PageCount = PageCount;
400 MemoryDescriptor->Flags = Flags;
401 MemoryDescriptor->Type = Type;
403
404 /* Increment the count and return the descriptor */
406 return MemoryDescriptor;
407}

Referenced by BlMmMapPhysicalAddressEx(), MmFwGetMemoryMap(), MmMdRemoveRegionFromMdlEx(), MmMdTruncateDescriptors(), MmPaInitialize(), MmPapAllocateRegionFromMdl(), MmPapFreePhysicalPages(), MmPapPageAllocatorExtend(), MmPaReleaseSelfMapPages(), MmTrInitialize(), and TrpGenerateMappingTracker().

◆ MmMdInitialize()

VOID MmMdInitialize ( _In_ ULONG  Phase,
_In_ PBL_LIBRARY_PARAMETERS  LibraryParameters 
)

Definition at line 1384 of file descriptor.c.

1388{
1389 /* Are we in phase 1? */
1390 if (Phase != 0)
1391 {
1392 /* Switch to dynamic descriptors if we have too many */
1393 if (LibraryParameters->DescriptorCount > RTL_NUMBER_OF(MmStaticMemoryDescriptors))
1394 {
1395 MmMdpSwitchToDynamicDescriptors(LibraryParameters->DescriptorCount);
1396 }
1397 }
1398 else
1399 {
1400 /* In phase 0, start with a pool of 512 static descriptors */
1405 }
1406}
VOID MmMdpSwitchToDynamicDescriptors(_In_ ULONG Count)
Definition: descriptor.c:148

Referenced by BlpMmInitialize().

◆ MmMdInitializeList()

VOID MmMdInitializeList ( _In_ PBL_MEMORY_DESCRIPTOR_LIST  DescriptorList,
_In_ ULONG  Type,
_In_ PLIST_ENTRY  ListHead 
)

Definition at line 222 of file descriptor.c.

227{
228 /* Check if a list was specified */
229 if (ListHead)
230 {
231 /* Use it */
232 MdList->First = ListHead;
233 }
234 else
235 {
236 /* Otherwise, use the internal, built-in list */
237 InitializeListHead(&MdList->ListHead);
238 MdList->First = &MdList->ListHead;
239 }
240
241 /* Set the type */
242 MdList->Type = Type;
243
244 /* Initialize current iterator to nothing */
245 MdList->This = NULL;
246}

Referenced by BlMmGetMemoryMap(), and MmMdRemoveRegionFromMdlEx().

◆ MmMdInitializeListHead()

FORCEINLINE VOID MmMdInitializeListHead ( _In_ PBL_MEMORY_DESCRIPTOR_LIST  List)

Definition at line 1376 of file bl.h.

1379{
1380 /* Initialize the list */
1381 InitializeListHead(&List->ListHead);
1382 List->First = &List->ListHead;
1383 List->This = NULL;
1384 List->Type = 0;
1385}

Referenced by BlMmGetMemoryMap(), MmPaInitialize(), MmTrInitialize(), and Mmx86pMapMemoryRegions().

◆ MmMdRemoveDescriptorFromList()

VOID MmMdRemoveDescriptorFromList ( _In_ PBL_MEMORY_DESCRIPTOR_LIST  MdList,
_In_ PBL_MEMORY_DESCRIPTOR  Entry 
)

Definition at line 338 of file descriptor.c.

342{
343 /* Remove the entry */
344 RemoveEntryList(&Entry->ListEntry);
345
346 /* Check if this was the current link */
347 if (MdList->This == &Entry->ListEntry)
348 {
349 /* Remove the current link and set the next one */
350 MdList->This = NULL;
351 MmMdpSaveCurrentListPointer(MdList, Entry->ListEntry.Blink);
352 }
353}

Referenced by BlMmMapPhysicalAddressEx(), MmMdFreeList(), MmMdRemoveRegionFromMdlEx(), MmMdTruncateDescriptors(), MmPapAllocateRegionFromMdl(), MmPapFreePhysicalPages(), and Mmx86pMapMemoryRegions().

◆ MmMdRemoveRegionFromMdlEx()

◆ MmMdTruncateDescriptors()

NTSTATUS MmMdTruncateDescriptors ( _In_ PBL_MEMORY_DESCRIPTOR_LIST  MdList,
_In_ PBL_MEMORY_DESCRIPTOR_LIST  NewList,
_In_ ULONGLONG  BasePage 
)

Definition at line 410 of file descriptor.c.

415{
416 PLIST_ENTRY ListHead, NextEntry;
418 ULONGLONG FoundEndPage;
419
420 /* Search the descriptor list */
421 ListHead = MdList->First;
422 NextEntry = ListHead->Flink;
423 while (NextEntry != ListHead)
424 {
425 /* Get the current descriptor */
426 Descriptor = CONTAINING_RECORD(NextEntry,
428 ListEntry);
429
430 /* Go to the next entry in case we have to remove */
431 NextEntry = NextEntry->Flink;
432
433 /* Don't touch anything else but free RAM */
434 if (((Descriptor->Type >> BL_MEMORY_CLASS_SHIFT) == BlSystemClass) &&
436 {
437 continue;
438 }
439
440 /* Check if this page is within the descriptor's region */
441 FoundEndPage = Descriptor->BasePage + Descriptor->PageCount;
442 if (BasePage > Descriptor->BasePage)
443 {
444 /* Check if it doesn't go beyond the descriptor */
445 if (BasePage < FoundEndPage)
446 {
447 /* Create a new descriptor to describe this region */
448 EfiPrintf(L"Truncating descriptor type %lx base: %llx end: %llx\r\n",
449 Descriptor->Type, Descriptor->BasePage, FoundEndPage);
451 Descriptor->Type,
452 BasePage,
453 0,
454 FoundEndPage - BasePage);
455 if (!NewDescriptor)
456 {
457 return STATUS_NO_MEMORY;
458 }
459
460 /* Cut off this descriptor to make it shorter */
461 Descriptor->PageCount = BasePage - Descriptor->BasePage;
462
463 /* Add the region to the new list */
467 }
468 }
469 else
470 {
471 /* This whole descriptor covers the truncated area */
472 EfiPrintf(L"Truncating descriptor type %lx base: %llx end: %llx\r\n",
473 Descriptor->Type, Descriptor->BasePage, FoundEndPage);
478 }
479 }
480
481 /* All good if we got here */
482 return STATUS_SUCCESS;
483}
#define BL_MEMORY_CLASS_SHIFT
Definition: bl.h:145
PBL_MEMORY_DESCRIPTOR MmMdInitByteGranularDescriptor(_In_ ULONG Flags, _In_ BL_MEMORY_TYPE Type, _In_ ULONGLONG BasePage, _In_ ULONGLONG VirtualPage, _In_ ULONGLONG PageCount)
Definition: descriptor.c:377

Referenced by MmPaTruncateMemory().

◆ MmPaInitialize()

NTSTATUS MmPaInitialize ( _In_ PBL_MEMORY_DATA  MemoryData,
_In_ ULONG  MinimumPages 
)

Referenced by BlpMmInitialize().

◆ MmPapAllocatePagesInRange()

NTSTATUS MmPapAllocatePagesInRange ( _Inout_ PVOID PhysicalAddress,
_In_ BL_MEMORY_TYPE  MemoryType,
_In_ ULONGLONG  Pages,
_In_ ULONG  Attributes,
_In_ ULONG  Alignment,
_In_opt_ PBL_ADDRESS_RANGE  Range,
_In_ ULONG  Type 
)

Definition at line 707 of file pagealloc.c.

716{
722
723 /* Increment nesting depth */
725
726 /* Default list */
728
729 /* Check for missing parameters or invalid range */
730 if (!(PhysicalAddress) ||
731 !(Pages) ||
732 ((Range) && (Range->Minimum >= Range->Maximum)))
733 {
735 goto Exit;
736 }
737
738 /* What translation mode are we using? */
740 {
741 /* Use 1 page alignment if none was requested */
742 if (!Alignment)
743 {
744 Alignment = 1;
745 }
746
747 /* Check if we got a range */
748 if (Range)
749 {
750 /* We don't support virtual memory yet @TODO */
751 EfiPrintf(L"virt range not yet implemented in %S\r\n", __FUNCTION__);
752 EfiStall(1000000);
754 goto Exit;
755 }
756 else
757 {
758 /* Use the entire range that's possible */
759 Request.BaseRange.Minimum = PapMinimumPhysicalPage;
760 Request.BaseRange.Maximum = 0xFFFFFFFF >> PAGE_SHIFT;
761 }
762
763 /* Check if a fixed allocation was requested */
765 {
766 /* We don't support virtual memory yet @TODO */
767 EfiPrintf(L"fixed not yet implemented in %S\r\n", __FUNCTION__);
768 EfiStall(1000000);
770 goto Exit;
771 }
772 else
773 {
774 /* Check if kernel range was specifically requested */
776 {
777 /* Use the kernel range */
778 Request.VirtualRange.Minimum = MmArchKsegAddressRange.Minimum >> PAGE_SHIFT;
779 Request.VirtualRange.Maximum = MmArchKsegAddressRange.Maximum >> PAGE_SHIFT;
780 }
781 else
782 {
783 /* Set the virtual address range */
784 Request.VirtualRange.Minimum = 0;
785 Request.VirtualRange.Maximum = 0xFFFFFFFF >> PAGE_SHIFT;
786 }
787 }
788
789 /* Check what type of allocation was requested */
790 if ((Type) && !(Type & ~(BL_MM_REQUEST_DEFAULT_TYPE |
792 {
793 /* Save it if it was valid */
794 Request.Type = Type;
795 }
796 else
797 {
798 /* Set the default */
800 }
801
802 /* Fill out the request of the request */
803 Request.Flags = Attributes;
804 Request.Alignment = Alignment;
805 Request.Pages = Pages;
806
807 /* Try to allocate the pages */
809 &Descriptor,
811 &Request,
812 MemoryType);
813 if (!NT_SUCCESS(Status))
814 {
815 /* Extend the physical allocator */
817 Alignment,
818 Pages,
821 Range,
822 Type);
823 if (!NT_SUCCESS(Status))
824 {
825 /* Fail since we're out of memory */
826 EfiPrintf(L"EXTEND OUT OF MEMORY: %lx\r\n", Status);
828 goto Exit;
829 }
830
831 /* Try the allocation again now */
833 &Descriptor,
835 &Request,
836 MemoryType);
837 if (!NT_SUCCESS(Status))
838 {
839 /* Fail since we're out of memory */
840 EfiPrintf(L"PALLOC OUT OF MEMORY: %lx\r\n", Status);
841 goto Exit;
842 }
843 }
844
845 /* Return the allocated address */
847 }
848 else
849 {
850 /* Check if this is a fixed allocation */
851 BaseAddress.QuadPart = (Attributes & BlMemoryFixed) ?
853
854 /* Allocate the pages */
856 MemoryType,
857 Pages,
859 Alignment,
864 Range,
865 Type);
866
867 /* Return the allocated address */
869 }
870
871Exit:
872 /* Restore the nesting depth */
875 return Status;
876}
#define BL_MM_REQUEST_DEFAULT_TYPE
Definition: bl.h:121
BL_ADDRESS_RANGE MmArchKsegAddressRange
Definition: mmx86.c:29
#define BL_MM_REQUEST_TOP_DOWN_TYPE
Definition: bl.h:122
union Alignment_ Alignment
NTSTATUS MmPapAllocatePhysicalPagesInRange(_Inout_ PPHYSICAL_ADDRESS BaseAddress, _In_ BL_MEMORY_TYPE MemoryType, _In_ ULONGLONG Pages, _In_ ULONG Attributes, _In_ ULONG Alignment, _In_ PBL_MEMORY_DESCRIPTOR_LIST NewList, _In_opt_ PBL_ADDRESS_RANGE Range, _In_ ULONG RangeType)
Definition: pagealloc.c:438
NTSTATUS MmPaAllocatePages(_In_ PBL_MEMORY_DESCRIPTOR_LIST NewList, _In_ PBL_MEMORY_DESCRIPTOR Descriptor, _In_ PBL_MEMORY_DESCRIPTOR_LIST CurrentList, _In_ PBL_PA_REQUEST Request, _In_ BL_MEMORY_TYPE MemoryType)
Definition: pagealloc.c:380
NTSTATUS MmPapPageAllocatorExtend(_In_ ULONG Attributes, _In_ ULONG Alignment, _In_ ULONGLONG PageCount, _In_ ULONGLONG VirtualPage, _In_opt_ PBL_ADDRESS_RANGE Range, _In_opt_ ULONG Type)
Definition: pagealloc.c:546
static void Exit(void)
Definition: sock.c:1330
Definition: range.c:39
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547

Referenced by BiLoadHive(), BlImgAllocateImageBuffer(), BlockIopAllocateAlignedBuffer(), BlockIopInitialize(), ImgArchEfiStartBootApplication(), MmFwGetMemoryMap(), and MmHapHeapAllocatorExtend().

◆ MmPapAllocatePhysicalPagesInRange()

NTSTATUS MmPapAllocatePhysicalPagesInRange ( _Inout_ PPHYSICAL_ADDRESS  BaseAddress,
_In_ BL_MEMORY_TYPE  MemoryType,
_In_ ULONGLONG  Pages,
_In_ ULONG  Attributes,
_In_ ULONG  Alignment,
_In_ PBL_MEMORY_DESCRIPTOR_LIST  NewList,
_In_opt_ PBL_ADDRESS_RANGE  Range,
_In_ ULONG  RangeType 
)

Definition at line 438 of file pagealloc.c.

448{
452
453 /* Increase nesting depth */
455
456 /* Bail out if no address was specified */
457 if (!BaseAddress)
458 {
460 goto Quickie;
461 }
462
463 /* Bail out if no page count was passed in, or a bad list was specified */
464 if (!(Pages) ||
465 ((NewList != &MmMdlUnmappedAllocated) &&
466 (NewList != &MmMdlPersistentMemory)))
467 {
469 goto Quickie;
470 }
471
472 /* Bail out if the passed in range is invalid */
473 if ((Range) && (Range->Minimum >= Range->Maximum))
474 {
476 goto Quickie;
477 }
478
479 /* Adjust alignment as needed */
480 if (!Alignment)
481 {
482 Alignment = 1;
483 }
484
485 /* Clear the virtual range */
486 Request.VirtualRange.Minimum = 0;
487 Request.VirtualRange.Maximum = 0;
488
489 /* Check if a fixed allocation was requested*/
491 {
492 /* Force the only available range to be the passed in address */
493 Request.BaseRange.Minimum = BaseAddress->QuadPart >> PAGE_SHIFT;
494 Request.BaseRange.Maximum = Request.BaseRange.Minimum + Pages - 1;
495 }
496 else if (Range)
497 {
498 /* Otherwise, a manual range was specified, use it */
499 Request.BaseRange.Minimum = Range->Minimum >> PAGE_SHIFT;
500 Request.BaseRange.Maximum = Request.BaseRange.Minimum +
501 (Range->Maximum >> PAGE_SHIFT) - 1;
502 }
503 else
504 {
505 /* Otherwise, use any possible range of pages */
506 Request.BaseRange.Minimum = PapMinimumPhysicalPage;
507 Request.BaseRange.Maximum = MAXULONG >> PAGE_SHIFT;
508 }
509
510 /* Check if no type was specified, or if it was invalid */
511 if (!(RangeType) ||
513 {
514 /* Use default type */
516 }
517 else
518 {
519 /* Use the requested type */
520 Request.Type = RangeType;
521 }
522
523 /* Capture the other request parameters */
524 Request.Alignment = Alignment;
525 Request.Pages = Pages;
526 Request.Flags = Attributes;
527 Status = MmPaAllocatePages(NewList,
528 &Descriptor,
530 &Request,
531 MemoryType);
532 if (NT_SUCCESS(Status))
533 {
534 /* We got a descriptor back, return its address */
535 BaseAddress->QuadPart = Descriptor.BasePage << PAGE_SHIFT;
536 }
537
538Quickie:
539 /* Restore the nesting depth */
542 return Status;
543}
#define MAXULONG
Definition: typedefs.h:251

Referenced by BlMmAllocatePhysicalPages(), BmFwMemoryInitialize(), MmDefInitializeTranslation(), MmDefpMapPhysicalAddress(), and MmPapAllocatePagesInRange().

◆ MmPapFreePages()

NTSTATUS MmPapFreePages ( _In_ PVOID  Address,
_In_ ULONG  WhichList 
)

Definition at line 1196 of file pagealloc.c.

1200{
1202
1203 /* Handle virtual memory scenario */
1205 {
1206 EfiPrintf(L"Unimplemented free virtual path: %p %lx\r\n", Address, WhichList);
1207 return STATUS_SUCCESS;
1208 }
1209
1210 /* Physical memory should be in the unmapped allocated list */
1211 if (WhichList != BL_MM_INCLUDE_PERSISTENT_MEMORY)
1212 {
1214 }
1215
1216 /* Free it from there */
1218 return MmPapFreePhysicalPages(WhichList, 0, PhysicalAddress);
1219}

Referenced by BiCloseKey(), BiLoadHive(), BlImgLoadImageWithProgress2(), BlImgUnallocateImageBuffer(), BlockIopFreeAlignedBuffer(), BlockIopInitialize(), ImgArchEfiStartBootApplication(), ImgpCloseFile(), ImgpLoadPEImage(), and MmFwGetMemoryMap().

◆ MmPaReleaseSelfMapPages()

NTSTATUS MmPaReleaseSelfMapPages ( _In_ PHYSICAL_ADDRESS  Address)

Definition at line 1505 of file pagealloc.c.

1508{
1510 ULONGLONG BasePage;
1512
1513 /* Only page-aligned addresses are accepted */
1514 if (Address.QuadPart & (PAGE_SIZE - 1))
1515 {
1516 EfiPrintf(L"free mem fail 1\r\n");
1518 }
1519
1520 /* Get the base page, and find a descriptor that matches */
1521 BasePage = Address.QuadPart >> PAGE_SHIFT;
1524 BasePage);
1525 if (!(Descriptor) || (Descriptor->BasePage != BasePage))
1526 {
1528 }
1529
1530 /* Free the physical pages */
1531 Status = MmFwFreePages(BasePage, Descriptor->PageCount);
1532 if (!NT_SUCCESS(Status))
1533 {
1534 return Status;
1535 }
1536
1537 /* Remove the firmware flags */
1538 Descriptor->Flags &= ~(BlMemoryNonFirmware |
1541
1542 /* Set it as free memory */
1544
1545 /* Create a new descriptor that's free memory, covering the old range */
1548 BasePage,
1549 0,
1550 Descriptor->PageCount);
1551 if (!Descriptor)
1552 {
1553 return STATUS_NO_MEMORY;
1554 }
1555
1556 /* Insert it into the virtual free list */
1558 Descriptor,
1561}
NTSTATUS MmFwFreePages(_In_ ULONG BasePage, _In_ ULONG PageCount)
Definition: fwutil.c:28
BL_MEMORY_DESCRIPTOR_LIST MmMdlFreeVirtual
Definition: pagealloc.c:45

Referenced by MmDefInitializeTranslation().

◆ MmPaReserveSelfMapPages()

NTSTATUS MmPaReserveSelfMapPages ( _Inout_ PPHYSICAL_ADDRESS  PhysicalAddress,
_In_ ULONG  Alignment,
_In_ ULONG  PageCount 
)

Definition at line 1564 of file pagealloc.c.

1569{
1573
1574 /* Increment descriptor usage count */
1576
1577 /* Bail if we don't have an address */
1578 if (!PhysicalAddress)
1579 {
1581 goto Quickie;
1582 }
1583
1584 /* Make a request for the required number of self-map pages */
1585 Request.BaseRange.Minimum = PapMinimumPhysicalPage;
1586 Request.BaseRange.Maximum = 0xFFFFFFFF >> PAGE_SHIFT;
1587 Request.VirtualRange.Minimum = 0;
1588 Request.VirtualRange.Maximum = 0;
1589 Request.Pages = PageCount;
1590 Request.Alignment = Alignment;
1592 Request.Flags = 0;
1594 &Descriptor,
1596 &Request,
1598 if (!NT_SUCCESS(Status))
1599 {
1600 goto Quickie;
1601 }
1602
1603 /* Remove this region from free virtual memory */
1606 Descriptor.BasePage,
1607 Descriptor.PageCount,
1608 0);
1609 if (!NT_SUCCESS(Status))
1610 {
1611 goto Quickie;
1612 }
1613
1614 /* Return the physical address */
1616
1617Quickie:
1618 /* Free global descriptors and reduce the count by one */
1621 return Status;
1622}

Referenced by MmDefInitializeTranslation().

◆ MmPaTruncateMemory()

NTSTATUS MmPaTruncateMemory ( _In_ ULONGLONG  BasePage)

Definition at line 51 of file pagealloc.c.

54{
56
57 /* Increase nesting depth */
59
60 /* Set the maximum page to the truncated request */
61 if (BasePage < PapMaximumPhysicalPage)
62 {
63 PapMaximumPhysicalPage = BasePage;
64 }
65
66 /* Truncate mapped and allocated memory */
69 BasePage);
70 if (NT_SUCCESS(Status))
71 {
72 /* Truncate unmapped and allocated memory */
75 BasePage);
76 if (NT_SUCCESS(Status))
77 {
78 /* Truncate mapped and unallocated memory */
81 BasePage);
82 if (NT_SUCCESS(Status))
83 {
84 /* Truncate unmapped and unallocated memory */
87 BasePage);
88 if (NT_SUCCESS(Status))
89 {
90 /* Truncate reserved memory */
93 BasePage);
94 }
95 }
96 }
97 }
98
99 /* Restore the nesting depth */
102 return Status;
103}
NTSTATUS MmMdTruncateDescriptors(_In_ PBL_MEMORY_DESCRIPTOR_LIST MdList, _In_ PBL_MEMORY_DESCRIPTOR_LIST NewList, _In_ ULONGLONG BasePage)
Definition: descriptor.c:410
ULONGLONG PapMaximumPhysicalPage
Definition: pagealloc.c:29

Referenced by BlpMmInitializeConstraints(), and MmDefInitializeTranslation().

◆ MmSelectMappingAddress()

NTSTATUS MmSelectMappingAddress ( _Out_ PVOID MappingAddress,
_In_ PVOID  PreferredAddress,
_In_ ULONGLONG  Size,
_In_ ULONG  AllocationAttributes,
_In_ ULONG  Flags,
_In_ PHYSICAL_ADDRESS  PhysicalAddress 
)

Definition at line 1625 of file pagealloc.c.

1633{
1637
1638 /* Are we in physical mode? */
1640 {
1641 /* Just return the physical address as the mapping address */
1642 PreferredAddress = PhysicalAddressToPtr(PhysicalAddress);
1643 goto Success;
1644 }
1645
1646 /* If no physical address, or caller wants a fixed address... */
1647 if ((PhysicalAddress.QuadPart == -1) || (Flags & BlMemoryFixed))
1648 {
1649 /* Then just return the preferred address */
1650 goto Success;
1651 }
1652
1653 /* Check which range of virtual memory should be used */
1655 {
1656 /* Use kernel range */
1657 Request.BaseRange.Minimum = MmArchKsegAddressRange.Minimum >> PAGE_SHIFT;
1658 Request.BaseRange.Maximum = MmArchKsegAddressRange.Maximum >> PAGE_SHIFT;
1660 }
1661 else
1662 {
1663 /* User user/application range */
1664 Request.BaseRange.Minimum = 0 >> PAGE_SHIFT;
1667 }
1668
1669 /* Build a request */
1670 Request.VirtualRange.Minimum = 0;
1671 Request.VirtualRange.Maximum = 0;
1673 Request.Alignment = 1;
1675
1676 /* Allocate the physical pages */
1680 &Request,
1682 if (!NT_SUCCESS(Status))
1683 {
1684 return Status;
1685 }
1686
1687 /* Return the address we got back */
1688 PreferredAddress = (PVOID)((ULONG_PTR)NewDescriptor.BasePage << PAGE_SHIFT);
1689
1690 /* Check if the existing physical address was not aligned */
1691 if (PhysicalAddress.QuadPart != -1)
1692 {
1693 /* Add the offset to the returned virtual address */
1694 PreferredAddress = (PVOID)((ULONG_PTR)PreferredAddress +
1696 }
1697
1698Success:
1699 /* Return the mapping address and success */
1700 *MappingAddress = PreferredAddress;
1701 return STATUS_SUCCESS;
1702}
ULONG_PTR MmArchTopOfApplicationAddressSpace
Definition: mmx86.c:30
@ Success
Definition: eventcreate.c:712
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ ULONG AllocationAttributes
Definition: mmfuncs.h:364
#define BYTE_OFFSET(Va)
#define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, _Size)

Referenced by BlMmMapPhysicalAddressEx().

◆ MmUnmapVirtualAddress()

NTSTATUS MmUnmapVirtualAddress ( _Inout_ PVOID VirtualAddress,
_Inout_ PULONGLONG  Size 
)

Definition at line 453 of file mm.c.

457{
459
460 /* Make sure parameters were passed in and are valid */
461 if ((VirtualAddress) && (Size) && (*Size <= 0xFFFFFFFF))
462 {
463 /* Nothing to do if translation isn't active */
465 {
467 }
468 else
469 {
470 /* We don't support virtual memory yet @TODO */
471 EfiPrintf(L"unmap not yet implemented in %S\r\n", __FUNCTION__);
472 EfiStall(1000000);
474 }
475 }
476 else
477 {
478 /* Fail */
480 }
481
482 /* All done */
483 return Status;
484}

Referenced by BlMmMapPhysicalAddressEx(), BlMmUnmapVirtualAddressEx(), and Mmx86MapInitStructure().

◆ PhysicalAddressToPtr()

◆ TblDoNotPurgeEntry()

NTSTATUS TblDoNotPurgeEntry ( _In_ PVOID  Entry)

Definition at line 495 of file util.c.

498{
499 /* Never purge this entry */
500 return STATUS_UNSUCCESSFUL;
501}

Referenced by BlHtCreate(), BlImgLoadBootApplication(), BlockIoFirmwareOpen(), BlpIoRegisterDestroyRoutine(), and EtfsMount().

Variable Documentation

◆ BlMmFlushTlb

PBL_MM_FLUSH_TLB BlMmFlushTlb
extern

Definition at line 48 of file mmx86.c.

Referenced by MmArchInitialize().

◆ BlMmMoveVirtualAddressRange

PBL_MM_MOVE_VIRTUAL_ADDRESS_RANGE BlMmMoveVirtualAddressRange
extern

Definition at line 17 of file arch.c.

Referenced by MmArchInitialize(), and OslArchKernelSetup().

◆ BlMmRelocateSelfMap

PBL_MM_RELOCATE_SELF_MAP BlMmRelocateSelfMap
extern

Definition at line 16 of file arch.c.

Referenced by MmArchInitialize(), and OslArchKernelSetup().

◆ BlMmZeroVirtualAddressRange

PBL_MM_ZERO_VIRTUAL_ADDRESS_RANGE BlMmZeroVirtualAddressRange
extern

Definition at line 18 of file arch.c.

Referenced by MmArchInitialize(), and OslArchKernelSetup().

◆ BlpApplicationEntry

◆ BlpApplicationFlags

ULONG BlpApplicationFlags
extern

◆ BlpBootDevice

◆ BlpLibraryParameters

◆ BlpStatusErrorHandler

PBL_STATUS_ERROR_HANDLER BlpStatusErrorHandler
extern

Definition at line 20 of file debug.c.

Referenced by BlStatusError(), and OslPrepareTarget().

◆ BlpTimePerformanceFrequency

ULONGLONG BlpTimePerformanceFrequency
extern

◆ BlScratchBuffer

WCHAR BlScratchBuffer[8192]
extern

Definition at line 39 of file firmware.c.

Referenced by BlStatusPrint(), and EfiPrintf().

◆ ConsoleGraphicalResolutionList

BL_DISPLAY_MODE ConsoleGraphicalResolutionList[]
extern

Definition at line 22 of file display.c.

Referenced by ConsoleEfiGopOpen(), and DsppInitialize().

◆ ConsoleGraphicalResolutionListFlags

ULONG ConsoleGraphicalResolutionListFlags
extern

Definition at line 21 of file display.c.

Referenced by ConsoleEfiGopOpen(), DsppInitialize(), and DsppReinitialize().

◆ ConsoleGraphicalResolutionListSize

ULONG ConsoleGraphicalResolutionListSize
extern

Definition at line 28 of file display.c.

Referenced by ConsoleEfiGopOpen().

◆ ConsoleTextResolutionList

BL_DISPLAY_MODE ConsoleTextResolutionList[]
extern

Definition at line 30 of file display.c.

Referenced by ConsoleFirmwareTextOpen().

◆ CurrentExecutionContext

◆ DspLocalInputConsole

PVOID DspLocalInputConsole
extern

◆ DspRemoteInputConsole

PVOID DspRemoteInputConsole
extern

Definition at line 35 of file display.c.

Referenced by ConsoleCreateRemoteConsole(), DsppInitialize(), and DsppReinitialize().

◆ EfiBlockIoProtocol

◆ EfiConInEx

Definition at line 25 of file firmware.c.

Referenced by BlpFwInitialize(), ConsoleInputLocalEraseBuffer(), and EfiConInExReset().

◆ EfiConOut

Definition at line 23 of file firmware.c.

Referenced by BlpFwInitialize(), ConsoleFirmwareTextOpen(), and EfiPrintf().

◆ EfiDevicePathProtocol

◆ EfiGlobalVariable

EFI_GUID EfiGlobalVariable
extern

Definition at line 36 of file firmware.c.

Referenced by BlpSecureBootEFIIsEnabled().

◆ EfiGraphicsOutputProtocol

EFI_GUID EfiGraphicsOutputProtocol
extern

◆ EfiLoadedImageProtocol

EFI_GUID EfiLoadedImageProtocol
extern

Definition at line 30 of file firmware.c.

Referenced by EfiInitCreateInputParametersEx(), and UefiMemGetMemoryMap().

◆ EfiRootAcpiTable10Guid

EFI_GUID EfiRootAcpiTable10Guid
extern

Definition at line 35 of file firmware.c.

Referenced by EfipGetRsdt().

◆ EfiRootAcpiTableGuid

EFI_GUID EfiRootAcpiTableGuid
extern

Definition at line 34 of file firmware.c.

Referenced by EfipGetRsdt().

◆ EfiSimpleTextInputExProtocol

EFI_GUID EfiSimpleTextInputExProtocol
extern

Definition at line 32 of file firmware.c.

Referenced by BlpFwInitialize().

◆ EfiUgaDrawProtocol

EFI_GUID EfiUgaDrawProtocol
extern

Definition at line 29 of file firmware.c.

Referenced by ConsoleEfiGraphicalOpenProtocol().

◆ MmArchKsegAddressRange

BL_ADDRESS_RANGE MmArchKsegAddressRange
extern

Definition at line 29 of file mmx86.c.

Referenced by MmArchInitialize(), MmPapAllocatePagesInRange(), and MmSelectMappingAddress().

◆ MmArchTopOfApplicationAddressSpace

ULONG_PTR MmArchTopOfApplicationAddressSpace
extern

Definition at line 30 of file mmx86.c.

Referenced by MmArchInitialize(), and MmSelectMappingAddress().

◆ MmDescriptorCallTreeCount

◆ MmMdlBadMemory

BL_MEMORY_DESCRIPTOR_LIST MmMdlBadMemory
extern

Definition at line 41 of file pagealloc.c.

Referenced by BlMmGetMemoryMap(), MmMdFindDescriptor(), and MmPaInitialize().

◆ MmMdlCompleteBadMemory

BL_MEMORY_DESCRIPTOR_LIST MmMdlCompleteBadMemory
extern

Definition at line 44 of file pagealloc.c.

Referenced by MmPaInitialize().

◆ MmMdlFreeVirtual

◆ MmMdlFwAllocationTracker

BL_MEMORY_DESCRIPTOR_LIST MmMdlFwAllocationTracker
extern

Definition at line 37 of file pagealloc.c.

Referenced by MmPaInitialize(), and MmPapPageAllocatorExtend().

◆ MmMdlMappedAllocated

◆ MmMdlMappedUnallocated

◆ MmMdlMappingTrackers

BL_MEMORY_DESCRIPTOR_LIST MmMdlMappingTrackers
extern

Definition at line 46 of file pagealloc.c.

Referenced by MmTrInitialize(), and TrpGenerateMappingTracker().

◆ MmMdlPersistentMemory

◆ MmMdlReservedAllocated

◆ MmMdlTruncatedMemory

BL_MEMORY_DESCRIPTOR_LIST MmMdlTruncatedMemory
extern

◆ MmMdlUnmappedAllocated

◆ MmMdlUnmappedUnallocated

◆ MmTranslationType

◆ RegisteredFileSystems

LIST_ENTRY RegisteredFileSystems
extern

Definition at line 18 of file file.c.

Referenced by BlpFileInitialize(), BlpFileRegisterFileSystem(), and FileIoOpen().