mirror of
https://github.com/FDOS/kernel.git
synced 2025-07-07 05:54:29 +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
@ -65,33 +65,8 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp)
|
|||||||
switch (rp->r_command)
|
switch (rp->r_command)
|
||||||
{
|
{
|
||||||
case C_INIT:
|
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]));
|
|
||||||
|
|
||||||
/*
|
/* done in initclk.c */
|
||||||
* 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;
|
||||||
@ -101,26 +76,28 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp)
|
|||||||
struct ClockRecord clk;
|
struct ClockRecord clk;
|
||||||
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 */
|
||||||
|
|
||||||
ticks = 5 * ReadPCClock();
|
ticks = 5 * ReadPCClock();
|
||||||
ticks = ((ticks / 59659u) << 16) + ((ticks % 59659u) << 16) / 59659u;
|
ticks = ((ticks / 59659u) << 16) + ((ticks % 59659u) << 16) / 59659u;
|
||||||
|
|
||||||
tmp = (int)(ticks / 6000);
|
tmp = (int)(ticks / 6000);
|
||||||
clk.clkHours = tmp / 60;
|
clk.clkHours = tmp / 60;
|
||||||
clk.clkMinutes = tmp % 60;
|
clk.clkMinutes = tmp % 60;
|
||||||
|
|
||||||
tmp = (int)(ticks % 6000);
|
tmp = (int)(ticks % 6000);
|
||||||
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;
|
||||||
|
|
||||||
case C_OUTPUT:
|
case C_OUTPUT:
|
||||||
@ -129,9 +106,11 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp)
|
|||||||
unsigned Day, Month, Year;
|
unsigned Day, Month, Year;
|
||||||
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;
|
||||||
@ -140,7 +119,7 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp)
|
|||||||
|
|
||||||
/* The scaling factor is now
|
/* The scaling factor is now
|
||||||
1193180/6553600 = 59659/327680 = 59659/65536/5 */
|
1193180/6553600 = 59659/327680 = 59659/65536/5 */
|
||||||
|
|
||||||
Ticks = ((hs >> 16) * 59659u + (((hs & 0xffff) * 59659u) >> 16)) / 5;
|
Ticks = ((hs >> 16) * 59659u + (((hs & 0xffff) * 59659u) >> 16)) / 5;
|
||||||
|
|
||||||
WritePCClock(Ticks);
|
WritePCClock(Ticks);
|
||||||
@ -159,7 +138,7 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp)
|
|||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Day contains the days left and count the number of */
|
/* Day contains the days left and count the number of */
|
||||||
/* days for that year. Use this to index the table. */
|
/* days for that year. Use this to index the table. */
|
||||||
for (Month = 1; Month < 13; ++Month)
|
for (Month = 1; Month < 13; ++Month)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user