2022-11-03 22:35:57 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2024-05-31 20:28:25 +00:00
|
|
|
#include "boot.h"
|
2022-11-03 22:35:57 +00:00
|
|
|
|
|
|
|
// LBA 0: Protective MBR
|
|
|
|
// ignored here
|
|
|
|
|
|
|
|
// Partition Table Header (LBA 1)
|
|
|
|
typedef struct gpt_pth
|
|
|
|
{
|
|
|
|
uint64_t signature;
|
|
|
|
uint32_t revision;
|
|
|
|
uint32_t header_size; //! little endian, usually 0x5c = 92
|
|
|
|
uint32_t crc_header;
|
|
|
|
uint32_t reserved; //! must be 0
|
|
|
|
uint64_t current_lba;
|
|
|
|
uint64_t backup_lba;
|
|
|
|
uint64_t first_usable_lba;
|
|
|
|
uint64_t last_usable_lba;
|
|
|
|
uint8_t disk_guid[16];
|
|
|
|
uint64_t partition_entries_lba;
|
|
|
|
uint32_t nr_partition_entries;
|
|
|
|
uint32_t size_partition_entry; //! usually 0x80 = 128
|
|
|
|
uint32_t crc_partition_entry;
|
|
|
|
} gpt_pth_t;
|
|
|
|
|
|
|
|
// Partition Entries (LBA 2-33)
|
|
|
|
typedef struct partition_entries
|
|
|
|
{
|
|
|
|
uint8_t partition_type_guid[16];
|
|
|
|
uint8_t partition_guid[16];
|
|
|
|
uint64_t first_lba;
|
|
|
|
uint64_t last_lba; //! inclusive
|
|
|
|
uint64_t attributes;
|
|
|
|
uint8_t name[72]; //! utf16 encoded
|
|
|
|
} partition_entries_t;
|
|
|
|
|
|
|
|
// Find boot partition and load it to the destination
|
2024-07-23 20:46:18 +00:00
|
|
|
int gpt_load_partitions();
|