Annotation of driverkit/doc/OLD_NRW/IODiskTalk.wn/WNDocument.wn, revision 1.1

1.1     ! root        1: &�"$�`�l�h�X�\       �#&!�G99�&&dHH&d�/d�&� �t�&� �tw�����=y"$�`�l�h�X�\     �h&G99�&&dHH&d�/d?�
&9?�
&9w���=







88xHH�/d&[(�HHd&d&&&&&'&&&�@&��Z
        !             2: Z&�@�`���0�P��I/O Threads
�Z
        !             3: Z&�@�`���0�P��
Instance variables:

�m
        !             4: m&�@�`���0�P�����queue_head_t       ioQueueDisk;    // for I/Os requiring disk 
��queue_head_t     ioQueueNodisk;  // for other I/O
id                     ioQLock;                // NXConditionLock - 
                                          // protects the queues; I/O
                                            // thread(s) sleeps on this
���
/*
 * Values for ioQLock.condition.
 */
 typedef enum { IOQueuesEmpty��, WorkAvailable }; 
�Z
        !             5: Z&�@�`���0�P��
�&�
Command Buffer:
`
/*
 * Device-specific eject method, only called on physical
 * device.
 */
- (IOReturn) ejectPhysical;

/*
 * Determine basic state of device. This method should NOT
 * implement any retries. It also should not return
 * RS_EJECTING (That's only used in the lastReadyState
 * instance variable).
 */
- (IODiskReadyState)updateReadyState;

@end
�&�

���/*
 * Basic "usefulness" state of drive.
 */
typedef enum {
    IO_Ready,               // Ready for r/w operations
    IO_NotReady,            // not ready (spinning up or busy)
     IO_NoDisk,              // no disk present
     IO_Ejecting             // eject in progress
} IODiskReadyState;
���&�
&����
�m
        !             6: m&�@�`���0�P��typedef struct {
        /* 
     * device-specific stuff here which defines one I/O.
    * For example, block number, transfer count,
   * return status, etc.
  */

   /* 
     * cmdLock is what an exported method blocks on
         * when waiting for the I/O thread to process this
      * command.
     */
    NXConditionLock cmdLock;

      /*
      * This determines whether the operation is 
            * synchronous or async.
        */
    void                    *pending;
} commandBuf;
&��Z
        !             7: Z&�@�`���0�P��
���&�Exported method:

�m
        !             8: m&�@�`���0�P�����{
 Cons up a commandBuffer for this I/O;

 /*
      * Enqueue on appropriate I/O queue and wake up I/O
     * thread.
      */
    if this I/O requires disk {
            enqueue on ioQueueDisk;
        }
      else {
         enqueue on ioQueueNodisk;
      }
      [ioQLock lock];
        [ioQLock unlockWith:WorkAvailable];

   /*
      * Wait for I/O complete.
       */
    [commandBuffer.cmdLock lockWhen:YES];
�Z
        !             9: Z&�@�`���0�P��}

���&�
&�
I/O thread:


�m
        !            10: m&�@�`���0�P�����{
 initialize;
    while(1) {
             [ioQLock lockWhen: WorkAvailable];
             [ioQLock unlock];
              process everything on ioQueueNodisk;
           if((lastReadyState != IO_RS_NODISK) &&
           (lastReadyState != IO_RS_EJECTING)) {
                        process everything in ioQueueDisk;
             else {
                 if ioQueueDisk non-empty {
                       [self requestInsertionPanelForDiskType];
                     }
              }
              [ioQLock unlockWith:<current queue state>];
    }
 }

&�
�Z
        !            11: Z&�@�`���0�P���&�To process one commandBuf�&�:

�m
        !            12: m&�@�`���0�P�����{
 perform device-specific I/O described in
               commandBuf;
    if(commandBuf.pending) {
               /*
              * Async operation. 
            */
            [self completeTransfer:commandBuf.pending
                                      withStatus:...
                                 actualLength:...];
     }
      else {
         /*
              * Wake up client.
              */
            [commandBuf.cmdLock lock];
             [commandBuf.cmdLock unlockWith:YES];
   } 
\�Z
        !            13: Z&�@�`���0�P��
Class Hierarchy
�Z
        !            14: Z&�@�`���0�P��




n
�Z
        !            15: Z&�@�`���0�P��   �&�&DiskHierarchy.590972.eps�
�Z
        !            16: Z&�@�`���0�P��
&� */
- (void)abortRequest;

/*
 * Called by the volCheck thread when a transition to
 * "ready" is detected. Pending I/Os which require a disk
 *  may proceed.
 */
- (void)diskBecameReady;

/*
 * Inquire if disk is present; if not, and 'prompt' is TRUE,
 * ask for it. 
 * Returns IO_R_NODISK if:
 *    prompt TRUE, disk not present, and user cancels
 *        request for disk.
 *    prompt FALSE, disk not present.
 * Else returns IO_R_SUCCESS.
 */
- (IOReturn)isDiskReady     : (BOOL)prompt;

&
zIODiskReadingAndWriting protocol
�Z
        !            17: Z&�@�`���0�P��

���@protocol IODiskReadingAndWriting

- (IOReturn) readAt           : (unsigned)offset 
                              length : (unsigned)length 
                             buffer : (unsigned char *)buffer
                               actualLength : (unsigned *)actualLength 
                               client : (vm_task_t)client;

- (IOReturn) readAsyncAt : (unsigned)offset 
                              length : (unsigned)length 
                             buffer : (unsigned char *)buffer
                               pending : (void *)pending
                              client : (vm_task_t)client;
          
- (IOReturn) writeAt           : (unsigned)offset 
                              length : (unsigned)length 
                             buffer : (unsigned char *)buffer
                               actualLength : (unsigned *)actualLength 
                               client : (vm_task_t)client;
            
- (IOReturn) writeAsyncAt    : (unsigned)offset 
                              length : (unsigned)length 
                             buffer : (unsigned char *)buffer
                               pending : (void *)pending
                              client : (vm_task_t)client;

@end
�&�

��Z
        !            18: Z&�@�`���0�P��

The volCheck module
�Z
        !            19: Z&�@�`���0�P��




� Disk Insertion detection

� Automount

� Alert panels

� abort notification


��Z
        !            20: Z&�@�`���0�P��Kernel "Glue" Layer
�Z
        !            21: Z&�@�`���0�P��

This struct provides mapping between dev_t and id:

���typedef struct {
    id liveId;                      // instance for live partition
 id partitionId[NPART-1];        // for block and raw devices
   dev_t rawDev;                   // used by volCheck logic
      dev_t blockDev;         // ditto
} IODevAndIdInfo;
���&�

� Allocated in glue layer module, one per physical
  disk

� Each instance of IODisk (or subclass) contains a 
  pointer to the associated IODevAndIdInfo.

� rawDev and blockDev initialized in device-
  specific routine in kernel glue layer, typically
  called from +probe or +initialize.

� Id fields initialized by IODiskPartition (drivers
  don't need to worry about these).


&!�Z
        !            22: Z&�0��&�Driverkit Disk Classes
16 April, 1993

�Z
        !            23: Z&�@�`���0�P��


Outline:

� Introduction

� The volCheck module

� IODiskReadingAndWriting protocol

� IOPhysicalDiskMethods protocol

� Interfacing to cdevsw and bdevsw

� I/O thread architecture

� Q & A


8�Z
        !            24: Z&�@�`���0�P��IOPhysicalDiskMethods protocol
�Z
        !            25: Z&�@�`���0�P��
���@protocol IOPhysicalDiskMethods

/*
 * Get physical parameters (dev_size, block_size, etc.) from
 * new disk. Called upon disk insertion detection, or other
 * transition to RS_READY, or other change of state of
 * disk (like a transition to "formatted").
 */
- (IOReturn)updatePhysicalParameters;

/*
 * Called by volCheck thread when WS has told us that a
 * requested disk is not present. Pending I/Os which require
 * a disk to be present must be aborted.
Zd&�TC�E���T}&et&t?&
        !            26: &P4�&�t0.t�&.d&&Pt�&�t
        !            27: �&tt�&Z&�
�Z
        !            28: Z&�@�`���0�P���&�To process one commandBuf�&�:

�m
        !            29: m&�@�`���0�P�����{
 perform device-specific I/O described in
               commandBuf;
    if(commandBuf.pending) {
               /*
              * Async operation. 
            */
            [self completeTransfer:commandBuf.pending
                                      withStatus:...
                                 actualLength:...];
     }
      else {
         /*
              * Wake up client.
              */
            [commandBuf.cmdLock lock];
             [commandBuf.cmdLock unlockWith:YES];
   } 
}
Zd&�TC�E���T}&et&t?&
        !            30: &P4�&�t0.t�&.d&&Pt�&�t
        !            31: �&tt�&j

unix.superglobalmegacorp.com

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