X-Git-Url: https://rtime.felk.cvut.cz/gitweb/l4.git/blobdiff_plain/5a0e6ead0fbfbb912cd817abad695c078e82481c..8d9e85aaae867f39cdd610261e3a4181c25add2d:/kernel/fiasco/src/kern/kernel_uart.cpp?ds=sidebyside diff --git a/kernel/fiasco/src/kern/kernel_uart.cpp b/kernel/fiasco/src/kern/kernel_uart.cpp index 68506b12c..2ac7322c7 100644 --- a/kernel/fiasco/src/kern/kernel_uart.cpp +++ b/kernel/fiasco/src/kern/kernel_uart.cpp @@ -3,6 +3,11 @@ INTERFACE: class Kernel_uart { public: + enum Init_mode + { + Init_before_mmu, + Init_after_mmu + }; Kernel_uart(); static void enable_rcv_irq(); }; @@ -33,56 +38,64 @@ IMPLEMENTATION [serial]: #include #include +#include "filter_console.h" #include "irq.h" #include "irq_chip.h" #include "irq_pin.h" +#include "kernel_console.h" #include "uart.h" -#include "cmdline.h" #include "config.h" +#include "kip.h" +#include "koptions.h" #include "panic.h" +static Static_object _fcon; +static Static_object _kernel_uart; + PUBLIC static FIASCO_CONST Uart * Kernel_uart::uart() +{ return _kernel_uart.get(); } + +PUBLIC static +bool +Kernel_uart::init(Init_mode init_mode = Init_before_mmu) { - static Kernel_uart c; - return &c; + if (init_mode != Bsp_init_mode) + return false; + + if (Koptions::o()->opt(Koptions::F_noserial)) // do not use serial uart + return true; + + _kernel_uart.init(); + _fcon.init(_kernel_uart.get()); + + Kconsole::console()->register_console(_fcon.get(), 0); + return true; } IMPLEMENT Kernel_uart::Kernel_uart() { - char const * const cmdline = Cmdline::cmdline(); - char *s; - bool ok; - - unsigned n = Config::default_console_uart_baudrate; + unsigned n = Config::default_console_uart_baudrate; Uart::TransferMode m = Uart::MODE_8N1; - unsigned p = Config::default_console_uart; - int i = -1; + unsigned long long p = Config::default_console_uart; + int i = -1; - if ( (s = strstr(cmdline, " -comspeed ")) - ||(s = strstr(cmdline, " -comspeed="))) - { - if ((n = strtoul(s + 11, 0, 0)) > 115200 || n < 1) - { - puts ("-comspeed > 115200 not supported or invalid (using 115200)!"); - n = 115200; - } - } + if (Koptions::o()->opt(Koptions::F_uart_baud)) + n = Koptions::o()->uart.baud; - if ( (s = strstr(cmdline, " -comport ")) - ||(s = strstr(cmdline, " -comport="))) - p = strtoul(s + 10, 0, 0); + if (Koptions::o()->opt(Koptions::F_uart_base)) + p = Koptions::o()->uart.base_address; - if ((s = strstr(cmdline, " -comirq="))) - i = strtoul(s + 9, 0, 0); + if (Koptions::o()->opt(Koptions::F_uart_irq)) + i = Koptions::o()->uart.irqno; - if (!(ok = startup(p, i))) - printf("Comport 0x%04x is not accepted by the uart driver!\n", p); - - if (ok && !change_mode(m, n)) - panic("Somthing is wrong with the baud rate (%d)!\n", n); + if (!startup(p, i)) + printf("Comport/base 0x%04lx is not accepted by the uart driver!\n", p); + else + if (!change_mode(m, n)) + panic("Somthing is wrong with the baud rate (%d)!\n", n); } @@ -101,7 +114,12 @@ Kernel_uart::enable_rcv_irq() } //--------------------------------------------------------------------------- -IMPLEMENTATION [!serial]: +IMPLEMENTATION [!serial]: + +PUBLIC static +bool +Kernel_uart::init(Init_mode = Init_before_mmu) +{ return false; } IMPLEMENT inline Kernel_uart::Kernel_uart()