2 * Copyright (C) 2009-2010, Shao Miller <shao.miller@yrdsb.edu.on.ca>.
3 * Copyright 2006-2008, V.
4 * For WinAoE contact information, see http://winaoe.org/
6 * This file is part of WinVBlock, derived from WinAoE.
8 * WinVBlock is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
13 * WinVBlock is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.
31 device__state_not_started,
32 device__state_started,
33 device__state_stop_pending,
34 device__state_stopped,
35 device__state_remove_pending,
36 device__state_surprise_remove_pending,
40 /* Forward declaration. */
44 * Device PDO creation routine.
46 * @v dev The device whose PDO should be created.
47 * @ret pdo Points to the new PDO, or is NULL upon failure.
49 typedef PDEVICE_OBJECT STDCALL device__create_pdo_func(
50 IN struct device__type *
53 extern winvblock__lib_func device__create_pdo_func device__create_pdo;
56 * Device initialization routine.
58 * @v dev The device being initialized.
60 typedef winvblock__bool STDCALL device__init_func(IN struct device__type *);
63 * Device close routine
65 * @v dev_ptr The device being closed
67 # define device__close_decl( x ) \
71 IN struct device__type * dev_ptr \
74 * Function pointer for a device close routine.
75 * 'indent' mangles this, so it looks weird
77 typedef device__close_decl (
78 ( *device__close_routine )
83 * @v dev_ptr Points to the device to close
85 extern winvblock__lib_func device__close_decl (
90 * Device deletion routine.
92 * @v dev_ptr Points to the device to delete.
94 typedef void STDCALL device__free_func(IN struct device__type *);
98 * @v dev_ptr Points to the device to delete.
100 extern winvblock__lib_func device__free_func device__free;
103 * Initialize the global, device-common environment
105 * @ret ntstatus STATUS_SUCCESS or the NTSTATUS for a failure
107 extern STDCALL NTSTATUS device__init (
112 * Create a new device
114 * @ret dev_ptr The address of a new device, or NULL for failure
116 * This function should not be confused with a PDO creation routine, which is
117 * actually implemented for each device type. This routine will allocate a
118 * device__type, track it in a global list, as well as populate the device
119 * with default values.
121 extern winvblock__lib_func struct device__type * device__create (
125 winvblock__def_struct(device__ops) {
126 device__create_pdo_func * create_pdo;
127 device__init_func * init;
128 device__close_routine close;
129 device__free_func * free;
132 typedef void STDCALL (device__thread_func)(IN void *);
134 /* Details common to all devices this driver works with */
137 winvblock__bool IsBus; /* For debugging */
138 /* A device's IRP dispatch routine. */
139 driver__dispatch_func * (dispatch);
140 /* The device's thread routine. */
141 device__thread_func * (thread);
142 /* The device's thread wakeup signal. */
143 KEVENT (thread_wakeup);
144 /* The device's IRP queue. */
145 LIST_ENTRY (irp_list);
146 /* The device's IRP queue lock. */
147 KSPIN_LOCK (irp_list_lock);
149 PDEVICE_OBJECT Parent;
150 PDRIVER_OBJECT DriverObject;
151 enum device__state state;
152 enum device__state old_state;
153 irp__handler_chain irp_handler_chain;
154 struct device__type * next_sibling_ptr;
157 winvblock__any_ptr ext;
160 extern winvblock__lib_func struct device__type * device__get(PDEVICE_OBJECT);
161 extern winvblock__lib_func void device__set(
163 struct device__type *
166 #endif /* _DEVICE_H */