{"id":921,"date":"2025-02-12T09:16:41","date_gmt":"2025-02-12T00:16:41","guid":{"rendered":"https:\/\/txn.myds.me\/blog\/?p=921"},"modified":"2025-02-12T09:16:41","modified_gmt":"2025-02-12T00:16:41","slug":"895-2-2","status":"publish","type":"post","link":"https:\/\/blog.txn.red\/?p=921","title":{"rendered":"edk2 \u30e1\u30e2\u30ea\u30de\u30c3\u30d7\u3092\u30d5\u30a1\u30a4\u30eb\u306b\u4fdd\u5b58"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u524d\u56de\u306f\u3001\u30e1\u30e2\u30ea\u30de\u30c3\u30d7\u3092\u753b\u9762\u306b\u30c0\u30f3\u30d7\u3057\u305f\u306e\u3067\u4eca\u56de\u306f\u3001\u30e1\u30e2\u30ea\u30de\u30c3\u30d7\u3092\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u306b\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Mikan \u672c\u306b\u306a\u3089\u3044\u3001\u30e1\u30e2\u30ea\u30de\u30c3\u30d7\u7528\u306e\u69cb\u9020\u4f53\u3092\u4f5c\u308a\u3001UEFI \u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u30e1\u30e2\u30ea\u30de\u30c3\u30d7\u3092\u8868\u793a\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"%25e3%2583%2595%25e3%2582%25a1%25e3%2582%25a4%25e3%2583%25ab%25e6%25a7%258b%25e6%2588%2590\">\u30d5\u30a1\u30a4\u30eb\u69cb\u6210<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>edk2 \u30d5\u30a9\u30eb\u30c0\n<ul class=\"wp-block-list\">\n<li>Hello6Pkg \u30d5\u30a9\u30eb\u30c0\n<ul class=\"wp-block-list\">\n<li>Hello6.inf<\/li>\n\n\n\n<li>Hello6Pkg.dec<\/li>\n\n\n\n<li>Hello6Pkg.dsc<\/li>\n\n\n\n<li>Hello6.c<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>mnt \u30d5\u30a9\u30eb\u30c0<\/li>\n\n\n\n<li>disk.img<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Hello6.c \u306f\u524d\u56de\u307e\u3067\u30d5\u30a1\u30a4\u30eb\u8aad\u307f\u66f8\u304d\u7528\u306e\u95a2\u6570\u306f\u5f8c\u3067\u4f7f\u3046\u4e88\u5b9a\u306a\u306e\u3067\u305d\u306e\u307e\u307e\u6b8b\u3057\u3066\u30e1\u30e2\u30ea\u30de\u30c3\u30d7\u307e\u308f\u308a\u306e\u51e6\u7406\u3092\u8ffd\u52a0\u3057\u3066\u3044\u304f\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-c\" data-file=\"Hello6.c\" data-lang=\"C\" data-start=\"18\"><code>#include &lt;Uefi.h&gt;\n#include &lt;Library\/UefiLib.h&gt;\n#include &lt;Library\/UefiBootServicesTableLib.h&gt;\n#include &lt;Protocol\/SimpleFileSystem.h&gt;\n#include &lt;Library\/MemoryAllocationLib.h&gt;\n#include &lt;Guid\/FileInfo.h&gt;\n#include &lt;Guid\/FileSystemInfo.h&gt;\n#include &lt;Library\/PrintLib.h&gt;\n\n#define MEMORY_MAP_BUFFER_PADDING 2\n\ntypedef struct {\n    UINTN BufferSize;\n    VOID* Buffer;\n    UINTN MapSize;\n    UINTN MapKey;\n    UINTN DescriptorSize;\n    UINT32 DescriptorVersion;\n} MemoryMap;\n\nVOID\nInitializeMemoryMap(\n    OUT MemoryMap* map\n)\n{\n    if (map == NULL) return;\n\n    map-&gt;BufferSize = 0;\n    map-&gt;Buffer = NULL;\n    map-&gt;MapSize = 0;\n    map-&gt;MapKey = 0;\n    map-&gt;DescriptorSize = 0;\n    map-&gt;DescriptorVersion =0;\n}\n\nVOID\nFreeMemoryMap(\n    IN OUT MemoryMap* map\n)\n{\n    if (map == NULL || map-&gt;Buffer == NULL) return;\n\n    FreePool(map-&gt;Buffer);\n    map-&gt;Buffer = NULL;\n    map-&gt;BufferSize = 0;\n}\n\nconst CHAR16*\nGetMemoryTypeString(\n    IN EFI_MEMORY_TYPE type\n)\n{\n    switch (type) {\n        case EfiReservedMemoryType:     return L&quot;Reserved&quot;;\n        case EfiLoaderCode:             return L&quot;LoaderCode&quot;;\n        case EfiLoaderData:             return L&quot;LoaderData&quot;;\n        case EfiBootServicesCode:       return L&quot;BootCode&quot;;\n        case EfiBootServicesData:       return L&quot;BootData&quot;;\n        case EfiRuntimeServicesCode:    return L&quot;RuntimeCode&quot;;\n        case EfiRuntimeServicesData:    return L&quot;RuntimeData&quot;;\n        case EfiConventionalMemory:     return L&quot;Conventional&quot;;\n        case EfiUnusableMemory:         return L&quot;Unusable&quot;;\n        case EfiACPIReclaimMemory:      return L&quot;ACPIReclaim&quot;;\n        case EfiACPIMemoryNVS:          return L&quot;ACPINVS&quot;;\n        case EfiMemoryMappedIO:         return L&quot;MMIO&quot;;\n        case EfiMemoryMappedIOPortSpace: return L&quot;MMIOPort&quot;;\n        case EfiPalCode:                return L&quot;PalCode&quot;;\n        default:                        return L&quot;Unknown&quot;;\n    }\n}\n\n\nVOID\nPrintMemoryMapEntry(\n    IN UINTN index,\n    IN CONST EFI_MEMORY_DESCRIPTOR* desc\n)\n{\n    Print(L&quot;%03d: Type=%s  Phys=0x%016lx-0x%016lx  Pages=%ld  Attr=0x%016lx\\n&quot;,\n        index,\n        GetMemoryTypeString(desc-&gt;Type),\n        desc-&gt;PhysicalStart,\n        desc-&gt;PhysicalStart + desc-&gt;NumberOfPages * EFI_PAGE_SIZE - 1,\n        desc-&gt;NumberOfPages,\n        desc-&gt;Attribute\n    );\n}\n\nVOID\nPrintMemoryMap(\n    IN CONST  MemoryMap* map\n)\n{\n    if (map == NULL || map-&gt;Buffer == NULL) {\n        Print(L&quot;Error: invalid memory map\\n&quot;);\n        return;\n    }\n\n    EFI_MEMORY_DESCRIPTOR* Desc = (EFI_MEMORY_DESCRIPTOR*)map-&gt;Buffer;\n    UINTN Entries = map-&gt;MapSize \/ map-&gt;DescriptorSize;\n\n    Print(L&quot;Memory Map: %d entries\\n&quot;, Entries);\n    Print(L&quot;DescriptorSize: %d\\n&quot;,map-&gt;DescriptorSize);\n\n    for (UINTN i = 0; i &lt; Entries; i++) {\n        PrintMemoryMapEntry(i, Desc);\n        Desc = NEXT_MEMORY_DESCRIPTOR(Desc, map-&gt;DescriptorSize);\n    }\n}\n\nEFI_STATUS\nSaveMemoryMap(\n    IN CONST MemoryMap* map,\n    IN CONST EFI_FILE_PROTOCOL* root,\n    IN CONST CHAR16* fileName\n)\n{\n    if (map == NULL || root == NULL || fileName ==NULL) {\n        return EFI_INVALID_PARAMETER;\n    }\n\n    EFI_STATUS Status;\n    EFI_FILE_PROTOCOL* File;\n    UINTN WriteSize;\n\n    Status = root-&gt;Open(\n        (EFI_FILE_PROTOCOL*)root,\n        &File,\n        (CHAR16*)fileName,\n        EFI_FILE_MODE_CREATE | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_READ,\n        0\n    );\n    if (EFI_ERROR(Status)) {\n        Print(L&quot;fail: to create memory map file: %r\\n&quot;, Status);\n        return Status;\n    }\n\n    \/\/ CSV header\n    CHAR8* Header = &quot;Index, Type, PhysicalStart, NumberOfPages, Attribute\\r\\n&quot;;\n    WriteSize = AsciiStrLen(Header);\n    Status = File-&gt;Write(File, &WriteSize, Header);\n    if (EFI_ERROR(Status)) {\n        Print(L&quot;fail: to write header%r\\n&quot;, Status);\n        File-&gt;Close(File);\n        return Status;\n    }\n\n    EFI_MEMORY_DESCRIPTOR* Desc = (EFI_MEMORY_DESCRIPTOR*)map-&gt;Buffer;\n    UINTN Entries = map-&gt;MapSize \/ map-&gt;DescriptorSize;\n\n    for (UINTN i = 0; i &lt; Entries; i++) {\n        \n        \/\/ setup string\n        CHAR8 Line[256];\n\n        WriteSize = AsciiSPrint(Line, sizeof(Line),\n            &quot;%d, %d, %-ls, 0x%08lx, %ld, 0x%lx\\r\\n&quot;,\n            i,\n            Desc-&gt;Type,\n            GetMemoryTypeString(Desc-&gt;Type),\n            Desc-&gt;PhysicalStart,\n            Desc-&gt;NumberOfPages,\n            Desc-&gt;Attribute\n        );\n\n        \/\/ write string to file\n        Status = File-&gt;Write(File, &WriteSize, Line);\n        if (EFI_ERROR(Status)) {\n            Print(L&quot;fail: to write entry: %d%r\\n&quot;, Status);\n            File-&gt;Close(File);\n            return Status;\n        }\n\n        Desc = NEXT_MEMORY_DESCRIPTOR(Desc, map-&gt;DescriptorSize);\n    }\n\n    \/\/ add Summary Info.\n    CHAR8 Summary[256];\n    WriteSize = AsciiSPrint(Summary, sizeof(Summary),\n        &quot;\\r\\nMemory Map Summary\\r\\nEntries: %d\\r\\nDescriptor Size: %d\\r\\n&quot;,\n        Entries,\n        map-&gt;DescriptorSize\n    );\n\n    Status = File-&gt;Write(File, &WriteSize, Summary);\n    if (EFI_ERROR(Status)) {\n        Print(L&quot;fail: to write MemMap summary%r\\n&quot;, Status);\n        File-&gt;Close(File);\n        return Status;\n    }\n\n    File-&gt;Close(File);\n    return EFI_SUCCESS;\n}\n\nEFI_STATUS\nGetMemoryMap(MemoryMap* map) {\n    EFI_STATUS Status;\n\n    if (map == NULL) {\n        return EFI_INVALID_PARAMETER;\n    }\n\n    \/\/ \u521d\u671f\u30b5\u30a4\u30ba 0 \u3067\u30e1\u30e2\u30ea\u30de\u30c3\u30d7\u306e\u5927\u304d\u3055\u3092\u53d6\u5f97\n    map-&gt;MapSize = 0;\n    Status = gBS-&gt;GetMemoryMap(\n        &map-&gt;MapSize,\n        map-&gt;Buffer,\n        &map-&gt;MapKey,\n        &map-&gt;DescriptorSize,\n        &map-&gt;DescriptorVersion\n    );\n\n    if (Status != EFI_BUFFER_TOO_SMALL) {\n        Print(L&quot;Error: Unexpected GetMemory Status: %r\\n&quot;, Status);\n        return Status;\n    }\n\n    map-&gt;BufferSize = map-&gt;MapSize + MEMORY_MAP_BUFFER_PADDING * map-&gt;DescriptorSize;\n\n    if (map-&gt;Buffer != NULL) {\n        FreePool(map-&gt;Buffer);\n    }\n\n    map-&gt;Buffer = AllocatePool(map-&gt;BufferSize);\n    if (map-&gt;Buffer == NULL) {\n        Print(L&quot;fail: to allocate memory for map buffer: %r\\n&quot;, Status);\n        return EFI_OUT_OF_RESOURCES;\n    }\n\n    Status = gBS-&gt;GetMemoryMap(\n        &map-&gt;MapSize,\n        map-&gt;Buffer,\n        &map-&gt;MapKey,\n        &map-&gt;DescriptorSize,\n        &map-&gt;DescriptorVersion\n    );\n\n    if (EFI_ERROR(Status)) {\n        FreePool(map-&gt;Buffer);\n        map-&gt;Buffer = NULL;\n        Print(L&quot;fail: to get memory map: %r\\n&quot;, Status);\n        return Status;\n    }\n\n    return EFI_SUCCESS;\n}\n\n\n\nEFI_STATUS\nWriteFile(\n    IN CONST EFI_FILE_PROTOCOL *Root,\n    IN CONST CHAR16 *FileName,\n    IN CONST CHAR8 *Data\n)\n{\n    if (Root == NULL || FileName == NULL || Data == NULL) {\n        return EFI_INVALID_PARAMETER;\n    }\n\n    EFI_STATUS Status;\n    EFI_FILE_PROTOCOL *File;\n    UINTN WriteSize = StrLen(Data) * sizeof(CHAR16);\n\n    Status = Root-&gt;Open(\n        (EFI_FILE_PROTOCOL*)Root,\n        &File,\n        (CHAR16*)FileName,\n        EFI_FILE_MODE_CREATE | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_READ,\n        0\n    );\n    if (EFI_ERROR(Status)) {\n        Print(L&quot;fail: to create file\\n&quot;);\n        return Status;\n    }\n\n    Status = File-&gt;Write(File, &WriteSize, (VOID*)Data);\n    if (EFI_ERROR(Status)) {\n        Print(L&quot;fail: to write file\\n&quot;);\n        File-&gt;Close(File);\n        return Status;\n    }\n    \n    File-&gt;Close(File);\n    return EFI_SUCCESS;\n}\n\nEFI_STATUS\nReadFile(\n    IN EFI_FILE_PROTOCOL *Root,\n    IN CHAR16 *FileName,\n    OUT CHAR8 *Buffer,\n    IN UINTN BufferSize,\n    OUT UINTN *ReadSize\n)\n{\n    if (Root == NULL || FileName == NULL || Buffer == NULL || \n        BufferSize == 0 || ReadSize == NULL) {\n        return EFI_INVALID_PARAMETER;\n    }\n\n    EFI_STATUS Status;\n    EFI_FILE_PROTOCOL *File;\n\n    Status = Root-&gt;Open(\n        Root,\n        &File,\n        (CHAR16*)FileName,\n        EFI_FILE_MODE_READ,\n        0\n    );\n    if (EFI_ERROR(Status)) {\n        Print(L&quot;fail: to open file for reading\\n&quot;);\n        return Status;\n    }\n\n    *ReadSize = BufferSize;\n    Status = File-&gt;Read(File, ReadSize, Buffer);\n    if (EFI_ERROR(Status)) {\n        Print(L&quot;fail: to read file: %r\\n&quot;, Status);\n        File-&gt;Close(File);\n        return Status;\n    }\n\n    File-&gt;Close(File);\n    return EFI_SUCCESS;\n}\n\nEFI_STATUS\nEFIAPI\nUefiMain(\n    IN EFI_HANDLE ImageHandle,\n    IN EFI_SYSTEM_TABLE *SystemTable\n)\n{\n    EFI_STATUS Status;\n    MemoryMap Map;\n\n    InitializeMemoryMap(&Map);\n\n    Status = GetMemoryMap(&Map);\n    if (EFI_ERROR(Status)) {\n        Print(L&quot;fail: to get memory map %r\\n&quot;, Status);\n        return Status;\n    }\n\n    PrintMemoryMap(&Map);\n\n    EFI_SIMPLE_FILE_SYSTEM_PROTOCOL* FileSystem;\n    EFI_FILE_PROTOCOL* Root;\n    Status = SystemTable-&gt;BootServices-&gt;LocateProtocol(\n        &gEfiSimpleFileSystemProtocolGuid,\n        NULL,\n        (VOID**)&FileSystem\n    );\n    if (EFI_ERROR(Status)) {\n        Print(L&quot;faile: locate file system protocol\\n&quot;);\n        FreeMemoryMap(&Map);\n        return Status;\n    }\n\n    Status = FileSystem-&gt;OpenVolume(FileSystem, &Root);\n    if (EFI_ERROR(Status)) {\n        Print(L&quot;faile: open root directory\\n&quot;);\n        FreeMemoryMap(&Map);\n        return Status;\n    }    \n\n    Status = SaveMemoryMap(&Map, Root, L&quot;\\\\memmap.csv&quot;);\n    if (EFI_ERROR(Status)) {\n        Print(L&quot;%r\\n&quot;);\n        Root-&gt;Close(Root);\n        FreeMemoryMap(&Map);\n        return Status;\n    }\n\n    Print(L&quot;\\nMemMap ha benn saved to \\\\memmap.csv\\n&quot;);\n\n\n    Root-&gt;Close(Root);\n    FreeMemoryMap(&Map);\n\n    return EFI_SUCCESS;\n}\n<\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Hello6.inf \u306b\u3001 PrintLib \u3092\u8ffd\u52a0\u3057\u305f\u3002PrintLib \u306e\u4e2d\u306b AsciiSPrint() \u304c\u542b\u307e\u308c\u3066\u3044\u308b\u3089\u3057\u3044\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\" data-file=\"Hello6.inf\" data-line=\"24\"><code>[Defines]\nINF_VERSION     = 0x00010005\nBASE_NAME       = Hello6\nFILE_GUID       = A522DAB7-30AE-4F3D-85D1-92D1C24BEF30\nMODULE_TYPE     = UEFI_APPLICATION\nVERSION_STRING  = 0.0.1\nENTRY_POINT     = UefiMain\n\n[Sources]\nHello6.c\n\n[Guids]\ngEfiFileInfoGuid\ngEfiFileSystemInfoGuid\n\n[Packages]\nMdePkg\/MdePkg.dec\nHello6Pkg\/Hello6Pkg.dec\n\n[LibraryClasses]\nUefiLib\nUefiApplicationEntryPoint\nMemoryAllocationLib\nPrintLib\n\n[Protocols]\ngEfiSimpleFileSystemProtocolGuid\n<\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Hello6Pkg.dec \u306f\u307b\u3068\u3093\u3069\u308f\u304b\u3089\u306a\u3044\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\" data-file=\"Hello\uff16Pkg.dec\"><code>[Defines]\nDEC_SPECIFICATION   = 0x00010005\nPACKAGE_NAME        = Hello6Pkg\nPACKAGE_GUID        = A1D6D642-D269-44DF-B225-5FFA7AB8E958\nPACKAGE_VERSION     = 0.0.1\n\n[Includes]\n\n[Guids]\n\n[Protocols]\n\n[PcdsFixedAtBuild]\n<\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Hello6Pkg.\uff44\uff53\uff43 \u30d5\u30a1\u30a4\u30eb\u306f\u5909\u66f4\u306f\u3042\u308a\u307e\u305b\u3093\u3002\u3068\u3044\u3046\u3053\u3068\u306f\u3001\u4ee5\u524d\u306e\u3082\u306e\u306f\u3001PrintLib \u884c\u306f\u3044\u3089\u306a\u304b\u3063\u305f\u306e\u304b\u3082\u3057\u308c\u306a\u3044\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\" data-file=\"Hello\uff16Pkg.dsc\"><code>[Defines]\nPLATFORM_NAME           = Hello6Pkg\nPLATFORM_GUID           = DA50351D-D7B7-45DD-911C-B54BAB54F702\nPLATFORM_VERSION        = 0.0.1\nDSC_SPECIFICATION       = 0x00010005\nOUTPUT_DIRECTORY        = Build\/Hello6Pkg\nSUPPORTED_ARCHITECTURES = X64\nBUILD_TARGETS           = DEBUG | RELEASE | NOOPT\nSKUID_IDENTIFIER        = DEFAULT\n\n[LibraryClasses]\nUefiApplicationEntryPoint|MdePkg\/Library\/UefiApplicationEntryPoint\/UefiApplicationEntryPoint.inf\nUefiLib|MdePkg\/Library\/UefiLib\/UefiLib.inf\n\n\nBaseLib|MdePkg\/Library\/BaseLib\/BaseLib.inf\nBaseMemoryLib|MdePkg\/Library\/BaseMemoryLib\/BaseMemoryLib.inf\nDebugLib|MdePkg\/Library\/BaseDebugLibNull\/BaseDebugLibNull.inf\nDevicePathLib|MdePkg\/Library\/UefiDevicePathLib\/UefiDevicePathLib.inf\nMemoryAllocationLib|MdePkg\/Library\/UefiMemoryAllocationLib\/UefiMemoryAllocationLib.inf\nPcdLib|MdePkg\/Library\/BasePcdLibNull\/BasePcdLibNull.inf\nPrintLib|MdePkg\/Library\/BasePrintLib\/BasePrintLib.inf\nRegisterFilterLib|MdePkg\/Library\/RegisterFilterLibNull\/RegisterFilterLibNull.inf\nUefiBootServicesTableLib|MdePkg\/Library\/UefiBootServicesTableLib\/UefiBootServicesTableLib.inf\nUefiRuntimeServicesTableLib|MdePkg\/Library\/UefiRuntimeServicesTableLib\/UefiRuntimeServicesTableLib.inf\n\n[Components]\nHello6Pkg\/Hello6.inf\n<\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u30d3\u30eb\u30c9\u306f\u3044\u3064\u3082\u3068\u540c\u3058\u611f\u3058\u3067\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u624b\u304f\u52d5\u304f\u3068\u3001test.txt \u304c\u30a4\u30e1\u30fc\u30b8\u30d5\u30a1\u30a4\u30eb\u306e\u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u4f5c\u6210\u3055\u308c\u3001QEMU \u306e\u753b\u9762\u306b test.txt \u304b\u3089\u8aad\u307f\u8fbc\u3093\u3060 Hello file system\\n \u304c\u8868\u793a\u3055\u308c\u308b\u306f\u305a\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">test.txt \u304c\u5b58\u5728\u3059\u308b\u72b6\u614b\u3067\u5b9f\u884c\u3057\u3066\u3082\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u308a\u76f4\u3057\u3066\u3044\u308b\u306e\u304b\u30d5\u30a1\u30a4\u30eb\u306e\u30bf\u30a4\u30e0\u30b9\u30bf\u30f3\u30d7\u306f\u66f4\u65b0\u3055\u308c\u3066\u554f\u984c\u306a\u304f\u52d5\u4f5c\u3057\u3066\u3044\u308b\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>$ cd edk2\n$ build -p Hello\uff16Pkg\/Hello\uff16Pkg.dsc\n$ cd ..\n\n# \u30a4\u30e1\u30fc\u30b8\u30c7\u30a3\u30b9\u30af\u306b\u66f8\u304d\u8fbc\u3080\n$ sudo mount -o loop,uid=$(id -u),gid=$(id -u) disk.img .\/mnt\n$ cp .\/edk2\/Build\/Hello\uff16Pkg\/DEBUG_CLANGDWARF\/X64\/Hello\uff16.efi .\/mnt\/EFI\/BOOT\n$ sudo umount .\/mnt\n\n# QEMU \u3067\u5b9f\u884c\n$ qemu-system-x86_64 \\\n\t\t-drive if=pflash,format=raw,readonly=on,file=edk2\/Build\/OvmfX64\/DEBUG_GCC\/FV\/OVMF_CODE.fd \\\n\t\t-drive if=pflash,format=raw,file=edk2\/Build\/OvmfX64\/DEBUG_GCC\/FV\/OVMF_VARS.fd \\\n\t\t-drive format=raw,file=disk.img\n<\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u6b21\u3053\u305d\u30ab\u30fc\u30cd\u30eb\u306e\u30ed\u30fc\u30c9\u306b\u306b\u9032\u3081\u308b\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">memmap.csv \u306f fs0: \u306e \u30eb\u30fc\u30c8\u306b\u4f5c\u6210\u3055\u308c\u308b\u3002\u4e0a\u624b\u304f\u884c\u3051\u3070\u3053\u3093\u306a\u611f\u3058\u306b\u306a\u308b\u3002QEMU \u3092\u540c\u3058\u3088\u3046\u306b\u8d77\u52d5\u3059\u308c\u3070\u6050\u3089\u304f\u540c\u3058\u3088\u3046\u306a\u30e1\u30e2\u30ea\u30de\u30c3\u30d7\u306b\u306a\u308b\u306f\u305a\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\" data-file=\"fs0:\\memmap.csv\"><code>Index, Type, PhysicalStart, NumberOfPages, Attribute\n0, 7, Conventional, 0x00000000, 160, 0xF\n1, 7, Conventional, 0x00100000, 1792, 0xF\n2, 10, ACPINVS, 0x00800000, 8, 0xF\n3, 7, Conventional, 0x00808000, 3, 0xF\n4, 10, ACPINVS, 0x0080B000, 1, 0xF\n5, 7, Conventional, 0x0080C000, 5, 0xF\n6, 10, ACPINVS, 0x00811000, 239, 0xF\n7, 4, BootData, 0x00900000, 3712, 0xF\n8, 7, Conventional, 0x01780000, 9196, 0xF\n9, 4, BootData, 0x03B6C000, 32, 0xF\n10, 7, Conventional, 0x03B8C000, 9325, 0xF\n11, 1, LoaderCode, 0x05FF9000, 227, 0xF\n12, 7, Conventional, 0x060DC000, 90, 0xF\n13, 4, BootData, 0x06136000, 31, 0xF\n14, 7, Conventional, 0x06155000, 15, 0xF\n15, 1, LoaderCode, 0x06164000, 3, 0xF\n16, 7, Conventional, 0x06167000, 3, 0xF\n17, 4, BootData, 0x0616A000, 1569, 0xF\n18, 3, BootCode, 0x0678B000, 180, 0xF\n19, 4, BootData, 0x0683F000, 108, 0xF\n20, 3, BootCode, 0x068AB000, 30, 0xF\n21, 4, BootData, 0x068C9000, 1, 0xF\n22, 3, BootCode, 0x068CA000, 22, 0xF\n23, 4, BootData, 0x068E0000, 2, 0xF\n24, 3, BootCode, 0x068E2000, 21, 0xF\n25, 4, BootData, 0x068F7000, 4, 0xF\n26, 3, BootCode, 0x068FB000, 30, 0xF\n27, 4, BootData, 0x06919000, 5, 0xF\n28, 3, BootCode, 0x0691E000, 47, 0xF\n29, 4, BootData, 0x0694D000, 6, 0xF\n30, 3, BootCode, 0x06953000, 40, 0xF\n31, 4, BootData, 0x0697B000, 1, 0xF\n32, 3, BootCode, 0x0697C000, 21, 0xF\n33, 4, BootData, 0x06991000, 8, 0xF\n34, 3, BootCode, 0x06999000, 19, 0xF\n35, 4, BootData, 0x069AC000, 1, 0xF\n36, 3, BootCode, 0x069AD000, 43, 0xF\n37, 4, BootData, 0x069D8000, 5, 0xF\n38, 3, BootCode, 0x069DD000, 35, 0xF\n39, 4, BootData, 0x06A00000, 514, 0xF\n40, 3, BootCode, 0x06C02000, 3, 0xF\n41, 4, BootData, 0x06C05000, 3, 0xF\n42, 3, BootCode, 0x06C08000, 11, 0xF\n43, 4, BootData, 0x06C13000, 1, 0xF\n44, 3, BootCode, 0x06C14000, 4, 0xF\n45, 4, BootData, 0x06C18000, 6, 0xF\n46, 3, BootCode, 0x06C1E000, 47, 0xF\n47, 4, BootData, 0x06C4D000, 9, 0xF\n48, 3, BootCode, 0x06C56000, 33, 0xF\n49, 4, BootData, 0x06C77000, 4, 0xF\n50, 3, BootCode, 0x06C7B000, 28, 0xF\n51, 4, BootData, 0x06C97000, 5, 0xF\n52, 3, BootCode, 0x06C9C000, 7, 0xF\n53, 4, BootData, 0x06CA3000, 3, 0xF\n54, 3, BootCode, 0x06CA6000, 36, 0xF\n55, 4, BootData, 0x06CCA000, 3, 0xF\n56, 3, BootCode, 0x06CCD000, 15, 0xF\n57, 4, BootData, 0x06CDC000, 2, 0xF\n58, 3, BootCode, 0x06CDE000, 3, 0xF\n59, 4, BootData, 0x06CE1000, 3, 0xF\n60, 3, BootCode, 0x06CE4000, 38, 0xF\n61, 4, BootData, 0x06D0A000, 5, 0xF\n62, 3, BootCode, 0x06D0F000, 2, 0xF\n63, 4, BootData, 0x06D11000, 1042, 0xF\n64, 3, BootCode, 0x07123000, 6, 0xF\n65, 4, BootData, 0x07129000, 2, 0xF\n66, 3, BootCode, 0x0712B000, 10, 0xF\n67, 4, BootData, 0x07135000, 6, 0xF\n68, 3, BootCode, 0x0713B000, 23, 0xF\n69, 4, BootData, 0x07152000, 923, 0xF\n70, 6, RuntimeData, 0x074ED000, 256, 0x800000000000000F\n71, 5, RuntimeCode, 0x075ED000, 256, 0x800000000000000F\n72, 0, Reserved, 0x076ED000, 128, 0xF\n73, 9, ACPIReclaim, 0x0776D000, 18, 0xF\n74, 10, ACPINVS, 0x0777F000, 128, 0xF\n75, 4, BootData, 0x077FF000, 1537, 0xF\n76, 7, Conventional, 0x07E00000, 96, 0xF\n77, 4, BootData, 0x07E60000, 32, 0xF\n78, 3, BootCode, 0x07E80000, 47, 0xF\n79, 0, Reserved, 0x07EAF000, 4, 0xF\n80, 10, ACPINVS, 0x07EB3000, 2, 0xF\n81, 3, BootCode, 0x07EB5000, 1, 0xF\n82, 4, BootData, 0x07EB6000, 17, 0xF\n83, 3, BootCode, 0x07EC7000, 45, 0xF\n84, 6, RuntimeData, 0x07EF4000, 132, 0x800000000000000F\n85, 10, ACPINVS, 0x07F78000, 136, 0xF\n86, 11, MMIO, 0xFFC00000, 1024, 0x8000000000000001\n87, 0, Reserved, 0xFD00000000, 3145728, 0x0\n\nMemory Map Summary\nEntries: 88\nDescriptor Size: 48<\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u56de\u306f\u3001\u30e1\u30e2\u30ea\u30de\u30c3\u30d7\u3092\u753b\u9762\u306b\u30c0\u30f3\u30d7\u3057\u305f\u306e\u3067\u4eca\u56de\u306f\u3001\u30e1\u30e2\u30ea\u30de\u30c3\u30d7\u3092\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u306b\u4fdd\u5b58\u3057\u307e\u3059\u3002 Mikan \u672c\u306b\u306a\u3089\u3044\u3001\u30e1\u30e2\u30ea\u30de\u30c3\u30d7\u7528\u306e\u69cb\u9020\u4f53\u3092\u4f5c\u308a\u3001UEFI \u30b3\u30f3\u30bd\u30fc\u30eb\u306b\u30e1\u30e2\u30ea\u30de\u30c3\u30d7\u3092\u8868\u793a\u3057\u3066\u307f\u307e\u3059\u3002 \u30d5\u30a1\u30a4\u30eb\u69cb\u6210 H [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":2,"footnotes":""},"categories":[9],"tags":[10],"class_list":["post-921","post","type-post","status-publish","format-standard","hentry","category-dev","tag-mikan"],"_links":{"self":[{"href":"https:\/\/blog.txn.red\/index.php?rest_route=\/wp\/v2\/posts\/921","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.txn.red\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.txn.red\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.txn.red\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.txn.red\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=921"}],"version-history":[{"count":0,"href":"https:\/\/blog.txn.red\/index.php?rest_route=\/wp\/v2\/posts\/921\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.txn.red\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=921"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.txn.red\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=921"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.txn.red\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=921"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}