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