Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

IdeLow.h File Reference

IDE driver::Low level routines header. More...

Go to the source code of this file.

Data Structures

struct  Device_Struct
struct  DeviceInfo_Struct
struct  IdeChannel_Struct

Defines

#define HDC_BASEPRI   0x1F0
#define HDC_BASESEC   0x170
#define HDC_CONTROLGAP   0x200
#define HDC_INTPRI   14
#define HDC_INTSEC   15
#define HDC_DATA   0
#define HDC_ERR   1
#define HDC_SECC   2
#define HDC_SECN   3
#define HDC_CYLL   4
#define HDC_CYLH   5
#define HDC_DEVH   6
#define HDC_STATUS   7
#define HDC_ASTAT   6
#define HDC_ADD   7
#define HDC_DEVH_OBSOLETE   0xa0
#define HDC_DEVH_DEV0   HDC_DEVH_OBSOLETE | 0x00
#define HDC_DEVH_DEV1   HDC_DEVH_OBSOLETE | 0x10
#define HDC_DEVH_LBA   0x40
#define HDC_DEVC_HD15   0x08
#define HDC_DEVC_SRST   0x04
#define HDC_DEVC_NIEN   0x02
#define HDC_STAT_BSY   0x80
#define HDC_STAT_RDY   0x40
#define HDC_STAT_DF   0x20
#define HDC_STAT_WFT   0x20
#define HDC_STAT_SKC   0x10
#define HDC_STAT_SERV   0x10
#define HDC_STAT_DRQ   0x08
#define HDC_STAT_CORR   0x04
#define HDC_STAT_IDX   0x02
#define HDC_STAT_ERR   0x01
#define HDC_STAT_CHK   0x01
#define HDC_CMD_CFA_ERASE_SECTORS   0xC0
#define HDC_CMD_CFA_REQUEST_EXT_ERR_CODE   0x03
#define HDC_CMD_CFA_TRANSLATE_SECTOR   0x87
#define HDC_CMD_CFA_WRITE_MULTIPLE_WO_ERASE   0xCD
#define HDC_CMD_CFA_WRITE_SECTORS_WO_ERASE   0x38
#define HDC_CMD_CHECK_POWER_MODE1   0xE5
#define HDC_CMD_CHECK_POWER_MODE2   0x98
#define HDC_CMD_DEVICE_RESET   0x08
#define HDC_CMD_EXECUTE_DEVICE_DIAGNOSTIC   0x90
#define HDC_CMD_FLUSH_CACHE   0xE7
#define HDC_CMD_FORMAT_TRACK   0x50
#define HDC_CMD_IDENTIFY_DEVICE   0xEC
#define HDC_CMD_IDENTIFY_PACKET_DEVICE   0xA1
#define HDC_CMD_IDLE1   0xE3
#define HDC_CMD_IDLE2   0x97
#define HDC_CMD_IDLE_IMMEDIATE1   0xE1
#define HDC_CMD_IDLE_IMMEDIATE2   0x95
#define HDC_CMD_INITIALIZE_DRIVE_PARAMETERS   0x91
#define HDC_CMD_INITIALIZE_DEVICE_PARAMETERS   0x91
#define HDC_CMD_NOP   0x00
#define HDC_CMD_PACKET   0xA0
#define HDC_CMD_READ_BUFFER   0xE4
#define HDC_CMD_READ_DMA   0xC8
#define HDC_CMD_READ_DMA_QUEUED   0xC7
#define HDC_CMD_READ_MULTIPLE   0xC4
#define HDC_CMD_READ_SECTORS   0x20
#define HDC_CMD_READ_VERIFY_SECTORS   0x40
#define HDC_CMD_RECALIBRATE   0x10
#define HDC_CMD_SEEK   0x70
#define HDC_CMD_SET_FEATURES   0xEF
#define HDC_CMD_SET_MULTIPLE_MODE   0xC6
#define HDC_CMD_SLEEP1   0xE6
#define HDC_CMD_SLEEP2   0x99
#define HDC_CMD_STANDBY1   0xE2
#define HDC_CMD_STANDBY2   0x96
#define HDC_CMD_STANDBY_IMMEDIATE1   0xE0
#define HDC_CMD_STANDBY_IMMEDIATE2   0x94
#define HDC_CMD_WRITE_BUFFER   0xE8
#define HDC_CMD_WRITE_DMA   0xCA
#define HDC_CMD_WRITE_DMA_QUEUED   0xCC
#define HDC_CMD_WRITE_MULTIPLE   0xC5
#define HDC_CMD_WRITE_SECTORS   0x30
#define HDC_CMD_WRITE_VERIFY   0x3C

Typedefs

typedef DeviceInfo_Struct DeviceInfo_Struct
typedef Device_Struct Device_Struct
typedef IdeChannel_Struct IdeChannel_Struct

Functions

void SetAtaRegisterIoPort (word CmdBase, word CntBase, int IntN)
void SelectAtaChannel (int Channel)
word AtaPort (word Port)
void OutPortAta (word Port, byte Val)
byte InPortAta (word Port)
void InPortAtaMul (word Port, word *Buffer, word Count)
void OutPortAtaMul (word Port, word *Buffer, word Count)
void SetDevBit (int Dev)
void SetFirstDevBit ()
void Ide_Handler (word Irq)


Detailed Description

IDE driver::Low level routines header.

Author:
Luca Giovacchini
Date:
Last update: 2003-11-07
Note:
Copyright (©) 2003 Luca Giovacchini
IMPORTANT!!!
Here you can find the base sub for communicating with Ide Devices. First subs expose a simpler interface to the rest of the driver, creating a simpler logical view of registers and most important data. You must not issue commands to device only with these subs, but you must use IdeAta subs (Ata protocol).

Definition in file IdeLow.h.


Define Documentation

#define HDC_ADD   7
 

Definition at line 67 of file IdeLow.h.

#define HDC_ASTAT   6
 

Definition at line 64 of file IdeLow.h.

#define HDC_BASEPRI   0x1F0
 

Definition at line 40 of file IdeLow.h.

#define HDC_BASESEC   0x170
 

Definition at line 41 of file IdeLow.h.

#define HDC_CMD_CFA_ERASE_SECTORS   0xC0
 

Definition at line 107 of file IdeLow.h.

#define HDC_CMD_CFA_REQUEST_EXT_ERR_CODE   0x03
 

Definition at line 108 of file IdeLow.h.

#define HDC_CMD_CFA_TRANSLATE_SECTOR   0x87
 

Definition at line 109 of file IdeLow.h.

#define HDC_CMD_CFA_WRITE_MULTIPLE_WO_ERASE   0xCD
 

Definition at line 110 of file IdeLow.h.

#define HDC_CMD_CFA_WRITE_SECTORS_WO_ERASE   0x38
 

Definition at line 111 of file IdeLow.h.

#define HDC_CMD_CHECK_POWER_MODE1   0xE5
 

Definition at line 112 of file IdeLow.h.

#define HDC_CMD_CHECK_POWER_MODE2   0x98
 

Definition at line 113 of file IdeLow.h.

#define HDC_CMD_DEVICE_RESET   0x08
 

Definition at line 114 of file IdeLow.h.

#define HDC_CMD_EXECUTE_DEVICE_DIAGNOSTIC   0x90
 

Definition at line 115 of file IdeLow.h.

#define HDC_CMD_FLUSH_CACHE   0xE7
 

Definition at line 116 of file IdeLow.h.

#define HDC_CMD_FORMAT_TRACK   0x50
 

Definition at line 117 of file IdeLow.h.

#define HDC_CMD_IDENTIFY_DEVICE   0xEC
 

Definition at line 118 of file IdeLow.h.

#define HDC_CMD_IDENTIFY_PACKET_DEVICE   0xA1
 

Definition at line 119 of file IdeLow.h.

#define HDC_CMD_IDLE1   0xE3
 

Definition at line 120 of file IdeLow.h.

#define HDC_CMD_IDLE2   0x97
 

Definition at line 121 of file IdeLow.h.

#define HDC_CMD_IDLE_IMMEDIATE1   0xE1
 

Definition at line 122 of file IdeLow.h.

#define HDC_CMD_IDLE_IMMEDIATE2   0x95
 

Definition at line 123 of file IdeLow.h.

#define HDC_CMD_INITIALIZE_DEVICE_PARAMETERS   0x91
 

Definition at line 125 of file IdeLow.h.

#define HDC_CMD_INITIALIZE_DRIVE_PARAMETERS   0x91
 

Definition at line 124 of file IdeLow.h.

#define HDC_CMD_NOP   0x00
 

Definition at line 126 of file IdeLow.h.

#define HDC_CMD_PACKET   0xA0
 

Definition at line 127 of file IdeLow.h.

#define HDC_CMD_READ_BUFFER   0xE4
 

Definition at line 128 of file IdeLow.h.

#define HDC_CMD_READ_DMA   0xC8
 

Definition at line 129 of file IdeLow.h.

#define HDC_CMD_READ_DMA_QUEUED   0xC7
 

Definition at line 130 of file IdeLow.h.

#define HDC_CMD_READ_MULTIPLE   0xC4
 

Definition at line 131 of file IdeLow.h.

#define HDC_CMD_READ_SECTORS   0x20
 

Definition at line 132 of file IdeLow.h.

#define HDC_CMD_READ_VERIFY_SECTORS   0x40
 

Definition at line 133 of file IdeLow.h.

#define HDC_CMD_RECALIBRATE   0x10
 

Definition at line 134 of file IdeLow.h.

#define HDC_CMD_SEEK   0x70
 

Definition at line 135 of file IdeLow.h.

#define HDC_CMD_SET_FEATURES   0xEF
 

Definition at line 136 of file IdeLow.h.

#define HDC_CMD_SET_MULTIPLE_MODE   0xC6
 

Definition at line 137 of file IdeLow.h.

#define HDC_CMD_SLEEP1   0xE6
 

Definition at line 138 of file IdeLow.h.

#define HDC_CMD_SLEEP2   0x99
 

Definition at line 139 of file IdeLow.h.

#define HDC_CMD_STANDBY1   0xE2
 

Definition at line 140 of file IdeLow.h.

#define HDC_CMD_STANDBY2   0x96
 

Definition at line 141 of file IdeLow.h.

#define HDC_CMD_STANDBY_IMMEDIATE1   0xE0
 

Definition at line 142 of file IdeLow.h.

#define HDC_CMD_STANDBY_IMMEDIATE2   0x94
 

Definition at line 143 of file IdeLow.h.

#define HDC_CMD_WRITE_BUFFER   0xE8
 

Definition at line 144 of file IdeLow.h.

#define HDC_CMD_WRITE_DMA   0xCA
 

Definition at line 145 of file IdeLow.h.

#define HDC_CMD_WRITE_DMA_QUEUED   0xCC
 

Definition at line 146 of file IdeLow.h.

#define HDC_CMD_WRITE_MULTIPLE   0xC5
 

Definition at line 147 of file IdeLow.h.

#define HDC_CMD_WRITE_SECTORS   0x30
 

Definition at line 148 of file IdeLow.h.

#define HDC_CMD_WRITE_VERIFY   0x3C
 

Definition at line 149 of file IdeLow.h.

#define HDC_CONTROLGAP   0x200
 

Definition at line 42 of file IdeLow.h.

#define HDC_CYLH   5
 

Definition at line 58 of file IdeLow.h.

#define HDC_CYLL   4
 

Definition at line 57 of file IdeLow.h.

#define HDC_DATA   0
 

Definition at line 53 of file IdeLow.h.

#define HDC_DEVC_HD15   0x08
 

Definition at line 82 of file IdeLow.h.

#define HDC_DEVC_NIEN   0x02
 

Definition at line 84 of file IdeLow.h.

#define HDC_DEVC_SRST   0x04
 

Definition at line 83 of file IdeLow.h.

#define HDC_DEVH   6
 

Definition at line 59 of file IdeLow.h.

#define HDC_DEVH_DEV0   HDC_DEVH_OBSOLETE | 0x00
 

Definition at line 75 of file IdeLow.h.

#define HDC_DEVH_DEV1   HDC_DEVH_OBSOLETE | 0x10
 

Definition at line 76 of file IdeLow.h.

#define HDC_DEVH_LBA   0x40
 

Definition at line 77 of file IdeLow.h.

#define HDC_DEVH_OBSOLETE   0xa0
 

Definition at line 73 of file IdeLow.h.

#define HDC_ERR   1
 

Definition at line 54 of file IdeLow.h.

#define HDC_INTPRI   14
 

Definition at line 45 of file IdeLow.h.

#define HDC_INTSEC   15
 

Definition at line 46 of file IdeLow.h.

#define HDC_SECC   2
 

Definition at line 55 of file IdeLow.h.

#define HDC_SECN   3
 

Definition at line 56 of file IdeLow.h.

#define HDC_STAT_BSY   0x80
 

Definition at line 91 of file IdeLow.h.

#define HDC_STAT_CHK   0x01
 

Definition at line 101 of file IdeLow.h.

#define HDC_STAT_CORR   0x04
 

Definition at line 98 of file IdeLow.h.

#define HDC_STAT_DF   0x20
 

Definition at line 93 of file IdeLow.h.

#define HDC_STAT_DRQ   0x08
 

Definition at line 97 of file IdeLow.h.

#define HDC_STAT_ERR   0x01
 

Definition at line 100 of file IdeLow.h.

#define HDC_STAT_IDX   0x02
 

Definition at line 99 of file IdeLow.h.

#define HDC_STAT_RDY   0x40
 

Definition at line 92 of file IdeLow.h.

#define HDC_STAT_SERV   0x10
 

Definition at line 96 of file IdeLow.h.

#define HDC_STAT_SKC   0x10
 

Definition at line 95 of file IdeLow.h.

#define HDC_STAT_WFT   0x20
 

Definition at line 94 of file IdeLow.h.

#define HDC_STATUS   7
 

Definition at line 60 of file IdeLow.h.


Typedef Documentation

typedef struct Device_Struct Device_Struct
 

typedef struct DeviceInfo_Struct DeviceInfo_Struct
 

typedef struct IdeChannel_Struct IdeChannel_Struct
 


Function Documentation

word AtaPort word    Port
 

Definition at line 91 of file IdeLow.c.

00092 {
00093         return CurrentChannel->IoPort[Port];
00094 }

void Ide_Handler word    Irq
 

byte InPortAta word    Port
 

Definition at line 107 of file IdeLow.c.

00108 {
00109         return inportb(AtaPort(Port));
00110 }

void InPortAtaMul word    Port,
word   Buffer,
word    Count
 

Definition at line 115 of file IdeLow.c.

00116 {
00117         // i suppose that user had set Buffer bigger enough!
00118         inportwm(AtaPort(Port),Buffer,Count);
00119 }

void OutPortAta word    Port,
byte    Val
 

Definition at line 99 of file IdeLow.c.

00100 {
00101         outportb(AtaPort(Port),Val);
00102 }

void OutPortAtaMul word    Port,
word   Buffer,
word    Count
 

Definition at line 124 of file IdeLow.c.

00125 {
00126         outportwm(AtaPort(Port),Buffer,Count);
00127 }

void SelectAtaChannel int    Channel
 

Definition at line 75 of file IdeLow.c.

00076 {
00077         // let primary be the default channel   
00078         if ( Channel == CC_SECONDARY )
00079         {
00080                 CurrentChannel=&IdeSecReg;
00081         }
00082         else
00083         {
00084                 CurrentChannel=&IdePriReg;      
00085         }
00086 }

void SetAtaRegisterIoPort word    CmdBase,
word    CntBase,
int    IntN
 

Definition at line 47 of file IdeLow.c.

00048 {
00049         CurrentChannel->CmdBasePort=CmdBase;
00050         CurrentChannel->CntBasePort=CntBase;
00051 
00052         CurrentChannel->IoPort[ CC_DATA  ] = CmdBase + HDC_DATA;
00053         CurrentChannel->IoPort[ CC_ERR   ] = CmdBase + HDC_ERR;
00054         CurrentChannel->IoPort[ CC_SECC  ] = CmdBase + HDC_SECC;
00055         CurrentChannel->IoPort[ CC_SECN  ] = CmdBase + HDC_SECN;
00056         CurrentChannel->IoPort[ CC_CYLL  ] = CmdBase + HDC_CYLL;
00057         CurrentChannel->IoPort[ CC_CYLH  ] = CmdBase + HDC_CYLH;
00058         CurrentChannel->IoPort[ CC_DEVH  ] = CmdBase + HDC_DEVH;
00059         CurrentChannel->IoPort[ CC_STAT  ] = CmdBase + HDC_STATUS;
00060         CurrentChannel->IoPort[ CC_ASTAT ] = CntBase + HDC_ASTAT;
00061         CurrentChannel->IoPort[ CC_ADDR  ] = CntBase + HDC_ADD;
00062         CurrentChannel->Device[ CC_DEV0 ].RegBit = HDC_DEVH_DEV0;
00063         CurrentChannel->Device[ CC_DEV0 ].Type   = CC_DEVTYPE_NONE;
00064         CurrentChannel->Device[ CC_DEV1 ].RegBit = HDC_DEVH_DEV1;
00065         CurrentChannel->Device[ CC_DEV1 ].Type   = CC_DEVTYPE_NONE;
00066 
00067         CurrentChannel->IntDone = FALSE;
00068         CurrentChannel->IntNum = IntN;
00069 }

void SetDevBit int    Dev
 

Definition at line 133 of file IdeLow.c.

00134 {
00135         OutPortAta( CC_DEVH, CurrentChannel->Device[Dev].RegBit);
00136         DELAY400NS;
00137 }

void SetFirstDevBit  
 

Definition at line 143 of file IdeLow.c.

00144 {       
00145         if ( CurrentChannel->Device[CC_DEV0].Type != CC_DEVTYPE_NONE )
00146                 SetDevBit(CC_DEV0);             
00147         else if( CurrentChannel->Device[CC_DEV1].Type != CC_DEVTYPE_NONE ) 
00148                 SetDevBit(CC_DEV1);             
00149 }


Generated on Fri Feb 20 15:32:18 2004 for Minirighi by doxygen1.2.18