FreeBSD/sys/compat/ndis/kern_ndis.c
/*
 * This allows us to export our symbols to other modules.
 * Note that we call ourselves 'ndisapi' to avoid a namespace
 * collision with if_ndis.ko, which internally calls itself
 * 'ndis.'
 *
 * Note: some of the subsystems depend on each other, so the
 * order in which they're started is important. The order of
 * importance is:
 *
 * HAL - spinlocks and IRQL manipulation
 * ntoskrnl - DPC and workitem threads, object waiting
 * windrv - driver/device registration
 *
 * The HAL should also be the last thing shut down, since
 * the ntoskrnl subsystem will use spinlocks right up until
 * the DPC and workitem threads are terminated.
 */
This allows us to export our symbols to other modules.
Note that we call ourselves 'ndisapi' to avoid a namespace
collision with if_ndis.ko, which internally calls itself
'ndis.'

some of the subsystems depend on each other, so the
order in which they're started is important. The order of
importance is.

spinlocks and IRQL manipulation
ntoskrnl - DPC and workitem threads, object waiting
windrv - driver/device registration

The HAL should also be the last thing shut down, since
the ntoskrnl subsystem will use spinlocks right up until
the DPC and workitem threads are terminated.
This allows us to export our symbols to other modules . Note that we call ourselves ' ndisapi ' to avoid a namespace collision with if_ndis . ko which internally calls itself ' ndis . ' some of the subsystems depend on each other so the order in which they ' re started is important . The order of importance is . spinlocks and IRQL manipulation ntoskrnl - DPC and workitem threads object waiting windrv - driver / device registration The HAL should also be the last thing shut down since the ntoskrnl subsystem will use spinlocks right up until the DPC and workitem threads are terminated .
static int
ndis_modevent(module_t mod, int cmd, void *arg)
{
	int			error = 0;
	image_patch_table	*patch;
	switch (cmd) {
	case MOD_LOAD:
		hal_libinit();
		ntoskrnl_libinit();
		windrv_libinit();
		ndis_libinit();
		usbd_libinit();
		patch = kernndis_functbl;
		while (patch->ipt_func != NULL) {
			windrv_wrap((funcptr)patch->ipt_func,
			    (funcptr *)&patch->ipt_wrap,
			    patch->ipt_argcnt, patch->ipt_ftype);
			patch++;
		}
		TAILQ_INIT(&ndis_devhead);
		break;
	case MOD_SHUTDOWN:
		if (TAILQ_FIRST(&ndis_devhead) == NULL) {
			ndis_libfini();
			usbd_libfini();
			windrv_libfini();
			ntoskrnl_libfini();
			hal_libfini();
			patch = kernndis_functbl;
			while (patch->ipt_func != NULL) {
				windrv_unwrap(patch->ipt_wrap);
				patch++;
			}
		}
		break;
	case MOD_UNLOAD:
		ndis_libfini();
		usbd_libfini();
		windrv_libfini();
		ntoskrnl_libfini();
		hal_libfini();
		patch = kernndis_functbl;
		while (patch->ipt_func != NULL) {
			windrv_unwrap(patch->ipt_wrap);
			patch++;
		}
		break;
	default:
		error = EINVAL;
		break;
	}
	return (error);
}
static int ndis_modevent ( module_t mod , int cmd , void * arg ) { int error = 0 ; image_patch_table * patch ; switch ( cmd ) { case MOD_LOAD : hal_libinit ( ) ; ntoskrnl_libinit ( ) ; windrv_libinit ( ) ; ndis_libinit ( ) ; usbd_libinit ( ) ; patch = kernndis_functbl ; while ( patch -> ipt_func != NULL ) { windrv_wrap ( ( funcptr ) patch -> ipt_func , ( funcptr * ) & patch -> ipt_wrap , patch -> ipt_argcnt , patch -> ipt_ftype ) ; patch ++ ; } TAILQ_INIT ( & ndis_devhead ) ; break ; case MOD_SHUTDOWN : if ( TAILQ_FIRST ( & ndis_devhead ) == NULL ) { ndis_libfini ( ) ; usbd_libfini ( ) ; windrv_libfini ( ) ; ntoskrnl_libfini ( ) ; hal_libfini ( ) ; patch = kernndis_functbl ; while ( patch -> ipt_func != NULL ) { windrv_unwrap ( patch -> ipt_wrap ) ; patch ++ ; } } break ; case MOD_UNLOAD : ndis_libfini ( ) ; usbd_libfini ( ) ; windrv_libfini ( ) ; ntoskrnl_libfini ( ) ; hal_libfini ( ) ; patch = kernndis_functbl ; while ( patch -> ipt_func != NULL ) { windrv_unwrap ( patch -> ipt_wrap ) ; patch ++ ; } break ; default : error = EINVAL ; break ; } return ( error ) ; }
This allows us to export our symbols to other modules.
This allows us to export our symbols to other modules .
/* Initialize subsystems */ /* Shut down subsystems */ /* Shut down subsystems */