2015-07-10 17:58:30 +00:00
|
|
|
/*
|
|
|
|
* \brief Structure of the Bios Data Area after preparation through Bender
|
|
|
|
* \author Martin Stein
|
|
|
|
* \date 2015-07-10
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 12:23:52 +00:00
|
|
|
* Copyright (C) 2015-2017 Genode Labs GmbH
|
2015-07-10 17:58:30 +00:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 12:23:52 +00:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2015-07-10 17:58:30 +00:00
|
|
|
*/
|
|
|
|
|
2015-09-03 12:55:05 +00:00
|
|
|
#ifndef _INCLUDE__SPEC__X86__BIOS_DATA_AREA_H_
|
|
|
|
#define _INCLUDE__SPEC__X86__BIOS_DATA_AREA_H_
|
2015-07-10 17:58:30 +00:00
|
|
|
|
|
|
|
/* Genode includes */
|
|
|
|
#include <util/mmio.h>
|
|
|
|
|
2016-01-20 17:27:18 +00:00
|
|
|
/* base-internal includes */
|
|
|
|
#include <base/internal/unmanaged_singleton.h>
|
2015-07-10 17:58:30 +00:00
|
|
|
|
|
|
|
namespace Genode { class Bios_data_area; }
|
|
|
|
|
mmio: upper-bounds checks
The classes Genode::Mmio, Genode::Register_set, Genode::Attached_mmio, and
Platform::Device::Mmio now receive a template parameter 'size_t SIZE'. In each
type that derives from one of these classes, it is now statically checked that
the range of each Genode::Register::Register- and
Genode::Register_set::Register_array-deriving sub-type is within [0..SIZE).
That said, SIZE is the minimum size of the memory region provided to the above
mentioned Mmio classes in order to avoid page faults or memory corruption when
accessing the registers and register arrays declared inside.
Note, that the range end of a register array is not the end of the last item
but the end of integer access that is used for accessing the last bit in the
last item.
The constructors of Genode::Mmio, Genode::Attached_mmio, and
Platform::Device::Mmio now receive an argument 'Byte_range_ptr range' that is
expected to be the range of the backing memory region. In each type that derives
from on of these classes, it is now dynamically checked that 'range.num_bytes
>= SIZE', thereby implementing the above mention protection against page faults
and memory corruption.
The rest of the commit adapts the code throughout the Genode Labs repositories
regarding the changes. Note that for that code inside Core, the commits mostly
uses a simplified approach by constructing MMIO objects with range
[base..base+SIZE) and not with a mapping- or specification-related range size.
This should be fixed in the future.
Furthermore, there are types that derive from an MMIO class but don't declare
any registers or register arrays (especially with Platform::Device::Mmio). In
this case SIZE is set to 0. This way, the parameters must be actively corrected
by someone who later wants to add registers or register arrays, plus the places
can be easily found by grep'ing for Mmio<0>.
Fix #4081
2024-01-10 14:08:53 +00:00
|
|
|
class Genode::Bios_data_area : Mmio<0x12>
|
2015-07-10 17:58:30 +00:00
|
|
|
{
|
|
|
|
friend Unmanaged_singleton_constructor;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
mmio: upper-bounds checks
The classes Genode::Mmio, Genode::Register_set, Genode::Attached_mmio, and
Platform::Device::Mmio now receive a template parameter 'size_t SIZE'. In each
type that derives from one of these classes, it is now statically checked that
the range of each Genode::Register::Register- and
Genode::Register_set::Register_array-deriving sub-type is within [0..SIZE).
That said, SIZE is the minimum size of the memory region provided to the above
mentioned Mmio classes in order to avoid page faults or memory corruption when
accessing the registers and register arrays declared inside.
Note, that the range end of a register array is not the end of the last item
but the end of integer access that is used for accessing the last bit in the
last item.
The constructors of Genode::Mmio, Genode::Attached_mmio, and
Platform::Device::Mmio now receive an argument 'Byte_range_ptr range' that is
expected to be the range of the backing memory region. In each type that derives
from on of these classes, it is now dynamically checked that 'range.num_bytes
>= SIZE', thereby implementing the above mention protection against page faults
and memory corruption.
The rest of the commit adapts the code throughout the Genode Labs repositories
regarding the changes. Note that for that code inside Core, the commits mostly
uses a simplified approach by constructing MMIO objects with range
[base..base+SIZE) and not with a mapping- or specification-related range size.
This should be fixed in the future.
Furthermore, there are types that derive from an MMIO class but don't declare
any registers or register arrays (especially with Platform::Device::Mmio). In
this case SIZE is set to 0. This way, the parameters must be actively corrected
by someone who later wants to add registers or register arrays, plus the places
can be easily found by grep'ing for Mmio<0>.
Fix #4081
2024-01-10 14:08:53 +00:00
|
|
|
struct Serial_base_com1 : Register<0x0, 16> { };
|
|
|
|
struct Equipment : Register<0x10, 16>
|
2015-07-10 17:58:30 +00:00
|
|
|
{
|
|
|
|
struct Serial_count : Bitfield<9, 3> { };
|
|
|
|
};
|
|
|
|
|
|
|
|
static addr_t _mmio_base_virt();
|
|
|
|
|
mmio: upper-bounds checks
The classes Genode::Mmio, Genode::Register_set, Genode::Attached_mmio, and
Platform::Device::Mmio now receive a template parameter 'size_t SIZE'. In each
type that derives from one of these classes, it is now statically checked that
the range of each Genode::Register::Register- and
Genode::Register_set::Register_array-deriving sub-type is within [0..SIZE).
That said, SIZE is the minimum size of the memory region provided to the above
mentioned Mmio classes in order to avoid page faults or memory corruption when
accessing the registers and register arrays declared inside.
Note, that the range end of a register array is not the end of the last item
but the end of integer access that is used for accessing the last bit in the
last item.
The constructors of Genode::Mmio, Genode::Attached_mmio, and
Platform::Device::Mmio now receive an argument 'Byte_range_ptr range' that is
expected to be the range of the backing memory region. In each type that derives
from on of these classes, it is now dynamically checked that 'range.num_bytes
>= SIZE', thereby implementing the above mention protection against page faults
and memory corruption.
The rest of the commit adapts the code throughout the Genode Labs repositories
regarding the changes. Note that for that code inside Core, the commits mostly
uses a simplified approach by constructing MMIO objects with range
[base..base+SIZE) and not with a mapping- or specification-related range size.
This should be fixed in the future.
Furthermore, there are types that derive from an MMIO class but don't declare
any registers or register arrays (especially with Platform::Device::Mmio). In
this case SIZE is set to 0. This way, the parameters must be actively corrected
by someone who later wants to add registers or register arrays, plus the places
can be easily found by grep'ing for Mmio<0>.
Fix #4081
2024-01-10 14:08:53 +00:00
|
|
|
Bios_data_area() : Mmio({(char *)(_mmio_base_virt() + 0x400), Mmio::SIZE}) { }
|
2015-07-10 17:58:30 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Obtain I/O ports of COM interfaces from BDA
|
|
|
|
*/
|
2021-12-02 10:21:14 +00:00
|
|
|
uint16_t serial_port() const
|
2015-07-10 17:58:30 +00:00
|
|
|
{
|
|
|
|
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>(); }
|
|
|
|
};
|
|
|
|
|
2015-09-03 12:55:05 +00:00
|
|
|
#endif /* _INCLUDE__SPEC__X86__BIOS_DATA_AREA_H_ */
|