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