feat: Vfs and Ext2 support. Code style/attribute improvements

Added VFS and Ext2 support.
Optimized attributes of methods to improve code highlighting.
Printf attribute, malloc attribute, etc.
This commit is contained in:
2021-10-06 21:45:15 +02:00
parent 073051c99e
commit 03f0ec6f88
24 changed files with 1322 additions and 90 deletions

View File

@@ -33,12 +33,11 @@ typedef struct {
} att_packed mbr_table;
typedef struct {
const block_device_t *device;
block_device_t *device;
uint32_t start_lba;
} mbr_block_driver_info;
uint8_t
mbr_block_dev_access(const block_device_t *device, uint8_t direction, uint32_t lba, uint8_t sectors, void *target) {
uint8_t mbr_block_dev_access(block_device_t *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;
}
@@ -52,9 +51,15 @@ mbr_block_dev_access(const block_device_t *device, uint8_t direction, uint32_t l
return info->device->access(info->device, direction, actual_lba, sectors, target);
}
uint8_t att_used mbr_check_device(const block_device_t *device, uint8_t *first_sector) {
uint8_t mbr_check_device(block_device_t *device) {
uint8_t *first_sector = malloc(512);
if (device->access(device, BLOCK_DEV_DIRECTION_READ, 0, 1, first_sector) != BLOCK_DEV_ACCESS_OK) {
free(first_sector);
return BLOCK_DEV_DRIVER_CHECK_NO_MATCH;
}
mbr_table table;
memcpy((uint8_t *) &table, first_sector + (device->block_size - sizeof(mbr_table)), sizeof(mbr_table));
free(first_sector);
if (table.signature[0] != 0x55 && table.signature[1] != 0xAA) { // AA 55 but in little endian
return BLOCK_DEV_DRIVER_CHECK_NO_MATCH;
}