Annotation of drvEIDE/EIDE.drvproj/EIDE.lksproj/IdeCnt.h, revision 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.0 (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-1998 by Apple Computer, Inc., All rights reserved.
        !            26:  * Copyright 1994-1997 NeXT Software, Inc., All rights reserved.
        !            27:  *
        !            28:  * IdeCnt.h - Interface for Ide Controller class. 
        !            29:  *
        !            30:  * HISTORY 
        !            31:  *
        !            32:  * 07-Jul-1994  Rakesh Dubey at NeXT
        !            33:  *     Created from original driver written by David Somayajulu.
        !            34:  */
        !            35:  
        !            36: #ifdef DRIVER_PRIVATE
        !            37: 
        !            38: #ifndef        _BSD_DEV_I386_IDECNT_H_
        !            39: #define _BSD_DEV_I386_IDECNT_H_
        !            40: 
        !            41: #import <driverkit/return.h>
        !            42: #import <driverkit/driverTypes.h>
        !            43: #import <driverkit/IODevice.h>
        !            44: #import <driverkit/machine/directDevice.h>
        !            45: #import <driverkit/generalFuncs.h>
        !            46: #import <sys/types.h>
        !            47: #import "IdeCntPublic.h"
        !            48: #import "AtapiCntPublic.h"
        !            49: #import <driverkit/IOPower.h>
        !            50: #import <string.h>     // bzero
        !            51: // #import <stdlib.h>  // strtol
        !            52: 
        !            53: /*
        !            54:  * Disable mach messaging, but instead use thead sleep/wakeup.
        !            55:  */
        !            56: // #define NO_IRQ_MSG 1
        !            57: 
        !            58: typedef enum {
        !            59:     IDE_PM_SLEEP = 0, IDE_PM_STANDBY, IDE_PM_IDLE, IDE_PM_ACTIVE
        !            60: } idePowerState_t;
        !            61: 
        !            62: typedef enum {
        !            63:     IDE_TRANSFER_PIO = 0,
        !            64:        IDE_TRANSFER_SW_DMA,
        !            65:        IDE_TRANSFER_MW_DMA,
        !            66:        IDE_TRANSFER_ULTRA_DMA,
        !            67: } ideTransferType_t;
        !            68: 
        !            69: typedef enum   {
        !            70:     IDE_TRANSFER_16_BIT = 0, IDE_TRANSFER_32_BIT
        !            71: } ideTransferWidth_t;
        !            72: 
        !            73: __private_extern__ unsigned int _ide_debug;
        !            74: 
        !            75: /*
        !            76:  * Structure used to keep track of PRD table memory within the driver.
        !            77:  */
        !            78: typedef struct {
        !            79:     void                       *ptr;
        !            80:     unsigned int       size;
        !            81:        void                    *ptrReal;
        !            82:        unsigned int    sizeReal;
        !            83: } memStruct_t;
        !            84: 
        !            85: /*
        !            86:  * ATA transfer Modes.
        !            87:  */
        !            88: #define ATA_MODE_NONE  0x0
        !            89: #define ATA_MODE_0             0x01
        !            90: #define ATA_MODE_1             0x02
        !            91: #define ATA_MODE_2             0x04
        !            92: #define ATA_MODE_3             0x08
        !            93: #define ATA_MODE_4             0x10
        !            94: #define ATA_MODE_5             0x20
        !            95: 
        !            96: /*
        !            97:  * Define type to encode a single mode, or a mask to represent a group
        !            98:  * of allowable modes.
        !            99:  */
        !           100: typedef unsigned char  ata_mode_t;
        !           101: typedef ata_mode_t             ata_mask_t;
        !           102: 
        !           103: /*
        !           104:  * ATA Transfer mode capability struct. This encodes all the transfer
        !           105:  * modes that a controller or a drive can support.
        !           106:  */
        !           107: typedef union {
        !           108:        struct {
        !           109:                ata_mask_t pio;
        !           110:                ata_mask_t swdma;
        !           111:                ata_mask_t mwdma;
        !           112:                ata_mask_t udma;
        !           113:        } mode;
        !           114:        struct {
        !           115:                ata_mask_t mode[4];     // indexed by ideTransferType_t
        !           116:        } array;
        !           117:        unsigned int modes;
        !           118: } txferModes_t;
        !           119: 
        !           120: /*
        !           121:  * Information stored for a given drive.
        !           122:  */
        !           123: typedef struct {
        !           124:        // For All IDE devices  
        !           125:        BOOL                            biosGeometry;   /* using BIOS? */
        !           126:        ideDriveInfo_t          ideInfo;
        !           127:        BOOL                            ideIdentifyInfoSupported;
        !           128:        ideIdentifyInfo_t       *ideIdentifyInfo;
        !           129:        u_short                         dmaChannel;
        !           130:        u_short                         multiSector;
        !           131:        u_char                          addressMode;    /* LBA or CHS */
        !           132:        txferModes_t            driveModes;             /* supported modes */
        !           133:        txferModes_t            driveMasks;             /* masks */
        !           134:        ideTransferType_t       transferType;   /* selected type */
        !           135:        ata_mode_t                      transferMode;   /* selected mode */
        !           136:        
        !           137:        // ATAPI only
        !           138:        BOOL                            atapiDevice;
        !           139:        BOOL                            atapiCommandActive;
        !           140:        u_char                          atapiCmdLen;
        !           141:        u_char                          atapiCmdDrqType;
        !           142: } driveInfo_t;
        !           143: 
        !           144: __private_extern__ unsigned char ata_mode_to_num(unsigned char mode);
        !           145: __private_extern__ ata_mode_t ata_mask_to_mode(ata_mask_t mask);
        !           146: __private_extern__ ata_mask_t ata_mode_to_mask(ata_mode_t mode);
        !           147: 
        !           148: 
        !           149: @interface IdeController:IODirectDevice<IdeControllerPublic, 
        !           150:                                AtapiControllerPublic, IOPower>
        !           151: {
        !           152: @private
        !           153:     id                         _ideCmdLock;                    /* NXLock */
        !           154:     ideRegsAddrs_t     _ideRegsAddrs;
        !           155:     port_t                     _ideDevicePort;
        !           156:     port_t                     _ideInterruptPort;
        !           157:     unsigned int       _interruptTimeOut;
        !           158: 
        !           159:     /*
        !           160:      * This is used for communication between ideSendCommand and methods for 
        !           161:      * individual commands. 
        !           162:      */
        !           163:     unsigned char      _driveNum;                              /* target drive */   
        !           164:     unsigned char      _controllerNum;                 /* our number */
        !           165:     
        !           166:        /*
        !           167:         * Information for the drives attached to this controller. 
        !           168:         */
        !           169:        driveInfo_t             _drives[MAX_IDE_DRIVES];
        !           170: 
        !           171:        /*
        !           172:         * User settings.
        !           173:         */
        !           174:        BOOL                            _multiSectorRequested;                  /* user option */
        !           175: 
        !           176:        /*
        !           177:         * IDE Controller information
        !           178:         */
        !           179:     BOOL                       _EIDESupport;           /* EIDE enabled? */
        !           180:     BOOL                       _IOCHRDYSupport;        /* Host side */
        !           181:        txferModes_t    _controllerModes;       /* Masks of transfer modes supported */
        !           182: 
        !           183:     /*
        !           184:      * PCI related ivars. 
        !           185:      */
        !           186:     ideTransferWidth_t         _transferWidth;         // 16 or 32 bits
        !           187:        unsigned long           _controllerID;          // PCI IDE controller's ID
        !           188:        unsigned short          _bmRegs;                        // I/O mapped bus master registers
        !           189:        memStruct_t                     _prdTable;                      // descriptor table memory
        !           190:        unsigned int            _tablePhyAddr;          // table's physical address
        !           191:        BOOL                            _busMaster;                     // YES for bus master controllers
        !           192:        enum {
        !           193:                PCI_CHANNEL_PRIMARY,                            // 0x1f0, 14
        !           194:                PCI_CHANNEL_SECONDARY,                          // 0x170, 15
        !           195:                PCI_CHANNEL_OTHER,
        !           196:        } _ideChannel;
        !           197: 
        !           198:     /*
        !           199:      * Power management related ivars. 
        !           200:      */
        !           201:     idePowerState_t    _drivePowerState;       /* PM state for both drives */
        !           202:     BOOL               _driveSleepRequest;
        !           203: 
        !           204: #ifdef NO_IRQ_MSG
        !           205:        BOOL            interruptOccurred;
        !           206:        int                     waitQueue;
        !           207: #endif NO_IRQ_MSG
        !           208: 
        !           209: #ifdef DEBUG    
        !           210:     /* For testing */
        !           211:     BOOL               _printWaitForNotBusy;
        !           212: #endif DEBUG
        !           213: }
        !           214: 
        !           215: /*
        !           216:  * Exported methods.
        !           217:  */
        !           218: + (BOOL)probe:(IODeviceDescription *)devDesc;
        !           219: 
        !           220: - (void)enableInterrupts;
        !           221: - (void)disableInterrupts;
        !           222: 
        !           223: - (void)setInterruptTimeOut:(unsigned int)timeOut;
        !           224: - (unsigned int)interruptTimeOut;
        !           225: 
        !           226: - (ide_return_t)ideWaitForInterrupt:(unsigned int)command
        !           227:                           ideStatus:(unsigned char *)status;
        !           228: - (void)clearInterrupts;
        !           229: 
        !           230: - free;
        !           231: 
        !           232: /*
        !           233:  * Controller status checks. 
        !           234:  */
        !           235: - (ide_return_t)waitForNotBusy;
        !           236: - (ide_return_t)waitForDeviceReady;
        !           237: - (ide_return_t)waitForDataReady;
        !           238: - (ide_return_t)waitForDeviceIdle;
        !           239: 
        !           240: - (ide_return_t)ataIdeReadGetInfoCommonWaitForDataReady;
        !           241: 
        !           242: /*
        !           243:  * Miscellaneous methods.
        !           244:  */
        !           245: - (void)xferData:(caddr_t)addr read:(BOOL)read client:(struct vm_map *)client 
        !           246:                length:(unsigned)length;
        !           247: 
        !           248: - (void)ideCntrlrLock;
        !           249: - (void)ideCntrlrUnLock;
        !           250: 
        !           251: - (void)atapiCntrlrLock;
        !           252: - (void)atapiCntrlrUnLock;
        !           253: 
        !           254: - (BOOL)isMultiSectorAllowed:(unsigned int)unit;
        !           255: - (void)getIdeRegisters:(ideRegsVal_t *)rvp Print:(char *)printString;
        !           256: 
        !           257: - (BOOL) isDmaSupported:(unsigned int)unit;
        !           258: 
        !           259: /*
        !           260:  * Number of sectors that can be transferred via READ_MULTIPLE or
        !           261:  * WRITE_MULTIPLE command. 
        !           262:  */
        !           263: - (unsigned int)getMultiSectorValue:(unsigned int)unit;
        !           264: 
        !           265: /*
        !           266:  * ATAPI related methods. 
        !           267:  */
        !           268: - (unsigned int)numDevices;                    /* max devices on ATA bus */
        !           269: - (BOOL)isAtapiDevice:(unsigned char)unit;
        !           270: - (BOOL)isAtapiCommandActive:(unsigned char)unit;
        !           271: - (void)setAtapiCommandActive:(BOOL)state forUnit:(unsigned char)unit;
        !           272: 
        !           273: /*
        !           274:  * Power management methods. 
        !           275:  */
        !           276: - (idePowerState_t)drivePowerState;
        !           277: - (void)setDrivePowerState:(idePowerState_t)state;
        !           278: - (void)putDriveToSleep;
        !           279: - (void)wakeUpDrive;
        !           280: - (BOOL)spinUpDrive:(unsigned int)unit;
        !           281: - (BOOL)startUpAttachedDevices;
        !           282: 
        !           283: /*
        !           284:  * The PM state is per controller, not per device. 
        !           285:  */
        !           286: - (IOReturn) getPowerState:(PMPowerState *)state_p;
        !           287: - (IOReturn) setPowerState:(PMPowerState)state;
        !           288: - (IOReturn) getPowerManagement:(PMPowerManagementState *)state_p;
        !           289: - (IOReturn) setPowerManagement:(PMPowerManagementState)state;
        !           290: 
        !           291: @end
        !           292: 
        !           293: #define MAX_BUSY_DELAY                 (10 * 1000 * 1000)      // 10 seconds
        !           294: #define MAX_DATA_READY_DELAY   (10 * 1000 * 1000)
        !           295:  
        !           296: #define CMOSADDR                               0x70
        !           297: #define CMOSDATA                               0x71
        !           298: #define HDTYPE                                 0x12
        !           299: 
        !           300: #define HD0_EXTTYPE                            0x19
        !           301: #define HD1_EXTTYPE                            0x1a
        !           302: 
        !           303: #define CMOS_IDE_TABLE                 0xfe401
        !           304: #define SIZE_OF_IDE_TABLE              16
        !           305: 
        !           306: /*
        !           307:  * This is actually quite a long time but it is mandated by the spec. 
        !           308:  */
        !           309: #define IDE_INTR_TIMEOUT               (30*1000)       // thirty seconds
        !           310: 
        !           311: #endif _BSD_DEV_I386_IDECNT_H_
        !           312: 
        !           313: #endif DRIVER_PRIVATE

unix.superglobalmegacorp.com

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