ahci: add block operations
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
7aed4b6579
commit
fc0720b118
5 changed files with 60 additions and 9 deletions
|
|
@ -2,6 +2,29 @@
|
|||
#include <kernel/common.h>
|
||||
#include <kernel/block.h>
|
||||
|
||||
#include <lib/string.h>
|
||||
|
||||
#include <fs/devfs.h>
|
||||
|
||||
int block_device_register(char *name, size_t lba_start, struct block_ops *ops, struct block_device **out)
|
||||
{
|
||||
struct block_device *ret = kzalloc(sizeof(struct block_device), ALLOC_KERN);
|
||||
if (!ret)
|
||||
return -ENOMEM;
|
||||
|
||||
ret->lba_start = lba_start;
|
||||
|
||||
strncpy(ret->name, name, sizeof(ret->name) - 1);
|
||||
*out = ret;
|
||||
|
||||
memcpy(ops, &ret->ops, sizeof(struct block_ops));
|
||||
|
||||
dirent_t *dirent;
|
||||
int res = devfs_insert_device_blk(ret->name, ret, &dirent);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ssize_t block_read(struct block_device *dev, char *buf, size_t offset, size_t n_blocks)
|
||||
{
|
||||
return dev->ops.read(dev, buf, offset, n_blocks);
|
||||
|
|
|
|||
Loading…
Reference in a new issue