[問題] 呼叫字串陣列並輸出
最近在學習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;
}
--
有沒有準備好我不知道,
但我已經做了我最好的選擇。
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.51.167.201 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1675408894.A.CBA.html
推
02/03 16:04,
1年前
, 1F
02/03 16:04, 1F
→
02/03 16:44,
1年前
, 2F
02/03 16:44, 2F
→
02/04 17:37,
1年前
, 3F
02/04 17:37, 3F
→
02/04 17:37,
1年前
, 4F
02/04 17:37, 4F
→
02/04 17:38,
1年前
, 5F
02/04 17:38, 5F
→
02/04 17:40,
1年前
, 6F
02/04 17:40, 6F
推
02/04 22:16,
1年前
, 7F
02/04 22:16, 7F
→
02/05 21:16,
1年前
, 8F
02/05 21:16, 8F
→
02/05 21:18,
1年前
, 9F
02/05 21:18, 9F
→
02/05 21:20,
1年前
, 10F
02/05 21:20, 10F
→
02/05 21:20,
1年前
, 11F
02/05 21:20, 11F
→
02/05 21:21,
1年前
, 12F
02/05 21:21, 12F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章