45 lines
1,013 B
C
45 lines
1,013 B
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
#ifndef _BLOCK_H_
|
|
#define _BLOCK_H_
|
|
|
|
#include <kernel/device.h>
|
|
#include <kernel/sg.h>
|
|
|
|
#include <fs/vfs.h>
|
|
|
|
struct block_device;
|
|
struct block_ops {
|
|
ssize_t (*read)(struct block_device *dev, struct sg_list *sg, size_t offset, size_t n);
|
|
ssize_t (*write)(struct block_device *dev, struct sg_list *sg, size_t offset, size_t n);
|
|
};
|
|
|
|
struct disk {
|
|
u8 is_disk;
|
|
char model[FILE_NAME_MAX_LEN + 1];
|
|
list_t part_table;
|
|
};
|
|
|
|
struct block_device {
|
|
dev_t dev;
|
|
char name[256];
|
|
|
|
size_t size;
|
|
size_t block_size;
|
|
size_t lba_start;
|
|
|
|
struct block_device *part_of; /* if it is a partition */
|
|
void *priv;
|
|
|
|
size_t sg_max_len;
|
|
size_t sg_max_segments;
|
|
|
|
struct block_ops ops;
|
|
struct disk disk;
|
|
};
|
|
|
|
ssize_t block_read(struct block_device *dev, char *buf, size_t offset, size_t n_blocks);
|
|
ssize_t block_write(struct block_device *dev, char *buf, size_t offset, size_t n_blocks);
|
|
|
|
int block_check_partitions(struct block_device *bdev);
|
|
|
|
#endif /* _BLOCK_H_ */
|