Unfortunately, this is two commits as one.
A bus thread will not attempt to free the bus, making a
caller or another thread responsible.
Make header #include guards consistently named.
* You should have received a copy of the GNU General Public License
* along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _aoe_h
-# define _aoe_h
+#ifndef AOE_M_AOE_H_
+# define AOE_M_AOE_H_
/**
* @file
extern void aoe__reset_probe(void);
-#endif /* _aoe_h */
+#endif /* AOE_M_AOE_H_ */
WV_FP_BUS_THREAD Thread;
KEVENT ThreadSignal;
winvblock__bool Stop;
+ KEVENT ThreadStopped;
struct {
LIST_ENTRY Nodes;
USHORT NodeCount;
* You should have received a copy of the GNU General Public License
* along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _byte_h
-# define _byte_h
+#ifndef WV_M_BYTE_H_
+# define WV_M_BYTE_H_
/**
* @file
# define byte__rev_array_union( x ) \
byte__order_swap ( x.bytes, sizeof(x.bytes) )
-#endif /* _byte_h */
+#endif /* WV_M_BYTE_H_ */
* Jul-03-2009@22:39: Initial revision.
*/
-#ifndef _DEBUG_H
-# define _DEBUG_H
+#ifndef WV_M_DEBUG_H_
+# define WV_M_DEBUG_H_
/**
* @file
IN NTSTATUS Status
);
-#endif /* _DEBUG_H */
+#endif /* WV_M_DEBUG_H_ */
* You should have received a copy of the GNU General Public License
* along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _WV_M_DEVICE_H_
-# define _WV_M_DEVICE_H_
+#ifndef WV_M_DEVICE_H_
+# define WV_M_DEVICE_H_
/**
* @file
extern winvblock__lib_func void WvDevForDevObj(PDEVICE_OBJECT, WV_SP_DEV_T);
extern WV_F_DEV_DISPATCH WvDevPnpQueryId;
-#endif /* _WV_M_DEVICE_H_ */
+#endif /* WV_M_DEVICE_H_ */
* You should have received a copy of the GNU General Public License
* along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _WV_M_DISK_H_
-# define _WV_M_DISK_H_
+#ifndef WV_M_DISK_H_
+# define WV_M_DISK_H_
/**
* @file
extern NTSTATUS disk__module_init(void);
-#endif /* _WV_M_DISK_H_ */
+#endif /* WV_M_DISK_H_ */
* You should have received a copy of the GNU General Public License
* along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _DRIVER_H
-# define _DRIVER_H
+#ifndef WV_M_DRIVER_H_
+# define WV_M_DRIVER_H_
/**
* @file
IN NTSTATUS
);
-#endif /* _DRIVER_H */
+#endif /* WV_M_DRIVER_H_ */
* You should have received a copy of the GNU General Public License
* along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _filedisk_h
-# define _filedisk_h
+#ifndef WV_M_FILEDISK_H_
+# define WV_M_FILEDISK_H_
/**
* @file
IN void *StartContext
);
-#endif /* _filedisk_h */
+#endif /* WV_M_FILEDISK_H_ */
* You should have received a copy of the GNU General Public License
* along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _grub4dos_h
-# define _grub4dos_h
+#ifndef WV_M_GRUB4DOS_H_
+# define WV_M_GRUB4DOS_H_
/**
* @file
void
);
-#endif /* _grub4dos_h */
+#endif /* WV_M_GRUB4DOS_H_ */
* Boston MA 02111-1307, USA; either version 2 of the License, or
* (at your option) any later version; incorporated herein by reference.
*/
-#ifndef _mdi_h
-# define _mdi_h
+#ifndef WV_M_MDI_H_
+# define WV_M_MDI_H_
/**
* @file
# pragma pack()
# endif
-#endif /* _mdi_h */
+#endif /* WV_M_MDI_H_ */
* You should have received a copy of the GNU General Public License
* along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _memdisk_h
-# define _memdisk_h
+#ifndef WV_M_MEMDISK_H_
+# define WV_M_MEMDISK_H_
/**
* @file
void
);
-#endif /* _memdisk_h */
+#endif /* WV_M_MEMDISK_H_ */
* You should have received a copy of the GNU General Public License
* along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _MOUNT_H
-# define _MOUNT_H
+#ifndef WV_M_MOUNT_H_
+# define WV_M_MOUNT_H_
/**
* @file
int sectors;
};
-#endif /* _MOUNT_H */
+#endif /* WV_M_MOUNT_H_ */
* You should have received a copy of the GNU General Public License
* along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _msvhd_h
-# define _msvhd_h
+#ifndef WV_M_MSVHD_H_
+# define WV_M_MSVHD_H_
/**
* @file
byte__rev_array_union ( footer_ptr->checksum );
}
-#endif /* _msvhd_h */
+#endif /* WV_M_MSVHD_H_ */
* You should have received a copy of the GNU General Public License
* along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _PORTABLE_H
-# define _PORTABLE_H
+#ifndef WV_M_PORTABLE_H_
+# define WV_M_PORTABLE_H_
/**
* @file
# endif
# endif
-#endif /* _PORTABLE_H */
+#endif /* WV_M_PORTABLE_H_ */
* You should have received a copy of the GNU General Public License
* along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _WV_M_PROBE_H_
-# define _WV_M_PROBE_H_
+#ifndef WV_M_PROBE_H_
+# define WV_M_PROBE_H_
/**
* @file
);
extern void WvProbeDisks(void);
-#endif /* _WV_M_PROBE_H_ */
+#endif /* WV_M_PROBE_H_ */
* You should have received a copy of the GNU General Public License
* along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _PROTOCOL_H
-# define _PROTOCOL_H
+#ifndef AOE_M_PROTOCOL_H_
+# define AOE_M_PROTOCOL_H_
/**
* @file
void
);
-#endif /* _PROTOCOL_H */
+#endif /* AOE_M_PROTOCOL_H_ */
* You should have received a copy of the GNU General Public License
* along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _ramdisk_h
-# define _ramdisk_h
+#ifndef WV_M_RAMDISK_H_
+# define WV_M_RAMDISK_H_
/**
* @file
void
);
-#endif /* _ramdisk_h */
+#endif /* WV_M_RAMDISK_H_ */
* You should have received a copy of the GNU General Public License
* along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _REGISTRY_H
-# define _REGISTRY_H
+#ifndef WV_M_REGISTRY_H_
+# define WV_M_REGISTRY_H_
/**
* @file
winvblock__uint32 value
);
-#endif /* _REGISTRY_H */
+#endif /* WV_M_REGISTRY_H_ */
* You should have received a copy of the GNU General Public License
* along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _winvblock_h
-# define _winvblock_h
+#ifndef WV_M_WINVBLOCK_H_
+# define WV_M_WINVBLOCK_H_
/**
* @file
# define winvblock__lib_func __declspec(dllimport)
# endif
-#endif /* _winvblock_h */
+#endif /* WV_M_WINVBLOCK_H_ */
* You should have received a copy of the GNU General Public License\r
* along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.\r
*/\r
-#ifndef _wv_stdbool_h\r
-# define _wv_stdbool_h\r
+#ifndef WV_M_STDBOOL_H_\r
+# define WV_M_STDBOOL_H_\r
\r
/* Boolean type. */\r
typedef unsigned short bool;\r
#define false (0)\r
#define true (1)\r
\r
-#endif /* _wv_stdbool_h */\r
+#endif /* WV_M_STDBOOL_H_ */\r
* You should have received a copy of the GNU General Public License\r
* along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.\r
*/\r
-#ifndef _wv_stddef_h\r
-# define _wv_stddef_h\r
+#ifndef WV_M_STDDEF_H_\r
+# define WV_M_STDDEF_H_\r
# include "stddef.h"\r
\r
/* Type for the size, in bytes, of any object. */\r
typedef size_t wv_size_t;\r
\r
-#endif /* _wv_stddef_h */\r
+#endif /* WV_M_STDDEF_H_ */\r
* You should have received a copy of the GNU General Public License\r
* along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.\r
*/\r
-#ifndef _WV_STDLIB_H\r
-# define _WV_STDLIB_H\r
+#ifndef WV_M_STDLIB_H_\r
+# define WV_M_STDLIB_H_\r
\r
#include "wv_stddef.h"\r
\r
/* Free allocated memory. */\r
void wv_free(void *ptr);\r
\r
-#endif /* _WV_STDLIB_H */\r
+#endif /* WV_M_STDLIB_H_ */\r
* You should have received a copy of the GNU General Public License\r
* along with WinVBlock. If not, see <http://www.gnu.org/licenses/>.\r
*/\r
-#ifndef _wv_string_h\r
-# define _wv_string_h\r
+#ifndef WV_M_STRING_H_\r
+# define WV_M_STRING_H_\r
# include "wv_stdbool.h"\r
# include "wv_stddef.h"\r
\r
/* Test two byte ranges in memory for equality. */\r
bool wv_memcmpeq(const void *s1, const void *s2, wv_size_t n);\r
\r
-#endif /* _wv_string_h */\r
+#endif /* WV_M_STRING_H_ */\r
KeInitializeSpinLock(&Bus->BusPrivate_.WorkItemsLock);
InitializeListHead(&Bus->BusPrivate_.WorkItems);
KeInitializeEvent(&Bus->ThreadSignal, SynchronizationEvent, FALSE);
+ KeInitializeEvent(&Bus->ThreadStopped, SynchronizationEvent, FALSE);
Bus->Dev.Ops.CreatePdo = WvBusCreatePdo_;
Bus->Dev.Ops.Init = WvBusDevInit_;
Bus->Dev.Ops.Free = WvBusFree_;
return;
}
-/* The WV_SP_DEV_T::ops.free implementation for a threaded bus. */
+/* The WV_S_DEV_T::Ops.Free implementation for a threaded bus. */
static void STDCALL WvBusThreadFree_(IN WV_SP_DEV_T dev) {
WV_SP_BUS_T bus = WvBusFromDev(dev);
*
* @v context The thread context. In our case, it points to
* the bus that the thread should use in processing.
+ *
+ * Note that we do not attempt to free the bus data; this is a bus
+ * implementor's responsibility. We do, however, set the ThreadStopped
+ * signal which should mean that resources can be freed, from a completed
+ * thread's perspective.
*/
static void STDCALL WvBusThread_(IN void * context) {
WV_SP_BUS_T bus = context;
}
bus->Thread(bus);
+ KeSetEvent(&bus->ThreadStopped, 0, FALSE);
return;
}
/* Wake up at least every 30 seconds. */
timeout.QuadPart = -300000000LL;
- /* Hook WV_SP_DEV_T::ops.free() */
+ /* Hook WV_S_DEV_T::Ops.Free() */
bus->Dev.Ops.Free = WvBusThreadFree_;
- /* When bus::Stop is set, we shut down. */
+ /* When WV_S_BUS_T::Stop is set, we shut down. */
while (!bus->Stop) {
DBG("Alive.\n");
KeResetEvent(&bus->ThreadSignal);
WvBusProcessWorkItems(bus);
- } /* while bus->alive */
+ } /* while !bus->Stop */
WvBusCancelWorkItems(bus);
- WvBusFree_(&bus->Dev);
return;
}
* @ret NTSTATUS The status of the thread creation operation.
*
* Also see WV_F_BUS_THREAD in the header for details about the prototype
- * for implementing your own bus thread routine. You set bus::Thread to
- * specify your own thread routine, then call this function to start it.
+ * for implementing your own bus thread routine. You set WV_S_BUS_T::Thread
+ * to specify your own thread routine, then call this function to start it.
*/
winvblock__lib_func NTSTATUS WvBusStartThread(
WV_SP_BUS_T Bus