idep.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. /****************************************************************************
  2. * This file is part of the AVRIDE device driver.
  3. *
  4. * Copyright (c) 2002-2003 by Michael Fischer. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the author nor the names of its contributors may
  16. * be used to endorse or promote products derived from this software
  17. * without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
  23. * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. ****************************************************************************
  33. * History:
  34. *
  35. * 14.12.02 mifi First Version
  36. * 18.01.03 mifi Change Licence from GPL to BSD.
  37. * 19.06.03 mifi Change address for ide port from 0x8000 to 0xE000
  38. * 29.06.03 mifi First ATAPI-Version
  39. ****************************************************************************/
  40. #ifndef __IDEP_H__
  41. #define __IDEP_H__
  42. #include <dev/ide.h>
  43. #include <fs/typedefs.h>
  44. /*-------------------------------------------------------------------------*/
  45. /* global defines */
  46. /*-------------------------------------------------------------------------*/
  47. //
  48. // If the driver should support the old
  49. // CHS drives, set IDE_SUPPORT_CHS to 1
  50. //
  51. #define IDE_SUPPORT_CHS 0
  52. #define IDE_BASE_ADDRESS 0xE000
  53. #define IDECS0 0x0000
  54. #define IDECS1 0x0500
  55. #define DATA_WRITE_REG_LOW (IDECS0 + 0x0100)
  56. #define DATA_WRITE_REG_HIGH (IDECS0 + 0x0200)
  57. #define DATA_READ_REG_LOW (IDECS0 + 0x0300)
  58. #define DATA_READ_REG_HIGH (IDECS0 + 0x0400)
  59. #define ERROR_REG (IDECS0 + 1)
  60. #define FEATURE_REG (IDECS0 + 1)
  61. #define SECTOR_COUNT_REG (IDECS0 + 2)
  62. #define SECTOR_REG (IDECS0 + 3)
  63. #define CYLINDER_LOW_REG (IDECS0 + 4)
  64. #define CYLINDER_HIGH_REG (IDECS0 + 5)
  65. #define DISK_HEAD_REG (IDECS0 + 6)
  66. #define COMMAND_REG (IDECS0 + 7)
  67. #define STATUS_REG (IDECS0 + 7)
  68. #define LBA_0_7 (IDECS0 + 3)
  69. #define LBA_8_15 (IDECS0 + 4)
  70. #define LBA_16_23 (IDECS0 + 5)
  71. #define CF_ERROR_REG (IDECS1 + 0)
  72. #define CONTROL_REG (IDECS1 + 6)
  73. #define ALTERNATE_STATUS (IDECS1 + 6)
  74. #define STATUS_BUSY 0x80
  75. #define STATUS_DRIVE_READY 0x40
  76. #define STATUS_DEVIDE_FAULT 0x20
  77. #define STATUS_SEEK_COMPLETE 0x10
  78. #define STATUS_DATA_REQUEST 0x08
  79. #define STATUS_CORRECTED_DATA 0x04
  80. #define STATUS_INDEX 0x02
  81. #define STATUS_ERROR 0x01
  82. #define ERROR_CRC 0x80
  83. #define ERROR_UNC 0x40
  84. #define ERROR_IDN 0x10
  85. #define ERROR_ABT 0x04
  86. #define ERROR_T0N 0x02
  87. #define ERROR_AMN 0x01
  88. #define COMMAND_DEVICE_INFO 0xEC
  89. #define COMMAND_DEVICE_INFO_P 0xA1
  90. #define COMMAND_READ_SECTORS 0x20
  91. #define COMMAND_WRITE_SECTORS 0x30
  92. #define COMMAND_RECALIBRATE 0x10
  93. #define COMMAND_DIAG 0x90
  94. #define SERIAL_SIZE 20
  95. #define REV_SIZE 8
  96. #define MODEL_SIZE 40
  97. //
  98. // ATAPI stuff
  99. //
  100. #define ATAPI_CMD_READ_CAPACITY 0x25
  101. #define ATAPI_CMD_MODE_SELECT 0x55
  102. #define ATAPI_CMD_MODE_SENSE 0x5A
  103. #define ATAPI_CMD_READ12 0xA8
  104. #define ATAPI_CMD_SET_CD_SPEED 0xBB
  105. /*-------------------------------------------------------------------------*/
  106. /* global types */
  107. /*-------------------------------------------------------------------------*/
  108. typedef struct {
  109. unsigned UnUsed0:1; // 0
  110. unsigned HardSector_O:1; // 0
  111. unsigned SoftSector_O:1; // 0
  112. unsigned MFM_O:1; // 0
  113. unsigned SlowHead_O:1; // 0
  114. unsigned SynchDriveMotor_O:1; // 0
  115. unsigned FixedDevice:1; // 0
  116. unsigned RemoveableDevice:1; // 0
  117. unsigned DiskTransferRate_O:3; // 0
  118. unsigned InaccurateSpeed_O:1; // 0
  119. unsigned DataStrobeOffset_O:1; // 0
  120. unsigned TrackOffsetOption_O:1; // 0
  121. unsigned FormatGapRequired_O:1; // 0
  122. unsigned ATAPI:1; // 0
  123. WORD Cylinders; // 1
  124. WORD UnUsed1; // 2
  125. WORD Heads; // 3
  126. WORD BytesPerTrack_O; // 4
  127. WORD BytesPerSector_O; // 5
  128. WORD SectorsPerTrack; // 6
  129. WORD VendorSpecific[3]; // 7 - 9
  130. char SerialNumber[SERIAL_SIZE]; // 10 - 19
  131. WORD BufferType_O; // 20
  132. WORD BufferSizeSectors_O; // 21
  133. WORD ECCBytes; // 22
  134. char FirmwareRevision[REV_SIZE]; // 23 - 26
  135. char Model[MODEL_SIZE]; // 27 - 46
  136. BYTE MaxMultipleSectors; // 47
  137. BYTE UnUsed2; // 47
  138. WORD Can32Bit_O; // 48
  139. unsigned CanDMA_O:1; // 49
  140. unsigned UnUsed3:9; // 49
  141. unsigned CanDisableIORDY:1; // 49
  142. unsigned IORDYSupported:1; // 49
  143. unsigned AdvancedTransferMode:1; // 49
  144. unsigned ATA3StandbyTimer:1; // 49
  145. unsigned UnUsed4:2;
  146. WORD UnUsed5; // 50
  147. BYTE UnUsed6; // 51
  148. BYTE PIOTransferSpeed; // 51
  149. BYTE UnUsed7; // 52
  150. BYTE DMATransferSpeed; // 52
  151. unsigned Fields_6C_75_Valid:1; // 53
  152. unsigned Fields_80_8C_Valid:1; // 53
  153. unsigned UnUsed8:14; // 53
  154. WORD Cylinders2; // 54
  155. WORD Heads2; // 55
  156. WORD SectorsPerTrack2; // 56
  157. DWORD Sectors; // 57,58
  158. BYTE MaxSectorsPerInt; // 59
  159. unsigned MaxSectorsPerIntIsValid:1; // 59
  160. unsigned UnUsed9:7; // 59
  161. DWORD LBASectors; // 60,61
  162. WORD UnUsed10; // 62
  163. BYTE SupportedDMAModes; // 63
  164. BYTE ActiveDMAModes; // 63
  165. BYTE PIOModesSupported; // 64
  166. BYTE UnUsed11; // 64
  167. WORD DMACycleTime; // 65
  168. WORD RecommendedDMACycleTime; // 66
  169. WORD PIOCycleTime; // 67
  170. WORD IORDYPIOCycleTime; // 68
  171. WORD Reserved1[2]; // 69 - 70
  172. WORD Reserved2[4]; // 71 - 74
  173. WORD QueueDepth; // 75
  174. WORD Reserved3[4]; // 76 - 79
  175. WORD ATAVersionMajor; // 80
  176. WORD ATAVersionMinor; // 81
  177. WORD CommandSetSupported[2]; // 82 - 83
  178. WORD CommandSetSupportedExtension; // 84
  179. WORD CommandSetEnabled[2]; // 85 - 86
  180. WORD CommandSetDefault; // 87
  181. WORD UltraDMAMode; // 88
  182. WORD SecurityStatus[2]; // 89 - 90
  183. WORD AdvancedPowerManagement; // 91
  184. WORD MasterPasswordRevisionCode; // 92
  185. WORD HardwareResetResult; // 93
  186. WORD AcousticManagementValue; // 94
  187. WORD Reserved4[5]; // 95 - 99
  188. WORD MaximumUserLBA48[4]; // 100 - 103
  189. WORD Reserved5[23]; // 104 - 126
  190. } IDEDEVICEINFO;
  191. /*-------------------------------------------------------------------------*/
  192. /* global macros */
  193. /*-------------------------------------------------------------------------*/
  194. /*-------------------------------------------------------------------------*/
  195. /* Prototypes */
  196. /*-------------------------------------------------------------------------*/
  197. #endif /* !__IDE_H__ */