SRCBOTH=misc.c stacks.c output.c string.c x86.c block.c cdrom.c mouse.c kbd.c \
serial.c clock.c resume.c pnpbios.c vgahooks.c pcibios.c apm.c \
fw/smp.c \
- hw/pci.c hw/timer.c hw/rtc.c hw/dma.c hw/pic.c hw/ps2port.c \
+ hw/pci.c hw/timer.c hw/rtc.c hw/dma.c hw/pic.c hw/ps2port.c hw/serialio.c \
hw/usb.c hw/usb-uhci.c hw/usb-ohci.c hw/usb-ehci.c hw/usb-xhci.c \
hw/usb-hid.c hw/usb-msc.c hw/usb-uas.c \
hw/blockcmd.c hw/floppy.c hw/ata.c hw/ramdisk.c \
################ VGA build rules
# VGA src files
-SRCVGA=src/output.c src/string.c src/hw/pci.c \
+SRCVGA=src/output.c src/string.c src/hw/pci.c src/hw/serialio.c \
vgasrc/vgabios.c vgasrc/vgafb.c vgasrc/vgafonts.c vgasrc/vbe.c \
vgasrc/stdvga.c vgasrc/stdvgamodes.c vgasrc/stdvgaio.c \
vgasrc/clext.c vgasrc/bochsvga.c vgasrc/geodevga.c
void VISIBLE32FLAT
handle_18(void)
{
- debug_serial_preinit();
+ debug_preinit();
debug_enter(NULL, DEBUG_HDL_18);
int seq = BootSequence + 1;
BootSequence = seq;
void VISIBLE32FLAT
handle_19(void)
{
- debug_serial_preinit();
+ debug_preinit();
debug_enter(NULL, DEBUG_HDL_19);
BootSequence = 0;
do_boot(0);
return;
}
-void debug_cbmem(char c)
+void coreboot_debug_putc(char c)
{
if (!CONFIG_DEBUG_COREBOOT)
return;
// This file may be distributed under the terms of the GNU LGPLv3 license.
#include "config.h"
+#include "hw/serialio.h" // DebugOutputPort
#include "malloc.h" // memalign_high
#include "memmap.h" // add_e820
#include "output.h" // dprintf
--- /dev/null
+// Low-level serial (and serial-like) device access.
+//
+// Copyright (C) 2008-1013 Kevin O'Connor <kevin@koconnor.net>
+//
+// This file may be distributed under the terms of the GNU LGPLv3 license.
+
+#include "config.h" // CONFIG_DEBUG_SERIAL
+#include "fw/paravirt.h" // RunningOnQEMU
+#include "output.h" // dprintf
+#include "serialio.h" // serial_debug_preinit
+#include "x86.h" // outb
+
+
+/****************************************************************
+ * Serial port debug output
+ ****************************************************************/
+
+#define DEBUG_TIMEOUT 100000
+
+// Setup the debug serial port for output.
+void
+serial_debug_preinit(void)
+{
+ if (!CONFIG_DEBUG_SERIAL)
+ return;
+ // setup for serial logging: 8N1
+ u8 oldparam, newparam = 0x03;
+ oldparam = inb(CONFIG_DEBUG_SERIAL_PORT+SEROFF_LCR);
+ outb(newparam, CONFIG_DEBUG_SERIAL_PORT+SEROFF_LCR);
+ // Disable irqs
+ u8 oldier, newier = 0;
+ oldier = inb(CONFIG_DEBUG_SERIAL_PORT+SEROFF_IER);
+ outb(newier, CONFIG_DEBUG_SERIAL_PORT+SEROFF_IER);
+
+ if (oldparam != newparam || oldier != newier)
+ dprintf(1, "Changing serial settings was %x/%x now %x/%x\n"
+ , oldparam, oldier, newparam, newier);
+}
+
+// Write a character to the serial port.
+static void
+serial_debug(char c)
+{
+ if (!CONFIG_DEBUG_SERIAL)
+ return;
+ int timeout = DEBUG_TIMEOUT;
+ while ((inb(CONFIG_DEBUG_SERIAL_PORT+SEROFF_LSR) & 0x20) != 0x20)
+ if (!timeout--)
+ // Ran out of time.
+ return;
+ outb(c, CONFIG_DEBUG_SERIAL_PORT+SEROFF_DATA);
+}
+
+void
+serial_debug_putc(char c)
+{
+ if (c == '\n')
+ serial_debug('\r');
+ serial_debug(c);
+}
+
+// Make sure all serial port writes have been completely sent.
+void
+serial_debug_flush(void)
+{
+ if (!CONFIG_DEBUG_SERIAL)
+ return;
+ int timeout = DEBUG_TIMEOUT;
+ while ((inb(CONFIG_DEBUG_SERIAL_PORT+SEROFF_LSR) & 0x60) != 0x60)
+ if (!timeout--)
+ // Ran out of time.
+ return;
+}
+
+
+/****************************************************************
+ * QEMU debug port
+ ****************************************************************/
+
+u16 DebugOutputPort VARFSEG = 0x402;
+
+// Write a character to the special debugging port.
+void
+qemu_debug_putc(char c)
+{
+ if (CONFIG_DEBUG_IO && runningOnQEMU())
+ // Send character to debug port.
+ outb(c, GET_GLOBAL(DebugOutputPort));
+}
#ifndef __SERIALIO_H
#define __SERIALIO_H
+#include "types.h" // u16
+
#define PORT_LPT2 0x0278
#define PORT_SERIAL4 0x02e8
#define PORT_SERIAL2 0x02f8
#define SEROFF_LSR 5
#define SEROFF_MSR 6
+void serial_debug_preinit(void);
+void serial_debug_putc(char c);
+void serial_debug_flush(void);
+extern u16 DebugOutputPort;
+void qemu_debug_putc(char c);
+
#endif // serialio.h
farcall16big(&br);
finish_preempt();
- debug_serial_preinit();
+ debug_preinit();
}
// Execute a given option rom at the standard entry vector.
// Raw screen writing and debug output code.
//
-// Copyright (C) 2008,2009 Kevin O'Connor <kevin@koconnor.net>
+// Copyright (C) 2008-2013 Kevin O'Connor <kevin@koconnor.net>
//
// This file may be distributed under the terms of the GNU LGPLv3 license.
#include "bregs.h" // struct bregs
#include "config.h" // CONFIG_*
#include "biosvar.h" // GET_GLOBAL
-#include "fw/paravirt.h" // PlatformRunningOn
-#include "hw/serialio.h" // SEROFF_IER
+#include "hw/serialio.h" // serial_debug_putc
#include "malloc.h" // malloc_tmp
#include "output.h" // dprintf
#include "stacks.h" // call16_int
* Debug output
****************************************************************/
-#define DEBUG_TIMEOUT 100000
-
-u16 DebugOutputPort VARFSEG = 0x402;
-
+// Setup debugging port(s).
void
-debug_serial_preinit(void)
+debug_preinit(void)
{
- if (!CONFIG_DEBUG_SERIAL)
- return;
- // setup for serial logging: 8N1
- u8 oldparam, newparam = 0x03;
- oldparam = inb(CONFIG_DEBUG_SERIAL_PORT+SEROFF_LCR);
- outb(newparam, CONFIG_DEBUG_SERIAL_PORT+SEROFF_LCR);
- // Disable irqs
- u8 oldier, newier = 0;
- oldier = inb(CONFIG_DEBUG_SERIAL_PORT+SEROFF_IER);
- outb(newier, CONFIG_DEBUG_SERIAL_PORT+SEROFF_IER);
-
- if (oldparam != newparam || oldier != newier)
- dprintf(1, "Changing serial settings was %x/%x now %x/%x\n"
- , oldparam, oldier, newparam, newier);
-}
-
-// Write a character to the serial port.
-static void
-debug_serial(char c)
-{
- if (!CONFIG_DEBUG_SERIAL)
- return;
- int timeout = DEBUG_TIMEOUT;
- while ((inb(CONFIG_DEBUG_SERIAL_PORT+SEROFF_LSR) & 0x20) != 0x20)
- if (!timeout--)
- // Ran out of time.
- return;
- outb(c, CONFIG_DEBUG_SERIAL_PORT+SEROFF_DATA);
+ serial_debug_preinit();
}
-// Make sure all serial port writes have been completely sent.
+// Write a character to debug port(s).
static void
-debug_serial_flush(void)
+debug_putc(struct putcinfo *action, char c)
{
- if (!CONFIG_DEBUG_SERIAL)
+ if (! CONFIG_DEBUG_LEVEL)
return;
- int timeout = DEBUG_TIMEOUT;
- while ((inb(CONFIG_DEBUG_SERIAL_PORT+SEROFF_LSR) & 0x60) != 0x60)
- if (!timeout--)
- // Ran out of time.
- return;
+ qemu_debug_putc(c);
+ if (!MODESEGMENT)
+ coreboot_debug_putc(c);
+ serial_debug_putc(c);
}
-// Write a character to debug port(s).
+// Flush any pending output to debug port(s).
static void
-putc_debug(struct putcinfo *action, char c)
+debug_flush(void)
{
- if (! CONFIG_DEBUG_LEVEL)
- return;
- if (CONFIG_DEBUG_IO && runningOnQEMU())
- // Send character to debug port.
- outb(c, GET_GLOBAL(DebugOutputPort));
- if (!MODESEGMENT)
- debug_cbmem(c);
- if (c == '\n')
- debug_serial('\r');
- debug_serial(c);
+ serial_debug_flush();
}
-// In segmented mode just need a dummy variable (putc_debug is always
+// In segmented mode just need a dummy variable (debug_putc is always
// used anyway), and in 32bit flat mode need a pointer to the 32bit
-// instance of putc_debug().
+// instance of debug_putc().
#if MODE16
static struct putcinfo debuginfo VAR16;
#elif MODESEGMENT
static struct putcinfo debuginfo VAR32SEG;
#else
-static struct putcinfo debuginfo = { putc_debug };
+static struct putcinfo debuginfo = { debug_putc };
#endif
// Handle a character from a printf request.
static void
-putc_screen(struct putcinfo *action, char c)
+screen_putc(struct putcinfo *action, char c)
{
if (ScreenAndDebug)
- putc_debug(&debuginfo, c);
+ debug_putc(&debuginfo, c);
if (c == '\n')
screenc('\r');
screenc(c);
}
-static struct putcinfo screeninfo = { putc_screen };
+static struct putcinfo screeninfo = { screen_putc };
/****************************************************************
{
if (MODESEGMENT) {
// Only debugging output supported in segmented mode.
- putc_debug(action, c);
+ debug_putc(action, c);
return;
}
va_start(args, fmt);
bvprintf(&debuginfo, fmt, args);
va_end(args);
- debug_serial_flush();
+ debug_flush();
}
// XXX - use PANIC PORT.
struct thread_info *cur = getCurThread();
if (cur != &MainThread) {
// Show "thread id" for this debug message.
- putc_debug(&debuginfo, '|');
+ debug_putc(&debuginfo, '|');
puthex(&debuginfo, (u32)cur, 8);
- putc_debug(&debuginfo, '|');
- putc_debug(&debuginfo, ' ');
+ debug_putc(&debuginfo, '|');
+ debug_putc(&debuginfo, ' ');
}
}
va_start(args, fmt);
bvprintf(&debuginfo, fmt, args);
va_end(args);
- debug_serial_flush();
+ debug_flush();
}
void
bvprintf(&screeninfo, fmt, args);
va_end(args);
if (ScreenAndDebug)
- debug_serial_flush();
+ debug_flush();
}
d+=4;
}
putc(&debuginfo, '\n');
- debug_serial_flush();
+ debug_flush();
}
static void
{
puts_cs(&debuginfo, fname);
putc(&debuginfo, '\n');
- debug_serial_flush();
+ debug_flush();
}
// Function called on handler startup.
#include "types.h" // u32
// output.c
-extern u16 DebugOutputPort;
-void debug_serial_preinit(void);
+void debug_preinit(void);
void panic(const char *fmt, ...)
__attribute__ ((format (printf, 1, 2))) __noreturn;
void printf(const char *fmt, ...)
if (!CONFIG_QEMU && !CONFIG_COREBOOT)
return;
- debug_serial_preinit();
+ debug_preinit();
dprintf(1, "Start bios (version %s)\n", VERSION);
// Check if we are running under Xen.
handle_resume(void)
{
ASSERT16();
- debug_serial_preinit();
+ debug_preinit();
int status = rtc_read(CMOS_RESET_CODE);
rtc_write(CMOS_RESET_CODE, 0);
dprintf(1, "In resume (status=%d)\n", status);
// fw/coreboot.c
extern const char *CBvendor, *CBpart;
struct cbfs_file;
-void debug_cbmem(char c);
+void coreboot_debug_putc(char c);
void cbfs_run_payload(struct cbfs_file *file);
void coreboot_platform_setup(void);
void cbfs_payload_setup(void);
void VISIBLE16
vga_post(struct bregs *regs)
{
- debug_serial_preinit();
+ debug_preinit();
dprintf(1, "Start SeaVGABIOS (version %s)\n", VERSION);
debug_enter(regs, DEBUG_VGA_POST);