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

IdeTimer.h

Go to the documentation of this file.
00001 /*!     \file include/kernel/IdeTimer.h
00002  *      \brief IDE driver::Timing header.
00003  *      \author Luca Giovacchini
00004  *      \date Last update: 2003-11-07
00005  *      \note Copyright (©) 2003 Luca Giovacchini
00006  *
00007  *      This driver is based on Atadrv by Hale Landis
00008  *      but it is completely rearranged for the minirighi32.
00009  *      \n
00010  *      <b>IMPORTANT!!!</b>\n
00011  *      Here you can find all subs regarding waiting and timing.
00012  *      Look at the specific sub comment.
00013  */
00014 
00015 #ifndef IDETIMER_H
00016 #define IDETIMER_H
00017 
00018 #include <const.h>
00019 
00020 
00021 // This macro provides a small delay that is used in several
00022 // places in the ATA command protocols:
00023 // 1) It is recommended that the host delay 400ns after
00024 //    writing the command register.
00025 // 2) ATA-4 has added a new requirement that the host delay
00026 //    400ns if the DEV bit in the Device/Head register is
00027 //    changed.  This was not recommended or required in ATA-1,
00028 //    ATA-2 or ATA-3.  This is the easy way to do that since it
00029 //    works in all PIO modes.
00030 // 3) ATA-4 has added another new requirement that the host delay
00031 //    after the last word of a data transfer before checking the
00032 //    status register.  This was not recommended or required in
00033 //    ATA-1, ATA-2 or ATA-3.  This is the easy to do that since it
00034 //    works in all PIO modes.
00035 
00036 // Waste some time by reading the alternate status a few times.
00037 // This gives the drive time to set BUSY in the status register on
00038 // really fast systems.  If we don't do this, a slow drive on a fast
00039 // system may not set BUSY fast enough and we would think it had
00040 // completed the command when it really had not even started the
00041 // command yet.
00042 #define DELAY400NS  { InPortAta( CC_ASTAT ); InPortAta( CC_ASTAT );  \
00043                       InPortAta( CC_ASTAT ); InPortAta( CC_ASTAT ); }
00044 
00045 #define HDC_ATATIMEOUT   31000
00046 #define HDC_ATAPIDELAY     150
00047 
00048 #define MSG_PRESSKEY "Press any key to continue"
00049 
00050 // This struct implement a Timer
00051 // Starting a timer means filling this struct with timer data
00052 // and next we can check when a timer is elapsed
00053 // Timer subs and this struct permit to create a lot of timer
00054 // concurrently
00055 typedef struct Timer_Struct
00056 {
00057         dword Start;
00058         dword Stop;
00059         int Cross;
00060 } Timer_Struct;
00061 
00062 
00063 void GoIdle();
00064 void Delay(dword ms);
00065 Timer_Struct TimerStart(dword ms);
00066 int TimerElapsed(Timer_Struct Timer);
00067 int WaitForInt(Timer_Struct Timer);
00068 int WaitForBsy(Timer_Struct Timer,word Port);
00069 void AtapiDelay(int Dev);
00070 void WaitKeyPress(char * Message);
00071 
00072 #endif

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