diff --git a/kernel/initclk.c b/kernel/initclk.c index b895e74..0780843 100644 --- a/kernel/initclk.c +++ b/kernel/initclk.c @@ -38,52 +38,26 @@ static char *RcsId = /* WARNING - THIS DRIVER IS NON-PORTABLE!!!! */ /* */ -STATIC int InitByteToBcd(int x) -{ - return ((x / 10) << 4) | (x % 10); -} - STATIC int InitBcdToByte(int x) { 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) { - 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; - regsT.d.x = regsT.c.x = 0; - 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; - } + init_call_intr(0x1a, ®sT); /* get BIOS time */ + init_call_intr(0x1a, ®sD); /* get BIOS date */ /* DosSetDate */ dosregs.a.b.h = 0x2b; - dosregs.c.x = 100 * InitBcdToByte(regsD.c.b.h) + - InitBcdToByte(regsD.c.b.l); + dosregs.c.x = 100 * InitBcdToByte(regsD.c.b.h) /* century */ + + InitBcdToByte(regsD.c.b.l);/* year */ dosregs.d.b.h = InitBcdToByte(regsD.d.b.h); /* month */ dosregs.d.b.l = InitBcdToByte(regsD.d.b.l); /* day */ 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.l = 0; init_call_intr(0x21, &dosregs); - -error:; - }