Untitled
unknown
plain_text
3 years ago
1.1 kB
5
Indexable
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/UefiBootServicesTableLib.h>
#define MESSAGE_BUFFER_SIZE 256
typedef struct {
CHAR8 Message[MESSAGE_BUFFER_SIZE];
UINTN MessageLength;
} MESSAGE_BUFFER;
EFI_STATUS
EFIAPI
UefiMain (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
MESSAGE_BUFFER *MessageBuffer;
UINTN MemorySize;
// Allocate memory for the message buffer
MemorySize = sizeof(MESSAGE_BUFFER);
MessageBuffer = NULL;
Status = gBS->AllocatePool (EfiRuntimeServicesData, MemorySize, (VOID**)&MessageBuffer);
if (EFI_ERROR (Status)) {
return Status;
}
// Write a message to the buffer
AsciiStrCpy (MessageBuffer->Message, "Hello, Operating System!");
MessageBuffer->MessageLength = AsciiStrLen (MessageBuffer->Message);
// Return the address of the message buffer in the Configuration Table
*(EFI_PHYSICAL_ADDRESS*)SystemTable->ConfigurationTable[0].VendorTable = (EFI_PHYSICAL_ADDRESS)(UINTN)MessageBuffer;
return EFI_SUCCESS;
}Editor is loading...