diff options
Diffstat (limited to 'src/kernel/gpt.h')
-rw-r--r-- | src/kernel/gpt.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/kernel/gpt.h b/src/kernel/gpt.h new file mode 100644 index 0000000..fb872df --- /dev/null +++ b/src/kernel/gpt.h @@ -0,0 +1,69 @@ +/* +Copyright 2019 Benji Dial + +Permission to use, copy, modify, and/or distribute this +software for any purpose with or without fee is hereby +granted, provided that the above copyright notice and this +permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS +ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO +EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER +RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE +OF THIS SOFTWARE. +*/ + +#include <stdint.h> +#include <stdbool.h> + +#ifndef GPT_H +#define GPT_H + +struct uuid { + uint64_t le; + uint64_t be; +} __attribute__ ((__packed__)); + +struct gpt_header { + uint8_t signature[8]; + uint32_t version; + uint32_t header_length; + uint32_t check;//crc + uint32_t spacing; + uint64_t head_sector; + uint64_t head_backup_sector; + uint64_t data_start; + uint64_t data_last; + struct uuid id; + uint64_t pt_sector; + uint32_t n_parts; + uint32_t part_size; + uint32_t pt_check; +} __attribute__ ((__packed__)); + +struct gpt_entry { + struct uuid type; + struct uuid id; + uint64_t sector; + uint64_t last_sector; + uint64_t flags; + uint8_t name[72]; +} __attribute__ ((__packed__)); + +enum type_le { + GPT_ESP_LE = 0xc12a7328f81f11d2, + GPT_BOOT_LE = 0x2168614864496e6f +}; + +enum type_be { + GPT_ESP_BE = 0x3bc93ec9a0004bba, + GPT_BOOT_BE = 0x4946456465654e74 +}; + +bool gpt_parse_pt(uint8_t dn, uint8_t *buffer); + +#endif
\ No newline at end of file |