block: read GPT header from block devices on init

This commit is contained in:
Michael Shaw 2023-05-13 23:04:15 -04:00
commit 05c528f64c
6 changed files with 138 additions and 8 deletions

52
include/kernel/gpt.h Normal file
View file

@ -0,0 +1,52 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef _GPT_H_
#define _GPT_H_
#include <kernel/common.h>
struct block_device;
/* GPT LBA 0 */
struct gpt_mbr_prot {
uint8_t boot[1];
uint8_t chs_start[3];
uint8_t type[1];
uint8_t chs_end[3];
uint8_t lba_start[4];
uint8_t lba_size[4];
} PACKED;
/* GPT LBA 1
* checksums use CRC32
*/
struct gpt_header {
uint64_t signature;
uint8_t revision[4];
uint8_t header_size[4];
uint8_t checksum[4];
uint8_t reserved[4];
uint64_t lba_this;
uint64_t lba_alt;
uint64_t lba_first;
uint64_t lba_last;
uint8_t guid[16];
uint64_t lba_table;
uint32_t entry_count;
uint32_t entry_size;
uint32_t checksum_table;
} PACKED;
/* GPT LBA 2 */
struct gpt_entry {
uint8_t guid[16];
uint8_t guid_parent[16];
uint64_t lba_first;
uint64_t lba_last;
uint8_t attr[8];
char name[72];
} PACKED;
void block_gpt_init(struct block_device *dev);
#endif /* _GPT_H_ */