12 static void enable_rcv_irq();
18 #include "std_macros.h"
22 * Glue between kernel and UART driver.
24 EXTENSION class Kernel_uart : public Uart, public Pm_object
28 * Prototype for the UART specific startup implementation.
29 * @param uart, the instantiation to start.
30 * @param port, the com port number.
32 bool startup(unsigned port, int irq=-1);
34 static bool init_for_mode(Init_mode init_mode);
37 //---------------------------------------------------------------------------
38 IMPLEMENTATION [serial]:
45 #include "filter_console.h"
49 #include "kernel_console.h"
57 static Static_object<Filter_console> _fcon;
58 static Static_object<Kernel_uart> _kernel_uart;
60 PUBLIC static FIASCO_CONST
63 { return _kernel_uart; }
66 IMPLEMENT_DEFAULT inline
68 Kernel_uart::init_for_mode(Init_mode init_mode)
69 { return (int)init_mode == Bsp_init_mode; }
73 Kernel_uart::init(Init_mode init_mode = Init_before_mmu)
75 if (!init_for_mode(init_mode))
78 if (Koptions::o()->opt(Koptions::F_noserial)) // do not use serial uart
81 _kernel_uart.construct();
82 _fcon.construct(_kernel_uart);
84 Kconsole::console()->register_console(_fcon, 0);
92 unsigned n = Config::default_console_uart_baudrate;
93 Uart::TransferMode m = Uart::MODE_8N1;
94 unsigned long long p = Config::default_console_uart;
97 if (Koptions::o()->opt(Koptions::F_uart_baud))
98 n = Koptions::o()->uart.baud;
100 if (Koptions::o()->opt(Koptions::F_uart_base))
101 p = Koptions::o()->uart.base_address;
103 if (Koptions::o()->opt(Koptions::F_uart_irq))
104 i = Koptions::o()->uart.irqno;
107 printf("Comport/base 0x%04llx is not accepted by the uart driver!\n", p);
108 else if (!change_mode(m, n))
109 panic("Something is wrong with the baud rate (%u)!\n", n);
113 Kernel_uart::Kernel_uart()
116 register_pm(Cpu_number::boot_cpu());
120 Kernel_uart::pm_on_suspend(Cpu_number cpu)
123 assert (cpu == Cpu_number::boot_cpu());
125 uart()->state(Console::DISABLED);
127 if(Config::serial_esc != Config::SERIAL_ESC_NOIRQ)
128 uart()->disable_rcv_irq();
132 Kernel_uart::pm_on_resume(Cpu_number cpu)
135 assert (cpu == Cpu_number::boot_cpu());
136 static_cast<Kernel_uart*>(Kernel_uart::uart())->setup();
137 uart()->state(Console::ENABLED);
139 if(Config::serial_esc != Config::SERIAL_ESC_NOIRQ)
140 uart()->enable_rcv_irq();
144 class Kuart_irq : public Irq_base
147 Kuart_irq() { hit_func = &handler_wrapper<Kuart_irq>; }
148 void switch_mode(bool) {}
149 void handle(Upstream_irq const *ui)
151 Kernel_uart::uart()->irq_ack();
163 Kernel_uart::enable_rcv_irq()
165 static Kuart_irq uart_irq;
166 if (Irq_mgr::mgr->alloc(&uart_irq, uart()->irq()))
169 uart()->enable_rcv_irq();
173 //---------------------------------------------------------------------------
174 IMPLEMENTATION [!serial]:
178 Kernel_uart::init(Init_mode = Init_before_mmu)
182 Kernel_uart::Kernel_uart()
187 Kernel_uart::enable_rcv_irq()