About

Parameters of entry point of  EDK2 Standalone MM

The entry point should take the following parameters:

Booting information structure

The following booting are copied from ARM definition. There are always a specific requirements for RISC-V so the structure can't be the same between ARM and RISC-V.

The code should have separated header file for RISC-V

TypeNameNote
UINT8TypeThe type of booting info structure.
UINT8VersionThe version of booting info structure.
UINT16SizeThe size of booting info structure.
UINT32Attr

The attributes of MM.

1: APTEE MM payload

TypeNameNote
UINT32ProcessorId The unique processor ID.
UINT32PackageThe zezo-based physical package number.
UINT32CoreThe zezo-based physical core number.
UINT32Flags1: This CPU is primary core provided boot service protocol (BSP).

EFI_RISCV_MM_CPU_INFO

TypeNameNote
EFI_PARAM_HEADERHeader
UINT64MmMemBaseThe base address of memory assigned to MM.
UINT64MmMemLimitThe limit address of memory assigned to MM.
UINT64MmImageBaseThe bass address of MM FD.
UINT64MmStackBase

The stack base address. Note, MM will setup SP register

with this value regardless it may be setup before entering entry point.

UINT64MmHeapBaseThe heap base address that will be used to allocate HOB memory.
UINT64MmNsCommBufBase

The base address of shared buffer between MM and non secure world.

It is set up as  non confidential memory.

UINT64MmSharedBufBase

The base address of shared buffer between MM and secure world.

It is set up as confidential memory. But it should not be trusted by MM.

UINT64MmImageSizeThe size of MM FD.
UINT64MmPcpuStackSizeThe size of stack per CPU.
UINT64MmHeapSizeThe size of heap region.
UINT64MmNsCommBufSizeThe size of shared buffer between MM and non secure world.
UINT64MmSharedBufSizeThe size of shared buffer between MM and secure world.
UINT64NumMmMemRegions

The number of memory regions that be registered with MM core. Minimum

are 6 core regions: MemBase, ImageBase, StackBase, HeapBase, NsCommBufBase,

SharedBufBase. Additional region can be added at the end of structure for a driver.

UINT64NumCpus

The number of CPUs info that assigned to MM.

EFI_RISCV_MM_CPU_INFOCpuInfo[NumCpus]The array of CPUs info.

EFI_RISCV_MM_BOOT_INFO

Communication between EDK2 Standalone MM and EDK2

Information will be communicated using MmNsCommBufBase and MmNsCommBufSize that passed from booting info.

The format of MmNsCommBufBase:

EFI_MMRAM_DESCRIPTION
EFI_MM_COMMUNICATE_HEADER
PAYLOAD

Both EFI_MMRAM_DESCRIPTION and EFI_MM_COMMUNICATE_HEADER are standard EDK2 communicate protocol as described:

EFI_MMRAM_DESCRIPTIONEFI_MM_COMMUNICATE_HEADER

///
/// Structure describing a MMRAM region and its accessibility attributes.
///
typedef struct {
///
/// Designates the physical address of the MMRAM in memory. This view of memory is
/// the same as seen by I/O-based agents, for example, but it may not be the address seen
/// by the processors.
///
EFI_PHYSICAL_ADDRESS PhysicalStart;
///
/// Designates the address of the MMRAM, as seen by software executing on the
/// processors. This address may or may not match PhysicalStart.
///
EFI_PHYSICAL_ADDRESS CpuStart;
///
/// Describes the number of bytes in the MMRAM region.
///
UINT64 PhysicalSize;
///
/// Describes the accessibility attributes of the MMRAM. These attributes include the
/// hardware state (e.g., Open/Closed/Locked), capability (e.g., cacheable), logical
/// allocation (e.g., allocated), and pre-use initialization (e.g., needs testing/ECC
/// initialization).
///
UINT64 RegionState;
} EFI_MMRAM_DESCRIPTOR;

///
/// To avoid confusion in interpreting frames, the communication buffer should always
/// begin with EFI_MM_COMMUNICATE_HEADER
///
typedef struct {
///
/// Allows for disambiguation of the message format.
///
EFI_GUID HeaderGuid;
///
/// Describes the size of Data (in bytes) and does not include the size of the header.
///
UINTN MessageLength;
///
/// Designates an array of bytes that is MessageLength in size.
///
UINT8 Data[1];
} EFI_MM_COMMUNICATE_HEADE