Move serial/lpt setup from post.c to serial.c
diff --git a/Makefile b/Makefile
index 5e66ab9..5684af7 100644
--- a/Makefile
+++ b/Makefile
@@ -8,9 +8,8 @@
OUT=out/
# Source files
-SRCBOTH=output.c util.c floppy.c ata.c kbd.c pci.c boot.c
-SRC16=$(SRCBOTH) disk.c system.c clock.c serial.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
+SRC16=$(SRCBOTH) disk.c system.c clock.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/post.c b/src/post.c
index 2671144..ad60f99 100644
--- a/src/post.c
+++ b/src/post.c
@@ -91,61 +91,6 @@
outb(0x0, PORT_PIT_COUNTER0);
}
-static u16
-detect_parport(u16 port, u8 timeout, u8 count)
-{
- // clear input mode
- outb(inb(port+2) & 0xdf, port+2);
-
- outb(0xaa, port);
- if (inb(port) != 0xaa)
- // Not present
- return 0;
- SET_BDA(port_lpt[count], port);
- SET_BDA(lpt_timeout[count], timeout);
- return 1;
-}
-
-static void
-lpt_setup()
-{
- u16 count = 0;
- count += detect_parport(0x378, 0x14, count);
- count += detect_parport(0x278, 0x14, count);
-
- // Equipment word bits 14..15 determing # parallel ports
- u16 eqb = GET_BDA(equipment_list_flags);
- SET_BDA(equipment_list_flags, (eqb & 0x3fff) | (count << 14));
-}
-
-static u16
-detect_serial(u16 port, u8 timeout, u8 count)
-{
- outb(0x02, port+1);
- if (inb(port+1) != 0x02)
- return 0;
- if (inb(port+2) != 0x02)
- return 0;
- outb(0x00, port+1);
- SET_BDA(port_com[count], port);
- SET_BDA(com_timeout[count], timeout);
- return 1;
-}
-
-static void
-serial_setup()
-{
- u16 count = 0;
- count += detect_serial(0x3f8, 0x0a, count);
- count += detect_serial(0x2f8, 0x0a, count);
- count += detect_serial(0x3e8, 0x0a, count);
- count += detect_serial(0x2e8, 0x0a, count);
-
- // Equipment word bits 9..11 determing # serial ports
- u16 eqb = GET_BDA(equipment_list_flags);
- SET_BDA(equipment_list_flags, (eqb & 0xf1ff) | (count << 9));
-}
-
static u32
bcd2bin(u8 val)
{
diff --git a/src/serial.c b/src/serial.c
index c620a0f..8ca7e36 100644
--- a/src/serial.c
+++ b/src/serial.c
@@ -14,6 +14,34 @@
****************************************************************/
static u16
+detect_serial(u16 port, u8 timeout, u8 count)
+{
+ outb(0x02, port+1);
+ if (inb(port+1) != 0x02)
+ return 0;
+ if (inb(port+2) != 0x02)
+ return 0;
+ outb(0x00, port+1);
+ SET_BDA(port_com[count], port);
+ SET_BDA(com_timeout[count], timeout);
+ return 1;
+}
+
+void
+serial_setup()
+{
+ u16 count = 0;
+ count += detect_serial(0x3f8, 0x0a, count);
+ count += detect_serial(0x2f8, 0x0a, count);
+ count += detect_serial(0x3e8, 0x0a, count);
+ count += detect_serial(0x2e8, 0x0a, count);
+
+ // Equipment word bits 9..11 determing # serial ports
+ u16 eqb = GET_BDA(equipment_list_flags);
+ SET_BDA(equipment_list_flags, (eqb & 0xf1ff) | (count << 9));
+}
+
+static u16
getComAddr(struct bregs *regs)
{
if (regs->dx >= 4) {
@@ -135,6 +163,33 @@
****************************************************************/
static u16
+detect_parport(u16 port, u8 timeout, u8 count)
+{
+ // clear input mode
+ outb(inb(port+2) & 0xdf, port+2);
+
+ outb(0xaa, port);
+ if (inb(port) != 0xaa)
+ // Not present
+ return 0;
+ SET_BDA(port_lpt[count], port);
+ SET_BDA(lpt_timeout[count], timeout);
+ return 1;
+}
+
+void
+lpt_setup()
+{
+ u16 count = 0;
+ count += detect_parport(0x378, 0x14, count);
+ count += detect_parport(0x278, 0x14, count);
+
+ // Equipment word bits 14..15 determing # parallel ports
+ u16 eqb = GET_BDA(equipment_list_flags);
+ SET_BDA(equipment_list_flags, (eqb & 0x3fff) | (count << 14));
+}
+
+static u16
getLptAddr(struct bregs *regs)
{
if (regs->dx >= 3) {
diff --git a/src/util.h b/src/util.h
index 7341855..ec52eac 100644
--- a/src/util.h
+++ b/src/util.h
@@ -143,6 +143,10 @@
// kbd.c
void handle_15c2(struct bregs *regs);
+// serial.c
+void serial_setup();
+void lpt_setup();
+
// clock.c
void handle_1583(struct bregs *regs);