12 static void enable_rcv_irq();
18 #include "std_macros.h"
21 * Glue between kernel and UART driver.
23 EXTENSION class Kernel_uart : public Uart
27 * Prototype for the UART specific startup implementation.
28 * @param uart, the instantiation to start.
29 * @param port, the com port number.
31 bool startup(unsigned port, int irq=-1);
34 //---------------------------------------------------------------------------
35 IMPLEMENTATION [serial]:
41 #include "filter_console.h"
45 #include "kernel_console.h"
53 static Static_object<Filter_console> _fcon;
54 static Static_object<Kernel_uart> _kernel_uart;
56 PUBLIC static FIASCO_CONST
59 { return _kernel_uart; }
63 Kernel_uart::init(Init_mode init_mode = Init_before_mmu)
65 if ((int)init_mode != Bsp_init_mode)
68 if (Koptions::o()->opt(Koptions::F_noserial)) // do not use serial uart
71 _kernel_uart.construct();
72 _fcon.construct(_kernel_uart);
74 Kconsole::console()->register_console(_fcon, 0);
79 Kernel_uart::Kernel_uart()
81 unsigned n = Config::default_console_uart_baudrate;
82 Uart::TransferMode m = Uart::MODE_8N1;
83 unsigned long long p = Config::default_console_uart;
86 if (Koptions::o()->opt(Koptions::F_uart_baud))
87 n = Koptions::o()->uart.baud;
89 if (Koptions::o()->opt(Koptions::F_uart_base))
90 p = Koptions::o()->uart.base_address;
92 if (Koptions::o()->opt(Koptions::F_uart_irq))
93 i = Koptions::o()->uart.irqno;
96 printf("Comport/base 0x%04llx is not accepted by the uart driver!\n", p);
97 else if (!change_mode(m, n))
98 panic("Somthing is wrong with the baud rate (%d)!\n", n);
102 class Kuart_irq : public Irq_base
105 Kuart_irq() { hit_func = &handler_wrapper<Kuart_irq>; }
106 void switch_mode(unsigned) {}
107 void handle(Upstream_irq const *ui)
120 Kernel_uart::enable_rcv_irq()
122 static Kuart_irq uart_irq;
123 if (Irq_mgr::mgr->alloc(&uart_irq, uart()->irq()))
126 uart()->enable_rcv_irq();
130 //---------------------------------------------------------------------------
131 IMPLEMENTATION [!serial]:
135 Kernel_uart::init(Init_mode = Init_before_mmu)
139 Kernel_uart::Kernel_uart()
144 Kernel_uart::enable_rcv_irq()