最近在学习BIOS 在写memory Map相关的练习 目前刚在构想怎么完成
我想问 先告一个字串阵列该怎么把它打印出来?
这部分一直build不过
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Protocol/ShellParameters.h>
EFI_SHELL_PARAMETERS_PROTOCOL *EfiShellParametersProtocol;
const CHAR16 *memory_types[] = { //有人有用const、STATIC,或没用,但我都过不了
L"EfiReservedMemoryType",
L"EfiLoaderCode",
L"EfiLoaderData",
L"EfiBootServicesCode",
L"EfiBootServicesData",
L"EfiRuntimeServicesCode",
L"EfiRuntimeServicesData",
L"EfiConventionalMemory",
L"EfiUnusableMemory",
L"EfiACPIReclaimMemory",
L"EfiACPIMemoryNVS",
L"EfiMemoryMappedIO",
L"EfiMemoryMappedIOPortSpace",
L"EfiPalCode",
L"EfiPersistentMemory",
L"EfiMaxMemoryType",
};
VOID PrintNUMType()
{
Print(L" NUM_type\n");
for (int i = 0; i < 3; i++) {
print(L" %d. %c", i+1, memory_types[i]);
}
};
EFI_STATUS
EFIAPI
UefiMain (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
CHAR16 **Argv;
UINTN Argc;
UINTN Index;
UINTN Value[4];
Status = gBS->OpenProtocol(ImageHandle,
&gEfiShellParametersProtocolGuid,
(VOID **)&EfiShellParametersProtocol,
ImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
Print(L"Status %r\n", Status);
return Status;
}
Print(L"Ex3 Protocol Status %r\n", Status);
Argc = EfiShellParametersProtocol->Argc;
Argv = EfiShellParametersProtocol->Argv;
// Judgment input value
if(Argc>1||Argc<5) {
for (Index = 1; Index < Argc; Index++) {
Print(L"Arg[%d]= %s \n", Index, *(Argv + Index));
Value[Index] = StrHexToUintn(*(Argv + Index));
Print(L"Data = %2X %2c %d %s\n", Value[Index], Value[Index],
Value[Index] );
}
}
switch (Argc) {
case 1:
Print(L"-map [Get Memory Map]\n");
Print(L"-page NUM_type size [Allocate memory Page & decide size and
type\n");
Print(L"-pool NUM_type size [Allocate memory pool & decide size and
type\n");
Print(L"-dump address [Dump specific memory address region (256
bytes)\n");
Print(L"-write address value[Dump specific memory address region (256
bytes)\n");
PrintNUMType();
break;
case 2:
case 3:
case 4:
Print(L"Tool text\n");
break;
default:
Print(L"ERROR\n");
break;
}
return Status;
}