2  * Serial output routines.
 
   3  * NetWatch system management mode administration console
 
   5  * Copyright (c) 2008 Jacob Potter and Joshua Wise.  All rights reserved.
 
   6  * This program is free software; you can redistribute and/or modify it under
 
   7  * the terms found in the file LICENSE in the root of this source tree.
 
  14 #define SER_BASE 0x3F8
 
  23 #define SER_LCR_DLAB 0x80
 
  26 #define SER_LSR_THR_EMPTY 0x20
 
  30 #define SER_BAUD_BASE 115200
 
  31 #define SER_BAUD_REQ 115200
 
  33 void _outb(unsigned short port, unsigned char d)
 
  35         outb(SER_BASE + port, d);
 
  38 unsigned char _inb(unsigned short port)
 
  40         return inb(SER_BASE + port);
 
  45         unsigned short baud = SER_BAUD_REQ / SER_BAUD_BASE;
 
  46         _outb(SER_LCR, _inb(SER_LCR) | SER_LCR_DLAB);
 
  47         _outb(SER_DLL, baud & 0xFF);
 
  48         _outb(SER_DLM, baud >> 8);
 
  49         _outb(SER_LCR, _inb(SER_LCR) & ~SER_LCR_DLAB);
 
  51         _outb(SER_FCR, 0x0);    /* FIFOs off */
 
  52         _outb(SER_LCR, 0x03);   /* 8 data bits, one stop bit, no parity */
 
  55 void serial_tx(unsigned char c)
 
  59         while (!(_inb(SER_LSR) & SER_LSR_THR_EMPTY) && (i--))