int VentoyFillGpt(UINT64 DiskSizeBytes, VTOY_GPT_INFO *pInfo)\r
{\r
INT64 ReservedValue = 0;\r
+ UINT64 ModSectorCount = 0;\r
UINT64 ReservedSector = 33;\r
UINT64 Part1SectorCount = 0;\r
UINT64 DiskSectorCount = DiskSizeBytes / 512;\r
ReservedSector += ReservedValue * 2048;\r
}\r
\r
+ Part1SectorCount = DiskSectorCount - ReservedSector - (VENTOY_EFI_PART_SIZE / 512) - 2048;\r
+\r
+ ModSectorCount = (Part1SectorCount % 8);\r
+ if (ModSectorCount)\r
+ {\r
+ Log("Part1SectorCount:%llu is not aligned by 4KB (%llu)", (ULONGLONG)Part1SectorCount, (ULONGLONG)ModSectorCount);\r
+ }\r
+\r
// check aligned with 4KB\r
if (IsPartNeed4KBAlign())\r
{\r
- if (DiskSectorCount % 8)\r
+ if (ModSectorCount)\r
{\r
- Log("Disk need to align with 4KB %u", (UINT32)(DiskSectorCount % 8));\r
- ReservedSector += (DiskSectorCount % 8);\r
+ Log("Disk need to align with 4KB %u", (UINT32)ModSectorCount);\r
+ Part1SectorCount -= ModSectorCount;\r
+ }\r
+ else\r
+ {\r
+ Log("no need to align with 4KB");\r
}\r
}\r
\r
- Part1SectorCount = DiskSectorCount - ReservedSector - (VENTOY_EFI_PART_SIZE / 512) - 2048;\r
-\r
memcpy(Head->Signature, "EFI PART", 8);\r
Head->Version[2] = 0x01;\r
Head->Length = 92;\r
CoCreateGuid(&(Table[1].PartGuid));\r
Table[1].StartLBA = Table[0].LastLBA + 1;\r
Table[1].LastLBA = Table[1].StartLBA + VENTOY_EFI_PART_SIZE / 512 - 1;\r
- Table[1].Attr = 0x8000000000000001ULL;\r
+ Table[1].Attr = 0xC000000000000001ULL;\r
memcpy(Table[1].Name, L"VTOYEFI", 7 * 2);\r
\r
#if 0\r