ide.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. * 25.01.03 mifi Change IDEInit.
  38. * 29.01.03 mifi Remove IDE_MAX_SUPPORTED_DEVICE, support 2 drives now.
  39. * 29.06.03 mifi First ATAPI-Version
  40. ****************************************************************************/
  41. #ifndef __IDE_H__
  42. #define __IDE_H__
  43. #include <fs/typedefs.h>
  44. /*-------------------------------------------------------------------------*/
  45. /* global defines */
  46. /*-------------------------------------------------------------------------*/
  47. //
  48. // Here we can switch on/off some
  49. // feature of the software
  50. //
  51. #define IDE_SUPPORT_WRITE 0
  52. #define IDE_SUPPORT_ATAPI 1
  53. #define ATAPI_START_SEARCH_SECTOR 16
  54. #define ATAPI_MAX_SEARCH_SECTOR 100
  55. #define IDE_OK 0x00
  56. #define IDE_ERROR 0x01
  57. #define IDE_DRIVE_NOT_FOUND 0x02
  58. #define IDE_PARAM_ERROR 0x03
  59. #define IDE_BUSY 0x04
  60. #define IDE_NOT_SUPPORTED 0x08
  61. #define IDE_DRIVE_C 0
  62. #define IDE_DRIVE_D 1
  63. //
  64. // IDE type for IDEInit
  65. //
  66. #define IDE_HARDDISK 0
  67. #define IDE_HARDDISK_7MHZ 1
  68. #define IDE_COMPACT_FLASH 2
  69. #define MEM_8BIT_COMPACT_FLASH 3
  70. //
  71. // Sector size for HD/CF-Card and CDROM
  72. //
  73. #define IDE_SECTOR_SIZE 512
  74. #define ATAPI_SECTOR_SIZE 2048
  75. #define MAX_SECTOR_SIZE 2048
  76. /*-------------------------------------------------------------------------*/
  77. /* global types */
  78. /*-------------------------------------------------------------------------*/
  79. typedef void IDE_MOUNT_FUNC(int nDevice);
  80. /*-------------------------------------------------------------------------*/
  81. /* global macros */
  82. /*-------------------------------------------------------------------------*/
  83. /*-------------------------------------------------------------------------*/
  84. /* Prototypes */
  85. /*-------------------------------------------------------------------------*/
  86. int IDEInit(int nBaseAddress, int nIDEMode, IDE_MOUNT_FUNC * pMountFunc, IDE_MOUNT_FUNC * pUnMountFunc);
  87. int IDEMountDevice(BYTE bDevice, BYTE * pSectorBuffer);
  88. int IDEGetSectorSize(BYTE bDevice);
  89. int IDEIsCDROMDevice(BYTE bDevice);
  90. int IDEIsZIPDevice(BYTE bDevice);
  91. int IDEUnMountDevice(BYTE bDevice);
  92. DWORD IDEGetTotalSectors(BYTE bDevice);
  93. int IDEReadSectors(BYTE bDevice, void *pData, DWORD dwStartSector, WORD wSectorCount);
  94. #if (IDE_SUPPORT_WRITE == 1)
  95. int IDEWriteSectors(BYTE bDevice, void *pData, DWORD dwStartSector, WORD wSectorCount);
  96. #endif
  97. #if (IDE_SUPPORT_ATAPI == 1)
  98. int IDEATAPISetCDSpeed(BYTE bDevice, WORD wSpeed);
  99. #endif
  100. #endif /* !__IDE_H__ */