mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-13 22:23:45 +00:00
base-hw: serial output as Main member
Let the kernel's serial-output driver be a member of the one Kernel::Main object instead of having it as global static variable. Ref #4217
This commit is contained in:
parent
910788313e
commit
b817e1977c
@ -42,6 +42,9 @@ class Kernel::Main
|
||||
friend void main_handle_kernel_entry();
|
||||
friend void main_initialize_and_handle_kernel_entry();
|
||||
friend time_t main_read_idle_thread_execution_time(unsigned cpu_idx);
|
||||
friend void main_print_char(char c);
|
||||
|
||||
enum { SERIAL_BAUD_RATE = 115200 };
|
||||
|
||||
static Main *_instance;
|
||||
|
||||
@ -52,6 +55,9 @@ class Kernel::Main
|
||||
Genode::Core_platform_pd _core_platform_pd { _addr_space_id_alloc };
|
||||
Genode::Constructible<Core_main_thread> _core_main_thread { };
|
||||
Board::Global_interrupt_controller _global_irq_ctrl { };
|
||||
Board::Serial _serial { Genode::Platform::mmio_to_virt(Board::UART_BASE),
|
||||
Board::UART_CLOCK,
|
||||
SERIAL_BAUD_RATE };
|
||||
|
||||
void _handle_kernel_entry();
|
||||
|
||||
@ -196,6 +202,12 @@ Genode::Platform_pd &Kernel::Main::core_platform_pd()
|
||||
}
|
||||
|
||||
|
||||
void Kernel::main_print_char(char c)
|
||||
{
|
||||
Main::_instance->_serial.put_char(c);
|
||||
}
|
||||
|
||||
|
||||
Kernel::time_t Kernel::main_read_idle_thread_execution_time(unsigned cpu_idx)
|
||||
{
|
||||
return Main::_instance->_cpu_pool.cpu(cpu_idx).idle_thread().execution_time();
|
||||
|
@ -19,11 +19,15 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
void main_print_char(char const c);
|
||||
|
||||
void main_handle_kernel_entry();
|
||||
|
||||
void main_initialize_and_handle_kernel_entry();
|
||||
|
||||
time_t main_read_idle_thread_execution_time(unsigned cpu_idx);
|
||||
|
||||
void main_print_char(char c);
|
||||
}
|
||||
|
||||
#endif /* _KERNEL__MAIN_H_ */
|
||||
|
@ -13,26 +13,19 @@
|
||||
*/
|
||||
|
||||
/* base-hw Core includes */
|
||||
#include <board.h>
|
||||
#include <platform.h>
|
||||
#include <kernel/main.h>
|
||||
#include <kernel/log.h>
|
||||
|
||||
|
||||
void Kernel::log(char const c)
|
||||
{
|
||||
using namespace Board;
|
||||
|
||||
enum {
|
||||
ASCII_LINE_FEED = 10,
|
||||
ASCII_CARRIAGE_RETURN = 13,
|
||||
BAUD_RATE = 115200
|
||||
};
|
||||
|
||||
static Serial serial { Genode::Platform::mmio_to_virt(UART_BASE),
|
||||
UART_CLOCK, BAUD_RATE };
|
||||
|
||||
if (c == ASCII_LINE_FEED)
|
||||
serial.put_char(ASCII_CARRIAGE_RETURN);
|
||||
main_print_char(ASCII_CARRIAGE_RETURN);
|
||||
|
||||
serial.put_char(c);
|
||||
main_print_char(c);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user