base: use BDA header in base-nova like base-hw

Moves the Bios Data Area header from base-hw to base. Modifies the
base-nova core console that it uses the header as replacement for
the previous BDA bit logic.

Ref #1625
This commit is contained in:
Martin Stein 2015-07-10 19:58:30 +02:00 committed by Norman Feske
parent c6f73d365a
commit f3e76b3e9a
7 changed files with 109 additions and 78 deletions

View File

@ -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

View File

@ -14,56 +14,10 @@
#pragma once
/* Genode includes */
#include <bios_data_area.h>
#include <drivers/uart/x86_uart_base.h>
#include <util/mmio.h>
#include <unmanaged_singleton.h>
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<Equipment::Serial_count>();
return count ? read<Serial_base_com1>() : 0;
}
/**
* Return BDA singleton
*/
static Bios_data_area * singleton() {
return unmanaged_singleton<Bios_data_area>(); }
};
namespace Genode { class Serial; }
/**
* Serial output driver for core

View File

@ -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 <bios_data_area.h>
using namespace Genode;
addr_t Bios_data_area::_mmio_base_virt() { return 0x1ff000; }

View File

@ -14,9 +14,9 @@
#pragma once
#include <base/console.h>
/* Genode includes */
#include <base/console.h>
#include <bios_data_area.h>
#include <drivers/uart/x86_uart_base.h>
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<char *>(MAP_ADDR_BDA);
uint16_t serial_count = *reinterpret_cast<uint16_t *>(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<uint16_t *>(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)
{ }
};

View File

@ -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 <bios_data_area.h>
using namespace Genode;
addr_t Bios_data_area::_mmio_base_virt() { return 0x1000; }

View File

@ -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

View File

@ -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 <util/mmio.h>
/* base includes */
#include <unmanaged_singleton.h>
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<Equipment::Serial_count>();
return count ? read<Serial_base_com1>() : 0;
}
/**
* Return BDA singleton
*/
static Bios_data_area * singleton() {
return unmanaged_singleton<Bios_data_area>(); }
};
#endif /* _BIOS_DATA_AREA_H_ */