summaryrefslogtreecommitdiffstats
path: root/include/block.h
blob: aaab4e3b36167dbaa984fb3685f2122aa1699848 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef __BLOCK_H
#define __BLOCK_H

#include <driver.h>

struct block_device;

struct block_device_ops {
	int (*read)(struct block_device *, void *buf, int block, int num_blocks);
	int (*write)(struct block_device *, const void *buf, int block, int num_blocks);
};

struct block_device {
	struct device_d *dev;
	struct block_device_ops *ops;
	int blockbits;
	int num_blocks;
	void *rdbuf; /* read buffer */
	int rdbufsize;
	int rdblock; /* start block in read buffer */
	int rdblockend; /* end block in read buffer */
	void *wrbuf; /* write buffer */
	int wrblock; /* start block in write buffer */
	int wrbufblocks; /* number of blocks currently in write buffer */
	int wrbufsize; /* size of write buffer in blocks */
	struct cdev cdev;
};

int blockdevice_register(struct block_device *blk);
int blockdevice_unregister(struct block_device *blk);

#endif /* __BLOCK_H */