OpenCore
1.0.4
OpenCore Bootloader
|
#include <Protocol/BlockIo.h>
#include <Protocol/DevicePath.h>
Go to the source code of this file.
Data Structures | |
struct | APPLE_RAM_DISK_PROTOCOL |
struct | APPLE_RAM_DISK |
struct | APPLE_RAM_DISK_INSTANCE |
Macros | |
#define | APPLE_RAM_DISK_PROTOCOL_GUID |
#define | APPLE_DMG_BOOT_PROTOCOL_REVISION 3 |
#define | APPLE_RAM_DISK_EXTENT_SIGNATURE 0x544E5458444D4152ULL |
#define | APPLE_RAM_DISK_EXTENT_VERSION 0x10000U |
#define | APPLE_RAM_DISK_MAX_EXTENTS 0xFE |
#define | APPLE_RAM_DISK_INSTANCE_SIGNATURE 0x444D4152U |
#define | APPLE_RAM_DISK_DEFAULT_SIZE 0xA00000U |
Functions | |
STATIC_ASSERT (sizeof(APPLE_RAM_DISK_DP_VENDOR)==24, "Invalid APPLE_RAM_DISK_DP_VENDOR size") | |
STATIC_ASSERT (sizeof(APPLE_RAM_DISK_DP)==52, "Invalid APPLE_RAM_DISK_DP size") | |
STATIC_ASSERT (sizeof(APPLE_RAM_DISK_EXTENT)==16, "Invalid APPLE_RAM_DISK_EXTENT size") | |
STATIC_ASSERT (sizeof(APPLE_RAM_DISK_EXTENT_TABLE)==4096, "Invalid APPLE_RAM_DISK_EXTENT_TABLE size") | |
STATIC_ASSERT (sizeof(APPLE_RAM_DISK_CONTEXT)==8192, "Invalid APPLE_RAM_DISK_CONTEXT size") | |
Variables | |
EFI_GUID | gAppleRamDiskProtocolGuid |
Apple RAM Disk protocol.
Copyright (C) 2019, vit9696. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Definition in file AppleRamDisk.h.
#define APPLE_DMG_BOOT_PROTOCOL_REVISION 3 |
Apple RAM Disk protocol revision.
Definition at line 32 of file AppleRamDisk.h.
#define APPLE_RAM_DISK_DEFAULT_SIZE 0xA00000U |
RAM Disk default size. This value is used when allocating APPLE_RAM_DISK structure.
Definition at line 305 of file AppleRamDisk.h.
#define APPLE_RAM_DISK_EXTENT_SIGNATURE 0x544E5458444D4152ULL |
RAM Disk extent signature, "RAMDXTNT".
Definition at line 37 of file AppleRamDisk.h.
#define APPLE_RAM_DISK_EXTENT_VERSION 0x10000U |
RAM Disk extent version.
Definition at line 42 of file AppleRamDisk.h.
#define APPLE_RAM_DISK_INSTANCE_SIGNATURE 0x444D4152U |
Vit: Below come the implementation specific details, which probably do not belong here. Since this is the only way to initialize RAM disk when it was not allocated at creation time, I put it here for now. RAM Disk instance signature, "RAMD".
Definition at line 299 of file AppleRamDisk.h.
#define APPLE_RAM_DISK_MAX_EXTENTS 0xFE |
RAM Disk maximum extent count.
Definition at line 47 of file AppleRamDisk.h.
#define APPLE_RAM_DISK_PROTOCOL_GUID |
Apple RAM Disk protocol GUID. 957932CC-7E8E-433B-8F41-D391EA3C10F8
Definition at line 25 of file AppleRamDisk.h.
typedef PACKED struct { ... } APPLE_RAM_DISK_CONTEXT |
RAM Disk protocol context. This might be called scatter pool.
typedef EFI_STATUS(EFIAPI * APPLE_RAM_DISK_CREATE) (IN UINT64 BlockCount OPTIONAL, IN UINT32 BlockSize OPTIONAL, IN BOOLEAN AllocateMemory, IN BOOLEAN ReserveMemory, OUT EFI_HANDLE *Handle) |
Create new RAM disk providing relevant protocols:
When AllocateMemory is TRUE, a writeable RAM disk is created. Its contents are initially zeroed, and then may be modified through normal writing and via RAM Disk context, which is accessible through GetRamDiskContext.
When AllocateMemory is FALSE, a read only RAM disk is created. Its contents are not allocated but reported to be all zero. MemMap StartingAddresss will be 0 and EndingAddress will be sizeof (APPLE_RAM_DISK_EXTENT_TABLE). Vit: Since no context is allocated, there is no way to initialise this disk image except in an implementatation specific way. AllocateMemory = FALSE is never used, so it may be a bug.
[in] | BlockCount | Block amount, ignored if AllocateMemory is FALSE. |
[in] | BlockSize | Block size, ignored if AllocateMemory is FALSE. |
[in] | AllocateMemory | Allocate disk memory. |
[in] | ReserveMemory | Mark memory as EfiACPIMemoryNVS, otherwise EfiBootServicesData. |
[in] | Handle | Resulting handle. |
EFI_SUCCESS | RAM disk was successfully created. |
EFI_OUT_OF_RESOURCES | Requested RAM disk of more than SIZE_16TB. |
EFI_OUT_OF_RESOURCES | Memory allocation error happened. |
EFI_INVALID_PARAMETER | Too many extents are needed for the allocation. |
EFI_BUFFER_TOO_SMALL | Not enough extents to allocate context extent. |
Definition at line 225 of file AppleRamDisk.h.
typedef EFI_STATUS(EFIAPI * APPLE_RAM_DISK_DESTROY) (IN EFI_HANDLE Handle) |
Destroy RAM disk freeing resources and uninstalling relevant protocols:
[in] | Handle | RAM disk handle. |
EFI_INVALID_PARAMETER | Not a RAM disk handle. |
EFI_NOT_FOUND | Missing Block I/O protocol. |
EFI_SUCCESS | Destroyed successfully. |
Definition at line 248 of file AppleRamDisk.h.
typedef PACKED struct { ... } APPLE_RAM_DISK_DP |
RAM Disk device path, 52 bytes in total.
typedef PACKED struct { ... } APPLE_RAM_DISK_DP_HEADER |
RAM Disk device path header for endpoint devices.
typedef PACKED struct { ... } APPLE_RAM_DISK_DP_VENDOR |
RAM Disk vendor device path, 24 bytes in total.
typedef PACKED struct { ... } APPLE_RAM_DISK_EXTENT |
RAM Disk extent. When automatically allocating at RAM disk creation, extents are created on demand as long as contiguous memory is found in the firmware.
Please note, that this must match IOAddressRange type in XNU, which can be found in iokit/IOKit/IOTypes.h.
typedef PACKED struct { ... } APPLE_RAM_DISK_EXTENT_TABLE |
RAM Disk externally accessible header containing references to extents.
typedef EFI_STATUS(EFIAPI * APPLE_RAM_DISK_GET_CONTEXT) (IN EFI_HANDLE Handle, OUT APPLE_RAM_DISK_CONTEXT *Context) |
Obtain RAM disk context. Context exists only for "allocated" RAM disks, i.e. disks created with AllocateMemory = TRUE. When an unallocated RAM disk is created, NULL Context will be returned.
[in] | Handle | RAM disk handle. |
[out] | Context | RAM disk context. |
EFI_INVALID_PARAMETER | Not a RAM disk handle. |
EFI_NOT_FOUND | Missing Block I/O protocol. |
EFI_SUCCESS | Obtained NULL or non-NULL context successfully. |
Definition at line 266 of file AppleRamDisk.h.
STATIC_ASSERT | ( | sizeof(APPLE_RAM_DISK_CONTEXT) | = =8192, |
"Invalid APPLE_RAM_DISK_CONTEXT size" | ) |
STATIC_ASSERT | ( | sizeof(APPLE_RAM_DISK_DP) | = =52, |
"Invalid APPLE_RAM_DISK_DP size" | ) |
STATIC_ASSERT | ( | sizeof(APPLE_RAM_DISK_DP_VENDOR) | = =24, |
"Invalid APPLE_RAM_DISK_DP_VENDOR size" | ) |
STATIC_ASSERT | ( | sizeof(APPLE_RAM_DISK_EXTENT) | = =16, |
"Invalid APPLE_RAM_DISK_EXTENT size" | ) |
STATIC_ASSERT | ( | sizeof(APPLE_RAM_DISK_EXTENT_TABLE) | = =4096, |
"Invalid APPLE_RAM_DISK_EXTENT_TABLE size" | ) |
UINT32 Counter |
Globally incremented counter to make every path unique.
Definition at line 150 of file AppleRamDisk.h.
UINT64 DiskSize |
Total addressible disk size specified at creation.
Definition at line 116 of file AppleRamDisk.h.
EFI_DEVICE_PATH_PROTOCOL End |
Device path end.
Definition at line 191 of file AppleRamDisk.h.
UINT64 ExtentCount |
Externally visible amount of extents.
Internally visible amount of extents.
Definition at line 86 of file AppleRamDisk.h.
Externally visible extent array.
Internally visible extent array.
Definition at line 90 of file AppleRamDisk.h.
APPLE_RAM_DISK_EXTENT_TABLE ExtentTable |
Normal extent table.
Definition at line 128 of file AppleRamDisk.h.
|
extern |
UINT64 Length |
Actual size of the extent. Allocated area size may be >= Length.
Definition at line 68 of file AppleRamDisk.h.
MEMMAP_DEVICE_PATH MemMap |
Memmap device path.
Definition at line 164 of file AppleRamDisk.h.
UINT64 Reserved |
Currently reserved or rather unknown.
Definition at line 94 of file AppleRamDisk.h.
UINT64 Reserved1 |
Currently reserved or rather unknown. Padding?
Definition at line 112 of file AppleRamDisk.h.
UINT64 Reserved2 |
Currently reserved or rather unknown. Padding?
Definition at line 124 of file AppleRamDisk.h.
UINT64 Signature |
Set to APPLE_RAM_DISK_EXTENT_SIGNATURE.
Definition at line 78 of file AppleRamDisk.h.
UINT64 Signature2 |
Set to APPLE_RAM_DISK_EXTENT_SIGNATURE.
Definition at line 98 of file AppleRamDisk.h.
UINT64 Start |
Extentent address pointing to a sequence of allocated pages from EfiACPIMemoryNVS or EfiBootServicesData depending on RamDisk init.
Definition at line 64 of file AppleRamDisk.h.
APPLE_RAM_DISK_DP_VENDOR Vendor |
Vendor device path. Type = HARDWARE_DEVICE_PATH. Subtype = HW_VENDOR_DP. Length = sizeof (VENDOR_DEVICE_PATH) + sizeof (UINT32). Guid = APPLE_RAM_DISK_PROTOCOL_GUID.
Vendor device path.
Vendor device path with APPLE_RAM_DISK_PROTOCOL_GUID. Type = HARDWARE_DEVICE_PATH. Subtype = HW_MEMMAP_DP. Length = sizeof (APPLE_RAM_DISK_ENTRY_DP). StartingAddresss = APPLE_RAM_DISK_EXTENT_TABLE pointer. EndingAddress = StartingAddresss + sizeof (APPLE_RAM_DISK_EXTENT_TABLE). MemoryType = EfiACPIMemoryNVS or EfiBootServicesData as allocated.
Note: EndingAddress, per UEFI specification and edk2 implementation, is supposed to be the top usable address, not the top of the buffer. Perhaps there is a mistake here.
Definition at line 146 of file AppleRamDisk.h.
UINT32 Version | ( | void | ) |
Set to APPLE_RAM_DISK_EXTENT_VERSION.
Definition at line 82 of file AppleRamDisk.h.