feat: reformatted driver code and linkage. Some optimizations
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#define NEW_KERNEL_BLOCKDEV_H
|
||||
|
||||
#include <types.h>
|
||||
#include <driver.h>
|
||||
|
||||
#define BLOCK_DEV_ACCESS_OK 0
|
||||
#define BLOCK_DEV_ACCESS_ERR 1
|
||||
@@ -31,15 +32,16 @@ typedef uint8_t (*block_device_driver_free)(const block_device *device);
|
||||
|
||||
typedef uint8_t (*block_device_access)(const block_device *device, uint8_t direction, uint32_t lba, uint8_t sectors, void *target);
|
||||
|
||||
|
||||
typedef struct {
|
||||
struct block_dev_driver {
|
||||
char name[16];
|
||||
struct {
|
||||
uint8_t root_only: 1;
|
||||
} flags;
|
||||
block_device_driver_check_device check_device;
|
||||
block_device_driver_free free_device;
|
||||
} block_dev_driver;
|
||||
} __attribute__((__aligned__(STRUCT_ALIGNMENT)));
|
||||
|
||||
#define BLOCK_DEV_DRIVER(data...) GENERIC_DRIVER(block_dev_driver, data)
|
||||
|
||||
typedef struct block_device {
|
||||
struct {
|
||||
@@ -53,13 +55,11 @@ typedef struct block_device {
|
||||
uint32_t num_lba;
|
||||
uint16_t block_size;
|
||||
block_device_access access;
|
||||
block_dev_driver *driver;
|
||||
struct block_dev_driver *driver;
|
||||
void *device_info; // pointer to driver defined structure
|
||||
// todo device info
|
||||
} block_device;
|
||||
|
||||
uint8_t block_dev_register_driver(block_dev_driver *driver);
|
||||
|
||||
uint8_t block_dev_register(block_device *device);
|
||||
|
||||
void block_dev_free(block_device *device);
|
||||
|
||||
Reference in New Issue
Block a user