FreeBSD kernel kern code
device_if.m
Go to the documentation of this file.
1#-
2# Copyright (c) 1998-2004 Doug Rabson
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright
9# notice, this list of conditions and the following disclaimer.
10# 2. Redistributions in binary form must reproduce the above copyright
11# notice, this list of conditions and the following disclaimer in the
12# documentation and/or other materials provided with the distribution.
13#
14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24# SUCH DAMAGE.
25#
26# $FreeBSD$
27#
28
29#include <sys/bus.h>
30
40INTERFACE device;
41
42# Needed for timestamping device probe/attach calls
44 #include <sys/tslog.h>
45}
46
47#
48# Default implementations of some methods.
49#
50CODE {
51 static int null_shutdown(device_t dev)
52 {
53 return 0;
54 }
55
56 static int null_suspend(device_t dev)
57 {
58 return 0;
59 }
60
61 static int null_resume(device_t dev)
62 {
63 return 0;
64 }
65
66 static int null_quiesce(device_t dev)
67 {
68 return 0;
69 }
70
71 static void * null_register(device_t dev)
72 {
73 return NULL;
74 }
75};
76
151 TSENTER2(device_get_name(dev));
152}
154 TSEXIT2(device_get_name(dev));
155}
156METHOD int probe {
157 device_t dev;
158};
159
185STATICMETHOD void identify {
186 driver_t *driver;
187 device_t parent;
188};
189
213PROLOG {
214 TSENTER2(device_get_name(dev));
215}
216EPILOG {
217 TSEXIT2(device_get_name(dev));
218}
219METHOD int attach {
220 device_t dev;
221};
222
245METHOD int detach {
246 device_t dev;
247};
248
263METHOD int shutdown {
264 device_t dev;
266
290METHOD int suspend {
291 device_t dev;
293
312METHOD int resume {
313 device_t dev;
315
338METHOD int quiesce {
339 device_t dev;
341
359METHOD void * register {
360 device_t dev;
CODE
Definition: bus_if.m:44
METHOD int suspend
This is called by the power-management subsystem when a suspend has been requested by the user or by ...
Definition: device_if.m:290
METHOD int resume
This is called when the system resumes after a suspend.
Definition: device_if.m:312
DEFAULT null_resume
Definition: device_if.m:314
device_t parent
Definition: device_if.m:187
METHOD int probe
Definition: device_if.m:156
EPILOG
Definition: device_if.m:153
HEADER
Definition: device_if.m:43
METHOD int detach
Detach a driver from a device.
Definition: device_if.m:245
METHOD int quiesce
This is called when the driver is asked to quiesce itself.
Definition: device_if.m:338
DEFAULT null_quiesce
Definition: device_if.m:340
DEFAULT null_shutdown
Definition: device_if.m:265
INTERFACE device
Definition: device_if.m:40
DEFAULT null_suspend
Definition: device_if.m:292
PROLOG
Probe to see if a device matches a driver.
Definition: device_if.m:150
STATICMETHOD void identify
Allow a device driver to detect devices not otherwise enumerated.
Definition: device_if.m:185
METHOD int shutdown
Called during system shutdown.
Definition: device_if.m:263
DEFAULT null_register
Definition: device_if.m:361
METHOD int attach
Definition: device_if.m:219
const char * device_get_name(device_t dev)
Return the name of the device's devclass or NULL if there is none.
Definition: subr_bus.c:2342
#define DEFAULT(foo, bar)