dev: implement reading from block devices
reading from block devices is done using the block cache (bcache). This cache stores sectors from a block device in pages of memory marked as 'cached', which will allow them to be reclaimed when memory pressure is high (TODO). while block device drivers implement callbacks allowing reading/writing at block-granularity, the device subsystem uses the block cache to implement reading/writing at byte-granularity in a driver-agnostic way. block drivers can disable the block cache for their devices, but this will require that any clients communicate with the devices at block-granularity. also added an offset parameter to device and object read/write functions/callbacks.
This commit is contained in:
@@ -60,7 +60,8 @@ kern_status_t input_device_report_event(struct input_device *dev, const struct i
|
||||
return r == sizeof *ev ? KERN_OK : KERN_WOULD_BLOCK;
|
||||
}
|
||||
|
||||
kern_status_t input_device_read(struct device *dev, void *buf, size_t size, size_t *bytes_read, socks_flags_t flags)
|
||||
kern_status_t input_device_read(struct device *dev, void *buf, size_t offset,
|
||||
size_t size, size_t *bytes_read, socks_flags_t flags)
|
||||
{
|
||||
if (dev->dev_type != DEV_TYPE_INPUT || (size % sizeof (struct input_event)) != 0) {
|
||||
return KERN_INVALID_ARGUMENT;
|
||||
|
||||
Reference in New Issue
Block a user