1#ifndef KERNEL_DEVICES_BLOCK_H
2#define KERNEL_DEVICES_BLOCK_H
4#include <kernel/device.h>
5#include <kernel/spinlock.h>
8#include <utils/container_of.h>
16 const struct block_device_ops *ops;
19static inline struct block_device *to_blkdev(
struct device *dev)
24enum block_io_request_type {
25 BLOCK_IO_REQUEST_READ,
26 BLOCK_IO_REQUEST_WRITE,
29struct block_io_request {
30 enum block_io_request_type type;
36struct block_device_ops {
37 error_t (*request)(
struct block_device *,
struct block_io_request *);
40error_t block_device_register(
struct block_device *);
42static inline size_t block_device_size(
struct block_device *blkdev)
44 return blkdev->block_count * blkdev->block_size;
55void *block_read(
struct block_device *, blkcnt_t block_index);
58void block_free(
struct block_device *blkdev,
void *block);
#define container_of(_ptr, _struct, _field)
Cast a member of a structure out to the containing structure.
Definition: container_of.h:12
Represents a device inside the kernel.
Definition: device.h:78