{"id":1405,"date":"2026-04-25T08:30:30","date_gmt":"2026-04-24T23:30:30","guid":{"rendered":"https:\/\/pg-mana.net\/blog\/?p=1405"},"modified":"2026-04-25T08:30:30","modified_gmt":"2026-04-24T23:30:30","slug":"efi_memory_descriptor_size","status":"publish","type":"post","link":"https:\/\/pg-mana.net\/blog\/efi_memory_descriptor_size\/","title":{"rendered":"EFI_MEMORY_DESCRIPTOR\u306e\u30b5\u30a4\u30ba\u306f\u4f55\u30d0\u30a4\u30c8"},"content":{"rendered":"\n<p>\u5c0f\u30cd\u30bf<\/p>\n\n\n\n<p>Methylenix\u306eUEFI\u30d6\u30fc\u30c8\u30ed\u30fc\u30c0\u3092\u4f5c\u308a\u76f4\u3057\u3066\u3044\u308b\u6642\u306b\u3001\u30e1\u30e2\u30ea\u30de\u30c3\u30d7\u3092\u53d6\u5f97\u3057\u3066\u78ba\u8a8d\u3059\u308b\u305f\u3081\u306b\u3001\u3068\u308a\u3042\u3048\u305a\u30a4\u30c6\u30ec\u30fc\u30bf\u3092\u56de\u3057\u3066\u8868\u793a\u3059\u308b\u969b\u306b<code>GetMemoryMap<\/code>\u95a2\u6570\u306e\u8fd4\u3059<code>EFI_MEMORY_DESCRIPTOR<\/code>\u306e\u30b5\u30a4\u30ba(<code>DescriptorSize<\/code>)\u3068\u624b\u5143\u3067\u5b9a\u7fa9\u3057\u305f\u69cb\u9020\u4f53\u306e\u30b5\u30a4\u30ba\u304c\u540c\u3058\u3067\u3042\u308b\u3068\u3044\u3046assert\u3092\u5165\u308c\u305f\u3068\u3053\u308d\u767a\u706b\u3057\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p><code>EFI_MEMORY_DESCRIPTOR<\/code>\u306f40\u30d0\u30a4\u30c8\u3001\u3067\u3082<code>DescriptorSize<\/code>\u306f48\u30d0\u30a4\u30c8\u3002\u3055\u3066\u3053\u306e8\u30d0\u30a4\u30c8\u306f\u4e00\u4f53\u306a\u3093\u3060\u308d\u3046\u3001\u30a2\u30e9\u30a4\u30e1\u30f3\u30c8\u3067\u3082\u3042\u308b\u307e\u3044\u3057\u3001\u77e5\u3089\u306a\u3044\u30e1\u30f3\u30d0\u3067\u3082\u3044\u308b\u306e\u304b\u306a\u3068\u601d\u3063\u3066\u8abf\u3079\u308b\u3082\u4f55\u3082\u51fa\u305a\u3002<\/p>\n\n\n\n<p>\u6d41\u884c\u308a\u306eAI\u306b\u805e\u304f\u3068\u300c4 + 4(Padding) + 8 + 8 + 8 + 8 = 48\u3067\u3059\uff01\u300d\u3068\u81ea\u4fe1\u6e80\u3005\u306b\u56de\u7b54\u3059\u308b\u306e\u3067\u3001\u81ea\u5206\u306f\u8db3\u3057\u7b97\u3059\u3089\u3067\u304d\u306a\u304f\u306a\u3063\u305f\u306e\u3067\u306f\u306a\u3044\u304b\u3068\u30af\u30e9\u30af\u30e9\u3059\u308b\u3070\u304b\u308a\u3002<\/p>\n\n\n\n<p>\u3084\u306f\u308a\u5b9f\u88c5\u306f\u6b63\u7fa9\u306a\u306e\u3067\u3001<a href=\"https:\/\/github.com\/tianocore\/edk2\/blob\/87cfc60f2066c35e58b0803e9c022397acc8797d\/MdeModulePkg\/Core\/Dxe\/Mem\/Page.c#L2192\">EDKII\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/a>\u3092\u898b\u306b\u884c\u3063\u305f\u3068\u3053\u308d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  Size = sizeof (EFI_MEMORY_DESCRIPTOR);\n\n  \/\/\n  \/\/ Make sure Size != sizeof(EFI_MEMORY_DESCRIPTOR). This will\n  \/\/ prevent people from having pointer math bugs in their code.\n  \/\/ now you have to use *DescriptorSize to make things work.\n  \/\/\n  Size += sizeof (UINT64) - (Size % sizeof (UINT64));<\/code><\/pre>\n\n\n\n<p>\u4eba\u985e\u304c\u611a\u304b\u306a\u904e\u3061\u3092\u4fb5\u3055\u306c\u3088\u3046\u306b\u308f\u3056\u3068\u305a\u3089\u3057\u3066\u3042\u308b\u3068\u306e\u3053\u3068\u3067\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u6c17\u6301\u3061\u306f\u308f\u304b\u3089\u306a\u304f\u3082\u306a\u3044\u304c\u3001\u30c7\u30d0\u30c3\u30b0\u306e\u305f\u3081\u306b\u7c21\u5358\u306b\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u969b(\u7279\u306bRust\u306a\u3069)\u306b\u306f\u5c11\u3057\u56f0\u308b\u3057\u3001\u4e16\u306b\u51fa\u3066\u3044\u308bEDKII\u30d9\u30fc\u30b9\u306eUEFI BIOS\u3092\u8f09\u305b\u305fPC\u306f\u6bce\u56de8\u30d0\u30a4\u30c8\u4f59\u5206\u306b\u7a7a\u3044\u305f\u30e1\u30e2\u30ea\u30de\u30c3\u30d7\u306e\u30ea\u30b9\u30c8\u3092\u8fd4\u3057\u3066\u3044\u308b\u306e\u306f\u306a\u3093\u3060\u304b\u306a\u3041\u3001\u3068\u601d\u3046\u306e\u3067\u3042\u3063\u305f\u3002<\/p>\n\n\n\n<p>\uff08\u8ffd\u4f38\uff1a\u304d\u3063\u3068\u3053\u306e\u8a18\u4e8b\u3092\u5b66\u7fd2\u3057\u3066AI\u3082\u8ce2\u304f\u306a\u308b\u306e\u3060\u308d\u3046&#8230;\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5c0f\u30cd\u30bf Methylenix\u306eUEFI\u30d6\u30fc\u30c8\u30ed\u30fc\u30c0\u3092\u4f5c\u308a\u76f4\u3057\u3066\u3044\u308b\u6642\u306b\u3001\u30e1\u30e2\u30ea\u30de\u30c3\u30d7\u3092\u53d6\u5f97\u3057\u3066\u78ba\u8a8d\u3059\u308b\u305f\u3081\u306b\u3001\u3068\u308a\u3042\u3048\u305a\u30a4\u30c6\u30ec\u30fc\u30bf\u3092\u56de\u3057\u3066\u8868\u793a\u3059\u308b\u969b\u306bGetMemoryMap\u95a2\u6570\u306e\u8fd4\u3059EFI_MEMORY_DESCRIP [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1405","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/pg-mana.net\/blog\/wp-json\/wp\/v2\/posts\/1405","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pg-mana.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pg-mana.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pg-mana.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pg-mana.net\/blog\/wp-json\/wp\/v2\/comments?post=1405"}],"version-history":[{"count":1,"href":"https:\/\/pg-mana.net\/blog\/wp-json\/wp\/v2\/posts\/1405\/revisions"}],"predecessor-version":[{"id":1406,"href":"https:\/\/pg-mana.net\/blog\/wp-json\/wp\/v2\/posts\/1405\/revisions\/1406"}],"wp:attachment":[{"href":"https:\/\/pg-mana.net\/blog\/wp-json\/wp\/v2\/media?parent=1405"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pg-mana.net\/blog\/wp-json\/wp\/v2\/categories?post=1405"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pg-mana.net\/blog\/wp-json\/wp\/v2\/tags?post=1405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}