mirror of
https://github.com/FDOS/kernel.git
synced 2025-07-28 16:24:08 +02:00
Initclk changes (mainly by Lucho)
git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@682 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
parent
b4bee283f9
commit
8c22873b3e
@ -38,52 +38,26 @@ static char *RcsId =
|
|||||||
/* WARNING - THIS DRIVER IS NON-PORTABLE!!!! */
|
/* WARNING - THIS DRIVER IS NON-PORTABLE!!!! */
|
||||||
/* */
|
/* */
|
||||||
|
|
||||||
STATIC int InitByteToBcd(int x)
|
|
||||||
{
|
|
||||||
return ((x / 10) << 4) | (x % 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC int InitBcdToByte(int x)
|
STATIC int InitBcdToByte(int x)
|
||||||
{
|
{
|
||||||
return ((x >> 4) & 0xf) * 10 + (x & 0xf);
|
return ((x >> 4) & 0xf) * 10 + (x & 0xf);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC void InitDayToBcd(BYTE * x, unsigned mon, unsigned day, unsigned yr)
|
|
||||||
{
|
|
||||||
x[1] = InitByteToBcd(mon);
|
|
||||||
x[0] = InitByteToBcd(day);
|
|
||||||
x[3] = InitByteToBcd(yr / 100);
|
|
||||||
x[2] = InitByteToBcd(yr % 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Init_clk_driver(void)
|
void Init_clk_driver(void)
|
||||||
{
|
{
|
||||||
iregs regsT, regsD, dosregs;
|
static iregs regsT = {0x200}; /* ah=0x02 */
|
||||||
|
static iregs regsD = {0x400, 0, 0x1400, 0x101};
|
||||||
|
/* ah=4, ch=20^ ^cl=0, ^dh=dl=1 (2000/1/1)
|
||||||
|
* (above date will be set on error) */
|
||||||
|
iregs dosregs;
|
||||||
|
|
||||||
regsT.a.b.h = 0x02;
|
init_call_intr(0x1a, ®sT); /* get BIOS time */
|
||||||
regsT.d.x = regsT.c.x = 0;
|
init_call_intr(0x1a, ®sD); /* get BIOS date */
|
||||||
regsT.flags = 0;
|
|
||||||
init_call_intr(0x1a, ®sT);
|
|
||||||
|
|
||||||
if ((regsT.flags & 0x0001) || (regsT.c.x == 0 && regsT.d.x == 0))
|
|
||||||
{
|
|
||||||
goto error; /* error */
|
|
||||||
}
|
|
||||||
|
|
||||||
regsD.a.b.h = 0x04;
|
|
||||||
regsD.d.x = regsD.c.x = 0;
|
|
||||||
regsD.flags = 0;
|
|
||||||
init_call_intr(0x1a, ®sD);
|
|
||||||
|
|
||||||
if ((regsD.flags & 0x0001) || regsD.c.x == 0 || regsD.d.x == 0)
|
|
||||||
{
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* DosSetDate */
|
/* DosSetDate */
|
||||||
dosregs.a.b.h = 0x2b;
|
dosregs.a.b.h = 0x2b;
|
||||||
dosregs.c.x = 100 * InitBcdToByte(regsD.c.b.h) +
|
dosregs.c.x = 100 * InitBcdToByte(regsD.c.b.h) /* century */
|
||||||
InitBcdToByte(regsD.c.b.l);
|
+ InitBcdToByte(regsD.c.b.l);/* year */
|
||||||
dosregs.d.b.h = InitBcdToByte(regsD.d.b.h); /* month */
|
dosregs.d.b.h = InitBcdToByte(regsD.d.b.h); /* month */
|
||||||
dosregs.d.b.l = InitBcdToByte(regsD.d.b.l); /* day */
|
dosregs.d.b.l = InitBcdToByte(regsD.d.b.l); /* day */
|
||||||
init_call_intr(0x21, &dosregs);
|
init_call_intr(0x21, &dosregs);
|
||||||
@ -95,7 +69,4 @@ void Init_clk_driver(void)
|
|||||||
dosregs.d.b.h = InitBcdToByte(regsT.d.b.h); /*seconds */
|
dosregs.d.b.h = InitBcdToByte(regsT.d.b.h); /*seconds */
|
||||||
dosregs.d.b.l = 0;
|
dosregs.d.b.l = 0;
|
||||||
init_call_intr(0x21, &dosregs);
|
init_call_intr(0x21, &dosregs);
|
||||||
|
|
||||||
error:;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user