diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2008-04-13 17:31:45 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2008-04-13 17:31:45 -0400 |
commit | 913cc2e089536edc3b0c2199d5b1f38545c50b1b (patch) | |
tree | c15bfc51c2ef94159e1691f48e1064c8587f19de /src/serial.c | |
parent | 9f0d94dee364ed9a9913e8fa7c0897a85014dc5c (diff) | |
download | seabios-hppa-913cc2e089536edc3b0c2199d5b1f38545c50b1b.zip seabios-hppa-913cc2e089536edc3b0c2199d5b1f38545c50b1b.tar.gz seabios-hppa-913cc2e089536edc3b0c2199d5b1f38545c50b1b.tar.bz2 |
Move serial/lpt setup from post.c to serial.c
Diffstat (limited to 'src/serial.c')
-rw-r--r-- | src/serial.c | 55 |
1 files changed, 55 insertions, 0 deletions
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 @@ handle_14(struct bregs *regs) ****************************************************************/ 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) { |