54#include <kernel/types.h>
134#define generate_device_rw_functions(_pfx, _dev_type, _reg_field, _off_type) \
135 __device_read(u8, b, _pfx, _dev_type, _reg_field, _off_type) \
136 __device_write(u8, b, _pfx, _dev_type, _reg_field, _off_type) \
137 __device_read(u16, w, _pfx, _dev_type, _reg_field, _off_type) \
138 __device_write(u16, w, _pfx, _dev_type, _reg_field, _off_type) \
139 __device_read(u32, l, _pfx, _dev_type, _reg_field, \
141 __device_write(u32, l, _pfx, _dev_type, _reg_field, \
144#define __device_read(_type, _type_pfx, _pfx, _device_type, _device_reg_field, \
146 static MAYBE_UNUSED inline _type _pfx##_read##_type_pfx( \
147 _device_type *device, _offset_type offset) \
149 return *(_type *)(device->_device_reg_field + offset); \
152#define __device_write(_type, _type_pfx, _pfx, _device_type, \
153 _device_reg_field, _offset_type) \
154 static MAYBE_UNUSED inline void _pfx##_write##_type_pfx( \
155 _device_type *device, _offset_type offset, _type val) \
157 *(_type *)(device->_device_reg_field + offset) = val; \
static void device_set_name(struct device *dev, const char *name)
Set the name of the device.
Definition: device.h:112
struct file * device_open(device_t *)
Open a device for interacting with it.
Definition: device.c:58
static const char * device_name(struct device *dev)
Definition: device.h:118
error_t device_register(device_t *)
Register a new device.
Definition: device.c:25
struct device * device_find(const char *name)
Find a registered device by name.
Definition: device.c:66
The basic device driver structure.
Definition: driver.h:77
Represents a device inside the kernel.
Definition: device.h:78
const char * name
The name of the device.
Definition: device.h:82
struct vnode * vnode
This device's vnode, used by the VFS.
Definition: device.h:94
driver_t * driver
The driver for this device.
Definition: device.h:83
const struct file_operations * fops
Operations applied to the device's underlying file.
Definition: device.h:93
Operations that can be performed on an opened file.
Definition: file.h:69
Opened file description.
Definition: file.h:29
Intrusive doubly-linked list node.
Definition: linked_list.h:27
represents a single virtual node
Definition: vfs.h:205