









             Contents             Contents
             Chapter 3 - NT Objects and Support for Drivers             Chapter 3 - NT Objects and Support for Drivers


             3.1    NT Executive Components and NT Drivers............3-1

             3.2    Device Objects and Device Extensions..............3-7
               3.2.1    Defining Device Extensions....................3-9
               3.2.2    Creating a Device Object and Device Extension3-10
               3.2.3    Initializing Driver-specific Device Objects and
                 Device Extensions...................................3-11
               3.2.4    Setting Up Access to User Buffers............3-13
                 3.2.4.1    Using Buffered I/O.......................3-13
                 3.2.4.2    Using Direct I/O.........................3-15
                 3.2.4.3    Using Neither Direct Nor Buffered I/O....3-18

             3.3     Adapter Objects and DMA.........................3-20
               3.3.1    Map Registers................................3-21
               3.3.2    Getting an NT Adapter Object.................3-23
               3.3.3    Splitting Transfer Requests..................3-26
               3.3.4    Using System DMA.............................3-28
                 3.3.4.1    Packet-based System DMA..................3-28
                 3.3.4.2    Common-buffer System DMA.................3-34
               3.3.5    Using Busmaster DMA..........................3-38
                 3.3.5.1    Packet-based DMA.........................3-39
                 3.3.5.2    Common-buffer DMA........................3-46

             3.4    Controller Objects...............................3-48
               3.4.1    Creating a Controller Object with a Controller
                 Extension...........................................3-49
               3.4.2    Allocating the Controller for I/O Operations.3-51

             3.5    Interrupt Objects................................3-54
               3.5.1    Getting a System-assigned Interrupt Vector, DIRQL,
                 and Processor Mask..................................3-54
               3.5.2    Registering an ISR...........................3-56

             3.6    DPC Objects......................................3-59
               3.6.1    Registering and Queueing a DpcForIsr Routine.3-59
               3.6.2    Registering and Queueing a CustomDpc Routine.3-62

             3.7    Timer Objects with Associated DPCs...............3-64
               3.7.1    Registering and Enabling an IoTimer Routine..3-65
               3.7.2    Registering and Queueing a CustomTimerDpc Routine     
                 3-67



















        3.8    Device Queue Objects and Interlocked Queues......3-70
          3.8.1    Setting up a Device Queue Object and Queueing IRPs    
            3-71
          3.8.2    Setting up an Interlocked Queue and Queueing IRPs     
            3-73

        3.9    Kernel Dispatcher Objects for Drivers............3-76
          3.9.1    Timer Objects................................3-78
          3.9.2    Event Objects................................3-80
          3.9.3    Semaphore Objects............................3-83
          3.9.4    Mutex Objects................................3-86


        Figures - Chapter 3        Figures - Chapter 3

          Figure 3.1    Executive Component Support for Drivers..3-2
          Figure 3.2    Device Object............................3-8
          Figure 3.3    Buffered I/O for User Buffers...........3-14
          Figure 3.4    Direct I/O on User Buffers..............3-16
          Figure 3.5    Physical, Logical, and Virtual Address Mappings  
            3-22
          Figure 3.6    Getting an Adapter Object...............3-24
          Figure 3.7    Allocating the System DMA Controller....3-30
          Figure 3.8    Programming the System DMA Controller...3-32
          Figure 3.9    Allocating a Common Buffer for System DMA3-34
          Figure 3.10    Allocating an Adapter Object for Busmaster DMA  
            3-40
          Figure 3.11    Setting Up a Logical Range for DMA.....3-44
          Figure 3.12    Allocating a Common Buffer for Busmaster DMA    
            3-46
          Figure 3.13    Controller Object......................3-50
          Figure 3.14   Allocating a Controller Object for I/O..3-52
          Figure 3.15    Getting a System Vector and IRQL.......3-55
          Figure 3.16    Setting Up Interrupt Objects...........3-56
          Figure 3.17    Using a DPC Object for a DpcForIsr Routine3-60
          Figure 3.18    Using a DPC Object for a CustomDpc Routine3-62
          Figure 3.19    Using a Timer Object for an IoTimer Routine     
            3-66
          Figure 3.20    Using Timer and DPC Objects for a
            CustomTimerDpc Routine..............................3-68
          Figure 3.21    Using a Device Queue Object............3-72
          Figure 3.22    Using an Interlocked Queue.............3-74
          Figure 3.23    Waiting on a Timer Object..............3-78
          Figure 3.24    Waiting on an Event Object.............3-80
          Figure 3.25    Waiting on a Semaphore Object..........3-84
          Figure 3.26    Waiting on a Mutex Object..............3-88












