|
|
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 1998 by Apple Computer, Inc., All rights reserved. ! 26: * ! 27: * Intel PIIX/PIIX3/PIIX4 PCI IDE controller timing tables. ! 28: * ! 29: * HISTORY: ! 30: * 1-Feb-1998 Joe Liu at Apple ! 31: * Created. ! 32: */ ! 33: #import "PIIX.h" ! 34: ! 35: typedef ideTransferType_t PIIXTransferType_t; ! 36: ! 37: /* ! 38: * PIIX PIO/DMA timing table. ! 39: */ ! 40: ! 41: typedef struct { ! 42: u_char pio_mode; ! 43: u_char swdma_mode; ! 44: u_char mwdma_mode; ! 45: u_char isp; // IORDY sample point in PCI clocks ! 46: u_char rct; // Recovery time in PCI clocks ! 47: u_short cycle; // cycle time in ns ! 48: } PIIXTiming; ! 49: ! 50: #define INV 255 // invalid mode ! 51: #define PIIX_TIMING_TABLE_SIZE 6 ! 52: ! 53: static const ! 54: PIIXTiming PIIXTimingTable[] = { ! 55: // PIO SW MW ! 56: {0, 0, 0, 5, 4, 600}, // compatible timing ! 57: {1, 1, INV, 5, 4, 600}, ! 58: {2, 2, INV, 4, 4, 240}, ! 59: {3, INV, 1, 3, 3, 180}, ! 60: {4, INV, 2, 3, 1, 120}, ! 61: {5, INV, 2, 3, 1, 120}, // Isn't this 90ns? ! 62: }; ! 63: ! 64: /* ! 65: * PIIX Ultra DMA/33 timing table. ! 66: */ ! 67: typedef struct { ! 68: u_char mode; ! 69: u_char ct; // Cycle time in PCI clocks ! 70: u_char rp; // Ready to Pause time in PCI clocks ! 71: u_char bits; // bit settings ! 72: u_short strobe; // strobe period in ns ! 73: } PIIXUltraDMATiming; ! 74: ! 75: static const ! 76: PIIXUltraDMATiming PIIXUltraDMATimingTable[] = { ! 77: {0, 4, 6, 0, 120}, ! 78: {1, 3, 5, 1, 90}, ! 79: {2, 2, 4, 2, 60}, ! 80: }; ! 81: ! 82: /* ! 83: * Given a transfer mode/type, return the index for the ! 84: * entry in PIIXTimingTable[] which matches the mode. ! 85: */ ! 86: static __inline__ ! 87: u_char ! 88: PIIXFindModeInTable(u_char mode, PIIXTransferType_t type) ! 89: { ! 90: int i; ! 91: for (i = (PIIX_TIMING_TABLE_SIZE - 1); i >= 0; i--) { ! 92: u_char m; ! 93: ! 94: switch (type) { ! 95: case IDE_TRANSFER_ULTRA_DMA: ! 96: case IDE_TRANSFER_MW_DMA: ! 97: m = PIIXTimingTable[i].mwdma_mode; ! 98: break; ! 99: case IDE_TRANSFER_SW_DMA: ! 100: m = PIIXTimingTable[i].swdma_mode; ! 101: break; ! 102: case IDE_TRANSFER_PIO: ! 103: default: ! 104: m = PIIXTimingTable[i].pio_mode; ! 105: } ! 106: ! 107: if (mode == m) ! 108: return (i); ! 109: } ! 110: ! 111: // not found, return compatible timing ! 112: return (0); ! 113: } ! 114: ! 115: /* ! 116: * Given a transfer mode/type, return the ISP value. ! 117: */ ! 118: static __inline__ ! 119: u_char ! 120: PIIXGetISPForMode(u_char mode, PIIXTransferType_t type) ! 121: { ! 122: u_char index = PIIXFindModeInTable(mode, type); ! 123: return (PIIX_CLK_TO_ISP(PIIXTimingTable[index].isp)); ! 124: } ! 125: ! 126: /* ! 127: * Given a transfer mode/type, return the RCT value. ! 128: */ ! 129: static __inline__ ! 130: u_char ! 131: PIIXGetRCTForMode(u_char mode, PIIXTransferType_t type) ! 132: { ! 133: u_char index = PIIXFindModeInTable(mode, type); ! 134: return (PIIX_CLK_TO_RCT(PIIXTimingTable[index].rct)); ! 135: } ! 136: ! 137: /* ! 138: * Given a transfer mode/type, return the cycle time in ns. ! 139: */ ! 140: static __inline__ ! 141: u_short ! 142: PIIXGetCycleForMode(u_char mode, PIIXTransferType_t type) ! 143: { ! 144: u_char index = PIIXFindModeInTable(mode, type); ! 145: return (PIIXTimingTable[index].cycle); ! 146: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.