16.8.1.2 Load-control Sets for NT Drivers

As shown in Figure 16.6, RegistryPath points to a subkey of \Registry\Machine\System\CurrentControlSet\Services\DriverName.

CurrentControlSet is a symbolic link to a particular ControlSetnnn in the registry. Each ControlSetnnn is a named key with subkeys and value entries that specify the load order for a set of NT drivers.

Every ControlSetnnn has the following two subkeys:

·Control, which holds miscellaneous machine-specific value entries, such as the size of nonpaged pool, the ServiceGroupOrder that specifies the load order for each group of layered NT drivers, and the GroupOrderList that controls the load order of drivers within a group. For example, an excerpt of the Control subkey might be:

Control

:

GroupOrderList

:

SCSI CDROM Class:REG_BINARY:02 00 00 00 01 ...

SCSI Class:REG_BINARY:03 00 00 00 01 ...

SCSI miniport:REG_BINARY:24 00 00 00 00 ...

:

:

ServiceGroupOrder

List:REG_MULTI_SZ:System Bus Extender

SCSI miniport

port

Primary disk

SCSI class

SCSI CDROM class...

:

This ServiceGroupOrder example indicates that HBA-specific SCSI miniport drivers (each linked to the NT SCSI port driver, which is implemented as a dynamic-link library) should be loaded before other drivers in the Primary disk group (such as add-on disk array, "AT" disk, and/or ABIOS disk drivers), followed by the SCSI class drivers, and so on.

The GroupOrderList defines the load order of drivers within each group. The first number in the list defines how many tags are used; in the above example, there are 03 tags for SCSI Class. The rest of the list defines the order in which drivers with those tags are loaded. The tags are not necessarily listed in increasing numerical order. The tag assignment for a driver is defined in its entry in the Services key.

·Services, which holds driver-specific information about how and when during system initialization a given driver is loaded and which, if any, lower-level drivers must be loaded first. For example, the Services subkeys pertaining to the SCSI class group might have:

Services

:

Disk

DependOnGroup:REG_MULTI_SZ:SCSI miniport

ErrorControl:REG_DWORD:0 // = SERVICE_ERROR_IGNORE

Group:REG_SZ:SCSI class

Start:REG_DWORD:0 // = SERVICE_BOOT_START

Tag:REG_DWORD:0x2

Type:REG_DWORD:0x1 // = SERVICE_KERNEL_DRIVER

:

Scsiscan

DependOnGroup:REG_MULTI_SZ:SCSI miniport

ErrorControl:REG_DWORD:0 // = SERVICE_ERROR_IGNORE

Group:REG_SZ:SCSI class

Start:REG_DWORD:0x1 // = SERVICE_SYSTEM_START

Tag:REG_DWORD:0x3

Type:REG_DWORD:0x1 // = SERVICE_KERNEL_DRIVER

:

This Services example indicates:

·These drivers are NT drivers (Type = SERVICE_KERNEL_DRIVER), rather than user-mode subsystem-specific drivers.

·Whether each driver must be loaded by the NT boot loader because the system itself might be loaded from the SCSI class driver's physical device (Start = SERVICE_BOOT_START) or during the next phase of system initialization (Start = SERVICE_SYSTEM_START). For more information about writing NT drivers for boot-from floppy and CD-ROM devices, see also Section 16.9.2.

·These drivers belong to the SCSI class Group in the ServiceGroupOrder of the Control section for this ControlSetnnn.

·What order these drivers will load within the SCSI class group (Tag). The position of a driver's Tag value in the CurrentControlSet\Control\GroupOrderList entry determines when that driver loads relative to other drivers in the group. A driver that has no Tag value in this list is loaded last within its group.

·If these drivers cannot be loaded, the system will skip them. (ErrorControl = SERVICE_ERROR_IGNORE). Other drivers have an ErrorControl value of SERVICE_ERROR_NORMAL, which means that the system will continue the boot process, possibly trying the LastKnownGood ControlSetmmm, if those drivers fail to initialize and cannot be loaded.

·These drivers cannot be loaded (DependOnGroup) unless at least one driver from the SCSI miniport Group in the ServiceGroupOrder section has already been loaded.

A new driver can be loaded in NT machines by adding appropriate subkeys with value entries for the driver to the CurrentControlSet in the registry.

For example, a new SCSI miniport driver that enables "WD1003 emulation" on its HBA should be loaded before any other SCSI miniport drivers so that it can claim an AtDisk..AddressSpace in the I/O Manager's configuration information structure, described in Section 16.8.1.1. On the other hand, a SCSI miniport driver for an HBA that does not support a BIOS should be loaded following all miniport drivers of HBAs that do.

Using Regedt32 to Load a New NT Driver

To create a driver-specific key in the registry for an under-development driver and to make it loadable, the driver writer can use the Windows NT registry editor, regedt32, to modify and add appropriate keys and their value entries in the registry. For example, the driver writer would modify the CurrentControlSet\Services key to get the under-development driver to load and add driver-specific keys, such as the DriverName\Parameters with appropriate value entries or subkeys with value entries.

However, every NT driver writer must decide whether to rely on a system administrator or end user to "install" the retail driver in the registry with regedt32, to use a setup utility, to have the driver set itself up in the registry, or to use some combination of these methods. For more information about these alternatives, see Sections 16.8.5 and 16.9.1 and the Programmer's Guide.

Note that the ServiceGroupOrder key is reset to its system-supplied value on a system upgrade. Drivers that modify this key may need to be reinstalled after a system upgrade.

LastKnownGood Control Set

The registry always contains additional load-control specifications, including a backup specification called LastKnownGood, in case modifications to the CurrentControlSet make it impossible to load the system.

Using the \Regisry\Machine\System Tree in Higher-Level NT Drivers

Note that the registry has other subkeys under the path \Registry\Machine\System, shown in Figure 16.6, that contain configuration information that is useful to higher-level NT drivers.

For example, the system-supplied ftdisk driver uses the subkey \Registry\Machine\System\Disk to find disk devices and logical partitions so it can set up device objects for its own mirror, stripe, stripe-with-parity, and volume sets, as mentioned in Chapter 5.