diff options
| author | Carlos Maiolino <[email protected]> | 2026-02-24 21:12:39 +0100 |
|---|---|---|
| committer | Carlos Maiolino <[email protected]> | 2026-02-24 21:12:39 +0100 |
| commit | 150499dbea44a4ecf1689990ed915467a14abb02 (patch) | |
| tree | 4821b1a6438a6b4728c26d5f4e3c745757f3987e /src/block/block.c | |
| parent | c96b289dc49c18ac36fb7e13242e5f855a56840e (diff) | |
block: Add a simple block layer
Signed-off-by: Carlos Maiolino <[email protected]>
Diffstat (limited to 'src/block/block.c')
| -rw-r--r-- | src/block/block.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/block/block.c b/src/block/block.c new file mode 100644 index 0000000..d4758f5 --- /dev/null +++ b/src/block/block.c @@ -0,0 +1,44 @@ +#include <toxic/config.h> +#include <toxic/string.h> +#include <block/block.h> +#include <ata/ata.h> + +/* + * Only primary ATA disk is supported by now, just + * hardcode it here. + */ +struct bdev hda; + +/* Init block layer */ +void +block_init() +{ + memset(&hda, 0, sizeof(struct bdev)); + hda.id = TOXIC_HDA_0; + hda.sector_size = SECTOR_SIZE; +} + +struct bdev * +bdev_get(int id) +{ + /* Just a single bdev is supported */ + if (id) + return NULL; + + return &hda; +} + +/* Read len bytes from bdev starting at addr into buf*/ +int +bread( + struct bdev *bdev, + unsigned int addr, + unsigned int len, + void *buf) +{ + /* + * XXX: This should be a function call into the disk driver. + * i.e. bdev->read(), or something like that + */ + return ata_read_sector(addr, len, buf); +} |
