Nut/OS  4.10.3
API Reference
ide.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 *  25.01.03  mifi   Change IDEInit. 
00038 *  29.01.03  mifi   Remove IDE_MAX_SUPPORTED_DEVICE, support 2 drives now.
00039 *  29.06.03  mifi   First ATAPI-Version
00040 ****************************************************************************/
00041 #ifndef __IDE_H__
00042 #define __IDE_H__
00043 
00044 #include <fs/typedefs.h>
00045 
00046 /*-------------------------------------------------------------------------*/
00047 /* global defines                                                          */
00048 /*-------------------------------------------------------------------------*/
00049 //
00050 // Here we can switch on/off some
00051 // feature of the software
00052 //
00053 #define IDE_SUPPORT_WRITE               0
00054 #define IDE_SUPPORT_ATAPI               1
00055 
00056 #define ATAPI_START_SEARCH_SECTOR       16
00057 #define ATAPI_MAX_SEARCH_SECTOR         100
00058 
00059 #define IDE_OK                          0x00
00060 #define IDE_ERROR                       0x01
00061 #define IDE_DRIVE_NOT_FOUND             0x02
00062 #define IDE_PARAM_ERROR                 0x03
00063 #define IDE_BUSY                        0x04
00064 #define IDE_NOT_SUPPORTED               0x08
00065 
00066 #define IDE_DRIVE_C                     0
00067 #define IDE_DRIVE_D                     1
00068 
00069 //
00070 // IDE type for IDEInit
00071 //
00072 #define IDE_HARDDISK                    0
00073 #define IDE_HARDDISK_7MHZ               1
00074 #define IDE_COMPACT_FLASH               2
00075 #define MEM_8BIT_COMPACT_FLASH          3
00076 
00077 //
00078 // Sector size for HD/CF-Card and CDROM
00079 //
00080 #define IDE_SECTOR_SIZE                 512
00081 #define ATAPI_SECTOR_SIZE               2048
00082 #define MAX_SECTOR_SIZE                 2048
00083 
00084 /*-------------------------------------------------------------------------*/
00085 /* global types                                                            */
00086 /*-------------------------------------------------------------------------*/
00087 typedef void IDE_MOUNT_FUNC(int nDevice);
00088 
00089 /*-------------------------------------------------------------------------*/
00090 /* global macros                                                           */
00091 /*-------------------------------------------------------------------------*/
00092 
00093 /*-------------------------------------------------------------------------*/
00094 /* Prototypes                                                              */
00095 /*-------------------------------------------------------------------------*/
00096 int IDEInit(int nBaseAddress, int nIDEMode, IDE_MOUNT_FUNC * pMountFunc, IDE_MOUNT_FUNC * pUnMountFunc);
00097 
00098 int IDEMountDevice(BYTE bDevice, BYTE * pSectorBuffer);
00099 
00100 int IDEGetSectorSize(BYTE bDevice);
00101 
00102 int IDEIsCDROMDevice(BYTE bDevice);
00103 
00104 int IDEIsZIPDevice(BYTE bDevice);
00105 
00106 int IDEUnMountDevice(BYTE bDevice);
00107 
00108 DWORD IDEGetTotalSectors(BYTE bDevice);
00109 
00110 int IDEReadSectors(BYTE bDevice, void *pData, DWORD dwStartSector, WORD wSectorCount);
00111 
00112 #if (IDE_SUPPORT_WRITE == 1)
00113 
00114 int IDEWriteSectors(BYTE bDevice, void *pData, DWORD dwStartSector, WORD wSectorCount);
00115 
00116 #endif
00117 
00118 #if (IDE_SUPPORT_ATAPI == 1)
00119 
00120 int IDEATAPISetCDSpeed(BYTE bDevice, WORD wSpeed);
00121 
00122 #endif
00123 
00124 #endif                          /* !__IDE_H__ */