feat: refactor to use gcc types
This commit is contained in:
@@ -11,31 +11,31 @@
|
||||
#include <libc/libc.h>
|
||||
|
||||
typedef struct {
|
||||
u8 bootable;
|
||||
u8 starting_head;
|
||||
u8 starting_sector: 6;
|
||||
u16 starting_cylinder: 10;
|
||||
u8 system_id;
|
||||
u8 ending_head;
|
||||
u8 ending_sector: 6;
|
||||
u16 ending_cylinder: 10;
|
||||
u32 start_lba;
|
||||
u32 num_lbas;
|
||||
uint8_t bootable;
|
||||
uint8_t starting_head;
|
||||
uint8_t starting_sector: 6;
|
||||
uint16_t starting_cylinder: 10;
|
||||
uint8_t system_id;
|
||||
uint8_t ending_head;
|
||||
uint8_t ending_sector: 6;
|
||||
uint16_t ending_cylinder: 10;
|
||||
uint32_t start_lba;
|
||||
uint32_t num_lbas;
|
||||
} __attribute((packed)) mbr_partition_table_entry;
|
||||
|
||||
typedef struct {
|
||||
u32 unique_id;
|
||||
u16 reserved;
|
||||
uint32_t unique_id;
|
||||
uint16_t reserved;
|
||||
mbr_partition_table_entry entries[4];
|
||||
u8 signature[2];
|
||||
uint8_t signature[2];
|
||||
} __attribute((packed)) mbr_table;
|
||||
|
||||
typedef struct {
|
||||
const block_device *device;
|
||||
u32 start_lba;
|
||||
uint32_t start_lba;
|
||||
} mbr_block_driver_info;
|
||||
|
||||
u8 mbr_check_device(const block_device *device, u8 *first_sector);
|
||||
uint8_t mbr_check_device(const block_device *device, uint8_t *first_sector);
|
||||
|
||||
block_dev_driver mbr_driver = {
|
||||
.name = "mbr",
|
||||
@@ -48,12 +48,12 @@ void mbr_register_block_driver() {
|
||||
block_dev_register_driver(&mbr_driver);
|
||||
}
|
||||
|
||||
u8 mbr_block_dev_access(const block_device *device, u8 direction, u32 lba, u8 sectors, void *target) {
|
||||
uint8_t mbr_block_dev_access(const block_device *device, uint8_t direction, uint32_t lba, uint8_t sectors, void *target) {
|
||||
if (!device->flags.present || lba > device->num_lba) {
|
||||
return BLOCK_DEV_ACCESS_ERR;
|
||||
}
|
||||
const mbr_block_driver_info *info = device->device_info;
|
||||
const u32 actual_lba = info->start_lba + lba;
|
||||
const uint32_t actual_lba = info->start_lba + lba;
|
||||
if (actual_lba > info->device->num_lba) {
|
||||
return BLOCK_DEV_ACCESS_ERR;
|
||||
}
|
||||
@@ -62,9 +62,9 @@ u8 mbr_block_dev_access(const block_device *device, u8 direction, u32 lba, u8 se
|
||||
return info->device->access(info->device, direction, actual_lba, sectors, target);
|
||||
}
|
||||
|
||||
u8 mbr_check_device(const block_device *device, u8 *first_sector) {
|
||||
uint8_t mbr_check_device(const block_device *device, uint8_t *first_sector) {
|
||||
mbr_table table;
|
||||
memcpy((u8 *) &table, first_sector + (device->block_size - sizeof(mbr_table)), sizeof(mbr_table));
|
||||
memcpy((uint8_t *) &table, first_sector + (device->block_size - sizeof(mbr_table)), sizeof(mbr_table));
|
||||
if (table.signature[0] != 0x55 && table.signature[1] != 0xAA) { // AA 55 but in little endian
|
||||
return BLOCK_DEV_DRIVER_CHECK_NO_MATCH;
|
||||
}
|
||||
@@ -104,7 +104,7 @@ u8 mbr_check_device(const block_device *device, u8 *first_sector) {
|
||||
return BLOCK_DEV_DRIVER_CHECK_OK;
|
||||
}
|
||||
|
||||
void mbr_read_from_ide(u8 ide_drive) {
|
||||
void mbr_read_from_ide(uint8_t ide_drive) {
|
||||
char *mbr_data = malloc(0x200);
|
||||
ide_access(0, ide_drive, 0, 1, mbr_data);
|
||||
mbr_partition_table_entry *entry = (mbr_partition_table_entry *) (mbr_data + 0x1BE);
|
||||
|
||||
Reference in New Issue
Block a user