xref: /haiku/src/add-ons/kernel/drivers/common/null.c (revision da199a7e781d23415247118bb116b833b0025337)
1 /*
2 ** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
3 ** Distributed under the terms of the NewOS License.
4 */
5 #include <kernel.h>
6 #include <stage2.h>
7 #include <memheap.h>
8 #include <devfs.h>
9 #include <Errors.h>
10 #include <null.h>
11 #include <string.h>
12 
13 #define DEVICE_NAME "null"
14 
15 static status_t
16 null_open(const char *name, uint32 flags, void * *cookie)
17 {
18 	*cookie = NULL;
19 	return 0;
20 }
21 
22 static status_t
23 null_close(void * cookie)
24 {
25 	return 0;
26 }
27 
28 static status_t
29 null_freecookie(void * cookie)
30 {
31 	return 0;
32 }
33 
34 static status_t
35 null_ioctl(void * cookie, uint32 op, void *buf, size_t len)
36 {
37 	return EPERM;
38 }
39 
40 static ssize_t
41 null_read(void * cookie, off_t pos, void *buf, size_t *len)
42 {
43 	return 0;
44 }
45 
46 static ssize_t
47 null_write(void * cookie, off_t pos, const void *buf, size_t *len)
48 {
49 	return 0;
50 }
51 
52 status_t
53 init_hardware()
54 {
55 	return 0;
56 }
57 
58 const char **
59 publish_devices(void)
60 {
61 	static const char *devices[] = {
62 		DEVICE_NAME,
63 		NULL
64 	};
65 
66 	return devices;
67 }
68 
69 device_hooks *
70 find_device(const char *name)
71 {
72 	static device_hooks hooks = {
73 		&null_open,
74 		&null_close,
75 		&null_freecookie,
76 		&null_ioctl,
77 		&null_read,
78 		&null_write,
79 		/* Leave select/deselect/readv/writev undefined. The kernel will
80 		 * use its own default implementation. The basic hooks above this
81 		 * line MUST be defined, however. */
82 		NULL,
83 		NULL,
84 		NULL,
85 		NULL
86 	};
87 
88 	if (!strcmp(name, DEVICE_NAME))
89 		return &hooks;
90 
91 	return NULL;
92 }
93 
94 status_t
95 init_driver()
96 {
97 	return 0;
98 }
99 
100 void
101 uninit_driver()
102 {
103 }
104 
105