Move timer setup from post.c to clock.c.
authorKevin O'Connor <kevin@koconnor.net>
Sun, 13 Apr 2008 21:37:41 +0000 (17:37 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Sun, 13 Apr 2008 21:37:41 +0000 (17:37 -0400)
Makefile
src/clock.c
src/post.c
src/util.h

index 5684af73e6ffc43080b27d03a172bbf9725e7d96..3d7c3e22f54c4f362d1377c23b799b66df4a2f8d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -8,8 +8,8 @@
 OUT=out/
 
 # Source files
-SRCBOTH=output.c util.c floppy.c ata.c kbd.c pci.c boot.c serial.c
-SRC16=$(SRCBOTH) disk.c system.c clock.c mouse.c cdrom.c apm.c pcibios.c
+SRCBOTH=output.c util.c floppy.c ata.c kbd.c pci.c boot.c serial.c clock.c
+SRC16=$(SRCBOTH) disk.c system.c mouse.c cdrom.c apm.c pcibios.c
 SRC32=$(SRCBOTH) post.c rombios32.c post_menu.c
 TABLESRC=font.c cbt.c floppy_dbt.c
 
index 4d8643fe82d59789456487b30418ce767d88a962..ad8347c3eb81c08121de1c05761f38922b23343a 100644 (file)
 #define DEBUGF1(fmt, args...) bprintf(0, fmt , ##args)
 #define DEBUGF(fmt, args...)
 
+static void
+pit_setup()
+{
+    // timer0: binary count, 16bit count, mode 2
+    outb(0x34, PORT_PIT_MODE);
+    // maximum count of 0000H = 18.2Hz
+    outb(0x0, PORT_PIT_COUNTER0);
+    outb(0x0, PORT_PIT_COUNTER0);
+}
+
+static u32
+bcd2bin(u8 val)
+{
+    return (val & 0xf) + ((val >> 4) * 10);
+}
+
+void
+timer_setup()
+{
+    pit_setup();
+
+    u32 seconds = bcd2bin(inb_cmos(CMOS_RTC_SECONDS));
+    u32 ticks = (seconds * 18206507) / 1000000;
+    u32 minutes = bcd2bin(inb_cmos(CMOS_RTC_MINUTES));
+    ticks += (minutes * 10923904) / 10000;
+    u32 hours = bcd2bin(inb_cmos(CMOS_RTC_HOURS));
+    ticks += (hours * 65543427) / 1000;
+    SET_BDA(timer_counter, ticks);
+    SET_BDA(timer_rollover, 0);
+}
+
 static void
 init_rtc()
 {
index ad60f9901d69d59273886fe82709cdb03e2a88e7..1b9fc5bfe1b46f2d51bb232b353d8d809181594e 100644 (file)
@@ -81,35 +81,6 @@ init_ebda()
             , offsetof(struct extended_bios_data_area_s, fdpt[1]));
 }
 
-static void
-pit_setup()
-{
-    // timer0: binary count, 16bit count, mode 2
-    outb(0x34, PORT_PIT_MODE);
-    // maximum count of 0000H = 18.2Hz
-    outb(0x0, PORT_PIT_COUNTER0);
-    outb(0x0, PORT_PIT_COUNTER0);
-}
-
-static u32
-bcd2bin(u8 val)
-{
-    return (val & 0xf) + ((val >> 4) * 10);
-}
-
-static void
-timer_setup()
-{
-    u32 seconds = bcd2bin(inb_cmos(CMOS_RTC_SECONDS));
-    u32 ticks = (seconds * 18206507) / 1000000;
-    u32 minutes = bcd2bin(inb_cmos(CMOS_RTC_MINUTES));
-    ticks += (minutes * 10923904) / 10000;
-    u32 hours = bcd2bin(inb_cmos(CMOS_RTC_HOURS));
-    ticks += (hours * 65543427) / 1000;
-    SET_BDA(timer_counter, ticks);
-    SET_BDA(timer_rollover, 0);
-}
-
 static void
 pic_setup()
 {
@@ -215,11 +186,10 @@ post()
     init_handlers();
     init_ebda();
 
-    pit_setup();
+    timer_setup();
     kbd_setup();
     lpt_setup();
     serial_setup();
-    timer_setup();
     pic_setup();
 
     rom_scan(0xc0000, 0xc7800);
index ec52eac7acc1b5fff1120e157ee0909b5bf427c4..e304a0b83a2213a061e7fcec43000af280785fc1 100644 (file)
@@ -148,6 +148,7 @@ void serial_setup();
 void lpt_setup();
 
 // clock.c
+void timer_setup();
 void handle_1583(struct bregs *regs);
 
 // apm.c