feat: moved file system code around
This commit is contained in:
75
include/myke/vfs/blockdev.h
Normal file
75
include/myke/vfs/blockdev.h
Normal file
@@ -0,0 +1,75 @@
|
||||
//
|
||||
// Created by rick on 06-02-21.
|
||||
//
|
||||
|
||||
#ifndef NEW_KERNEL_BLOCKDEV_H
|
||||
#define NEW_KERNEL_BLOCKDEV_H
|
||||
|
||||
#include <stdbool.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_t;
|
||||
|
||||
typedef uint8_t (*block_device_driver_check_device)(const block_device_t *device, uint8_t *first_sector);
|
||||
|
||||
typedef uint8_t (*block_device_driver_free)(const block_device_t *device);
|
||||
|
||||
typedef uint8_t (*block_device_access)(const block_device_t *device, uint8_t direction, uint32_t lba, uint8_t sectors,
|
||||
void *target);
|
||||
|
||||
struct block_dev_driver {
|
||||
char name[16];
|
||||
struct {
|
||||
uint8_t partitioning: 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)
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
uint8_t block_dev_register(block_device_t *device);
|
||||
|
||||
void block_dev_free(block_device_t *device);
|
||||
|
||||
void block_dev_start_task();
|
||||
|
||||
void block_dev_print_info();
|
||||
|
||||
bool block_dev_mount(char *identifier, char *driver);
|
||||
|
||||
#endif //NEW_KERNEL_BLOCKDEV_H
|
||||
Reference in New Issue
Block a user