AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
memdev.c
Go to the documentation of this file.
1
10
11#include <core/system.h>
12#include <core/module.h>
13#include <dev/dev.h>
14
15#include <memdev.h>
16
17struct dev memdev;
18
25struct dev *memdev_mux(struct devid *dd)
26{
27 switch (dd->minor) {
28 case 0:
29 case 1: /* /dev/mem */
30 case 2: /* /dev/kmem */
31 break;
32 case 3: /* /dev/null */
33 return &nulldev;
34 case 4: /* /dev/port */
35 break;
36 case 5: /* /dev/zero */
37 return &zerodev;
38 case 6: /* /dev/core */
39 break;
40 case 7: /* /dev/full */
41 break;
42 case 8: /* /dev/random */
43 case 9: /* /dev/urandom */
44 return &randomdev;
45 case 10: /* /dev/aio */
46 break;
47 case 11: /* /dev/kmsg */
48 return &kmsgdev;
49 }
50
51 return NULL;
52}
53
60{
62 return 0;
63}
64
65struct dev memdev = {
66 .name = "memdev",
67 .mux = memdev_mux,
68};
69
void kdev_chrdev_register(devid_t major, struct dev *dev)
Registers a driver as the character device of a major number.
Definition kdev.c:575
struct dev kmsgdev
Definition kmsg.c:18
struct dev memdev
Definition memdev.c:17
struct dev * memdev_mux(struct devid *dd)
Picks the driver of a memory device, by its minor.
Definition memdev.c:25
int memdev_probe()
Registers the memory devices, as character devices of major 1.
Definition memdev.c:59
struct dev zerodev
Definition zero.c:27
struct dev nulldev
Definition null.c:27
struct dev randomdev
Definition random.c:173
#define MODULE_INIT(name, i, f)
Definition module.h:10
#define NULL
Definition stddef.h:27
A device driver: its operations, any of which may be NULL.
Definition dev.h:28
Which device: its kind (S_IFCHR or S_IFBLK) and numbers.
Definition dev.h:21
devid_t minor
Definition dev.h:24