Files
my-kern/include/myke/fs/blockdev.h

72 lines
1.8 KiB
C

//
// Created by rick on 06-02-21.
//
#ifndef NEW_KERNEL_BLOCKDEV_H
#define NEW_KERNEL_BLOCKDEV_H
#include <sys/types.h>
#include <myke/driver.h>
#define BLOCK_DEV_ACCESS_OK 0
#define BLOCK_DEV_ACCESS_ERR 1
#define BLOCK_DEV_DIRECTION_READ 0
#define BLOCK_DEV_DIRECTION_WRITE 1
#define BLOCK_DEV_DRIVER_CHECK_OK 0
#define BLOCK_DEV_DRIVER_CHECK_NO_MATCH 1
#define BLOCK_DEV_REGISTER_DRIVER_OK 0
#define BLOCK_DEV_REGISTER_DRIVER_FULL 1
#define BLOCK_DEV_REGISTER_OK 0
#define BLOCK_DEV_REGISTER_FULL 1
typedef struct block_device block_device;
typedef uint8_t (*block_device_driver_check_device)(const block_device *device, uint8_t *first_sector);
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);
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;
} __attribute__((__aligned__(STRUCT_ALIGNMENT)));
#define BLOCK_DEV_DRIVER(order) GENERIC_DRIVER(block_dev_driver, order)
typedef struct block_device {
struct {
uint8_t present: 1;
uint8_t scanned: 1;
uint8_t unreadable: 1;
uint8_t root_device: 1;
uint8_t driver_installed: 1;
} flags;
char identifier[16];
uint32_t num_lba;
uint16_t block_size;
block_device_access access;
struct block_dev_driver *driver;
void *device_info; // pointer to driver defined structure
// todo device info
} block_device;
uint8_t block_dev_register(block_device *device);
void block_dev_free(block_device *device);
void block_dev_start_task();
void block_dev_print_info();
#endif //NEW_KERNEL_BLOCKDEV_H