Add library header files for partition tables
authorTormod Volden <debian.tormod@gmail.com>
Fri, 23 Feb 2018 21:31:27 +0000 (22:31 +0100)
committerAlan Cox <alan@linux.intel.com>
Sat, 10 Mar 2018 23:55:02 +0000 (23:55 +0000)
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
Library/include/gpt.h [new file with mode: 0644]
Library/include/mbr.h [new file with mode: 0644]

diff --git a/Library/include/gpt.h b/Library/include/gpt.h
new file mode 100644 (file)
index 0000000..db9d11d
--- /dev/null
@@ -0,0 +1,46 @@
+#ifndef __GPT_DOT_H__
+#define __GPT_DOT_H__
+
+/* Copyright 2018 Tormod Volden */
+
+#define MBR_GPT_PROTECTED_TYPE 0xEE
+
+/* FUZIX root partition type */
+#define GPT_FUZIX_ROOT_UUID 63ce1ba5-46ab-49bd-abf4-2859975849e1
+#define GPT_FUZIX_ROOT_UUID_16BIT 1ba5
+
+typedef struct __attribute((packed)) {
+       uint8_t signature[8];
+       uint32_t        revision;
+       uint32_t        header_size;
+       uint32_t        header_crc;
+       uint8_t reserved[4];
+       uint32_t        current_lba_lsb; /* 64 bit LSB */
+       uint32_t        current_lba_msb;
+       uint32_t        backup_lba_lsb;
+       uint32_t        backup_lba_msb;
+       uint32_t        first_usable_lba_lsb;
+       uint32_t        first_usable_lba_msb;
+       uint32_t        last_usable_lba_lsb;
+       uint32_t        last_usable_lba_msb;
+       uint8_t disk_guid[16];
+       uint32_t        table_starting_lba_lsb;
+       uint32_t        table_starting_lba_msb;
+       uint32_t        num_part_entries;
+       uint32_t        size_part_entry;
+       uint32_t        crc_part_array;
+       /* reserved to end of block */
+} gpt_header_t;
+
+typedef struct __attribute((packed)) {
+       uint8_t type_guid[16];
+       uint8_t uniq_part_guid[16];
+       uint32_t        first_lba_lsb;
+       uint32_t        first_lba_msb;
+       uint32_t        last_lba_lsb;
+       uint32_t        last_lba_msb;
+       uint8_t attr_flags[8];
+       uint8_t part_name[72]; /* 36 UTF_16LE */
+} gpt_partition_entry_t;
+
+#endif /* __GPT_DOT_H__ */
diff --git a/Library/include/mbr.h b/Library/include/mbr.h
new file mode 100644 (file)
index 0000000..d2f44d5
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef __MBR_DOT_H__
+#define __MBR_DOT_H__
+
+/* 2015-01-04 Will Sowerbutts */
+
+typedef struct __attribute((packed)) {
+    /* Described this way so that it packs */
+    uint8_t  status_chs_first[4];
+    uint8_t  type_chs_last[4];
+    uint32_t lba_first;
+    uint32_t lba_count;
+} partition_table_entry_t;
+
+#define MBR_ENTRY_COUNT 4
+#define MBR_SIGNATURE 0xAA55
+typedef struct __attribute((packed)) {
+    uint8_t bootcode[446];
+    partition_table_entry_t partition[MBR_ENTRY_COUNT];
+    uint16_t signature;
+} boot_record_t;
+
+#endif /* __MBR_DOT_H__ */