Annotation of drvEIDE/EIDE.drvproj/EIDE.lksproj/ata_extern.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:  * ata_extern.h -- Externally used data structures and constants for IDE
        !            29:  *             disk driver
        !            30:  *
        !            31:  * KERNEL VERSION
        !            32:  *
        !            33:  * HISTORY  
        !            34:  * 04-Mar-1997  Scott Vail at NeXT
        !            35:  *     Changes made to ideDriveInfo_t struct.  No longer stores
        !            36:  *     capacity, only total sectors.
        !            37:  *
        !            38:  * 07-Jul-1994  Rakesh Dubey at NeXT
        !            39:  *     Created from original driver written by David Somayajulu.
        !            40:  */
        !            41:  
        !            42: #ifdef DRIVER_PRIVATE
        !            43: 
        !            44: #ifndef        _BSD_DEV_ATA_EXTERN_H
        !            45: #define _BSD_DEV_ATA_EXTERN_H
        !            46: 
        !            47: #import <sys/types.h>
        !            48: #import <sys/ioctl.h>
        !            49: #if (IO_DRIVERKIT_VERSION == 330)
        !            50: #ifdef KERNEL
        !            51: #import <machdep/machine/pmap.h>
        !            52: #import <vm/vm_map.h>
        !            53: #endif KERNEL
        !            54: #endif
        !            55: #import <mach/boolean.h>
        !            56: #import <mach/vm_param.h>
        !            57: 
        !            58: #define MAX_IDE_DRIVES                         2       /* for a PC AT connector */
        !            59: #define MAX_IDE_CONTROLLERS            2       /* that we support */
        !            60: 
        !            61: /*
        !            62:  * This should be removed when CDIS stops looking for NIDE_PCAT. 
        !            63:  */
        !            64: #define NIDE_PCAT                      MAX_IDE_DRIVES  
        !            65: 
        !            66: /*
        !            67:  * This struct stores the info returned from the BIOS. 
        !            68:  */
        !            69: typedef struct _ideDriveInfo {
        !            70:     unsigned short     type;                   /* from CMOS RAM */
        !            71:     unsigned char      control_byte;   
        !            72:     unsigned char      interleave;             /* interleave factor */
        !            73:     unsigned int       total_sectors;          /* total number of sectors */
        !            74:     unsigned short     cylinders;              /* number of cylinders */
        !            75:     unsigned char      heads;                  /* total number of heads */
        !            76:     unsigned char      sectors_per_trk;        /* sectors per track */
        !            77:     unsigned           bytes_per_sector;       /* bytes per sector */
        !            78:     unsigned           access_time;            /* average access time */
        !            79:     unsigned short     precomp;                /* not used anymore */
        !            80:     unsigned short     landing_zone;
        !            81: } ideDriveInfo_t;
        !            82: 
        !            83: /*
        !            84:  * Port addresses for IDE controller registers on PC AT. Don't change the
        !            85:  * identifiers without changing the #define's in AtapiCnt.h as well. This is
        !            86:  * because the ATAPI interface uses the same registers but has different
        !            87:  * names for them. 
        !            88:  */
        !            89: 
        !            90: typedef struct  _ideRegsAddrs {
        !            91: 
        !            92:     /* Command block registers */
        !            93:     unsigned data;             /* data register base port (read/write) */
        !            94:     unsigned features;         /* features register (write only) */
        !            95:     unsigned error;            /* error register (read only) */
        !            96:     unsigned sectCnt;          /* sector count (read/write) */
        !            97:     unsigned sectNum;          /* sector number (read/write) */
        !            98:     unsigned cylLow;           /* cylinder low (read/write) */
        !            99:     unsigned cylHigh;          /* cylinder high (read/write) */
        !           100:     unsigned drHead;           /* drive, head select register (read/write) */
        !           101:     unsigned status;           /* status register (read only) */
        !           102:     unsigned command;          /* command register (write only) */
        !           103: 
        !           104:     /* Control Block Registers */
        !           105:     unsigned deviceControl;    /* control register */
        !           106:     unsigned altStatus;        /* shadow of status register but read does */ 
        !           107:                                /* not clear a pending interrupt */
        !           108:     unsigned driveAddress;     /* not used */
        !           109: } ideRegsAddrs_t; 
        !           110: 
        !           111: /*
        !           112:  * Register values for IDE controller for PC AT. 
        !           113:  */
        !           114: 
        !           115: typedef struct _ideRegsVal {
        !           116:     unsigned short     data;           /* data register  */
        !           117:     unsigned char      features;       /* features register  */
        !           118:     unsigned char      error;          /* error register  */
        !           119:     unsigned char      sectCnt;        /* sector count  */
        !           120:     unsigned char      sectNum;        /* sector number  */
        !           121:     unsigned char      cylLow;         /* cylinder low  */
        !           122:     unsigned char      cylHigh;        /* cylinder high  */
        !           123:     unsigned char      drHead;         /* drive, head select (write first) */
        !           124:     unsigned char      status;         /* status register  */
        !           125:     unsigned char      command;        /* command register  */
        !           126: } ideRegsVal_t; 
        !           127: 
        !           128: /*
        !           129:  * Defines for error register. 
        !           130:  */
        !           131: #define BAD_BLOCK                      0x80
        !           132: #define ECC_ERROR                      0x40
        !           133: #define ID_NOT_FOUND                   0x10
        !           134: #define CMD_ABORTED                    0x04
        !           135: #define TRK0_NOT_FOUND                 0x02
        !           136: #define DAM_NOT_FOUND                  0x01
        !           137: 
        !           138: 
        !           139: /*
        !           140:  * Defines for drive, head select register. 
        !           141:  */
        !           142: #define SEL_DRIVE0                     0x00
        !           143: #define        SEL_DRIVE1                      0x10
        !           144: 
        !           145: /*
        !           146:  * Addressing method, LBA or CHS. 
        !           147:  */
        !           148: #define ADDRESS_MODE_CHS               0xa0
        !           149: #define ADDRESS_MODE_LBA               0xe0
        !           150: 
        !           151: /*
        !           152:  * Defines for the status register. 
        !           153:  */
        !           154: 
        !           155: #define BUSY                           0x80
        !           156: #define READY                          0x40
        !           157: #define WRITE_FAULT                    0x20
        !           158: #define SEEK_COMPLETE                  0x10
        !           159: #define DREQUEST                       0x08
        !           160: #define ERROR_CORRECTED                        0x04    /* really not used */
        !           161: #define INDEX                          0x02
        !           162: #define ERROR                          0x01    /* Last command failed */
        !           163: 
        !           164: /*
        !           165:  * Defines for control register. 
        !           166:  */
        !           167: #define HEADSEL3_ENABLE                        0x08
        !           168: #define DISK_RESET_ENABLE              0x04
        !           169: #define DISK_INTERRUPT_ENABLE          0x00
        !           170: #define DISK_INTERRUPT_DISABLE         0x02
        !           171: 
        !           172: /*
        !           173:  * End of IDE register related defines. 
        !           174:  */
        !           175: 
        !           176: /*
        !           177:  * IDE commands -- as defined in the ATA spec. 
        !           178:  */
        !           179: 
        !           180: /*
        !           181:  * Mandatory commands. 
        !           182:  */
        !           183: #define        IDE_READ                0x20
        !           184: #define        IDE_WRITE               0x30
        !           185: #define        IDE_SEEK                0x70
        !           186: #define                IDE_RESTORE             0x10
        !           187: #define                IDE_FORMAT_TRACK        0x50    /* do not use */
        !           188: #define        IDE_READ_VERIFY         0x40
        !           189: #define                IDE_DIAGNOSE            0x90
        !           190: #define                IDE_SET_PARAMS          0x91
        !           191: 
        !           192: /*
        !           193:  * Optional commands. 
        !           194:  */
        !           195: 
        !           196: #define                IDE_IDENTIFY_DRIVE      0xec
        !           197: #define                IDE_SET_MULTIPLE        0xc6
        !           198: #define                IDE_READ_MULTIPLE       0xc4
        !           199: #define                IDE_WRITE_MULTIPLE      0xc5
        !           200: #define                IDE_READ_DMA            0xc8
        !           201: #define                IDE_WRITE_DMA           0xca
        !           202: #define                IDE_SET_FEATURES        0xef
        !           203: #define                IDE_IDLE                0xe3
        !           204: #define                IDE_SLEEP               0xe6
        !           205: 
        !           206: typedef        int ide_return_t;
        !           207: 
        !           208: /*
        !           209:  * Return values for IDE commmands to the controller. 
        !           210:  */
        !           211: 
        !           212: #define IDER_SUCCESS           0       /* OK */
        !           213: #define IDER_TIMEOUT           1       /* cmd timed out */
        !           214: #define IDER_MEMALLOC          2       /* couldn't allocate memory */
        !           215: #define IDER_MEMFAIL           3       /* memory transfer error */
        !           216: #define IDER_REJECT            4       /* bad field in ideIoReq_t */
        !           217: #define IDER_BADDRV            5       /* drive not present */
        !           218: #define IDER_CMD_ERROR         6       /* basic command failure */
        !           219: #define IDER_VOLUNAVAIL                7       /* Requested Volume not available */
        !           220: #define IDER_SPURIOUS          8       /* spurious interrupt */
        !           221: #define IDER_CNTRL_REJECT      9       /* controller has rejected */
        !           222: #define IDER_RETRY             10      /* controller requests retrying */
        !           223: #define IDER_DEV_NOT_READY     11      /* DRQ bit not set (status reg) */
        !           224: #define IDER_DEV_BUSY          12      /* BUSY bit is set */
        !           225: #define IDER_ERROR                     13      /* other IDE error */
        !           226: #define IDER_ABORT                     14  /* ABRT bit is set */
        !           227: 
        !           228: 
        !           229: /*
        !           230:  * I/O request struct. Used in IDEIOCREQ ioctl to specify one command
        !           231:  * sequence to be executed. 
        !           232:  */
        !           233: 
        !           234: typedef struct _ideIoReq {
        !           235: 
        !           236:     /*
        !           237:      * Inputs to driver 
        !           238:      */
        !           239:     unsigned           cmd;    
        !           240: 
        !           241:     /* Starting block for IDE_READ, IDE_WRITE, IDE_READ_VERIFY, IDE_SEEK */
        !           242:     unsigned           block;  
        !           243:     /* Number of blocks for IDE_READ, IDE_SEEK IDE_WRITE, IDE_READ_VERIFY */
        !           244:     unsigned           blkcnt; 
        !           245: 
        !           246:     /* Starting address for IDE_READ, IDE_WRITE and IDE_IDENTIFY_DRIVE */
        !           247:     caddr_t            addr;   
        !           248:                                                                            
        !           249:     unsigned           timeout;                /* milliseconds */
        !           250:     unsigned char      maxSectorsPerIntr;      /* Only for IDE_SET_MULTIPLE */
        !           251: 
        !           252:     /*
        !           253:      * Outputs from driver. 
        !           254:      */
        !           255: 
        !           256:     ide_return_t       status;         /* IDER_SUCCESS, etc. */
        !           257:     unsigned           blocks_xfered;  /* Blocks actually transfered */
        !           258:     ideRegsVal_t       regValues;      /* Valid if status is IDER_CMD_ERROR */
        !           259:     unsigned           diagResult;     /* Result if cmd was IDE_DIAGNOSE */
        !           260: 
        !           261:     /*
        !           262:      * Used internally by the driver. 
        !           263:      */
        !           264: #ifdef KERNEL
        !           265:        struct vm_map   *map;           /* Map of requestor's task  */
        !           266: #else
        !           267:        void            *map;
        !           268: #endif KERNEL
        !           269: 
        !           270: } ideIoReq_t;
        !           271: 
        !           272: /*
        !           273:  * Ioctls specific to IDE. 
        !           274:  */
        !           275: 
        !           276: #define IDEDIOCINFO                    _IOR('i',1, struct _ideDriveInfo)
        !           277: 
        !           278: #define IDEDIOCREQ                     _IOWR('i',2, struct _ideIoReq)
        !           279:  
        !           280: #define MAX_CMOS_IDETYPE               0x00ff
        !           281: #define MIN_CMOS_IDETYPE               0x0001
        !           282: 
        !           283: #define MAX_BLOCKS_PER_XFER            256
        !           284: #define IDE_SECTOR_SIZE                        512             /* bytes */
        !           285: #define IDE_MAX_PHYS_IO                        (MAX_BLOCKS_PER_XFER * IDE_SECTOR_SIZE)
        !           286: 
        !           287: /*
        !           288:  * Structure returned by (optional) IDE_IDENTIFY_DRIVE command. Field
        !           289:  * definitions from standard X3T9.2 791D Rev4 (17-Mar-93). Some of these
        !           290:  * definitions have changed in proposed ATA-2 standard. 
        !           291:  */
        !           292: #define        IDE_MULTI_SECTOR_MASK           0x00ff
        !           293: 
        !           294: #define        IDE_CAP_LBA_SUPPORTED           0x0200
        !           295: #define IDE_CAP_DMA_SUPPORTED          0x0100
        !           296: #define IDE_CAP_IORDY_SUPPORTED                0x0800          /* from ATA-2 */
        !           297: 
        !           298: #define IDE_PIO_TIMING_MODE_MASK       0xff00
        !           299: #define IDE_DMA_TIMING_MODE_MASK       0xff00
        !           300: 
        !           301: #define        IDE_TRANSLATION_VALID           0x0001  
        !           302: 
        !           303: #define        IDE_MULTI_SECTOR_VALID          0x0100
        !           304: #define IDE_SECTORS_PER_INTERRUPT      0x00ff
        !           305: 
        !           306: #define IDE_SW_DMA_ACTIVE                      0xff00
        !           307: #define IDE_SW_DMA_SUPPORTED           0x00ff
        !           308: #define IDE_MW_DMA_ACTIVE                      0xff00
        !           309: #define IDE_MW_DMA_SUPPORTED           0x00ff
        !           310: #define IDE_UDMA_ACTIVE                                0xff00
        !           311: #define IDE_UDMA_SUPPORTED                     0x00ff
        !           312: 
        !           313: #define IDE_FC_PIO_MODE_3_SUPPORTED    0x0001
        !           314: #define IDE_FC_PIO_MODE_4_SUPPORTED    0x0002
        !           315: #define IDE_FC_PIO_MODE_5_SUPPORTED    0x0004
        !           316: 
        !           317: /*
        !           318:  * fieldValidity bit definitions.
        !           319:  */
        !           320: #define IDE_WORDS54_TO_58_SUPPORTED    0x0001
        !           321: #define IDE_WORDS64_TO_70_SUPPORTED    0x0002
        !           322: #define IDE_WORDS64_TO_68_SUPPORTED IDE_WORDS64_TO_70_SUPPORTED
        !           323: #define IDE_WORD88_SUPPORTED           0x0004          /* UDMA support */
        !           324: 
        !           325: typedef        struct  _ideIdentifyInfo {
        !           326:     unsigned short     genConfig;
        !           327:     unsigned short     cylinders;
        !           328:     unsigned short     reserved_2;
        !           329:     unsigned short     heads;
        !           330:     unsigned short     unformattedBytesPerTrack;               /* retired */
        !           331:     unsigned short     unformattedBytesPerSector;              /* retired */
        !           332:     unsigned short     sectorsPerTrack;
        !           333:     unsigned short     vendorSpecific0[3];                             /* retired */
        !           334:     unsigned char      serialNumber[20];
        !           335:     unsigned short     bufferType;                                             /* retired */
        !           336:     unsigned short     bufferSize;                                             /* retired */
        !           337:     unsigned short     eccBytes;                                               /* obsolete */
        !           338:     unsigned char      firmwareRevision[8];
        !           339:     unsigned char      modelNumber[40];
        !           340:     unsigned short     multipleSectors;
        !           341:     unsigned short     doubleWordIO;                                   /* Vendor Unique */
        !           342:     unsigned short     capabilities;
        !           343:     
        !           344:     unsigned short     capabilities2;
        !           345:     unsigned short     pioDataTransferCyleTimingMode;
        !           346:     unsigned short     dmaDataTransferCyleTimingMode;  /* retired */
        !           347:     unsigned short     fieldValidity;
        !           348:                                    
        !           349:     unsigned short     currentCylinders;
        !           350:     unsigned short     currentHeads;
        !           351:     unsigned short     currentSectorsPerTrack;
        !           352:     unsigned short     capacity[2];    
        !           353:     unsigned short     multiSectorInfo;
        !           354:     unsigned           userAddressableSectors;                 /* LBA mode only */
        !           355:     unsigned short     swDma;                                                  /* retired */   
        !           356:     unsigned short     mwDma;  
        !           357:     unsigned short     fcPioDataTransferCyleTimingMode;
        !           358:     unsigned short     minMwDMATransferCycleTimePerWord;
        !           359:     unsigned short     RecommendedMwDMACycleTime;
        !           360:     unsigned short     MinPIOTransferCycleTimeWithoutFlowControl;
        !           361:     unsigned short     MinPIOTransferCycleTimeWithIORDY;
        !           362:        
        !           363:        /* ATA4/ATA3 additions */
        !           364:        unsigned short  reserved_69_74[6];
        !           365:        unsigned short  queueDepth;
        !           366:        unsigned short  reserved_76_79[4];
        !           367:        unsigned short  majorVersionNumber;
        !           368:        unsigned short  minorVersionNumber;
        !           369:        unsigned short  commandSetSupported[2];                 /* word 82-83 */
        !           370:        unsigned short  commandSetExtension;                    /* word 84 */
        !           371:        unsigned short  commandSetEnabled[2];                   /* word 85-86 */
        !           372:        unsigned short  commandSetDefault;                              /* word 87 */
        !           373:        unsigned short  UDma;                                                   /* word 88 */
        !           374:        unsigned short  timeForSecurityErase;                   /* word 89 */
        !           375:        unsigned short  timeForEnhancedErase;                   /* word 90 */
        !           376:        unsigned short  currentAPMValue;                                /* word 91 */
        !           377:        unsigned short  reserved_92_126[35];
        !           378:        unsigned short  removableMediaStatusSupport;    /* word 127 */
        !           379:        unsigned short  securityStatus;                                 /* word 128 */
        !           380:        unsigned short  reserved_129_159[31];
        !           381:        unsigned short  reserved_160_255[96];
        !           382: } ideIdentifyInfo_t;
        !           383: 
        !           384: /*
        !           385:  * Maximum Number of bytes of data that can be transfered via DMA using
        !           386:  * IDEDIOCREQ ioctl command. 
        !           387:  */
        !           388: 
        !           389: #ifdef KERNEL
        !           390: #define IDE_MAX_DMA_SIZE                       PAGE_SIZE 
        !           391: #else KERNEL
        !           392: #define IDE_MAX_DMA_SIZE                       vm_page_size 
        !           393: #endif KERNEL
        !           394: 
        !           395: /*
        !           396:  * Register and mask definitions for IDE_SET_FEATURES command. 
        !           397:  */
        !           398: 
        !           399: #define FEATURE_SET_TRANSFER_MODE                      0x03
        !           400: #define FEATURE_ENABLE_POWER_ON_DEFAULTS       0xcc
        !           401: #define FEATURE_DISABLE_POWER_ON_DEFAULTS      0x66
        !           402: 
        !           403: #define PIO_FLOW_CONTROL_TM_MASK               0x000f
        !           404: #define DMA_FLOW_CONTROL_TM_MASK               0x0017
        !           405: 
        !           406: #endif _BSD_DEV_ATA_EXTERN_H
        !           407: 
        !           408: #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.