From 1887222b530e063f597252c192d93c427c12ab67 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Mon, 10 Jun 2013 11:36:21 +0200 Subject: [PATCH] okl4: use bender, read out comport from BDA Issue #768 --- base-okl4/patches/README | 5 ++++ base-okl4/patches/bda.patch | 59 +++++++++++++++++++++++++++++++++++++ base-okl4/run/env | 4 ++- 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 base-okl4/patches/bda.patch diff --git a/base-okl4/patches/README b/base-okl4/patches/README index a29c77328..757241ca1 100644 --- a/base-okl4/patches/README +++ b/base-okl4/patches/README @@ -61,6 +61,11 @@ This directory contains patches for the OKL4 kernel version 2.1.1-patch.9. console instead of sending an exception IPC to the userland. This patch fixes the problem by removing the code that invokes the debugger console. +:'bda.patch': + + This patch reads out the I/O port of the serial device from the BIOS data + area (on x86). + Applying the patches -------------------- diff --git a/base-okl4/patches/bda.patch b/base-okl4/patches/bda.patch new file mode 100644 index 000000000..45822482b --- /dev/null +++ b/base-okl4/patches/bda.patch @@ -0,0 +1,59 @@ +--- pistachio/platform/pc99/pistachio/kdb/io.cc 2013-06-10 11:34:34.607813369 +0200 ++++ pistachio/platform/pc99/pistachio/kdb/io.cc 2013-06-10 11:32:02.607810593 +0200 +@@ -336,16 +336,23 @@ + #define COMPORT CONFIG_KDB_COMPORT + #define RATE CONFIG_KDB_COMSPEED + ++static unsigned short comport = COMPORT; ++ + void Platform::serial_init(void) + { +-#define IER (COMPORT+1) +-#define EIR (COMPORT+2) +-#define LCR (COMPORT+3) +-#define MCR (COMPORT+4) +-#define LSR (COMPORT+5) +-#define MSR (COMPORT+6) +-#define DLLO (COMPORT+0) +-#define DLHI (COMPORT+1) ++ /* read BDA region to obtain I/O ports of serial device */ ++ unsigned short comport_count = (*((unsigned short *)0x410) >> 9) & 0x7; ++ if (comport_count) ++ comport = *((unsigned short *)0x400); ++ ++#define IER (comport+1) ++#define EIR (comport+2) ++#define LCR (comport+3) ++#define MCR (comport+4) ++#define LSR (comport+5) ++#define MSR (comport+6) ++#define DLLO (comport+0) ++#define DLHI (comport+1) + + out_u8(LCR, 0x80); /* select bank 1 */ + for (volatile int i = 10000000; i--; ); +@@ -367,8 +374,8 @@ + + void Platform::serial_putc(char c) + { +- while ((in_u8(COMPORT+5) & 0x60) == 0); +- out_u8(COMPORT,c); ++ while ((in_u8(comport+5) & 0x60) == 0); ++ out_u8(comport,c); + if (c == '\n') + Platform::serial_putc('\r'); + +@@ -376,11 +383,11 @@ + + int Platform::serial_getc(bool can_block) + { +- if ((in_u8(COMPORT+5) & 0x01) == 0) ++ if ((in_u8(comport+5) & 0x01) == 0) + { + return -1; + } +- return (int) in_u8(COMPORT); ++ return (int) in_u8(comport); + } + + DECLARE_CMD (cmd_dumpvga, arch, 'V', "screendump", "dump VGA screen contents"); diff --git a/base-okl4/run/env b/base-okl4/run/env index 7e5fb0085..99128319b 100644 --- a/base-okl4/run/env +++ b/base-okl4/run/env @@ -11,6 +11,7 @@ # proc install_pxe_bootloader_to_run_dir { } { exec cp [genode_dir]/tool/boot/pulsar [run_dir]/boot/pulsar + exec cp [genode_dir]/tool/boot/bender [run_dir]/boot/bender } ## @@ -211,7 +212,8 @@ proc build_boot_image {binaries} { set fh [open "[run_dir]/config-52-54-00-12-34-56" "WRONLY CREAT TRUNC"] # load okl4 at 256M to avoid overwritting binary, adjust by need puts $fh " addr 0x10000000" - puts $fh " exec /image.elf" + puts $fh " exec /boot/bender" + puts $fh " load /image.elf" close $fh #