Annotation of kernel/bsd/dev/ppc/drvPPCATA/IdeCnt.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
                      3:  *
                      4:  * @APPLE_LICENSE_HEADER_START@
                      5:  * 
                      6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
                      7:  * Reserved.  This file contains Original Code and/or Modifications of
                      8:  * Original Code as defined in and that are subject to the Apple Public
                      9:  * Source License Version 1.1 (the "License").  You may not use this file
                     10:  * except in compliance with the License.  Please obtain a copy of the
                     11:  * License at http://www.apple.com/publicsource and read it before using
                     12:  * this file.
                     13:  * 
                     14:  * The Original Code and all software distributed under the License are
                     15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
                     16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
                     17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
                     18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
                     19:  * License for the specific language governing rights and limitations
                     20:  * under the License.
                     21:  * 
                     22:  * @APPLE_LICENSE_HEADER_END@
                     23:  */
                     24: 
                     25: // Copyright 1997 by Apple Computer, Inc., all rights reserved.
                     26: /*
                     27:  * Copyright (c) 1991-1997 NeXT Software, Inc.  All rights reserved. 
                     28:  *
                     29:  * IdeCnt.h - Interface for Ide Controller class. 
                     30:  *
                     31:  * HISTORY 
                     32:  *
                     33:  * 07-Jul-1994  Rakesh Dubey at NeXT
                     34:  *     Created from original driver written by David Somayajulu.
                     35:  */
                     36:  
                     37: #ifdef DRIVER_PRIVATE
                     38: 
                     39: #ifndef        _BSD_DEV_I386_IDECNT_H_
                     40: #define _BSD_DEV_I386_IDECNT_H_
                     41: 
                     42: #define __APPLE_TYPES_DEFINED__ 1
                     43: 
                     44: #import <driverkit/return.h>
                     45: #import <driverkit/driverTypes.h>
                     46: #import <driverkit/IODevice.h>
                     47: #import <driverkit/ppc/IOTreeDevice.h>
                     48: #import <driverkit/ppc/IODBDMA.h>
                     49: #import <driverkit/ppc/directDevice.h>
                     50: #import <driverkit/generalFuncs.h>
                     51: #import <sys/types.h>
                     52: #import "IdeCntPublic.h"
                     53: #import "AtapiCntPublic.h"
                     54: #import <driverkit/IOPower.h>
                     55: 
                     56: 
                     57: typedef enum   {
                     58:     IDE_PM_SLEEP = 0, IDE_PM_STANDBY, IDE_PM_IDLE, IDE_PM_ACTIVE
                     59: } idePowerState_t;
                     60: 
                     61: typedef enum   {
                     62:     IDE_TRANSFER_PIO = 0, IDE_TRANSFER_SW_DMA, IDE_TRANSFER_MW_DMA, IDE_TRANSFER_ULTRA_DMA,
                     63: } ideTransferType_t;
                     64: 
                     65: typedef enum   {
                     66:     IDE_TRANSFER_16_BIT = 0, IDE_TRANSFER_32_BIT
                     67: } ideTransferWidth_t;
                     68: 
                     69: typedef enum   {
                     70:     IDE_PIO_ACCESS_BASE                = 0,
                     71:     IDE_PIO_ACCESS_MIN                 = 4,
                     72:     IDE_PIO_RECOVERY_BASE      = 4,
                     73:     IDE_PIO_RECOVERY_MIN       = 1,
                     74: 
                     75:     IDE_DMA_ACCESS_BASE        = 0,
                     76:     IDE_DMA_ACCESS_MIN         = 1,
                     77:     IDE_DMA_RECOVERY_BASE      = 1,
                     78:     IDE_DMA_RECOVERY_MIN       = 1,
                     79: } ideDMAConfigLimits_t;
                     80: 
                     81: typedef enum   {
                     82:     IDE_DMA_NONE, IDE_DMA_SINGLEWORD, IDE_DMA_MULTIWORD, IDE_DMA_ULTRA
                     83: } ideDMATypes_t;
                     84: 
                     85: typedef struct _Cmd646xRegs
                     86: {
                     87:             u_int8_t    cntrlReg;
                     88:             u_int8_t   arttimReg;
                     89:             u_int8_t   cmdtimReg;
                     90:             u_int8_t   drwtimRegPIO;
                     91:             u_int8_t   drwtimRegDMA;
                     92:             u_int8_t   udidetcrReg;
                     93: } Cmd646xRegs_t;       
                     94: 
                     95: 
                     96: typedef struct
                     97: {
                     98:     BOOL               fChanged;
                     99:     BOOL               useDMA;
                    100:     int                pioMode;
                    101:     int                        pioAccessTime;
                    102:     int                        pioCycleTime;
                    103:     ideDMATypes_t      dmaType;
                    104:     int                dmaMode;
                    105:     int                dmaAccessTime;
                    106:     int                dmaCycleTime;
                    107:     union 
                    108:     {
                    109:         u_int32_t      dbdmaConfig;
                    110:         Cmd646xRegs_t  cmd646XConfig;
                    111:     } ideConfig;
                    112: } ideCycleTimes_t;
                    113: 
                    114: 
                    115: @interface IdeController:IODirectDevice<IdeControllerPublic, 
                    116:                                AtapiControllerPublic, IOPower>
                    117: {
                    118: @private
                    119:     id                                 _ideCmdLock;                    /* NXLock */
                    120: 
                    121:     ideRegsAddrs_t                     _ideRegsAddrs;
                    122: 
                    123:     volatile IODBDMAChannelRegisters   *_ideDMARegs;
                    124:     volatile IODBDMADescriptor         *_ideDMACommands;
                    125:     uint                               _ideDMACommandsPhys;
                    126: 
                    127:     port_t             _ideDevicePort;
                    128:     port_t             _ideInterruptPort;
                    129:     unsigned int       _interruptTimeOut;
                    130: 
                    131:     unsigned int       _busNum;
                    132:     /*
                    133:      * From BIOS/CMOS. We use this only if the user asks for it. The ideInfo
                    134:      * structure is like the INT41 table. We fill this in even if we do not
                    135:      * use BIOS and get all our info from the drive using IDE_IDENTIFY_DRIVE. 
                    136:      */
                    137:     ideDriveInfo_t     _ideInfo[MAX_IDE_DRIVES];
                    138: 
                    139:     /*
                    140:      * This is used for communication between ideSendCommand and methods for 
                    141:      * individual commands. 
                    142:      */
                    143:     unsigned char      _driveNum;                      /* target drive */
                    144:     
                    145:     unsigned char      _controllerNum;                 /* our number */
                    146:     
                    147:     unsigned char      _controllerType;
                    148:    /*
                    149:     * Information from IDE_IDENTIFY_DRIVE commnad. 
                    150:     */
                    151:     BOOL               _ideIdentifyInfoSupported[MAX_IDE_DRIVES];
                    152:     ideIdentifyInfo_t   _ideIdentifyInfo[MAX_IDE_DRIVES];
                    153:     BOOL               _dmaSupported[MAX_IDE_DRIVES];
                    154:     unsigned char      _driveReset[MAX_IDE_DRIVES];
                    155: 
                    156:     BOOL               _multiSectorRequested;          /* user option */
                    157:     unsigned short     _multiSector[MAX_IDE_DRIVES];
                    158:     unsigned char      _addressMode[MAX_IDE_DRIVES];   /* LBA or CHS */
                    159:     ideCycleTimes_t     _cycleTimes[MAX_IDE_DRIVES];
                    160: 
                    161:     BOOL               _IOCHRDYSupport;                /* Host side */
                    162:     
                    163:     /*
                    164:      * ATAPI related ivars. 
                    165:      */
                    166:     BOOL               _atapiDevice[MAX_IDE_DRIVES];
                    167:     BOOL               _atapiCommandActive[MAX_IDE_DRIVES];
                    168:     unsigned char      _atapiCmdLen[MAX_IDE_DRIVES];
                    169:     unsigned char      _atapiCmdDrqType[MAX_IDE_DRIVES];
                    170: 
                    171:     /*
                    172:      * Power management related ivars. 
                    173:      */
                    174:     idePowerState_t    _drivePowerState;       /* PM state for both drives */
                    175:     BOOL               _driveSleepRequest;
                    176: }
                    177: 
                    178: /*
                    179:  * Exported methods.
                    180:  */
                    181: + (BOOL)probe:(IOTreeDevice *)devDesc;
                    182: 
                    183: - (void)enableInterrupts;
                    184: - (void)disableInterrupts;
                    185: 
                    186: - (void)setInterruptTimeOut:(unsigned int)timeOut;
                    187: - (unsigned int)interruptTimeOut;
                    188: 
                    189: - (ide_return_t)ideWaitForInterrupt:(unsigned int)command
                    190:                           ideStatus:(unsigned char *)status;
                    191: - (void)clearInterrupts;
                    192: 
                    193: /*
                    194:  * Controller status checks. 
                    195:  */
                    196: - (ide_return_t)waitForNotBusy;
                    197: - (ide_return_t)waitForDeviceReady;
                    198: - (ide_return_t)waitForDataReady;
                    199: 
                    200: - (ide_return_t)ataIdeReadGetInfoCommonWaitForDataReady;
                    201: 
                    202: /*
                    203:  * Miscellaneous methods.
                    204:  */
                    205: 
                    206: - (void) configWriteByte: (u_int32_t)reg value: (u_int8_t)cfgByte;
                    207: - (void) configReadByte: (u_int32_t)reg value: (u_int8_t *)cfgByte;
                    208: 
                    209: 
                    210: - (IOReturn) ideExecuteCmd:(ideIoReq_t *)ideIoReq ToDrive:(unsigned char)drive;
                    211: 
                    212: - (void)xferData:(caddr_t)addr read:(BOOL)read client:(struct vm_map *)client 
                    213:                length:(unsigned)length;
                    214: 
                    215: - (void)ideCntrlrLock;
                    216: - (void)ideCntrlrUnLock;
                    217: 
                    218: - (u_int) numberOfDrives;
                    219: 
                    220: - (void)atapiCntrlrLock;
                    221: - (void)atapiCntrlrUnLock;
                    222: 
                    223: - (BOOL)isMultiSectorAllowed:(unsigned int)unit;
                    224: - (unsigned int)getMultiSectorValue:(unsigned int)unit;
                    225: - (ideIdentifyInfo_t *) getIdeIdentifyInfo:(unsigned int)unit;
                    226: - (ideDriveInfo_t *) getIdeDriveInfo:(unsigned int)unit;
                    227: - (void)getIdeRegisters:(ideRegsVal_t *)rvp Print:(char *)printString;
                    228: - (BOOL) isDmaSupported:(unsigned int)unit;
                    229: 
                    230: -(void) setTransferRate: (int) unit UseDMA:(BOOL)fUseDMA;
                    231: -(void) setTransferMode:(int) unit;
                    232: 
                    233: /*
                    234:  * Number of sectors that can be transferred via READ_MULTIPLE or
                    235:  * WRITE_MULTIPLE command. 
                    236:  */
                    237: - (unsigned int)getMultiSectorValue:(unsigned int)unit;
                    238: 
                    239: /*
                    240:  * ATAPI related methods. 
                    241:  */
                    242: - (unsigned int)numDevices;                    /* max devices on ATA bus */
                    243: - (BOOL)isAtapiDevice:(unsigned char)unit;
                    244: - (BOOL)isAtapiCommandActive:(unsigned char)unit;
                    245: - (void)setAtapiCommandActive:(BOOL)state forUnit:(unsigned char)unit;
                    246: 
                    247: /*
                    248:  * Power management methods. 
                    249:  */
                    250: - (idePowerState_t)drivePowerState;
                    251: - (void)setDrivePowerState:(idePowerState_t)state;
                    252: - (void)putDriveToSleep;
                    253: - (void)wakeUpDrive;
                    254: - (BOOL)spinUpDrive:(unsigned int)unit;
                    255: - (BOOL)startUpAttachedDevices;
                    256: 
                    257: /*
                    258:  * The PM state is per controller, not per device. 
                    259:  */
                    260: - (IOReturn) getPowerState:(PMPowerState *)state_p;
                    261: - (IOReturn) setPowerState:(PMPowerState)state;
                    262: - (IOReturn) getPowerManagement:(PMPowerManagementState *)state_p;
                    263: - (IOReturn) setPowerManagement:(PMPowerManagementState)state;
                    264: 
                    265: @end
                    266: 
                    267: #define MAX_BUSY_DELAY                 (10 * 1000 * 1000)      // 10 seconds
                    268: #define MAX_DATA_READY_DELAY           (10 * 1000 * 1000)
                    269:  
                    270: #define MEDIA_BAY_ID_MASK              0x0000ff00
                    271: #define MEDIA_BAY_ID_CDROM             0x00003000
                    272: 
                    273: /*
                    274:  * This is actually quite a long time but it is mandated by the spec. 
                    275:  */
                    276: #define IDE_INTR_TIMEOUT               (30*1000)       // thirty seconds
                    277: 
                    278: #endif _BSD_DEV_I386_IDECNT_H_
                    279: 
                    280: #endif DRIVER_PRIVATE
                    281: 

unix.superglobalmegacorp.com

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