diff --git a/repos/base-hw/lib/mk/x86/core.inc b/repos/base-hw/lib/mk/x86/core.inc index 3d82c5d67..51739600b 100644 --- a/repos/base-hw/lib/mk/x86/core.inc +++ b/repos/base-hw/lib/mk/x86/core.inc @@ -14,6 +14,7 @@ SRC_CC += spec/x86/kernel/thread.cc SRC_CC += spec/x86/kernel/cpu.cc SRC_CC += spec/x86/kernel/pd.cc SRC_CC += spec/x86/cpu.cc +SRC_CC += spec/x86/bios_data_area.cc SRC_CC += kernel/vm_thread.cc SRC_CC += x86/io_port_session_component.cc SRC_CC += x86/platform_services.cc diff --git a/repos/base-hw/src/core/include/spec/x86/serial.h b/repos/base-hw/src/core/include/spec/x86/serial.h index f59491960..2ea9e3a73 100644 --- a/repos/base-hw/src/core/include/spec/x86/serial.h +++ b/repos/base-hw/src/core/include/spec/x86/serial.h @@ -14,56 +14,10 @@ #pragma once /* Genode includes */ +#include #include -#include -#include -namespace Genode -{ - enum { BDA_MMIO_BASE_VIRT = 0x1ff000 }; - - class Bios_data_area; - class Serial; - - Bios_data_area * bda(); -} - -class Genode::Bios_data_area : Mmio -{ - friend Unmanaged_singleton_constructor; - - private: - - struct Serial_base_com1 : Register<0x400, 16> { }; - struct Equipment : Register<0x410, 16> - { - struct Serial_count : Bitfield<9, 3> { }; - }; - - /* - * Constructor - * - * The BDA page must be mapped already (see crt0_translation_table.s). - */ - Bios_data_area() : Mmio(BDA_MMIO_BASE_VIRT) { } - - public: - - /** - * Obtain I/O ports of COM interfaces from BDA - */ - addr_t serial_port() const - { - Equipment::access_t count = read(); - return count ? read() : 0; - } - - /** - * Return BDA singleton - */ - static Bios_data_area * singleton() { - return unmanaged_singleton(); } -}; +namespace Genode { class Serial; } /** * Serial output driver for core diff --git a/repos/base-hw/src/core/spec/x86/bios_data_area.cc b/repos/base-hw/src/core/spec/x86/bios_data_area.cc new file mode 100644 index 000000000..036f6673d --- /dev/null +++ b/repos/base-hw/src/core/spec/x86/bios_data_area.cc @@ -0,0 +1,19 @@ +/* + * \brief Structure of the Bios Data Area after preparation through Bender + * \author Martin Stein + * \date 2015-07-10 + */ + +/* + * Copyright (C) 2015 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* core includes */ +#include + +using namespace Genode; + +addr_t Bios_data_area::_mmio_base_virt() { return 0x1ff000; } diff --git a/repos/base-nova/src/base/console/core_console.h b/repos/base-nova/src/base/console/core_console.h index 2b0fcf7b2..ea1dd7a68 100644 --- a/repos/base-nova/src/base/console/core_console.h +++ b/repos/base-nova/src/base/console/core_console.h @@ -14,9 +14,9 @@ #pragma once -#include - /* Genode includes */ +#include +#include #include namespace Genode { class Core_console; } @@ -25,33 +25,6 @@ class Genode::Core_console : public X86_uart_base, public Console { private: - addr_t _port() - { - /** - * Read BDA (Bios Data Area) to obtain I/O ports of COM - * interfaces. The page must be mapped by the platform code ! - */ - - enum { - MAP_ADDR_BDA = 0x1000, - - BDA_SERIAL_BASE_COM1 = 0x400, - BDA_EQUIPMENT_WORD = 0x410, - BDA_EQUIPMENT_SERIAL_COUNT_MASK = 0x7, - BDA_EQUIPMENT_SERIAL_COUNT_SHIFT = 9, - }; - - char * map_bda = reinterpret_cast(MAP_ADDR_BDA); - uint16_t serial_count = *reinterpret_cast(map_bda + BDA_EQUIPMENT_WORD); - serial_count >>= BDA_EQUIPMENT_SERIAL_COUNT_SHIFT; - serial_count &= BDA_EQUIPMENT_SERIAL_COUNT_MASK; - - if (serial_count > 0) - return *reinterpret_cast(map_bda + BDA_SERIAL_BASE_COM1); - - return 0; - } - enum { CLOCK = 0, BAUDRATE = 115200 }; void _out_char(char c) @@ -64,5 +37,9 @@ class Genode::Core_console : public X86_uart_base, public Console public: - Core_console() : X86_uart_base(_port(), CLOCK, BAUDRATE) {} + Core_console() + : + X86_uart_base(Bios_data_area::singleton()->serial_port(), + CLOCK, BAUDRATE) + { } }; diff --git a/repos/base-nova/src/core/bios_data_area.cc b/repos/base-nova/src/core/bios_data_area.cc new file mode 100644 index 000000000..e29fa7aab --- /dev/null +++ b/repos/base-nova/src/core/bios_data_area.cc @@ -0,0 +1,19 @@ +/* + * \brief Structure of the Bios Data Area after preparation through Bender + * \author Martin Stein + * \date 2015-07-10 + */ + +/* + * Copyright (C) 2015 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* core includes */ +#include + +using namespace Genode; + +addr_t Bios_data_area::_mmio_base_virt() { return 0x1000; } diff --git a/repos/base-nova/src/core/target.inc b/repos/base-nova/src/core/target.inc index d7fe801d6..5bcbd31cf 100644 --- a/repos/base-nova/src/core/target.inc +++ b/repos/base-nova/src/core/target.inc @@ -33,11 +33,13 @@ SRC_CC = context_area.cc \ rom_session_component.cc \ signal_session_component.cc \ thread_start.cc \ + bios_data_area.cc \ trace_session_component.cc INC_DIR = $(REP_DIR)/src/core/include \ $(REP_DIR)/src/base/console \ $(BASE_DIR)/src/base/thread \ + $(BASE_DIR)/src/base/include \ $(GEN_CORE_DIR)/include include $(GEN_CORE_DIR)/version.inc diff --git a/repos/base/include/x86/bios_data_area.h b/repos/base/include/x86/bios_data_area.h new file mode 100644 index 000000000..38c67285e --- /dev/null +++ b/repos/base/include/x86/bios_data_area.h @@ -0,0 +1,59 @@ +/* + * \brief Structure of the Bios Data Area after preparation through Bender + * \author Martin Stein + * \date 2015-07-10 + */ + +/* + * Copyright (C) 2015 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _BIOS_DATA_AREA_H_ +#define _BIOS_DATA_AREA_H_ + +/* Genode includes */ +#include + +/* base includes */ +#include + +namespace Genode { class Bios_data_area; } + +class Genode::Bios_data_area : Mmio +{ + friend Unmanaged_singleton_constructor; + + private: + + struct Serial_base_com1 : Register<0x400, 16> { }; + struct Equipment : Register<0x410, 16> + { + struct Serial_count : Bitfield<9, 3> { }; + }; + + static addr_t _mmio_base_virt(); + + Bios_data_area() : Mmio(_mmio_base_virt()) { } + + public: + + /** + * Obtain I/O ports of COM interfaces from BDA + */ + addr_t serial_port() const + { + Equipment::access_t count = read(); + return count ? read() : 0; + } + + /** + * Return BDA singleton + */ + static Bios_data_area * singleton() { + return unmanaged_singleton(); } +}; + +#endif /* _BIOS_DATA_AREA_H_ */