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