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