Annotation of Examples/DriverKit/Adaptec1542B/README.rtf, revision 1.1

1.1     ! root        1: {\rtf0\ansi{\fonttbl\f0\fmodern Ohlfs;\f1\fmodern Courier;}
        !             2: \paperw13040
        !             3: \paperh9540
        !             4: \margl120
        !             5: \margr120
        !             6: {\colortbl;\red0\green0\blue0;}
        !             7: \pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\f0\b0\i0\ulnone\fs24\fc0\cf0             
        !             8: \f1\b\fs28 Adaptec 154x SCSI Host Adaptor Driver
        !             9: \f0\b0\fs24 \
        !            10:                \
        !            11: This directory contains the all of the source files needed to build a driver for the Adaptec 1542B/C series of SCSI Host Adapters.  \
        !            12: \
        !            13: \
        !            14: \
        !            15: 
        !            16: \f1\b\fs28 Files\
        !            17: 
        !            18: \f0\b0\fs24 \
        !            19: 
        !            20: \li700 The following files comprise this driver.\
        !            21: 
        !            22: \fc1\cf1 \
        !            23: PB.project             Used by Project Builder.\
        !            24: Makefile                       Created by Project Builder; used by 'make'.\
        !            25: Makefile.preamble              Standard boilerplate driverkit Makefile extension.\
        !            26: Makefile.postamble     Standard boilerplate driverkit Makefile extension.\
        !            27: Default.table          Default table file, used by Configure app.\
        !            28: English.lproj/Localizable.strings\
        !            29:                                Used by Configure app. \
        !            30: README.rtf             This file.\
        !            31: \
        !            32: These files compile to build the actual relocatable driver binary. They reside in the Adaptec1542B_reloc.tproj subdirectory.\
        !            33: \
        !            34: AHAController.h                Public class declaration.\
        !            35: AHAController.m                Implementation of public and common methods.\
        !            36: AHAThread.h            I/O thread definitions.\
        !            37: AHAThread.m            I/O Thread implementation.\
        !            38: AHARoutines.m          Common low-level I/O routines. \
        !            39: AHATypes.h             H/W defintions for Adaptec 1542B Host Adaptor.\
        !            40: AHAControllerPrivate.h Driver-private typedefs.\
        !            41: AHAInline.h            Static inlines and macros. \
        !            42: scsivar.h                      Device-independent SCSI definitions.\
        !            43: AHA.ddm                        DDM defintions (for debugging only).\
        !            44: Default.table          Default config table.\
        !            45: Load_Commands.sect     Standard boilerplate driverkit tool.\
        !            46: Makefile                       Builds the driver.\
        !            47: 
        !            48: \f1\fs28\li0 \
        !            49: \
        !            50: 
        !            51: \b Architecture
        !            52: \b0 \
        !            53: \
        !            54: 
        !            55: \f0\fs24\li700 This driver uses one I/O thread to perform all hardware operations which occur subsequent to +probe time. This eliminates the need for using locking protocols to gain access to the hardware or related resources. The I/O thread is actually implemented in IODirectDevice; it is started up by our superclass, IOSCSIController, in the -initFromDeviceDescription method. \
        !            56: \
        !            57: Requests are passed from public methods (-executeRequest:buffer:client and -resetSCSIBus) to the I/O thread via the struct AHACommandBuf, defined in AHAControllerPrivate.h. These AHACommandBuf's are enqueued on the instance variable commandQ in the common method -executeCmdBuf; after enqueueing, a message with msg_id of IO_COMMAND_MSG is sent to the I/O thread (via the interruptPort). This wakes up the I/O thread, resulting in a call to our -commandRequestOccurred method. Command requests are then dispatched from -commandRequestOccurred to the appropriate command-specific code in AHAThread.m. During the execution of a command, -executeCmdBuf is waiting on the cmdLock field (an NXConditionLock) in AHACommandBuf. When the I/O thread completes a command, it unlocks the associated cmdLock with condition = CMD_COMPLETE; this wakes up -executeCmdBuf, which returns to the originating caller. \
        !            58: \
        !            59: This implementation, using AHACommandBuf's, is a textbook case of the mechanism described in the Driverkit Technical Documentation, Chapter 2 ("Designing a Driver"), in the section entitled "Communicating using Condition Locks". \
        !            60: \
        !            61: \
        !            62: The methods in this class can be grouped into the following 4 categories:\
        !            63: 
        !            64: \f1\fs28\li0 \
        !            65: 
        !            66: \b\li700 Initialization\
        !            67: 
        !            68: \li0 \
        !            69: 
        !            70: \f0\b0\fs24\li700 The +probe and -initFromDeviceDescription methods each run once per hardware instance. They run in the I/O task context, but not in our I/O thread context.\
        !            71: 
        !            72: \li0 \
        !            73: \
        !            74: 
        !            75: \f1\b\fs28\li700 Public Exported Methods\
        !            76: 
        !            77: \li0 \
        !            78: 
        !            79: \f0\b0\fs24\li700 These consist of -executeRequest:buffer:client and -resetSCSIBus. Each of these merely create an AHACommandBuf and call -executeCmdBuf, which passes the AHACommandBuf over to the I/O thread for processing.\
        !            80: 
        !            81: \li0 \
        !            82: \
        !            83: 
        !            84: \f1\b\fs28\li700 Methods Called by IODirectDevice's I/O Thread\
        !            85: 
        !            86: \li0 \
        !            87: 
        !            88: \f0\b0\fs24\li700 These methods are implemented in AHAController.m for a consistent API (since they are called from outside of the class), but they run in the I/O thread context. The three methods of interest are:\
        !            89: \
        !            90: -interruptOccurred: a hardware interrupt has been detected. This generally means an I/O is complete.\
        !            91: \
        !            92: -timeoutOccurred: A pending I/O has timed out. This is detected by a callout to the function ahaTimeout(), in AHAThread.m. A callout is scheduled to this function when a command is sent to the host adaptor in the form of a CCB. If the timeout specified in IOSCSIRequest.timeoutLength elapses without an I/O complete for the associated CCB, ahaTimeout() is called. AhaTimeout() then sends a message with msg_id = IO_TIMEOUT_MSG to the I/O thread via the interruptPort. The I/O thread then calls -timeoutOccurred. We abort the offending command with driverStatus = SR_IOST_IOTO, reset the SCSI bus, and abort all other pending commands with driverStatus = SR_IOST_RESET.\
        !            93: \
        !            94: -commandRequestOccurred: This is called by the I/O thread when it receives a message on interruptPort with msg_id = IO_COMMAND_MSG. Our response is to dequeue all of the commands we find on commandQ and send them to the host adaptor. One possible problem: the Host Adaptor's input queue (i.e., its array of mailboxes) might be full. In that case, commandRequestOccurred leaves the new I/O request(s) on commandQ. Later on, when we detect an I/O complete - thus freeing up one of the Host Adaptor's mailboxes, we call -commandRequestOccurred ourself to process any possible pending commands in commandQ.\
        !            95: 
        !            96: \f1\b\fs28\li0 \
        !            97: \
        !            98: 
        !            99: \li700 Private I/O thread methods\
        !           100: 
        !           101: \li0 \
        !           102: 
        !           103: \f0\b0\fs24\li700 These methods, implemented in AHAThread.m, perform the bulk of the hardware manipulation. All of these methods run solely in the context of the I/O thread.\
        !           104: 
        !           105: \li0 \
        !           106: \
        !           107: 
        !           108: \f1\b\fs28 Debugging
        !           109: \b0 \
        !           110: \
        !           111: 
        !           112: \f0\fs24\li700 This driver has been extensively instrumented with DDM calls. The file AHA.ddm can be loaded into DDMViewer (currently in /NextDeveloper/Demos) to allow selective access to various events in the driver. See the Driverkit Technical Documentation for more information on DDMViewer and the DDM module in general. Note that the DDM calls are only enabled in the DEBUG build configuration.\
        !           113: \
        !           114: 
        !           115: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.