Enable by turning on CONFIG_DEBUG_SERIAL option.
#define CONFIG_APPNAME "Bochs"
#endif
#define CONFIG_APPNAME "Bochs"
#endif
+#define CONFIG_DEBUG_SERIAL 0
+
#define CONFIG_FLOPPY_SUPPORT 1
#define CONFIG_PS2_MOUSE 1
#define CONFIG_ATA 1
#define CONFIG_FLOPPY_SUPPORT 1
#define CONFIG_PS2_MOUSE 1
#define CONFIG_ATA 1
static void
putc(u16 action, char c)
{
static void
putc(u16 action, char c)
{
- outb(c, PORT_BIOS_DEBUG);
+ if (CONFIG_DEBUG_SERIAL)
+ // Send character to serial port.
+ debug_serial(c);
+ else
+ // Send character to debug port.
+ outb(c, PORT_BIOS_DEBUG);
+
+ // Send character to video screen.
if (c == '\n')
screenc('\r');
screenc(c);
if (c == '\n')
screenc('\r');
screenc(c);
+ if (CONFIG_DEBUG_SERIAL)
+ debug_serial_setup();
+
BX_INFO("Start bios\n");
init_bda();
BX_INFO("Start bios\n");
init_bda();
+// SERIAL - INITIALIZE PORT
static void
handle_1400(struct bregs *regs)
{
static void
handle_1400(struct bregs *regs)
{
-static void
-handle_1401(struct bregs *regs)
+static int
+write_serial(u16 addr, u16 timeout, char c)
- u16 addr = getComAddr(regs);
- if (!addr)
- return;
u16 timer = GET_BDA(timer_counter);
u16 timer = GET_BDA(timer_counter);
- u16 timeout = GET_BDA(com_timeout[regs->dx]);
while (((inb(addr+5) & 0x60) != 0x60) && (timeout)) {
u16 val16 = GET_BDA(timer_counter);
if (val16 != timer) {
while (((inb(addr+5) & 0x60) != 0x60) && (timeout)) {
u16 val16 = GET_BDA(timer_counter);
if (val16 != timer) {
- if (timeout)
- outb(regs->al, addr);
- regs->ah = inb(addr+5);
+ // Ran out of time.
+ return -1;
+ outb(c, addr);
+ return 0;
+}
+
+// SERIAL - WRITE CHARACTER TO PORT
+static void
+handle_1401(struct bregs *regs)
+{
+ u16 addr = getComAddr(regs);
+ if (!addr)
+ return;
+ u16 timeout = GET_BDA(com_timeout[regs->dx]);
+ int ret = write_serial(addr, timeout, regs->al);
+ regs->ah = inb(addr+5);
+ if (ret)
regs->ah |= 0x80;
set_success(regs);
}
regs->ah |= 0x80;
set_success(regs);
}
+// SERIAL - READ CHARACTER FROM PORT
static void
handle_1402(struct bregs *regs)
{
static void
handle_1402(struct bregs *regs)
{
+// SERIAL - GET PORT STATUS
static void
handle_1403(struct bregs *regs)
{
static void
handle_1403(struct bregs *regs)
{
+/****************************************************************
+ * Serial debugging
+ ****************************************************************/
+
+#define BX_DEBUG_PORT 0x03f8
+
+void
+debug_serial_setup()
+{
+ /* setup for serial logging: 8N1 */
+ outb(0x03, BX_DEBUG_PORT+3);
+}
+
+void
+debug_serial(char c)
+{
+ write_serial(BX_DEBUG_PORT, 0x0a, c);
+}
+
+
/****************************************************************
* LPT ports
****************************************************************/
/****************************************************************
* LPT ports
****************************************************************/
// serial.c
void serial_setup();
// serial.c
void serial_setup();
+void debug_serial_setup();
+void debug_serial(char c);
void lpt_setup();
// clock.c
void lpt_setup();
// clock.c