Luna/kernel/src/fs/GPT.h

44 lines
1.0 KiB
C++

#pragma once
#include "fs/MBR.h"
#define GPT_SIGNATURE "EFI PART"
#define GPT_SIGNATURE_LENGTH 8
#define GPT_SECTOR_SIZE 512ul
#define GPT_REVISION 0x00010000
namespace GPT
{
struct [[gnu::packed]] Header
{
u8 signature[GPT_SIGNATURE_LENGTH];
u32 revision;
u32 hdr_size;
u32 checksum;
u32 reserved;
u64 this_lba;
u64 alternate_lba;
u64 first_usable;
u64 last_usable;
u8 guid[16];
u64 partition_table_lba;
u32 num_partitions;
u32 partition_entry_size;
u32 partition_table_checksum;
char blank[512 - 0x5c];
};
struct [[gnu::packed]] PartitionEntry
{
u8 type_guid[16];
u8 unique_guid[16];
u64 start_lba;
u64 end_lba;
u64 attributes;
char partition_name[72]; // Could be more or less, see Header::partition_entry_size - 0x38 for the actual size.
};
Result<bool> identify(SharedPtr<Device> device);
u32 checksum_gpt(Header header);
}