Annotation of XNU/iokit/Drivers/ata/drvAppleATA/AppleATAPIIXTiming.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 2000 Apple Computer, Inc.  All rights reserved. 
        !             3:  *
        !             4:  * AppleATAPIIXTiming.h - Timing tables.
        !             5:  *
        !             6:  * HISTORY
        !             7:  *
        !             8:  */
        !             9: 
        !            10: #ifndef _APPLEATAPIIXTIMING_H
        !            11: #define _APPLEATAPIIXTIMING_H
        !            12: 
        !            13: /*
        !            14:  * Supported transfer protocols. Entries in this table must map to the
        !            15:  * entries in ATATimingProtocol table.
        !            16:  */
        !            17: typedef enum {
        !            18:     kPIIXProtocolPIO  = 0,
        !            19:     kPIIXProtocolDMA,
        !            20:     kPIIXProtocolUDMA33,
        !            21:     kPIIXProtocolUDMA66,
        !            22:     kPIIXProtocolLast
        !            23: } PIIXProtocol;
        !            24: 
        !            25: /*
        !            26:  * PIIX PIO/DMA timing table.
        !            27:  */
        !            28: typedef struct {
        !            29:     UInt8    pioMode;        // PIO mode
        !            30:     UInt8    swDMAMode;      // single-word DMA mode (obsolete)
        !            31:     UInt8    mwDMAMode;      // multiword DMA mode
        !            32:     UInt8    isp;            // IORDY sample point in PCI clocks
        !            33:     UInt8    rtc;            // Recovery time in PCI clocks
        !            34:     UInt16   cycle;          // cycle time in ns
        !            35: } PIIXTiming;
        !            36: 
        !            37: #define _NVM_    0xff        // not a valid mode
        !            38: 
        !            39: static const
        !            40: PIIXTiming PIIXPIOTimingTable[] = {
        !            41: /*  PIO     SW     MW     ISP   RTC   CYCLE (ns)   */
        !            42:     {0,     0,     0,     5,    4,    600},
        !            43:     {1,     1,     _NVM_, 5,    4,    600},
        !            44:     {2,     2,     _NVM_, 4,    4,    240},
        !            45:     {3,     _NVM_, 1,     3,    3,    180},
        !            46:     {4,     _NVM_, 2,     3,    1,    120},
        !            47:     {5,     _NVM_, 2,     3,    1,    120},
        !            48: };
        !            49: 
        !            50: static const UInt8 PIIXPIOTimingTableSize = sizeof(PIIXPIOTimingTable) / 
        !            51:                                             sizeof(PIIXPIOTimingTable[0]);
        !            52: 
        !            53: /*
        !            54:  * PIIX Ultra-DMA/33 timing table.
        !            55:  */
        !            56: typedef struct {
        !            57:     UInt8    mode;           // mode number
        !            58:     UInt8    ct;             // cycle time in PCI clocks
        !            59:     UInt8    rp;             // Ready to Pause time in PCI clocks
        !            60:     UInt8    bits;           // register bit setting
        !            61:     UInt16   strobe;         // strobe period (cycle) in ns
        !            62: } PIIXUDMATiming;
        !            63: 
        !            64: static const
        !            65: PIIXUDMATiming PIIXUDMATimingTable[] = {
        !            66: /*  MODE    CT     RP     BITS   STROBE/CYCLE (ns)   */
        !            67:     {0,     4,     6,     0,     120},
        !            68:     {1,     3,     5,     1,     90},
        !            69:     {2,     2,     4,     2,     60},
        !            70: };
        !            71: 
        !            72: static const UInt8
        !            73: PIIXUDMATimingTableSize = sizeof(PIIXUDMATimingTable) / 
        !            74:                           sizeof(PIIXUDMATimingTable[0]);
        !            75: 
        !            76: /*
        !            77:  * For each drive, the following table will store the chosen timings
        !            78:  * for each supported protocol.
        !            79:  */
        !            80: typedef struct {
        !            81:     UInt8   activeTimings[kPIIXProtocolLast];   // selected timings
        !            82:     UInt8   validTimings[kPIIXProtocolLast];    // calculated timings
        !            83:     UInt32  validFlag;
        !            84:     UInt32  activeFlag;
        !            85: } PIIXSelectedTimings;
        !            86: 
        !            87: /*
        !            88:  * Convert from ATATimingProtocol to PIIXProtocol.
        !            89:  */
        !            90: inline PIIXProtocol ataToPIIXProtocol(ATATimingProtocol timingProtocol)
        !            91: {
        !            92:     int piixProtocol = kPIIXProtocolPIO;
        !            93:     int ataProtocol  = timingProtocol;
        !            94:     
        !            95:     while (ataProtocol != 1) {
        !            96:         ataProtocol >>= 1; piixProtocol++;
        !            97:     }
        !            98:     return ((PIIXProtocol) piixProtocol);
        !            99: }
        !           100: 
        !           101: /*
        !           102:  * Misc macros to get information from the PIIXSelectedTimings table.
        !           103:  */
        !           104: #define PIIX_ACTIVATE_PROTOCOL(p) {                                  \
        !           105:     timings[unit].activeTimings[p] = timings[unit].validTimings[p];  \
        !           106:     timings[unit].activeFlag |= (1 << (p));                          \
        !           107: }
        !           108: 
        !           109: #define PIIX_DEACTIVATE_PROTOCOL(p) {                                \
        !           110:     timings[unit].activeFlag &= ~(1 << (p));                         \
        !           111: }
        !           112: 
        !           113: #define PIIX_GET_ACTIVE_TIMING(p)    (timings[unit].activeTimings[p])
        !           114: 
        !           115: #define PIIX_PROTOCOL_IS_ACTIVE(p)   ((bool) \
        !           116:                                       (timings[unit].activeFlag & (1 << (p))))
        !           117: 
        !           118: #define PIIX_PROTOCOL_IS_VALID(p)    ((bool) \
        !           119:                                       (timings[unit].validFlag & (1 << (p))))
        !           120: 
        !           121: #endif /* !_APPLEATAPIIXTIMING_H */

unix.superglobalmegacorp.com

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