mirror of
https://github.com/FDOS/kernel.git
synced 2025-07-06 21:44:30 +02:00
(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:
parent
59484b2fc9
commit
b4bee283f9
@ -66,32 +66,7 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp)
|
||||
{
|
||||
case C_INIT:
|
||||
|
||||
#if 0
|
||||
/* 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
|
||||
/* done in initclk.c */
|
||||
/* rp->r_endaddr = device_end(); not needed - bart */
|
||||
rp->r_nunits = 0;
|
||||
return S_DONE;
|
||||
@ -102,7 +77,8 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp)
|
||||
int tmp;
|
||||
ticks_t ticks;
|
||||
|
||||
clk.clkDays = DaysSinceEpoch;
|
||||
if (sizeof(struct ClockRecord) != rp->r_count)
|
||||
return failure(E_LENGTH);
|
||||
|
||||
/* The scaling factor is now
|
||||
6553600/1193180 = 327680/59659 = 65536*5/59659 */
|
||||
@ -118,8 +94,9 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp)
|
||||
clk.clkSeconds = tmp / 100;
|
||||
clk.clkHundredths = tmp % 100;
|
||||
|
||||
fmemcpy(rp->r_trans, &clk,
|
||||
min(sizeof(struct ClockRecord), rp->r_count));
|
||||
clk.clkDays = DaysSinceEpoch;
|
||||
|
||||
fmemcpy(rp->r_trans, &clk, sizeof(struct ClockRecord));
|
||||
}
|
||||
return S_DONE;
|
||||
|
||||
@ -130,8 +107,10 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp)
|
||||
struct ClockRecord clk;
|
||||
ticks_t hs, Ticks;
|
||||
|
||||
rp->r_count = min(rp->r_count, sizeof(struct ClockRecord));
|
||||
fmemcpy(&clk, rp->r_trans, rp->r_count);
|
||||
if (sizeof(struct ClockRecord) != rp->r_count)
|
||||
return failure(E_LENGTH);
|
||||
|
||||
fmemcpy(&clk, rp->r_trans, sizeof(struct ClockRecord));
|
||||
|
||||
/* Set PC Clock first */
|
||||
DaysSinceEpoch = clk.clkDays;
|
||||
|
Loading…
x
Reference in New Issue
Block a user