k-tana-zero/k/include/k/blockdev.h
Julien CLEMENT d0f6a2592b fix: coding style
Signed-off-by: Julien CLEMENT <julien.clement@epita.fr>
2021-07-12 18:01:40 +02:00

40 lines
671 B
C

#ifndef BLOCKDEV_H_
#define BLOCKDEV_H_
# include <assert.h>
# include <k/types.h>
struct blockdev;
struct blk_ops {
void *(*read)(struct blockdev *, size_t);
void (*free_blk)(struct blockdev *, void *);
};
struct blockdev {
size_t blk_size;
struct blk_ops *ops;
void *blocks;
};
static inline void *block_read(struct blockdev *bd, size_t lba)
{
assert(bd);
assert(bd->ops);
assert(bd->ops->read);
return bd->ops->read(bd, lba);
}
static inline void block_free(struct blockdev *bd, void *ptr)
{
assert(bd);
assert(bd->ops);
assert(bd->ops->free_blk);
bd->ops->free_blk(bd, ptr);
}
#endif /* BLOCKDEV_H_ */