Nut/OS  4.10.3
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:

Go to the source code of this file.

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__

Definition at line 57 of file ide.c.

#define HIBYTE (   _x)    (BYTE)((_x >> 8) & 0x00FF)

Definition at line 73 of file ide.c.

#define LOBYTE (   _x)    (BYTE)(_x & 0x00FF)

Definition at line 74 of file ide.c.

#define IDE_IRQ   INT7

Definition at line 83 of file ide.c.

Referenced by IDEInit().

#define IDE_INT_RISING_EDGE   0xC0

Definition at line 84 of file ide.c.

Referenced by IDEInit().

#define CF_IRQ   INT6

Definition at line 86 of file ide.c.

Referenced by CFChange(), and IDEInit().

#define CF_INT_SENS_MASK   0x30

Definition at line 87 of file ide.c.

Referenced by CFChange(), and IDEInit().

#define CF_INT_FALLING_EDGE   0x20

Definition at line 88 of file ide.c.

Referenced by CFChange(), and IDEInit().

#define CF_INT_RISING_EDGE   0x30

Definition at line 89 of file ide.c.

Referenced by CFChange(), and IDEInit().

#define IDE_MAX_SUPPORTED_DEVICE   1
#define CF_AVAILABLE   0

Definition at line 94 of file ide.c.

Referenced by CFChange(), and IDEInit().

#define CF_NOT_AVAILABLE   1

Definition at line 95 of file ide.c.

Referenced by CFChange(), and IDEInit().

#define INITTIMEOUT   10000

Definition at line 97 of file ide.c.

#define DISKTIMEOUT   10000

Definition at line 98 of file ide.c.

#define CONTROLLERTIMEOUT   200

Definition at line 99 of file ide.c.

#define ATAPITIMEOUT   5000

Definition at line 100 of file ide.c.

#define IDEIn (   x)    pIDE[x]

Definition at line 102 of file ide.c.

#define IDEOut (   x,
 
)    pIDE[x] = y

Definition at line 103 of file ide.c.

#define IDE_SUPPORT_LBA   0x0001

Definition at line 108 of file ide.c.

#define IDE_SUPPORT_LBA48   0x0002

Definition at line 109 of file ide.c.

#define IDE_SUPPORT_PACKET   0x0004

Definition at line 110 of file ide.c.

Referenced by IDEATAPISetCDSpeed(), IDEMountDevice(), and IDEReadSectors().

#define IDE_SUPPORT_INTRQ_PACKET   0x0008

Definition at line 115 of file ide.c.

#define IDE_CDROM_DEVICE   0x1000

Definition at line 117 of file ide.c.

Referenced by IDEIsCDROMDevice().

#define IDE_ZIP_DEVICE   0x2000

Definition at line 118 of file ide.c.

Referenced by IDEIsZIPDevice().

#define IDE_READ_ONLY   0x4000

Definition at line 120 of file ide.c.

#define IDE_READY   0x8000
#define ATAPI_CFG_12_BYTE_MSK   0x0003

Definition at line 127 of file ide.c.

#define ATAPI_CFG_INTRQ   0x0060

Definition at line 128 of file ide.c.

#define ATAPI_CFG_REM_MEDIUM   0x0080

Definition at line 129 of file ide.c.

#define ATAPI_CFG_DEVICE   0x1F00

Definition at line 130 of file ide.c.

#define ATAPI_CFG_ATAPI   0xC000

Definition at line 131 of file ide.c.

#define ATAPI_IS_12_BYTE   0x0000

Definition at line 133 of file ide.c.

#define ATAPI_USE_INTRQ   0x0020

Definition at line 134 of file ide.c.

#define ATAPI_IS_DIRECT_ACCESS   0x0000

Definition at line 135 of file ide.c.

#define ATAPI_IS_CDROM   0x0500

Definition at line 136 of file ide.c.

#define ATAPI_IS_PACKET   0x8000

Definition at line 137 of file ide.c.

#define ATAPI_CMD (   _x)
Value:
{                       \
  memset(aATAPICmd, 0x00, sizeof(aATAPICmd)); \
  aATAPICmd[0] = _x;                          \
}

Definition at line 192 of file ide.c.

Referenced by IDEATAPISetCDSpeed(), and IDEReadSectors().

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

Definition at line 197 of file ide.c.


Typedef Documentation

typedef struct _drive DRIVE
typedef struct _drive * LPDRIVE

Function Documentation

void IDELock ( void  )

Definition at line 227 of file ide.c.

References NutEventWait().

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

Here is the call graph for this function:

void IDEFree ( void  )

Definition at line 235 of file ide.c.

References NutEventPost().

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

Here is the call graph for this function:

void IDESemaInit ( void  )

Definition at line 243 of file ide.c.

References NutEventPost().

Referenced by IDEInit().

Here is the call graph for this function:

void CFChange ( void *  arg)
int IDEMountDevice ( BYTE  bDevice,
BYTE pSectorBuffer 
)

Definition at line 1325 of file ide.c.

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

Referenced by CFChange().

Here is the call graph for this function:

int IDEGetSectorSize ( BYTE  bDevice)

Definition at line 1391 of file ide.c.

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

Here is the call graph for this function:

int IDEIsCDROMDevice ( BYTE  bDevice)

Definition at line 1415 of file ide.c.

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)

Definition at line 1441 of file ide.c.

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)

Definition at line 1467 of file ide.c.

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

Referenced by CFChange().

Here is the call graph for this function:

DWORD IDEGetTotalSectors ( BYTE  bDevice)

Definition at line 1492 of file ide.c.

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 
)
int IDEATAPISetCDSpeed ( BYTE  bDevice,
WORD  wSpeed 
)