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

IdeLow.c File Reference

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

#include <string.h>
#include <arch/i386.h>
#include <arch/interrupt.h>
#include <arch/mem.h>
#include <kernel/clock.h>
#include <kernel/Ide.h>
#include <kernel/IdeAta.h>
#include <kernel/IdeDebug.h>
#include <kernel/IdeTimer.h>
#include <kernel/keyboard.h>
#include <kernel/video.h>
#include <kernel/IdeLow.h>

Go to the source code of this file.

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_Pri ()
void Ide_Handler_Sec ()

Variables

volatile IdeChannel_StructCurrentChannel
IdeChannel_Struct IdePriReg
IdeChannel_Struct IdeSecReg


Detailed Description

IDE driver::Low level routines.

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.c.


Function Documentation

word AtaPort word    Port
 

Definition at line 91 of file IdeLow.c.

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

void Ide_Handler_Pri  
 

Definition at line 157 of file IdeLow.c.

00158 {
00159         IdePriReg.IntDone = TRUE;
00160 }

void Ide_Handler_Sec  
 

Definition at line 162 of file IdeLow.c.

00163 {
00164         IdeSecReg.IntDone = TRUE;
00165 }

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 }


Variable Documentation

volatile IdeChannel_Struct* CurrentChannel
 

Definition at line 35 of file IdeLow.c.

IdeChannel_Struct IdePriReg [static]
 

Definition at line 38 of file IdeLow.c.

IdeChannel_Struct IdeSecReg [static]
 

Definition at line 40 of file IdeLow.c.


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