Nut/OS  5.0.5
API Reference
ide.c File Reference
#include <stddef.h>
#include <string.h>
#include <sys/timer.h>
#include <sys/thread.h>
#include <sys/event.h>
#include <sys/atom.h>
#include <sys/heap.h>
#include <dev/irqreg.h>
#include <dev/ide.h>
#include <dev/idep.h>
#include <fs/typedefs.h>
Include dependency graph for ide.c:

Data Structures

struct  _drive

Defines

#define __IDE_C__
#define HIBYTE(_x)   (BYTE)((_x >> 8) & 0x00FF)
#define LOBYTE(_x)   (BYTE)(_x & 0x00FF)
#define IDE_IRQ   INT7
#define IDE_INT_RISING_EDGE   0xC0
#define CF_IRQ   INT6
#define CF_INT_SENS_MASK   0x30
#define CF_INT_FALLING_EDGE   0x20
#define CF_INT_RISING_EDGE   0x30
#define IDE_MAX_SUPPORTED_DEVICE   1
#define CF_AVAILABLE   0
#define CF_NOT_AVAILABLE   1
#define INITTIMEOUT   10000
#define DISKTIMEOUT   10000
#define CONTROLLERTIMEOUT   200
#define ATAPITIMEOUT   5000
#define IDEIn(x)   pIDE[x]
#define IDEOut(x, y)   pIDE[x] = y
#define IDE_SUPPORT_LBA   0x0001
#define IDE_SUPPORT_LBA48   0x0002
#define IDE_SUPPORT_PACKET   0x0004
#define IDE_SUPPORT_INTRQ_PACKET   0x0008
#define IDE_CDROM_DEVICE   0x1000
#define IDE_ZIP_DEVICE   0x2000
#define IDE_READ_ONLY   0x4000
#define IDE_READY   0x8000
#define ATAPI_CFG_12_BYTE_MSK   0x0003
#define ATAPI_CFG_INTRQ   0x0060
#define ATAPI_CFG_REM_MEDIUM   0x0080
#define ATAPI_CFG_DEVICE   0x1F00
#define ATAPI_CFG_ATAPI   0xC000
#define ATAPI_IS_12_BYTE   0x0000
#define ATAPI_USE_INTRQ   0x0020
#define ATAPI_IS_DIRECT_ACCESS   0x0000
#define ATAPI_IS_CDROM   0x0500
#define ATAPI_IS_PACKET   0x8000
#define ATAPI_CMD(_x)
#define CLEAR_ATAPI_CMD()   memset(aATAPICmd, 0x00, sizeof(aATAPICmd));

Typedefs

typedef struct _drive DRIVE
typedef struct _driveLPDRIVE

Functions

void IDELock (void)
void IDEFree (void)
void IDESemaInit (void)
void CFChange (void *arg)
int IDEInit (int nBaseAddress, int nIDEMode, IDE_MOUNT_FUNC *pMountFunc, IDE_MOUNT_FUNC *pUnMountFunc)
int IDEMountDevice (BYTE bDevice, BYTE *pSectorBuffer)
int IDEGetSectorSize (BYTE bDevice)
int IDEIsCDROMDevice (BYTE bDevice)
int IDEIsZIPDevice (BYTE bDevice)
int IDEUnMountDevice (BYTE bDevice)
DWORD IDEGetTotalSectors (BYTE bDevice)
int IDEReadSectors (BYTE bDevice, void *pData, DWORD dwStartSector, WORD wSectorCount)
int IDEATAPISetCDSpeed (BYTE bDevice, WORD wSpeed)

Define Documentation

#define __IDE_C__
#define HIBYTE (   _x)    (BYTE)((_x >> 8) & 0x00FF)
#define LOBYTE (   _x)    (BYTE)(_x & 0x00FF)
#define IDE_IRQ   INT7

Referenced by IDEInit().

#define IDE_INT_RISING_EDGE   0xC0

Referenced by IDEInit().

#define CF_IRQ   INT6

Referenced by CFChange(), and IDEInit().

#define CF_INT_SENS_MASK   0x30

Referenced by CFChange(), and IDEInit().

#define CF_INT_FALLING_EDGE   0x20

Referenced by CFChange(), and IDEInit().

#define CF_INT_RISING_EDGE   0x30

Referenced by CFChange(), and IDEInit().

#define CF_AVAILABLE   0

Referenced by CFChange(), and IDEInit().

#define CF_NOT_AVAILABLE   1

Referenced by CFChange(), and IDEInit().

#define INITTIMEOUT   10000
#define DISKTIMEOUT   10000
#define CONTROLLERTIMEOUT   200
#define ATAPITIMEOUT   5000
#define IDEIn (   x)    pIDE[x]
#define IDEOut (   x,
 
)    pIDE[x] = y
#define IDE_SUPPORT_LBA   0x0001
#define IDE_SUPPORT_LBA48   0x0002
#define IDE_SUPPORT_PACKET   0x0004
#define IDE_SUPPORT_INTRQ_PACKET   0x0008
#define IDE_CDROM_DEVICE   0x1000

Referenced by IDEIsCDROMDevice().

#define IDE_ZIP_DEVICE   0x2000

Referenced by IDEIsZIPDevice().

#define IDE_READ_ONLY   0x4000
#define IDE_READY   0x8000
#define ATAPI_CFG_12_BYTE_MSK   0x0003
#define ATAPI_CFG_INTRQ   0x0060
#define ATAPI_CFG_REM_MEDIUM   0x0080
#define ATAPI_CFG_DEVICE   0x1F00
#define ATAPI_CFG_ATAPI   0xC000
#define ATAPI_IS_12_BYTE   0x0000
#define ATAPI_USE_INTRQ   0x0020
#define ATAPI_IS_DIRECT_ACCESS   0x0000
#define ATAPI_IS_CDROM   0x0500
#define ATAPI_IS_PACKET   0x8000
#define ATAPI_CMD (   _x)
Value:
{                       \
  memset(aATAPICmd, 0x00, sizeof(aATAPICmd)); \
  aATAPICmd[0] = _x;                          \
}

Referenced by IDEATAPISetCDSpeed(), and IDEReadSectors().

#define CLEAR_ATAPI_CMD ( )    memset(aATAPICmd, 0x00, sizeof(aATAPICmd));

Typedef Documentation

typedef struct _drive DRIVE
typedef struct _drive * LPDRIVE

Function Documentation

void IDELock ( void  )

References NutEventWait().

Referenced by IDEGetSectorSize(), IDEGetTotalSectors(), IDEIsCDROMDevice(), IDEIsZIPDevice(), IDEMountDevice(), IDEReadSectors(), and IDEUnMountDevice().

Here is the call graph for this function:

void IDEFree ( void  )

References NutEventPost().

Referenced by IDEGetSectorSize(), IDEGetTotalSectors(), IDEIsCDROMDevice(), IDEIsZIPDevice(), IDEMountDevice(), IDEReadSectors(), and IDEUnMountDevice().

Here is the call graph for this function:

void IDESemaInit ( void  )

References NutEventPost().

Referenced by IDEInit().

Here is the call graph for this function:

void CFChange ( void *  arg)

References BV, CF_AVAILABLE, CF_INT_FALLING_EDGE, CF_INT_RISING_EDGE, CF_INT_SENS_MASK, CF_IRQ, CF_NOT_AVAILABLE, EICR, IDE_DRIVE_C, IDEMountDevice(), IDEUnMountDevice(), NULL, NutEnterCritical, NutEventWaitNext(), NutExitCritical, NutHeapAlloc, NutHeapFree, and NutSleep().

Referenced by IDEInit().

Here is the call graph for this function:

int IDEInit ( int  nBaseAddress,
int  nIDEMode,
IDE_MOUNT_FUNC pMountFunc,
IDE_MOUNT_FUNC pUnMountFunc 
)
int IDEMountDevice ( BYTE  bDevice,
BYTE pSectorBuffer 
)

References ATAPI_SECTOR_SIZE, _drive::dwTotalSectors, IDE_ERROR, IDE_MAX_SUPPORTED_DEVICE, IDE_OK, IDE_READY, IDE_SECTOR_SIZE, IDE_SUPPORT_PACKET, IDEFree(), IDELock(), NULL, _drive::wFlags, and _drive::wSectorSize.

Referenced by CFChange().

Here is the call graph for this function:

int IDEGetSectorSize ( BYTE  bDevice)

References IDE_MAX_SUPPORTED_DEVICE, IDEFree(), IDELock(), and _drive::wSectorSize.

Here is the call graph for this function:

int IDEIsCDROMDevice ( BYTE  bDevice)

References FALSE, IDE_CDROM_DEVICE, IDE_MAX_SUPPORTED_DEVICE, IDE_READY, IDEFree(), IDELock(), TRUE, and _drive::wFlags.

Here is the call graph for this function:

int IDEIsZIPDevice ( BYTE  bDevice)

References FALSE, IDE_MAX_SUPPORTED_DEVICE, IDE_READY, IDE_ZIP_DEVICE, IDEFree(), IDELock(), TRUE, and _drive::wFlags.

Here is the call graph for this function:

int IDEUnMountDevice ( BYTE  bDevice)

References IDE_ERROR, IDE_MAX_SUPPORTED_DEVICE, IDEFree(), IDELock(), NULL, and _drive::wFlags.

Referenced by CFChange().

Here is the call graph for this function:

DWORD IDEGetTotalSectors ( BYTE  bDevice)

References _drive::dwTotalSectors, IDE_MAX_SUPPORTED_DEVICE, IDEFree(), and IDELock().

Here is the call graph for this function:

int IDEReadSectors ( BYTE  bDevice,
void *  pData,
DWORD  dwStartSector,
WORD  wSectorCount 
)

References ATAPI_CMD, ATAPI_CMD_READ12, _drive::dwTotalSectors, IDE_DRIVE_NOT_FOUND, IDE_ERROR, IDE_MAX_SUPPORTED_DEVICE, IDE_OK, IDE_PARAM_ERROR, IDE_READY, IDE_SUPPORT_PACKET, IDEFree(), IDELock(), _drive::wFlags, and _drive::wSectorSize.

Referenced by FATFileRead().

Here is the call graph for this function: