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