Some buggy stuff about optimization of PIT

This commit is contained in:
Adrien Bourmault 2019-12-21 12:40:53 +01:00
parent fcf6e745a7
commit b21f82cbdb
3 changed files with 25 additions and 11 deletions

View File

@ -61,9 +61,9 @@ char *KeFormatCurTime(void);
void KeSetCurTime(Time_t); void KeSetCurTime(Time_t);
void KeEnablePIT(void); void KeEnablePIT(void);
void KeSleep(uint); void KeSleep(uint volatile);
Timer_t *KeSetTimer(uint delay); Timer_t *KeSetTimer(uint volatile delay);
int KeGetTimer(Timer_t*); int KeGetTimer(Timer_t volatile *);
//----------------------------------------------------------------------------// //----------------------------------------------------------------------------//

View File

@ -29,10 +29,10 @@
#define COUNTDONE 1 #define COUNTDONE 1
#define PIT_FREQUENCY 1000 // Hz = 1ms #define PIT_FREQUENCY 1000 // Hz = 1ms
static Timer_t Timer[20]; //20 concurrent sleep max static Timer_t volatile Timer[20]; //20 concurrent sleep max
static ulong Ticks = 0; static ulong volatile Ticks = 0;
static Time_t CurTime; static Time_t volatile CurTime;
static char TimeFmtBuf[22] = { 0 }; static char volatile TimeFmtBuf[22] = { 0 };
// //
// ISR handler for the Programmable Interval Timer // ISR handler for the Programmable Interval Timer
@ -78,11 +78,11 @@ void KeSleep(uint delay)
timerBlock->sema = 0; timerBlock->sema = 0;
} }
Timer_t *KeSetTimer(uint delay) Timer_t *KeSetTimer(uint volatile delay)
{ {
Timer_t *timerBlock; Timer_t volatile *timerBlock;
if ((timerBlock = (Timer_t*)KeFindTimerBlock()) == NULL) if ((timerBlock = (Timer_t volatile*)KeFindTimerBlock()) == NULL)
return NULL; return NULL;
timerBlock->countDown = delay * PIT_FREQUENCY / 1000; timerBlock->countDown = delay * PIT_FREQUENCY / 1000;
@ -90,7 +90,7 @@ Timer_t *KeSetTimer(uint delay)
return timerBlock; return timerBlock;
} }
int KeGetTimer(Timer_t *timerBlock) int KeGetTimer(Timer_t volatile *timerBlock)
{ {
if (!(timerBlock->sema)) { if (!(timerBlock->sema)) {
return 0; return 0;

View File

@ -55,6 +55,19 @@ error_t CmdArgs(int argc, char **argv, char *cmdline)
return EOK; return EOK;
} }
error_t CmdAtoi(int argc, char **argv, char *cmdline)
{
int i;
KernLog("cmdline: '%s'\nargc: %d\n", cmdline, argc);
for (i = 0; i < argc; i++) {
KernLog("argv[%d]: '%u'\n", i, atoi(argv[i]));
}
return EOK;
}
error_t CmdDumpATASect(int argc, char **argv, char *cmdline) error_t CmdDumpATASect(int argc, char **argv, char *cmdline)
{ {
char sector[512] = {0}; char sector[512] = {0};
@ -199,6 +212,7 @@ error_t CmdTimerTest(int argc, char **argv, char *cmdline)
static Command_t testcmdtable[] = static Command_t testcmdtable[] =
{ {
{ "args", CmdArgs, "Print command line" }, { "args", CmdArgs, "Print command line" },
{ "atoi", CmdAtoi, "Print command line atoised" },
{ "dmpsec", CmdDumpATASect, "Dump an ATA sector on screen" }, { "dmpsec", CmdDumpATASect, "Dump an ATA sector on screen" },
{ "help", CmdHelpTest, "Show this message" }, { "help", CmdHelpTest, "Show this message" },
{ "div", CmdFloatDiv, "Float div. Usage : div a b. Returns a/b"}, { "div", CmdFloatDiv, "Float div. Usage : div a b. Returns a/b"},