2023-05-07 22:19:36 +00:00
|
|
|
// This file is part of noxos and licensed under the MIT open source license
|
|
|
|
|
|
|
|
#ifndef NOXOS_GPT_H
|
|
|
|
#define NOXOS_GPT_H
|
|
|
|
|
|
|
|
#include "utils/stdtypes.h"
|
2023-05-08 15:30:35 +00:00
|
|
|
#include "utils/string.h"
|
2023-05-07 22:19:36 +00:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
GPT_PARTITION_GUID_UNUSED,
|
2023-05-08 15:30:35 +00:00
|
|
|
GPT_PARTITION_GUID_UNKNOWN,
|
|
|
|
GPT_PARTITION_GUID_PRIMARY,
|
2023-05-07 22:19:36 +00:00
|
|
|
GPT_PARTITION_GUID_EFI_SYSTEM,
|
|
|
|
|
|
|
|
GPT_PARTITION_GUID_ENUM_END
|
|
|
|
} gpt_partition_type_guids_E;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
uint8_t signature [8];
|
|
|
|
uint32_t revision;
|
|
|
|
uint32_t header_size;
|
|
|
|
uint32_t checksum_crc32;
|
|
|
|
uint32_t reserved;
|
|
|
|
uint64_t current_lba;
|
|
|
|
uint64_t backup_lba;
|
|
|
|
uint64_t first_usable_lba;
|
|
|
|
uint64_t last_usable_lba;
|
2023-05-08 15:30:35 +00:00
|
|
|
uint8_t disk_guid [16];
|
2023-05-07 22:19:36 +00:00
|
|
|
uint64_t starting_lba;
|
|
|
|
uint32_t num_partitions;
|
|
|
|
uint32_t partition_entry_size;
|
|
|
|
uint32_t partition_entry_crc32;
|
|
|
|
uint8_t reserved2 [0x1A4];
|
|
|
|
}__attribute__((packed)) gpt_table_header_T;
|
|
|
|
|
|
|
|
typedef struct {
|
2023-05-08 15:30:35 +00:00
|
|
|
uint8_t partition_type_guid [16];
|
|
|
|
uint8_t partition_guid [16];
|
2023-05-07 22:19:36 +00:00
|
|
|
uint64_t starting_lba;
|
|
|
|
uint64_t ending_lba;
|
|
|
|
uint64_t attributes;
|
2023-05-08 15:30:35 +00:00
|
|
|
uint16_t name [36]; // UTF-16 encoded
|
2023-05-07 22:19:36 +00:00
|
|
|
}__attribute__((packed)) gpt_partition_entry_T;
|
|
|
|
|
2023-05-08 15:30:35 +00:00
|
|
|
gpt_partition_type_guids_E gpt_get_partition_type (uint8_t guid[16]);
|
|
|
|
string_t gpt_partition_type_to_string(gpt_partition_type_guids_E type);
|
|
|
|
|
|
|
|
extern uint8_t g_gpt_partition_type_guides[GPT_PARTITION_GUID_ENUM_END][16];
|
2023-05-07 22:19:36 +00:00
|
|
|
|
|
|
|
#endif //NOXOS_GPT_H
|