Nut/OS  4.10.3
API Reference
idep.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 *  This file is part of the AVRIDE device driver.
00003 *
00004 *  Copyright (c) 2002-2003 by Michael Fischer. All rights reserved.
00005 *
00006 *  Redistribution and use in source and binary forms, with or without 
00007 *  modification, are permitted provided that the following conditions 
00008 *  are met:
00009 *  
00010 *  1. Redistributions of source code must retain the above copyright 
00011 *     notice, this list of conditions and the following disclaimer.
00012 *  2. Redistributions in binary form must reproduce the above copyright
00013 *     notice, this list of conditions and the following disclaimer in the 
00014 *     documentation and/or other materials provided with the distribution.
00015 *  3. Neither the name of the author nor the names of its contributors may 
00016 *     be used to endorse or promote products derived from this software 
00017 *     without specific prior written permission.
00018 *
00019 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
00020 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
00021 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
00022 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 
00023 *  THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
00024 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
00025 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 
00026 *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
00027 *  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
00028 *  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 
00029 *  THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
00030 *  SUCH DAMAGE.
00031 *
00032 ****************************************************************************
00033 *  History:
00034 *
00035 *  14.12.02  mifi   First Version 
00036 *  18.01.03  mifi   Change Licence from GPL to BSD.
00037 *  19.06.03  mifi   Change address for ide port from 0x8000 to 0xE000
00038 *  29.06.03  mifi   First ATAPI-Version
00039 ****************************************************************************/
00040 #ifndef __IDEP_H__
00041 #define __IDEP_H__
00042 
00043 #include <dev/ide.h>
00044 #include <fs/typedefs.h>
00045 
00046 /*-------------------------------------------------------------------------*/
00047 /* global defines                                                          */
00048 /*-------------------------------------------------------------------------*/
00049 //
00050 // If the driver should support the old
00051 // CHS drives, set IDE_SUPPORT_CHS to 1
00052 // 
00053 #define IDE_SUPPORT_CHS         0
00054 
00055 #define IDE_BASE_ADDRESS        0xE000
00056 #define IDECS0                  0x0000
00057 #define IDECS1                  0x0500
00058 
00059 #define DATA_WRITE_REG_LOW      (IDECS0 + 0x0100)
00060 #define DATA_WRITE_REG_HIGH     (IDECS0 + 0x0200)
00061 
00062 #define DATA_READ_REG_LOW       (IDECS0 + 0x0300)
00063 #define DATA_READ_REG_HIGH      (IDECS0 + 0x0400)
00064 
00065 #define ERROR_REG               (IDECS0 + 1)
00066 #define FEATURE_REG             (IDECS0 + 1)
00067 #define SECTOR_COUNT_REG        (IDECS0 + 2)
00068 #define SECTOR_REG              (IDECS0 + 3)
00069 #define CYLINDER_LOW_REG        (IDECS0 + 4)
00070 #define CYLINDER_HIGH_REG       (IDECS0 + 5)
00071 #define DISK_HEAD_REG           (IDECS0 + 6)
00072 #define COMMAND_REG             (IDECS0 + 7)
00073 #define STATUS_REG              (IDECS0 + 7)
00074 
00075 #define LBA_0_7                 (IDECS0 + 3)
00076 #define LBA_8_15                (IDECS0 + 4)
00077 #define LBA_16_23               (IDECS0 + 5)
00078 
00079 #define CF_ERROR_REG            (IDECS1 + 0)
00080 
00081 #define CONTROL_REG             (IDECS1 + 6)
00082 #define ALTERNATE_STATUS        (IDECS1 + 6)
00083 
00084 #define STATUS_BUSY             0x80
00085 #define STATUS_DRIVE_READY      0x40
00086 #define STATUS_DEVIDE_FAULT     0x20
00087 #define STATUS_SEEK_COMPLETE    0x10
00088 #define STATUS_DATA_REQUEST     0x08
00089 #define STATUS_CORRECTED_DATA   0x04
00090 #define STATUS_INDEX            0x02
00091 #define STATUS_ERROR            0x01
00092 
00093 #define ERROR_CRC               0x80
00094 #define ERROR_UNC               0x40
00095 #define ERROR_IDN               0x10
00096 #define ERROR_ABT               0x04
00097 #define ERROR_T0N               0x02
00098 #define ERROR_AMN               0x01
00099 
00100 #define COMMAND_DEVICE_INFO     0xEC
00101 #define COMMAND_DEVICE_INFO_P   0xA1
00102 #define COMMAND_READ_SECTORS    0x20
00103 #define COMMAND_WRITE_SECTORS   0x30
00104 #define COMMAND_RECALIBRATE     0x10
00105 #define COMMAND_DIAG            0x90
00106 
00107 #define SERIAL_SIZE             20
00108 #define REV_SIZE                8
00109 #define MODEL_SIZE              40
00110 
00111 //
00112 // ATAPI stuff
00113 //
00114 #define ATAPI_CMD_READ_CAPACITY 0x25
00115 #define ATAPI_CMD_MODE_SELECT   0x55
00116 #define ATAPI_CMD_MODE_SENSE    0x5A
00117 #define ATAPI_CMD_READ12        0xA8
00118 #define ATAPI_CMD_SET_CD_SPEED  0xBB
00119 
00120 
00121 /*-------------------------------------------------------------------------*/
00122 /* global types                                                            */
00123 /*-------------------------------------------------------------------------*/
00124 
00125 typedef struct {
00126     unsigned UnUsed0:1;         //  0
00127     unsigned HardSector_O:1;    //  0
00128     unsigned SoftSector_O:1;    //  0
00129     unsigned MFM_O:1;           //  0
00130     unsigned SlowHead_O:1;      //  0
00131     unsigned SynchDriveMotor_O:1;       //  0
00132     unsigned FixedDevice:1;     //  0
00133     unsigned RemoveableDevice:1;        //  0
00134     unsigned DiskTransferRate_O:3;      //  0
00135     unsigned InaccurateSpeed_O:1;       //  0
00136     unsigned DataStrobeOffset_O:1;      //  0
00137     unsigned TrackOffsetOption_O:1;     //  0
00138     unsigned FormatGapRequired_O:1;     //  0
00139     unsigned ATAPI:1;           //  0
00140 
00141     WORD Cylinders;             //  1
00142     WORD UnUsed1;               //  2
00143     WORD Heads;                 //  3
00144     WORD BytesPerTrack_O;       //  4
00145     WORD BytesPerSector_O;      //  5
00146     WORD SectorsPerTrack;       //  6
00147     WORD VendorSpecific[3];     //  7 - 9
00148     char SerialNumber[SERIAL_SIZE];     //  10 - 19
00149     WORD BufferType_O;          //  20
00150     WORD BufferSizeSectors_O;   //  21
00151     WORD ECCBytes;              //  22
00152     char FirmwareRevision[REV_SIZE];    //  23 - 26
00153     char Model[MODEL_SIZE];     //  27 - 46
00154     BYTE MaxMultipleSectors;    //  47
00155     BYTE UnUsed2;               //  47
00156     WORD Can32Bit_O;            //  48
00157 
00158     unsigned CanDMA_O:1;        //  49
00159     unsigned UnUsed3:9;         //  49
00160     unsigned CanDisableIORDY:1; //  49
00161     unsigned IORDYSupported:1;  //  49
00162     unsigned AdvancedTransferMode:1;    //  49
00163     unsigned ATA3StandbyTimer:1;        //  49
00164     unsigned UnUsed4:2;
00165 
00166     WORD UnUsed5;               //  50
00167 
00168     BYTE UnUsed6;               //  51
00169     BYTE PIOTransferSpeed;      //  51
00170     BYTE UnUsed7;               //  52
00171     BYTE DMATransferSpeed;      //  52
00172 
00173     unsigned Fields_6C_75_Valid:1;      //  53
00174     unsigned Fields_80_8C_Valid:1;      //  53
00175     unsigned UnUsed8:14;        //  53
00176 
00177     WORD Cylinders2;            //  54
00178     WORD Heads2;                //  55
00179     WORD SectorsPerTrack2;      //  56
00180     DWORD Sectors;              //  57,58
00181 
00182     BYTE MaxSectorsPerInt;      //  59
00183     unsigned MaxSectorsPerIntIsValid:1; //  59
00184     unsigned UnUsed9:7;         //  59
00185 
00186     DWORD LBASectors;           //  60,61
00187 
00188     WORD UnUsed10;              //  62
00189 
00190     BYTE SupportedDMAModes;     //  63
00191     BYTE ActiveDMAModes;        //  63
00192 
00193     BYTE PIOModesSupported;     //  64
00194     BYTE UnUsed11;              //  64
00195 
00196     WORD DMACycleTime;          //  65
00197     WORD RecommendedDMACycleTime;       //  66
00198     WORD PIOCycleTime;          //  67
00199     WORD IORDYPIOCycleTime;     //  68
00200 
00201     WORD Reserved1[2];          //  69 - 70
00202     WORD Reserved2[4];          //  71 - 74
00203 
00204     WORD QueueDepth;            //  75
00205 
00206     WORD Reserved3[4];          //  76 - 79
00207 
00208     WORD ATAVersionMajor;       //  80
00209     WORD ATAVersionMinor;       //  81
00210 
00211     WORD CommandSetSupported[2];        //  82 - 83
00212     WORD CommandSetSupportedExtension;  //  84
00213     WORD CommandSetEnabled[2];  //  85 - 86
00214     WORD CommandSetDefault;     //  87
00215 
00216     WORD UltraDMAMode;          //  88
00217 
00218     WORD SecurityStatus[2];     //  89 - 90
00219 
00220     WORD AdvancedPowerManagement;       //  91
00221     WORD MasterPasswordRevisionCode;    //  92
00222 
00223     WORD HardwareResetResult;   //  93
00224 
00225     WORD AcousticManagementValue;       //  94
00226 
00227     WORD Reserved4[5];          //  95 - 99
00228 
00229     WORD MaximumUserLBA48[4];   //  100 - 103
00230 
00231     WORD Reserved5[23];         //  104 - 126
00232 
00233 } IDEDEVICEINFO;
00234 
00235 /*-------------------------------------------------------------------------*/
00236 /* global macros                                                           */
00237 /*-------------------------------------------------------------------------*/
00238 
00239 /*-------------------------------------------------------------------------*/
00240 /* Prototypes                                                              */
00241 /*-------------------------------------------------------------------------*/
00242 
00243 #endif                          /* !__IDE_H__ */