blob: f6083d8d89c02367ddcea2f134130d07705163c3 (
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#pragma once
#include "drivers/dev.h"
#include "util/list.h"
struct vnode;
struct pframe;
struct chardev_ops;
struct mobj;
typedef struct chardev
{
devid_t cd_id;
struct chardev_ops *cd_ops;
list_link_t cd_link;
} chardev_t;
typedef struct chardev_ops
{
ssize_t (*read)(chardev_t *dev, size_t pos, void *buf, size_t count);
ssize_t (*write)(chardev_t *dev, size_t pos, const void *buf, size_t count);
long (*mmap)(struct vnode *file, struct mobj **ret);
long (*fill_pframe)(struct vnode *file, struct pframe *pf);
long (*flush_pframe)(struct vnode *file, struct pframe *pf);
} chardev_ops_t;
/**
* Initializes the byte device subsystem.
*/
void chardev_init(void);
/**
* Registers the given byte device.
*
* @param dev the byte device to register
*/
long chardev_register(chardev_t *dev);
/**
* Finds a byte device with a given device id.
*
* @param id the device id of the byte device to find
* @return the byte device with the given id if it exists, or NULL if
* it cannot be found
*/
chardev_t *chardev_lookup(devid_t id);
|