ReactOS 0.4.15-dev-7998-gdb93cb1
firmware.c File Reference
#include "bl.h"
Include dependency graph for firmware.c:

Go to the source code of this file.

Classes

struct  _BL_EFI_PROTOCOL
 

Typedefs

typedef struct _BL_EFI_PROTOCOL BL_EFI_PROTOCOL
 
typedef struct _BL_EFI_PROTOCOLPBL_EFI_PROTOCOL
 

Functions

EFI_DEVICE_PATHEfiIsDevicePathParent (_In_ EFI_DEVICE_PATH *DevicePath1, _In_ EFI_DEVICE_PATH *DevicePath2)
 
EFI_DEVICE_PATHEfiGetLeafNode (_In_ EFI_DEVICE_PATH *DevicePath)
 
VOID EfiPrintf (_In_ PWCHAR Format,...)
 
NTSTATUS EfiVmOpenProtocol (_In_ EFI_HANDLE Handle, _In_ EFI_GUID *Protocol, _Outptr_ PVOID *Interface)
 
NTSTATUS EfiOpenProtocol (_In_ EFI_HANDLE Handle, _In_ EFI_GUID *Protocol, _Outptr_ PVOID *Interface)
 
NTSTATUS EfiVmpCloseProtocol (_In_ EFI_HANDLE Handle, _In_ EFI_GUID *Protocol)
 
NTSTATUS EfiVmpFreeInterfaceEntry (_In_ EFI_HANDLE Handle, _In_ PBL_EFI_PROTOCOL EfiProtocol)
 
NTSTATUS EfiVmCloseProtocol (_In_ EFI_HANDLE Handle, _In_ EFI_GUID *Protocol)
 
NTSTATUS EfiCloseProtocol (_In_ EFI_HANDLE Handle, _In_ EFI_GUID *Protocol)
 
NTSTATUS EfiGetVariable (_In_ PWCHAR VariableName, _In_ EFI_GUID *VendorGuid, _Out_opt_ PULONG Attributes, _Inout_ PULONG DataSize, _Out_ PVOID Data)
 
NTSTATUS BlpSecureBootEFIIsEnabled (VOID)
 
NTSTATUS BlSecureBootIsEnabled (_Out_ PBOOLEAN SecureBootEnabled)
 
NTSTATUS BlSecureBootCheckForFactoryReset (VOID)
 
NTSTATUS EfiConInReset (VOID)
 
NTSTATUS EfiConInExReset (VOID)
 
NTSTATUS EfiConInExSetState (_In_ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *ConInEx, _In_ EFI_KEY_TOGGLE_STATE *KeyToggleState)
 
NTSTATUS EfiSetWatchdogTimer (VOID)
 
NTSTATUS EfiGetMemoryMap (_Out_ UINTN *MemoryMapSize, _Inout_ EFI_MEMORY_DESCRIPTOR *MemoryMap, _Out_ UINTN *MapKey, _Out_ UINTN *DescriptorSize, _Out_ UINTN *DescriptorVersion)
 
NTSTATUS EfiFreePages (_In_ ULONG Pages, _In_ EFI_PHYSICAL_ADDRESS PhysicalAddress)
 
NTSTATUS EfiStall (_In_ ULONG StallTime)
 
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)
 
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 EfiConOutOutputString (_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface, _In_ PWCHAR String)
 
VOID EfiConOutReadCurrentMode (_In_ SIMPLE_TEXT_OUTPUT_INTERFACE *TextInterface, _Out_ EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode)
 
VOID EfiGopGetFrameBuffer (_In_ EFI_GRAPHICS_OUTPUT_PROTOCOL *GopInterface, _Out_ PHYSICAL_ADDRESS *FrameBuffer, _Out_ UINTN *FrameBufferSize)
 
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)
 
NTSTATUS EfiLocateHandleBuffer (_In_ EFI_LOCATE_SEARCH_TYPE SearchType, _In_ EFI_GUID *Protocol, _Inout_ PULONG HandleCount, _Inout_ EFI_HANDLE **Buffer)
 
VOID EfiResetSystem (_In_ EFI_RESET_TYPE ResetType)
 
NTSTATUS EfiConnectController (_In_ EFI_HANDLE ControllerHandle)
 
NTSTATUS EfiAllocatePages (_In_ ULONG Type, _In_ ULONG Pages, _Inout_ EFI_PHYSICAL_ADDRESS *Memory)
 
NTSTATUS EfipGetSystemTable (_In_ EFI_GUID *TableGuid, _Out_ PPHYSICAL_ADDRESS TableAddress)
 
NTSTATUS EfipGetRsdt (_Out_ PPHYSICAL_ADDRESS FoundRsdt)
 
BL_MEMORY_ATTR MmFwpGetOsAttributeType (_In_ ULONGLONG Attribute)
 
BL_MEMORY_TYPE MmFwpGetOsMemoryType (_In_ EFI_MEMORY_TYPE MemoryType)
 
NTSTATUS MmFwGetMemoryMap (_Out_ PBL_MEMORY_DESCRIPTOR_LIST MemoryMap, _In_ ULONG Flags)
 
NTSTATUS BlpFwInitialize (_In_ ULONG Phase, _In_ PBL_FIRMWARE_DESCRIPTOR FirmwareData)
 
NTSTATUS BlFwGetParameters (_In_ PBL_FIRMWARE_DESCRIPTOR Parameters)
 
NTSTATUS BlFwEnumerateDevice (_In_ PBL_DEVICE_DESCRIPTOR Device)
 
EFI_STATUS EfiGetEfiStatusCode (_In_ NTSTATUS Status)
 
NTSTATUS EfiGetNtStatusCode (_In_ EFI_STATUS EfiStatus)
 

Variables

PBL_FIRMWARE_DESCRIPTOR EfiFirmwareParameters
 
BL_FIRMWARE_DESCRIPTOR EfiFirmwareData
 
EFI_HANDLE EfiImageHandle
 
EFI_SYSTEM_TABLEEfiSystemTable
 
EFI_SYSTEM_TABLEEfiST
 
EFI_BOOT_SERVICESEfiBS
 
EFI_RUNTIME_SERVICESEfiRT
 
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOLEfiConOut
 
EFI_SIMPLE_TEXT_INPUT_PROTOCOLEfiConIn
 
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOLEfiConInEx
 
PHYSICAL_ADDRESS EfiRsdt
 
EFI_GUID EfiGraphicsOutputProtocol = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID
 
EFI_GUID EfiUgaDrawProtocol = EFI_UGA_DRAW_PROTOCOL_GUID
 
EFI_GUID EfiLoadedImageProtocol = EFI_LOADED_IMAGE_PROTOCOL_GUID
 
EFI_GUID EfiDevicePathProtocol = EFI_DEVICE_PATH_PROTOCOL_GUID
 
EFI_GUID EfiSimpleTextInputExProtocol = EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID
 
EFI_GUID EfiBlockIoProtocol = EFI_BLOCK_IO_PROTOCOL_GUID
 
EFI_GUID EfiRootAcpiTableGuid = EFI_ACPI_20_TABLE_GUID
 
EFI_GUID EfiRootAcpiTable10Guid = EFI_ACPI_TABLE_GUID
 
EFI_GUID EfiGlobalVariable = EFI_GLOBAL_VARIABLE
 
EFI_GUID BlpEfiSecureBootPrivateNamespace = { 0x77FA9ABD , 0x0359, 0x4D32, { 0xBD, 0x60, 0x28, 0xF4, 0xE7, 0x8F, 0x78, 0x4B } }
 
WCHAR BlScratchBuffer [8192]
 
BOOLEAN BlpFirmwareChecked
 
BOOLEAN BlpFirmwareEnabled
 
BOOLEAN EfiProtHashTableInitialized
 
ULONG EfiProtHashTableId
 

Typedef Documentation

◆ BL_EFI_PROTOCOL

◆ PBL_EFI_PROTOCOL

Function Documentation

◆ 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
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS BlockIoEfiCompareDevice(_In_ PBL_DEVICE_DESCRIPTOR Device, _In_ EFI_HANDLE Handle)
Definition: device.c:1268
@ LegacyPartitionDevice
Definition: bl.h:248
@ DiskDevice
Definition: bl.h:247
@ PartitionDevice
Definition: bl.h:252
NTSTATUS BlMmFreeHeap(_In_ PVOID Buffer)
Definition: heapalloc.c:663
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 NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:25
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
#define STATUS_NOT_FOUND
Definition: shellext.h:72
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474

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
#define STATUS_SUCCESS
Definition: shellext.h:65
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869

Referenced by ImgpInitializeBootApplicationParameters().

◆ BlpFwInitialize()

NTSTATUS BlpFwInitialize ( _In_ ULONG  Phase,
_In_ PBL_FIRMWARE_DESCRIPTOR  FirmwareData 
)

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().

◆ 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}
unsigned char BOOLEAN
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 TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4755
#define STATUS_INVALID_SIGNATURE
Definition: ntstatus.h:1172
#define L(x)
Definition: ntvdm.h:50

Referenced by BlSecureBootIsEnabled().

◆ 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
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69

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().

◆ 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}
Type
Definition: Type.h:7
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:52
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:31
@ EfiLoaderData
VOID BlpArchSwitchContext(_In_ BL_ARCH_MODE NewMode)
Definition: arch.c:166
PBL_ARCH_CONTEXT CurrentExecutionContext
Definition: arch.c:17
FORCEINLINE PVOID PhysicalAddressToPtr(_In_ PHYSICAL_ADDRESS PhysicalAddress)
Definition: bl.h:1389
@ BlRealMode
Definition: bl.h:239
BOOLEAN BlMmTranslateVirtualAddress(_In_ PVOID VirtualAddress, _Out_ PPHYSICAL_ADDRESS PhysicalAddress)
Definition: mm.c:525
enum _BL_ARCH_MODE BL_ARCH_MODE
NTSTATUS EfiGetNtStatusCode(_In_ EFI_STATUS EfiStatus)
Definition: firmware.c:2539
EFI_ALLOCATE_PAGES AllocatePages
Definition: UefiSpec.h:1810
BL_ARCH_MODE Mode
Definition: bl.h:999
_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
@ BlNone
Definition: bl.h:230
BL_TRANSLATION_TYPE MmTranslationType
Definition: mm.c:17
NTSTATUS EfiVmCloseProtocol(_In_ EFI_HANDLE Handle, _In_ EFI_GUID *Protocol)
Definition: firmware.c:522
ULONG Handle
Definition: gdb_input.c:15
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().

◆ EfiConInExSetState()

NTSTATUS EfiConInExSetState ( _In_ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL ConInEx,
_In_ EFI_KEY_TOGGLE_STATE KeyToggleState 
)

Definition at line 856 of file firmware.c.

860{
861 BL_ARCH_MODE OldMode;
862 EFI_STATUS EfiStatus;
863 PHYSICAL_ADDRESS ConInExPhys, KeyTogglePhys;
864
865 /* Are we in protected mode? */
866 OldMode = CurrentExecutionContext->Mode;
867 if (OldMode != BlRealMode)
868 {
869 /* Translate pointers from virtual to physical */
870 BlMmTranslateVirtualAddress(ConInEx, &ConInExPhys);
872 BlMmTranslateVirtualAddress(KeyToggleState, &KeyTogglePhys);
873 KeyToggleState = (EFI_KEY_TOGGLE_STATE*)PhysicalAddressToPtr(KeyTogglePhys);
874
875 /* Switch to real mode */
877 }
878
879 /* Make the EFI call */
880 EfiStatus = ConInEx->SetState(ConInEx, KeyToggleState);
881
882 /* Switch back to protected mode if we came from there */
883 if (OldMode != BlRealMode)
884 {
885 BlpArchSwitchContext(OldMode);
886 }
887
888 /* Convert the error to an NTSTATUS */
889 return EfiGetNtStatusCode(EfiStatus);
890}

Referenced by BlpFwInitialize().

◆ 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().

◆ EfiConnectController()

NTSTATUS EfiConnectController ( _In_ EFI_HANDLE  ControllerHandle)

Definition at line 1530 of file firmware.c.

1533{
1534 BL_ARCH_MODE OldMode;
1535 EFI_STATUS EfiStatus;
1536
1537 /* Is this EFI 1.02? */
1539 {
1540 /* This function didn't exist back then */
1541 return STATUS_NOT_SUPPORTED;
1542 }
1543
1544 /* Are we in protected mode? */
1545 OldMode = CurrentExecutionContext->Mode;
1546 if (OldMode != BlRealMode)
1547 {
1548 /* FIXME: Not yet implemented */
1549 EfiPrintf(L"connectctrl vm path\r\n");
1550 EfiStall(10000000);
1552 }
1553
1554 /* Make the EFI call */
1555 EfiStatus = EfiBS->ConnectController(ControllerHandle, NULL, NULL, TRUE);
1556
1557 /* Switch back to protected mode if we came from there */
1558 if (OldMode != BlRealMode)
1559 {
1560 BlpArchSwitchContext(OldMode);
1561 }
1562
1563 /* Convert the error to an NTSTATUS */
1564 return EfiGetNtStatusCode(EfiStatus);
1565}
EFI_CONNECT_CONTROLLER ConnectController
Definition: UefiSpec.h:1858
EFI_TABLE_HEADER Hdr
Definition: UefiSpec.h:1912

Referenced by BlFwEnumerateDevice().

◆ 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}
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433

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 Mode
Definition: hubbusif.h:303
_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}
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

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
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1098

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_DEVICE_NOT_READY
Definition: shellext.h:70
#define STATUS_IO_DEVICE_ERROR
Definition: udferr_usr.h:179
#define STATUS_MEDIA_WRITE_PROTECTED
Definition: udferr_usr.h:161
#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
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158

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().

◆ EfiGetMemoryMap()

NTSTATUS EfiGetMemoryMap ( _Out_ UINTN MemoryMapSize,
_Inout_ EFI_MEMORY_DESCRIPTOR MemoryMap,
_Out_ UINTN MapKey,
_Out_ UINTN DescriptorSize,
_Out_ UINTN DescriptorVersion 
)

Definition at line 922 of file firmware.c.

929{
930 BL_ARCH_MODE OldMode;
931 EFI_STATUS EfiStatus;
932 PHYSICAL_ADDRESS MemoryMapSizePhysical, MemoryMapPhysical, MapKeyPhysical;
933 PHYSICAL_ADDRESS DescriptorSizePhysical, DescriptorVersionPhysical;
934
935 /* Are we in protected mode? */
936 OldMode = CurrentExecutionContext->Mode;
937 if (OldMode != BlRealMode)
938 {
939 /* Convert all of the addresses to physical */
940 BlMmTranslateVirtualAddress(MemoryMapSize, &MemoryMapSizePhysical);
941 MemoryMapSize = (UINTN*)PhysicalAddressToPtr(MemoryMapSizePhysical);
942 BlMmTranslateVirtualAddress(MemoryMap, &MemoryMapPhysical);
944 BlMmTranslateVirtualAddress(MapKey, &MapKeyPhysical);
945 MapKey = (UINTN*)PhysicalAddressToPtr(MapKeyPhysical);
946 BlMmTranslateVirtualAddress(DescriptorSize, &DescriptorSizePhysical);
947 DescriptorSize = (UINTN*)PhysicalAddressToPtr(DescriptorSizePhysical);
948 BlMmTranslateVirtualAddress(DescriptorVersion, &DescriptorVersionPhysical);
949 DescriptorVersion = (UINTN*)PhysicalAddressToPtr(DescriptorVersionPhysical);
950
951 /* Switch to real mode */
953 }
954
955 /* Make the EFI call */
956 EfiStatus = EfiBS->GetMemoryMap(MemoryMapSize,
957 MemoryMap,
958 MapKey,
960 DescriptorVersion);
961
962 /* Switch back to protected mode if we came from there */
963 if (OldMode != BlRealMode)
964 {
965 BlpArchSwitchContext(OldMode);
966 }
967
968 /* Convert the error to an NTSTATUS */
969 return EfiGetNtStatusCode(EfiStatus);
970}
UINT32 UINTN
BIOS_MEMORY_MAP MemoryMap[32]
Definition: loader.c:11
EFI_GET_MEMORY_MAP GetMemoryMap
Definition: UefiSpec.h:1812
_In_ SIZE_T DescriptorSize
Definition: nls.c:40

Referenced by MmFwGetMemoryMap().

◆ 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
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

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().

◆ EfiGetVariable()

NTSTATUS EfiGetVariable ( _In_ PWCHAR  VariableName,
_In_ EFI_GUID VendorGuid,
_Out_opt_ PULONG  Attributes,
_Inout_ PULONG  DataSize,
_Out_ PVOID  Data 
)

Definition at line 639 of file firmware.c.

646{
647 EFI_STATUS EfiStatus;
649 BL_ARCH_MODE OldMode;
650 ULONG LocalAttributes;
651
652 /* Are we in protected mode? */
653 OldMode = CurrentExecutionContext->Mode;
654 if (OldMode != BlRealMode)
655 {
656 /* FIXME: Not yet implemented */
657 EfiPrintf(L"getvar vm path\r\n");
658 EfiStall(10000000);
660 }
661
662 /* Call the runtime API */
663 EfiStatus = EfiRT->GetVariable(VariableName,
664 VendorGuid,
665 (UINT32*)&LocalAttributes,
666 (UINTN*)DataSize,
667 Data);
668
669 /* Switch back to protected mode if we came from there */
670 if (OldMode != BlRealMode)
671 {
672 BlpArchSwitchContext(OldMode);
673 }
674
675 /* Return attributes back to the caller if asked to */
676 if (Attributes)
677 {
678 *Attributes = LocalAttributes;
679 }
680
681 /* Convert the error to an NTSTATUS and return it */
682 Status = EfiGetNtStatusCode(EfiStatus);
683 return Status;
684}
unsigned int UINT32
EFI_GET_VARIABLE GetVariable
Definition: UefiSpec.h:1766
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes

Referenced by BlpSecureBootEFIIsEnabled(), and BlSecureBootCheckForFactoryReset().

◆ 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}
ULONG FrameBufferSize
Definition: xboxvideo.c:29
PVOID FrameBuffer
Definition: xboxvideo.c:28

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
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
unsigned short USHORT
Definition: pedump.c:61

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
PVOID BlMmAllocateHeap(_In_ SIZE_T Size)
Definition: heapalloc.c:569
Definition: bufpool.h:45
#define BufferSize
Definition: mmc.h:75
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
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
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

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

◆ EfiOpenProtocol()

NTSTATUS EfiOpenProtocol ( _In_ EFI_HANDLE  Handle,
_In_ EFI_GUID Protocol,
_Outptr_ PVOID Interface 
)

Definition at line 369 of file firmware.c.

374{
375 EFI_STATUS EfiStatus;
377 BL_ARCH_MODE OldMode;
378
379 /* Are we using virtual memory/ */
381 {
382 /* We need complex tracking to make this work */
384 }
385 else
386 {
387 /* Are we in protected mode? */
388 OldMode = CurrentExecutionContext->Mode;
389 if (OldMode != BlRealMode)
390 {
391 /* Switch to real mode */
393 }
394
395 /* Are we on legacy 1.02? */
397 {
398 /* Make the legacy call */
400 }
401 else
402 {
403 /* Use the UEFI version */
404 EfiStatus = EfiBS->OpenProtocol(Handle,
405 Protocol,
406 Interface,
408 NULL,
410
411 /* Switch back to protected mode if we came from there */
412 if (OldMode != BlRealMode)
413 {
414 BlpArchSwitchContext(OldMode);
415 }
416 }
417
418 /* Convert the error to an NTSTATUS */
419 Status = EfiGetNtStatusCode(EfiStatus);
420 }
421
422 /* Clear the interface on failure, and return the status */
423 if (!NT_SUCCESS(Status))
424 {
425 *Interface = NULL;
426 }
427
428 return Status;
429}
#define EFI_OPEN_PROTOCOL_GET_PROTOCOL
Definition: UefiSpec.h:1251
NTSTATUS EfiVmOpenProtocol(_In_ EFI_HANDLE Handle, _In_ EFI_GUID *Protocol, _Outptr_ PVOID *Interface)
Definition: firmware.c:176
EFI_HANDLE_PROTOCOL HandleProtocol
Definition: UefiSpec.h:1832
EFI_OPEN_PROTOCOL OpenProtocol
Definition: UefiSpec.h:1864
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465

Referenced by BlpFwInitialize().

◆ 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}
NTSTATUS BlMmUnmapVirtualAddressEx(_In_ PVOID VirtualAddress, _In_ ULONGLONG Size)
Definition: mm.c:487
NTSTATUS BlMmMapPhysicalAddressEx(_In_ PVOID *VirtualAddress, _In_ ULONG Attributes, _In_ ULONGLONG Size, _In_ PHYSICAL_ADDRESS PhysicalAddress)
Definition: mm.c:192
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
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
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
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by BlUtlGetAcpiTable().

◆ EfipGetSystemTable()

NTSTATUS EfipGetSystemTable ( _In_ EFI_GUID TableGuid,
_Out_ PPHYSICAL_ADDRESS  TableAddress 
)

Definition at line 1604 of file firmware.c.

1608{
1609 ULONG i;
1611
1612 /* Assume failure */
1614
1615 /* Loop through the configuration tables */
1616 for (i = 0; i < EfiST->NumberOfTableEntries; i++)
1617 {
1618 /* Check if this one matches the one we want */
1620 TableGuid,
1621 sizeof(*TableGuid)))
1622 {
1623 /* Return its address */
1624 TableAddress->QuadPart = (ULONG_PTR)EfiST->ConfigurationTable[i].VendorTable;
1626 break;
1627 }
1628 }
1629
1630 /* Return the search result */
1631 return Status;
1632}
#define ULONG_PTR
Definition: config.h:101
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
#define RtlEqualMemory(a, b, c)
Definition: kdvm.h:18
EFI_CONFIGURATION_TABLE * ConfigurationTable
Definition: UefiSpec.h:1968
UINTN NumberOfTableEntries
Definition: UefiSpec.h:1963

Referenced by EfipGetRsdt().

◆ 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
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
@ BlProtectedMode
Definition: bl.h:238
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 UNICODE_NULL
#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().

◆ EfiSetWatchdogTimer()

NTSTATUS EfiSetWatchdogTimer ( VOID  )

Definition at line 893 of file firmware.c.

896{
897 BL_ARCH_MODE OldMode;
898 EFI_STATUS EfiStatus;
899
900 /* Are we in protected mode? */
901 OldMode = CurrentExecutionContext->Mode;
902 if (OldMode != BlRealMode)
903 {
904 /* Switch to real mode */
906 }
907
908 /* Make the EFI call */
909 EfiStatus = EfiBS->SetWatchdogTimer(0, 0, 0, NULL);
910
911 /* Switch back to protected mode if we came from there */
912 if (OldMode != BlRealMode)
913 {
914 BlpArchSwitchContext(OldMode);
915 }
916
917 /* Convert the error to an NTSTATUS */
918 return EfiGetNtStatusCode(EfiStatus);
919}
EFI_SET_WATCHDOG_TIMER SetWatchdogTimer
Definition: UefiSpec.h:1853

Referenced by BlpFwInitialize().

◆ 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().

◆ EfiVmCloseProtocol()

NTSTATUS EfiVmCloseProtocol ( _In_ EFI_HANDLE  Handle,
_In_ EFI_GUID Protocol 
)

Definition at line 522 of file firmware.c.

526{
528 PLIST_ENTRY ListHead, NextEntry;
529 NTSTATUS Status, CloseStatus;
531 PBL_EFI_PROTOCOL EfiProtocol;
532
533 /* Lookup the list entry for this handle */
534 HashEntry.Size = sizeof(Handle);
536 HashEntry.Value = Handle;
538 if (!NT_SUCCESS(Status))
539 {
540 /* This handle was never used for any protocols */
542 }
543
544 /* Iterate through the list of opened protocols */
545 ListHead = (PLIST_ENTRY)HashValue->Data;
546 NextEntry = ListHead->Flink;
547 while (NextEntry != ListHead)
548 {
549 /* Get this protocol entry and check for a match */
550 EfiProtocol = CONTAINING_RECORD(NextEntry, BL_EFI_PROTOCOL, ListEntry);
551 if (EfiProtocol->Protocol == Protocol)
552 {
553 /* Drop a reference -- was it the last one? */
554 if (EfiProtocol->ReferenceCount-- == 1)
555 {
556 /* Yep -- free this entry */
557 Status = EfiVmpFreeInterfaceEntry(Handle, EfiProtocol);
558
559 /* Call firmware to close the protocol */
560 CloseStatus = EfiVmpCloseProtocol(Handle, Protocol);
561 if (!NT_SUCCESS(CloseStatus))
562 {
563 /* Override free status if close was a failure */
564 Status = CloseStatus;
565 }
566
567 /* Return final status */
568 return Status;
569 }
570 }
571
572 /* Next entry */
573 NextEntry = NextEntry->Flink;
574 }
575
576 /* This protocol was never opened */
578}
#define BL_HT_VALUE_IS_INLINE
Definition: bl.h:137
NTSTATUS BlHtLookup(_In_ ULONG TableId, _In_ PBL_HASH_ENTRY Entry, _Out_ PBL_HASH_VALUE *Value)
ULONG EfiProtHashTableId
Definition: firmware.c:164
NTSTATUS EfiVmpFreeInterfaceEntry(_In_ EFI_HANDLE Handle, _In_ PBL_EFI_PROTOCOL EfiProtocol)
Definition: firmware.c:480
NTSTATUS EfiVmpCloseProtocol(_In_ EFI_HANDLE Handle, _In_ EFI_GUID *Protocol)
Definition: firmware.c:432
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
Definition: hash.c:61
EFI_GUID * Protocol
Definition: firmware.c:169
LONG ReferenceCount
Definition: firmware.c:171
Definition: bl.h:1177
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
struct _LIST_ENTRY * PLIST_ENTRY
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
_In_ BOOLEAN _In_ ULONG _Out_ PULONG HashValue
Definition: rtlfuncs.h:2039

Referenced by EfiCloseProtocol().

◆ EfiVmOpenProtocol()

NTSTATUS EfiVmOpenProtocol ( _In_ EFI_HANDLE  Handle,
_In_ EFI_GUID Protocol,
_Outptr_ PVOID Interface 
)

Definition at line 176 of file firmware.c.

181{
182 BOOLEAN AddressMapped;
183 PLIST_ENTRY HashList, NextEntry;
184 PHYSICAL_ADDRESS InterfaceAddress, TranslatedAddress;
188 PBL_EFI_PROTOCOL EfiProtocol;
189 BL_ARCH_MODE OldMode;
190 EFI_STATUS EfiStatus;
191 PVOID InterfaceVa;
192
193 /* Initialize failure paths */
194 AddressMapped = FALSE;
195 HashList = NULL;
196 InterfaceAddress.QuadPart = 0;
197
198 /* Have we initialized the protocol table yet? */
200 {
201 /* Nope -- create the hash table */
203 if (!NT_SUCCESS(Status))
204 {
205 return Status;
206 }
207
208 /* Remember for next time */
210 }
211
212 /* Check if we already have a list of protocols for this handle */
214 HashEntry.Size = sizeof(Handle);
215 HashEntry.Value = Handle;
217 if (NT_SUCCESS(Status))
218 {
219 /* We do -- the hash value is the list itself */
220 HashList = (PLIST_ENTRY)HashValue->Data;
221 NextEntry = HashList->Flink;
222
223 /* Iterate over it */
224 while (NextEntry != HashList)
225 {
226 /* Get each protocol in the list, checking for a match */
227 EfiProtocol = CONTAINING_RECORD(NextEntry,
229 ListEntry);
230 if (EfiProtocol->Protocol == Protocol)
231 {
232 /* Match found -- add a reference and return it */
233 EfiProtocol->ReferenceCount++;
234 *Interface = EfiProtocol->Interface;
235 return STATUS_SUCCESS;
236 }
237
238 /* Try the next entry */
239 NextEntry = NextEntry->Flink;
240 }
241 }
242
243 /* Switch to real mode for firmware call */
244 OldMode = CurrentExecutionContext->Mode;
245 if (OldMode != BlRealMode)
246 {
248 }
249
250 /* Check if this is EFI 1.02 */
252 {
253 /* Use the old call */
254 EfiStatus = EfiBS->HandleProtocol(Handle,
255 Protocol,
256 (PVOID*)&InterfaceAddress);
257 }
258 else
259 {
260 /* Use the EFI 2.00 API instead */
261 EfiStatus = EfiBS->OpenProtocol(Handle,
262 Protocol,
263 (PVOID*)&InterfaceAddress,
265 NULL,
267 }
268
269 /* Switch back to protected mode if needed */
270 if (OldMode != BlRealMode)
271 {
272 BlpArchSwitchContext(OldMode);
273 }
274
275 /* Check the result, and bail out on failure */
276 Status = EfiGetNtStatusCode(EfiStatus);
277 if (!NT_SUCCESS(Status))
278 {
279 return Status;
280 }
281
282 /* Check what address the interface lives at, and translate it */
283 InterfaceVa = PhysicalAddressToPtr(InterfaceAddress);
285 {
286 /* We expect firmware to be 1:1 mapped, fail if not */
287 if (InterfaceAddress.QuadPart != TranslatedAddress.QuadPart)
288 {
290 }
291 }
292 else
293 {
294 /* Create a virtual (1:1) mapping for the interface */
295 Status = BlMmMapPhysicalAddressEx(&InterfaceVa,
297 PAGE_SIZE,
298 InterfaceAddress);
299 if (!NT_SUCCESS(Status))
300 {
301 return Status;
302 }
303
304 /* Remember for cleanup */
305 AddressMapped = TRUE;
306 }
307
308 /* The caller now has the interface */
309 *Interface = InterfaceVa;
310
311 /* Did we already have some protocols on this handle? */
312 if (!HashList)
313 {
314 /* Nope, this is the first time -- so allocate the list */
315 HashList = BlMmAllocateHeap(sizeof(*HashList));
316 if (!HashList)
317 {
319 goto Quickie;
320 }
321
322 /* Initialize it */
323 InitializeListHead(HashList);
324
325 /* And then store it in the hash table for this handle */
327 &HashEntry,
328 HashList,
329 sizeof(*HashList));
330 if (!NT_SUCCESS(Status))
331 {
332 BlMmFreeHeap(HashList);
333 goto Quickie;
334 }
335 }
336
337 /* Finally, allocate a protocol tracker structure */
338 EfiProtocol = BlMmAllocateHeap(sizeof(*EfiProtocol));
339 if (!EfiProtocol)
340 {
342 goto Quickie;
343 }
344
345 /* And store this information in case the protocol is needed again */
346 EfiProtocol->Protocol = Protocol;
347 EfiProtocol->Interface = *Interface;
348 EfiProtocol->ReferenceCount = 1;
349 EfiProtocol->AddressMapped = AddressMapped;
350 InsertTailList(HashList, &EfiProtocol->ListEntry);
351
352 /* Passthru to success case */
353 AddressMapped = FALSE;
354
355Quickie:
356 /* Failure path -- did we map anything ?*/
357 if (AddressMapped)
358 {
359 /* Get rid of it */
361 *Interface = NULL;
362 }
363
364 /* Return the failure */
365 return Status;
366}
NTSTATUS BlHtStore(_In_ ULONG TableId, _In_ PBL_HASH_ENTRY Entry, _In_ PVOID Data, _In_ ULONG DataSize)
Definition: util.c:668
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
@ BlMemoryFixed
Definition: bl.h:368
BOOLEAN EfiProtHashTableInitialized
Definition: firmware.c:163
#define InsertTailList(ListHead, Entry)
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
BOOLEAN AddressMapped
Definition: firmware.c:172
LIST_ENTRY ListEntry
Definition: firmware.c:168
_In_ ULONG _In_ PHYSICAL_ADDRESS _Inout_ PULONG _Out_ PPHYSICAL_ADDRESS TranslatedAddress
Definition: iofuncs.h:2275

Referenced by EfiOpenProtocol().

◆ EfiVmpCloseProtocol()

NTSTATUS EfiVmpCloseProtocol ( _In_ EFI_HANDLE  Handle,
_In_ EFI_GUID Protocol 
)

Definition at line 432 of file firmware.c.

436{
437 EFI_STATUS EfiStatus;
438 BL_ARCH_MODE OldMode;
439
440 /* Are we in protected mode? */
441 OldMode = CurrentExecutionContext->Mode;
442 if (OldMode != BlRealMode)
443 {
444 /* Switch to real mode */
446 }
447
448 /* Are we on legacy 1.02? */
450 {
451 /* Nothing to close */
452 EfiStatus = EFI_SUCCESS;
453 }
454 else
455 {
456 /* Use the UEFI version */
457 EfiStatus = EfiBS->CloseProtocol(Handle,
458 Protocol,
460 NULL);
461
462 /* Normalize not found as success */
463 if (EfiStatus == EFI_NOT_FOUND)
464 {
465 EfiStatus = EFI_SUCCESS;
466 }
467 }
468
469 /* Switch back to protected mode if we came from there */
470 if (OldMode != BlRealMode)
471 {
472 BlpArchSwitchContext(OldMode);
473 }
474
475 /* Convert to NT status */
476 return EfiGetNtStatusCode(EfiStatus);
477}

Referenced by EfiVmCloseProtocol().

◆ EfiVmpFreeInterfaceEntry()

NTSTATUS EfiVmpFreeInterfaceEntry ( _In_ EFI_HANDLE  Handle,
_In_ PBL_EFI_PROTOCOL  EfiProtocol 
)

Definition at line 480 of file firmware.c.

484{
487
488 /* Assume success */
490
491 /* Is this the last protocol on this handle? */
492 if (IsListEmpty(&EfiProtocol->ListEntry))
493 {
494 /* Delete the hash table entry for this handle */
495 HashEntry.Value = Handle;
496 HashEntry.Size = sizeof(Handle);
499
500 /* This will free the list head itself */
501 BlMmFreeHeap(EfiProtocol->ListEntry.Flink);
502 }
503 else
504 {
505 /* Simply remove this entry */
506 RemoveEntryList(&EfiProtocol->ListEntry);
507 }
508
509 /* Had we virtually mapped this protocol? */
510 if (EfiProtocol->AddressMapped)
511 {
512 /* Unmap it */
513 BlMmUnmapVirtualAddressEx(EfiProtocol->Interface, PAGE_SIZE);
514 }
515
516 /* Free the protocol entry, and return */
517 BlMmFreeHeap(EfiProtocol);
518 return Status;
519}
NTSTATUS BlHtDelete(_In_ ULONG TableId, _In_ PBL_HASH_ENTRY Entry)
Definition: util.c:722
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954

Referenced by EfiVmCloseProtocol().

◆ 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
NTSTATUS MmMdAddDescriptorToList(_In_ PBL_MEMORY_DESCRIPTOR_LIST MdList, _In_ PBL_MEMORY_DESCRIPTOR MemoryDescriptor, _In_ ULONG Flags)
Definition: descriptor.c:582
@ BlReservedMemory
Definition: bl.h:329
@ BlLoaderData
Definition: bl.h:313
@ BlConventionalMemory
Definition: bl.h:327
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
#define BL_MM_FLAG_REQUEST_COALESCING
Definition: bl.h:87
#define BL_LIBRARY_FLAG_INITIALIZATION_COMPLETED
Definition: bl.h:131
#define BL_MM_INCLUDE_MAPPED_ALLOCATED
Definition: bl.h:96
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
enum _BL_MEMORY_TYPE BL_MEMORY_TYPE
NTSTATUS MmPapFreePages(_In_ PVOID Address, _In_ ULONG WhichList)
Definition: pagealloc.c:1196
PBL_DEVICE_DESCRIPTOR BlpBootDevice
Definition: bootlib.c:16
#define BL_MM_ADD_DESCRIPTOR_COALESCE_FLAG
Definition: bl.h:89
#define BL_MM_REMOVE_PHYSICAL_REGION_FLAG
Definition: bl.h:124
enum _BL_MEMORY_ATTR BL_MEMORY_ATTR
#define BL_MM_ADD_DESCRIPTOR_TRUNCATE_FLAG
Definition: bl.h:90
@ RamDiskDevice
Definition: bl.h:264
@ LocalDevice
Definition: bl.h:261
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
VOID MmMdFreeList(_In_ PBL_MEMORY_DESCRIPTOR_LIST MdList)
Definition: descriptor.c:356
NTSTATUS MmMdRemoveRegionFromMdlEx(__in PBL_MEMORY_DESCRIPTOR_LIST MdList, __in ULONG Flags, __in ULONGLONG BasePage, __in ULONGLONG PageCount, __in PBL_MEMORY_DESCRIPTOR_LIST NewMdList)
@ BlMemoryBelow1MB
Definition: bl.h:369
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
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
EFI_PHYSICAL_ADDRESS PhysicalStart
Definition: UefiSpec.h:99
DEVICE_TYPE DeviceType
Definition: bl.h:950
BL_LOCAL_DEVICE Local
Definition: bl.h:956
ULONG LibraryFlags
Definition: bl.h:757
BL_LOCAL_DEVICE_TYPE Type
Definition: bl.h:925
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint64_t ULONGLONG
Definition: typedefs.h:67
EFI_MEMORY_DESCRIPTOR * EfiMemoryMap
Definition: uefimem.c:35
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
int WINAPI EndPage(_In_ HDC)
int WINAPI StartPage(_In_ HDC)
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define ROUND_TO_PAGES(Size)
#define BYTES_TO_PAGES(Size)

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

◆ MmFwpGetOsAttributeType()

BL_MEMORY_ATTR MmFwpGetOsAttributeType ( _In_ ULONGLONG  Attribute)

Definition at line 1727 of file firmware.c.

1730{
1731 BL_MEMORY_ATTR OsAttribute = 0;
1732
1733 if (Attribute & EFI_MEMORY_UC)
1734 {
1735 OsAttribute = BlMemoryUncached;
1736 }
1737
1738 if (Attribute & EFI_MEMORY_WC)
1739 {
1740 OsAttribute |= BlMemoryWriteCombined;
1741 }
1742
1743 if (Attribute & EFI_MEMORY_WT)
1744 {
1745 OsAttribute |= BlMemoryWriteThrough;
1746 }
1747
1748 if (Attribute & EFI_MEMORY_WB)
1749 {
1750 OsAttribute |= BlMemoryWriteBack;
1751 }
1752
1753 if (Attribute & EFI_MEMORY_UCE)
1754 {
1755 OsAttribute |= BlMemoryUncachedExported;
1756 }
1757
1758 if (Attribute & EFI_MEMORY_WP)
1759 {
1760 OsAttribute |= BlMemoryWriteProtected;
1761 }
1762
1763 if (Attribute & EFI_MEMORY_RP)
1764 {
1765 OsAttribute |= BlMemoryReadProtected;
1766 }
1767
1768 if (Attribute & EFI_MEMORY_XP)
1769 {
1770 OsAttribute |= BlMemoryExecuteProtected;
1771 }
1772
1773 if (Attribute & EFI_MEMORY_RUNTIME)
1774 {
1775 OsAttribute |= BlMemoryRuntime;
1776 }
1777
1778 return OsAttribute;
1779}
#define EFI_MEMORY_RUNTIME
Definition: UefiSpec.h:80
#define EFI_MEMORY_RP
Definition: UefiSpec.h:75
#define EFI_MEMORY_WT
Definition: UefiSpec.h:68
#define EFI_MEMORY_WC
Definition: UefiSpec.h:67
#define EFI_MEMORY_UCE
Definition: UefiSpec.h:70
#define EFI_MEMORY_WP
Definition: UefiSpec.h:74
#define EFI_MEMORY_WB
Definition: UefiSpec.h:69
#define EFI_MEMORY_XP
Definition: UefiSpec.h:76
#define EFI_MEMORY_UC
Definition: UefiSpec.h:66
@ BlMemoryReadProtected
Definition: bl.h:358
@ BlMemoryExecuteProtected
Definition: bl.h:359
@ BlMemoryWriteThrough
Definition: bl.h:348
@ BlMemoryWriteProtected
Definition: bl.h:357
@ BlMemoryUncached
Definition: bl.h:346
@ BlMemoryRuntime
Definition: bl.h:376
@ BlMemoryWriteBack
Definition: bl.h:349
@ BlMemoryWriteCombined
Definition: bl.h:347
@ BlMemoryUncachedExported
Definition: bl.h:350

Referenced by MmFwGetMemoryMap().

◆ MmFwpGetOsMemoryType()

BL_MEMORY_TYPE MmFwpGetOsMemoryType ( _In_ EFI_MEMORY_TYPE  MemoryType)

Definition at line 1782 of file firmware.c.

1785{
1786 BL_MEMORY_TYPE OsType;
1787
1788 switch (MemoryType)
1789 {
1790 case EfiLoaderCode:
1791 case EfiLoaderData:
1792 OsType = BlLoaderMemory;
1793 break;
1794
1797 OsType = BlEfiBootMemory;
1798 break;
1799
1801 OsType = BlEfiRuntimeCodeMemory;
1802 break;
1803
1805 OsType = BlEfiRuntimeDataMemory;
1806 break;
1807
1809 OsType = BlConventionalMemory;
1810 break;
1811
1812 case EfiUnusableMemory:
1813 OsType = BlUnusableMemory;
1814 break;
1815
1817 OsType = BlAcpiReclaimMemory;
1818 break;
1819
1820 case EfiACPIMemoryNVS:
1821 OsType = BlAcpiNvsMemory;
1822 break;
1823
1824 case EfiMemoryMappedIO:
1825 OsType = BlDeviceIoMemory;
1826 break;
1827
1829 OsType = BlDevicePortMemory;
1830 break;
1831
1832 case EfiPalCode:
1833 OsType = BlPalMemory;
1834 break;
1835
1836 default:
1837 OsType = BlReservedMemory;
1838 break;
1839 }
1840
1841 return OsType;
1842}
@ EfiUnusableMemory
@ EfiBootServicesData
@ EfiBootServicesCode
@ EfiConventionalMemory
@ EfiACPIMemoryNVS
@ EfiMemoryMappedIOPortSpace
@ EfiACPIReclaimMemory
@ EfiLoaderCode
@ EfiMemoryMappedIO
@ EfiPalCode
@ EfiRuntimeServicesCode
@ EfiRuntimeServicesData
@ BlLoaderMemory
Definition: bl.h:306
@ BlUnusableMemory
Definition: bl.h:328
@ BlEfiRuntimeDataMemory
Definition: bl.h:338
@ BlDeviceIoMemory
Definition: bl.h:335
@ BlEfiBootMemory
Definition: bl.h:330
@ BlPalMemory
Definition: bl.h:337
@ BlEfiRuntimeCodeMemory
Definition: bl.h:332
@ BlAcpiNvsMemory
Definition: bl.h:334
@ BlAcpiReclaimMemory
Definition: bl.h:333
@ BlDevicePortMemory
Definition: bl.h:336

Referenced by MmFwGetMemoryMap().

Variable Documentation

◆ BlpEfiSecureBootPrivateNamespace

EFI_GUID BlpEfiSecureBootPrivateNamespace = { 0x77FA9ABD , 0x0359, 0x4D32, { 0xBD, 0x60, 0x28, 0xF4, 0xE7, 0x8F, 0x78, 0x4B } }

Definition at line 37 of file firmware.c.

Referenced by BlSecureBootCheckForFactoryReset().

◆ BlpFirmwareChecked

BOOLEAN BlpFirmwareChecked

Definition at line 41 of file firmware.c.

Referenced by BlSecureBootIsEnabled().

◆ BlpFirmwareEnabled

BOOLEAN BlpFirmwareEnabled

Definition at line 42 of file firmware.c.

Referenced by BlSecureBootIsEnabled().

◆ BlScratchBuffer

WCHAR BlScratchBuffer[8192]

Definition at line 39 of file firmware.c.

Referenced by BlStatusPrint(), and EfiPrintf().

◆ EfiBlockIoProtocol

◆ EfiBS

◆ EfiConIn

Definition at line 24 of file firmware.c.

Referenced by BlpFwInitialize(), and EfiConInReset().

◆ EfiConInEx

◆ EfiConOut

Definition at line 23 of file firmware.c.

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

◆ EfiDevicePathProtocol

◆ EfiFirmwareData

BL_FIRMWARE_DESCRIPTOR EfiFirmwareData

Definition at line 16 of file firmware.c.

Referenced by BlpFwInitialize().

◆ EfiFirmwareParameters

PBL_FIRMWARE_DESCRIPTOR EfiFirmwareParameters

Definition at line 15 of file firmware.c.

Referenced by BlFwGetParameters(), and BlpFwInitialize().

◆ EfiGlobalVariable

EFI_GUID EfiGlobalVariable = EFI_GLOBAL_VARIABLE

Definition at line 36 of file firmware.c.

Referenced by BlpSecureBootEFIIsEnabled().

◆ EfiGraphicsOutputProtocol

EFI_GUID EfiGraphicsOutputProtocol = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID

Definition at line 28 of file firmware.c.

◆ EfiImageHandle

◆ EfiLoadedImageProtocol

EFI_GUID EfiLoadedImageProtocol = EFI_LOADED_IMAGE_PROTOCOL_GUID

Definition at line 30 of file firmware.c.

Referenced by EfiInitCreateInputParametersEx(), and UefiMemGetMemoryMap().

◆ EfiProtHashTableId

ULONG EfiProtHashTableId

Definition at line 164 of file firmware.c.

Referenced by EfiVmCloseProtocol(), EfiVmOpenProtocol(), and EfiVmpFreeInterfaceEntry().

◆ EfiProtHashTableInitialized

BOOLEAN EfiProtHashTableInitialized

Definition at line 163 of file firmware.c.

Referenced by EfiVmOpenProtocol().

◆ EfiRootAcpiTable10Guid

EFI_GUID EfiRootAcpiTable10Guid = EFI_ACPI_TABLE_GUID

Definition at line 35 of file firmware.c.

Referenced by EfipGetRsdt().

◆ EfiRootAcpiTableGuid

EFI_GUID EfiRootAcpiTableGuid = EFI_ACPI_20_TABLE_GUID

Definition at line 34 of file firmware.c.

Referenced by EfipGetRsdt().

◆ EfiRsdt

Definition at line 26 of file firmware.c.

Referenced by EfipGetRsdt().

◆ EfiRT

Definition at line 22 of file firmware.c.

Referenced by BlpFwInitialize(), EfiGetVariable(), and EfiResetSystem().

◆ EfiSimpleTextInputExProtocol

EFI_GUID EfiSimpleTextInputExProtocol = EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID

Definition at line 32 of file firmware.c.

Referenced by BlpFwInitialize().

◆ EfiST

◆ EfiSystemTable

EFI_SYSTEM_TABLE* EfiSystemTable

Definition at line 18 of file firmware.c.

Referenced by BlpFwInitialize().

◆ EfiUgaDrawProtocol

EFI_GUID EfiUgaDrawProtocol = EFI_UGA_DRAW_PROTOCOL_GUID

Definition at line 29 of file firmware.c.

Referenced by ConsoleEfiGraphicalOpenProtocol().