fs: begin basic block driver
This just makes the API for accessing drives generic, instead of relying solely on the corresponding driver code
This commit is contained in:
parent
7ca418ff10
commit
03eb0b0048
3 changed files with 116 additions and 4 deletions
25
include/kernel/block.h
Normal file
25
include/kernel/block.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#ifndef _BLOCK_H_
|
||||
#define _BLOCK_H_
|
||||
|
||||
#include <kernel/common.h>
|
||||
|
||||
struct block_device;
|
||||
|
||||
struct block_device_ops {
|
||||
int (*read)(struct block_device *bdev, void *buf, size_t offset, size_t size);
|
||||
int (*write)(struct block_device *bdev, void *buf, size_t offset, size_t size);
|
||||
};
|
||||
|
||||
struct block_device {
|
||||
char *name;
|
||||
struct block_device_ops ops;
|
||||
void *data;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
struct block_device *block_register(char *name, struct block_device_ops *ops, void *data);
|
||||
int block_read(struct block_device *bdev, void *buf, size_t offset, size_t size);
|
||||
int block_write(struct block_device *bdev, void *buf, size_t offset, size_t size);
|
||||
|
||||
#endif /* _BLOCK_H_ */
|
||||
Loading…
Reference in a new issue