xref: /haiku/src/add-ons/kernel/drivers/common/null.c (revision 57e81ac7d835b7ce0584381d04b14a3cf9852604)
1fb8aa061SDavid Reid /*
26023deb2SAxel Dörfler  * Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
36023deb2SAxel Dörfler  * Distributed under the terms of the MIT License.
46023deb2SAxel Dörfler  *
56023deb2SAxel Dörfler  * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
66023deb2SAxel Dörfler  * Distributed under the terms of the NewOS License.
7fb8aa061SDavid Reid  */
805928f80SAxel Dörfler 
905928f80SAxel Dörfler 
1005928f80SAxel Dörfler #include <Drivers.h>
11fb8aa061SDavid Reid #include <string.h>
12fb8aa061SDavid Reid 
136023deb2SAxel Dörfler 
14fb8aa061SDavid Reid #define DEVICE_NAME "null"
15fb8aa061SDavid Reid 
16c59538b9SAxel Dörfler int32 api_version = B_CUR_DRIVER_API_VERSION;
17c59538b9SAxel Dörfler 
1805928f80SAxel Dörfler 
19f817f7d9Sbeveloper static status_t
null_open(const char * name,uint32 flags,void ** cookie)20f817f7d9Sbeveloper null_open(const char *name, uint32 flags, void **cookie)
21fb8aa061SDavid Reid {
22fb8aa061SDavid Reid 	*cookie = NULL;
23c59538b9SAxel Dörfler 	return B_OK;
24fb8aa061SDavid Reid }
25fb8aa061SDavid Reid 
2605928f80SAxel Dörfler 
27f817f7d9Sbeveloper static status_t
null_close(void * cookie)28f817f7d9Sbeveloper null_close(void *cookie)
29fb8aa061SDavid Reid {
30c59538b9SAxel Dörfler 	return B_OK;
31fb8aa061SDavid Reid }
32fb8aa061SDavid Reid 
3305928f80SAxel Dörfler 
34f817f7d9Sbeveloper static status_t
null_freecookie(void * cookie)35f817f7d9Sbeveloper null_freecookie(void *cookie)
36fb8aa061SDavid Reid {
37c59538b9SAxel Dörfler 	return B_OK;
38fb8aa061SDavid Reid }
39fb8aa061SDavid Reid 
4005928f80SAxel Dörfler 
41f817f7d9Sbeveloper static status_t
null_ioctl(void * cookie,uint32 op,void * buffer,size_t length)4205928f80SAxel Dörfler null_ioctl(void *cookie, uint32 op, void *buffer, size_t length)
43fb8aa061SDavid Reid {
44fb8aa061SDavid Reid 	return EPERM;
45fb8aa061SDavid Reid }
46fb8aa061SDavid Reid 
4705928f80SAxel Dörfler 
48c59538b9SAxel Dörfler static status_t
null_read(void * cookie,off_t pos,void * buffer,size_t * _length)496023deb2SAxel Dörfler null_read(void *cookie, off_t pos, void *buffer, size_t *_length)
50fb8aa061SDavid Reid {
516023deb2SAxel Dörfler 	*_length = 0;
52c59538b9SAxel Dörfler 	return B_OK;
53fb8aa061SDavid Reid }
54fb8aa061SDavid Reid 
5505928f80SAxel Dörfler 
56c59538b9SAxel Dörfler static status_t
null_write(void * cookie,off_t pos,const void * buffer,size_t * _length)576023deb2SAxel Dörfler null_write(void *cookie, off_t pos, const void *buffer, size_t *_length)
58fb8aa061SDavid Reid {
59c59538b9SAxel Dörfler 	return B_OK;
60fb8aa061SDavid Reid }
61fb8aa061SDavid Reid 
6205928f80SAxel Dörfler 
6305928f80SAxel Dörfler //	#pragma mark -
6405928f80SAxel Dörfler 
6505928f80SAxel Dörfler 
66f817f7d9Sbeveloper status_t
init_hardware()67f817f7d9Sbeveloper init_hardware()
68fb8aa061SDavid Reid {
69c59538b9SAxel Dörfler 	return B_OK;
70fb8aa061SDavid Reid }
71fb8aa061SDavid Reid 
7205928f80SAxel Dörfler 
73f817f7d9Sbeveloper const char **
publish_devices(void)74f817f7d9Sbeveloper publish_devices(void)
75fb8aa061SDavid Reid {
76fb8aa061SDavid Reid 	static const char *devices[] = {
77fb8aa061SDavid Reid 		DEVICE_NAME,
78fb8aa061SDavid Reid 		NULL
79fb8aa061SDavid Reid 	};
80fb8aa061SDavid Reid 
81fb8aa061SDavid Reid 	return devices;
82fb8aa061SDavid Reid }
83fb8aa061SDavid Reid 
8405928f80SAxel Dörfler 
85f817f7d9Sbeveloper device_hooks *
find_device(const char * name)86f817f7d9Sbeveloper find_device(const char *name)
87fb8aa061SDavid Reid {
88fb8aa061SDavid Reid 	static device_hooks hooks = {
89fb8aa061SDavid Reid 		&null_open,
90fb8aa061SDavid Reid 		&null_close,
91fb8aa061SDavid Reid 		&null_freecookie,
92fb8aa061SDavid Reid 		&null_ioctl,
93fb8aa061SDavid Reid 		&null_read,
94fb8aa061SDavid Reid 		&null_write,
95*57e81ac7SMichael Lotz 		/* Leave select/deselect/readv/writev undefined. The kernel will
96*57e81ac7SMichael Lotz 		 * use its own default implementation. The basic hooks above this
97*57e81ac7SMichael Lotz 		 * line MUST be defined, however. */
98*57e81ac7SMichael Lotz 		NULL,
99*57e81ac7SMichael Lotz 		NULL,
100*57e81ac7SMichael Lotz 		NULL,
101*57e81ac7SMichael Lotz 		NULL
102fb8aa061SDavid Reid 	};
103fb8aa061SDavid Reid 
104fb8aa061SDavid Reid 	if (!strcmp(name, DEVICE_NAME))
105fb8aa061SDavid Reid 		return &hooks;
106fb8aa061SDavid Reid 
107fb8aa061SDavid Reid 	return NULL;
108fb8aa061SDavid Reid }
109fb8aa061SDavid Reid 
11005928f80SAxel Dörfler 
111f817f7d9Sbeveloper status_t
init_driver(void)11205928f80SAxel Dörfler init_driver(void)
113fb8aa061SDavid Reid {
114c59538b9SAxel Dörfler 	return B_OK;
115fb8aa061SDavid Reid }
116fb8aa061SDavid Reid 
11705928f80SAxel Dörfler 
118f817f7d9Sbeveloper void
uninit_driver(void)11905928f80SAxel Dörfler uninit_driver(void)
120fb8aa061SDavid Reid {
121fb8aa061SDavid Reid }
122fb8aa061SDavid Reid 
123