X-Git-Url: http://git.joshuawise.com/netwatch.git/blobdiff_plain/92bb2596b1eda2324da82825b882df5dce9dfbbb..41506fc5c8cf80c1f1891e1d77f372b9bf5a9ba3:/lib/serial.c?ds=sidebyside diff --git a/lib/serial.c b/lib/serial.c index 5318c95..95d8300 100644 --- a/lib/serial.c +++ b/lib/serial.c @@ -1,3 +1,13 @@ +/* serial.c + * Serial output routines. + * NetWatch system management mode administration console + * + * Copyright (c) 2008 Jacob Potter and Joshua Wise. All rights reserved. + * This program is free software; you can redistribute and/or modify it under + * the terms found in the file LICENSE in the root of this source tree. + * + */ + #include #include @@ -33,10 +43,10 @@ unsigned char _inb(unsigned short port) void serial_init() { unsigned short baud = SER_BAUD_REQ / SER_BAUD_BASE; - _outb(SER_LCR, inb(SER_LCR) | SER_LCR_DLAB); + _outb(SER_LCR, _inb(SER_LCR) | SER_LCR_DLAB); _outb(SER_DLL, baud & 0xFF); _outb(SER_DLM, baud >> 8); - _outb(SER_LCR, inb(SER_LCR) & ~SER_LCR_DLAB); + _outb(SER_LCR, _inb(SER_LCR) & ~SER_LCR_DLAB); _outb(SER_IER, 0x0); _outb(SER_FCR, 0x0); /* FIFOs off */ _outb(SER_LCR, 0x03); /* 8 data bits, one stop bit, no parity */ @@ -44,7 +54,9 @@ void serial_init() void serial_tx(unsigned char c) { - while (!(_inb(SER_LSR) & SER_LSR_THR_EMPTY)) + int i = 100000; + + while (!(_inb(SER_LSR) & SER_LSR_THR_EMPTY) && (i--)) ; _outb(SER_THR, c); }