Move timer setup from post.c to clock.c.
diff --git a/Makefile b/Makefile
index 5684af7..3d7c3e2 100644
--- 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
diff --git a/src/clock.c b/src/clock.c
index 4d8643f..ad8347c 100644
--- a/src/clock.c
+++ b/src/clock.c
@@ -14,6 +14,37 @@
#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()
{
outb_cmos(0x26, CMOS_STATUS_A);
diff --git a/src/post.c b/src/post.c
index ad60f99..1b9fc5b 100644
--- a/src/post.c
+++ b/src/post.c
@@ -82,35 +82,6 @@
}
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()
{
outb(0x11, PORT_PIC1);
@@ -215,11 +186,10 @@
init_handlers();
init_ebda();
- pit_setup();
+ timer_setup();
kbd_setup();
lpt_setup();
serial_setup();
- timer_setup();
pic_setup();
rom_scan(0xc0000, 0xc7800);
diff --git a/src/util.h b/src/util.h
index ec52eac..e304a0b 100644
--- a/src/util.h
+++ b/src/util.h
@@ -148,6 +148,7 @@
void lpt_setup();
// clock.c
+void timer_setup();
void handle_1583(struct bregs *regs);
// apm.c