(suggestion from Arkady)

if sizeof(struct ClockRecord) != rp->r_count error
move year init below reading the BIOS
remove trailing whitespace


git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@681 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2003-09-09 17:32:20 +00:00
parent 59484b2fc9
commit b4bee283f9

View File

@ -66,32 +66,7 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp)
{ {
case C_INIT: case C_INIT:
#if 0 /* done in initclk.c */
/* If AT clock exists, copy AT clock time to system clock */
if (!ReadATClock(bcd_days, &bcd_hours, &bcd_minutes, &bcd_seconds))
{
ticks_t seconds;
DaysSinceEpoch =
DaysFromYearMonthDay(100 * BcdToByte(bcd_days[3]) +
BcdToByte(bcd_days[2]),
BcdToByte(bcd_days[1]),
BcdToByte(bcd_days[0]));
/*
* This is a rather tricky calculation. The number of timer ticks per
* second is not exactly 18.2, but rather 1193180 / 65536
* where 1193180 = 0x1234dc
* The timer interrupt updates the midnight flag when the tick count
* reaches 0x1800b0 -- ror4.
*/
seconds =
60 * (ticks_t)(60 * BcdToByte(bcd_hours) + BcdToByte(bcd_minutes)) +
BcdToByte(bcd_seconds);
WritePCClock(seconds * 0x12 + ((seconds * 0x34dc) >> 16));
}
#endif
/* rp->r_endaddr = device_end(); not needed - bart */ /* rp->r_endaddr = device_end(); not needed - bart */
rp->r_nunits = 0; rp->r_nunits = 0;
return S_DONE; return S_DONE;
@ -102,7 +77,8 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp)
int tmp; int tmp;
ticks_t ticks; ticks_t ticks;
clk.clkDays = DaysSinceEpoch; if (sizeof(struct ClockRecord) != rp->r_count)
return failure(E_LENGTH);
/* The scaling factor is now /* The scaling factor is now
6553600/1193180 = 327680/59659 = 65536*5/59659 */ 6553600/1193180 = 327680/59659 = 65536*5/59659 */
@ -118,8 +94,9 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp)
clk.clkSeconds = tmp / 100; clk.clkSeconds = tmp / 100;
clk.clkHundredths = tmp % 100; clk.clkHundredths = tmp % 100;
fmemcpy(rp->r_trans, &clk, clk.clkDays = DaysSinceEpoch;
min(sizeof(struct ClockRecord), rp->r_count));
fmemcpy(rp->r_trans, &clk, sizeof(struct ClockRecord));
} }
return S_DONE; return S_DONE;
@ -130,8 +107,10 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp)
struct ClockRecord clk; struct ClockRecord clk;
ticks_t hs, Ticks; ticks_t hs, Ticks;
rp->r_count = min(rp->r_count, sizeof(struct ClockRecord)); if (sizeof(struct ClockRecord) != rp->r_count)
fmemcpy(&clk, rp->r_trans, rp->r_count); return failure(E_LENGTH);
fmemcpy(&clk, rp->r_trans, sizeof(struct ClockRecord));
/* Set PC Clock first */ /* Set PC Clock first */
DaysSinceEpoch = clk.clkDays; DaysSinceEpoch = clk.clkDays;