hw: factor out x86 specific bootinfo

Ref #3326
This commit is contained in:
Stefan Kalkowski 2019-05-16 14:20:39 +02:00 committed by Christian Helmuth
parent 054df95ea4
commit 5c77ebb1fb
27 changed files with 96 additions and 40 deletions

View File

@ -196,8 +196,7 @@ Platform::Platform()
*construct_at<Boot_info>(bi_base, (addr_t)&core_pd->table, *construct_at<Boot_info>(bi_base, (addr_t)&core_pd->table,
(addr_t)&core_pd->array, (addr_t)&core_pd->array,
core_pd->mappings, boot_modules, core_pd->mappings, boot_modules,
board.core_mmio, board.acpi_rsdp, board.core_mmio, board.cpus, board.info);
board.framebuffer, board.cpus);
/* add all left RAM to bootinfo */ /* add all left RAM to bootinfo */
ram_alloc.for_each_free_region([&] (Memory_region const & r) { ram_alloc.for_each_free_region([&] (Memory_region const & r) {

View File

@ -27,7 +27,7 @@ namespace Bootstrap {
using Genode::addr_t; using Genode::addr_t;
using Genode::size_t; using Genode::size_t;
using Hw::Boot_info; using Boot_info = Hw::Boot_info<::Board::Boot_info>;
using Hw::Mmio_space; using Hw::Mmio_space;
using Hw::Mapping; using Hw::Mapping;
using Hw::Memory_region; using Hw::Memory_region;
@ -45,9 +45,8 @@ class Bootstrap::Platform
Memory_region_array early_ram_regions { }; Memory_region_array early_ram_regions { };
Memory_region_array late_ram_regions { }; Memory_region_array late_ram_regions { };
Mmio_space const core_mmio; Mmio_space const core_mmio;
Hw::Acpi_rsdp acpi_rsdp { };
Hw::Framebuffer framebuffer { };
unsigned cpus { NR_OF_CPUS }; unsigned cpus { NR_OF_CPUS };
::Board::Boot_info info { };
Board(); Board();
}; };

View File

@ -69,6 +69,7 @@ Bootstrap::Platform::Board::Board()
Memory_region { __initial_bx & ~0xFFFUL, Memory_region { __initial_bx & ~0xFFFUL,
get_page_size() }) get_page_size() })
{ {
Hw::Acpi_rsdp & acpi_rsdp = info.acpi_rsdp;
static constexpr size_t initial_map_max = 1024 * 1024 * 1024; static constexpr size_t initial_map_max = 1024 * 1024 * 1024;
auto lambda = [&] (addr_t base, addr_t size) { auto lambda = [&] (addr_t base, addr_t size) {
@ -117,7 +118,7 @@ Bootstrap::Platform::Board::Board()
acpi_rsdp = rsdp; acpi_rsdp = rsdp;
}, },
[&] (Hw::Framebuffer const &fb) { [&] (Hw::Framebuffer const &fb) {
framebuffer = fb; info.framebuffer = fb;
}); });
} else if (__initial_ax == Multiboot_info::MAGIC) { } else if (__initial_ax == Multiboot_info::MAGIC) {
for (unsigned i = 0; true; i++) { for (unsigned i = 0; true; i++) {

View File

@ -19,6 +19,7 @@
#include <kernel/irq.h> #include <kernel/irq.h>
#include <kernel/pd.h> #include <kernel/pd.h>
#include <pic.h> #include <pic.h>
#include <board.h>
#include <hw/assert.h> #include <hw/assert.h>
#include <hw/boot_info.h> #include <hw/boot_info.h>
@ -186,5 +187,6 @@ Cpu & Cpu_pool::cpu(unsigned const id)
} }
using Boot_info = Hw::Boot_info<Board::Boot_info>;
Cpu_pool::Cpu_pool() Cpu_pool::Cpu_pool()
: _count(reinterpret_cast<Hw::Boot_info*>(Hw::Mm::boot_info().base)->cpus) { } : _count(reinterpret_cast<Boot_info*>(Hw::Mm::boot_info().base)->cpus) { }

View File

@ -40,8 +40,8 @@ using namespace Genode;
** Platform ** ** Platform **
**************/ **************/
Hw::Boot_info const & Platform::_boot_info() { Hw::Boot_info<Board::Boot_info> const & Platform::_boot_info() {
return *reinterpret_cast<Hw::Boot_info*>(Hw::Mm::boot_info().base); } return *reinterpret_cast<Hw::Boot_info<Board::Boot_info>*>(Hw::Mm::boot_info().base); }
addr_t Platform::mmio_to_virt(addr_t mmio) { addr_t Platform::mmio_to_virt(addr_t mmio) {
return _boot_info().mmio_space.virt_addr(mmio); } return _boot_info().mmio_space.virt_addr(mmio); }

View File

@ -34,6 +34,7 @@
#include <core_mem_alloc.h> #include <core_mem_alloc.h>
#include <translation_table.h> #include <translation_table.h>
#include <assertion.h> #include <assertion.h>
#include <board.h>
namespace Genode { namespace Genode {
class Address_space; class Address_space;
@ -50,7 +51,7 @@ class Genode::Platform : public Genode::Platform_generic
Phys_allocator _irq_alloc; /* IRQ allocator */ Phys_allocator _irq_alloc; /* IRQ allocator */
Rom_fs _rom_fs { }; /* ROM file system */ Rom_fs _rom_fs { }; /* ROM file system */
static Hw::Boot_info const &_boot_info(); static Hw::Boot_info<Board::Boot_info> const &_boot_info();
static Hw::Memory_region_array const & _core_virt_regions(); static Hw::Memory_region_array const & _core_virt_regions();
/** /**

View File

@ -14,11 +14,10 @@
#ifndef _CORE__SPEC__X86_64__MUEN__BOARD_H_ #ifndef _CORE__SPEC__X86_64__MUEN__BOARD_H_
#define _CORE__SPEC__X86_64__MUEN__BOARD_H_ #define _CORE__SPEC__X86_64__MUEN__BOARD_H_
#include <drivers/uart/x86_pc.h> #include <hw/spec/x86_64/pc_board.h>
namespace Board { namespace Board {
struct Serial; using namespace Hw::Pc_board;
enum Dummies { UART_BASE, UART_CLOCK };
enum { enum {
TIMER_BASE_ADDR = 0xe00010000, TIMER_BASE_ADDR = 0xe00010000,
@ -34,9 +33,4 @@ namespace Board {
}; };
} }
struct Board::Serial : Genode::X86_uart {
Serial(Genode::addr_t, Genode::size_t, unsigned);
};
#endif /* _CORE__SPEC__X86_64__MUEN__BOARD_H_ */ #endif /* _CORE__SPEC__X86_64__MUEN__BOARD_H_ */

View File

@ -21,9 +21,9 @@ using namespace Genode;
void Platform::_init_additional_platform_info(Xml_generator &xml) void Platform::_init_additional_platform_info(Xml_generator &xml)
{ {
xml.node("acpi", [&] () { xml.node("acpi", [&] () {
uint32_t const revision = _boot_info().acpi_rsdp.revision; uint32_t const revision = _boot_info().plat_info.acpi_rsdp.revision;
uint32_t const rsdt = _boot_info().acpi_rsdp.rsdt; uint32_t const rsdt = _boot_info().plat_info.acpi_rsdp.rsdt;
uint64_t const xsdt = _boot_info().acpi_rsdp.xsdt; uint64_t const xsdt = _boot_info().plat_info.acpi_rsdp.xsdt;
if (revision && (rsdt || xsdt)) { if (revision && (rsdt || xsdt)) {
xml.attribute("revision", revision); xml.attribute("revision", revision);
@ -36,7 +36,7 @@ void Platform::_init_additional_platform_info(Xml_generator &xml)
}); });
xml.node("boot", [&] () { xml.node("boot", [&] () {
xml.node("framebuffer", [&] () { xml.node("framebuffer", [&] () {
Hw::Framebuffer const &boot_fb = _boot_info().framebuffer; Hw::Framebuffer const &boot_fb = _boot_info().plat_info.framebuffer;
xml.attribute("phys", String<32>(Hex(boot_fb.addr))); xml.attribute("phys", String<32>(Hex(boot_fb.addr)));
xml.attribute("width", boot_fb.width); xml.attribute("width", boot_fb.width);
xml.attribute("height", boot_fb.height); xml.attribute("height", boot_fb.height);

View File

@ -14,12 +14,11 @@
#ifndef _SRC__LIB__HW__BOOT_INFO_H_ #ifndef _SRC__LIB__HW__BOOT_INFO_H_
#define _SRC__LIB__HW__BOOT_INFO_H_ #define _SRC__LIB__HW__BOOT_INFO_H_
#include <hw/acpi_rsdp.h>
#include <hw/memory_map.h> #include <hw/memory_map.h>
#include <hw/framebuffer.h>
namespace Hw { struct Boot_info; } namespace Hw { template <typename> struct Boot_info; }
template <typename PLAT_INFO>
struct Hw::Boot_info struct Hw::Boot_info
{ {
using Mapping_pool = Array<Mapping, 32>; using Mapping_pool = Array<Mapping, 32>;
@ -30,22 +29,19 @@ struct Hw::Boot_info
Mapping const boot_modules; Mapping const boot_modules;
Mmio_space const mmio_space; Mmio_space const mmio_space;
Memory_region_array ram_regions { }; Memory_region_array ram_regions { };
Acpi_rsdp const acpi_rsdp;
Framebuffer const framebuffer;
unsigned const cpus; unsigned const cpus;
PLAT_INFO const plat_info;
Boot_info(addr_t const table, Boot_info(addr_t const table,
addr_t const table_alloc, addr_t const table_alloc,
Mapping_pool const elf_mappings, Mapping_pool const elf_mappings,
Mapping const boot_modules, Mapping const boot_modules,
Mmio_space const mmio_space, Mmio_space const mmio_space,
Acpi_rsdp const &acpi_rsdp, unsigned const cpus,
Framebuffer const &fb, PLAT_INFO const &plat_info)
unsigned const &cpus)
: table(table), table_allocator(table_alloc), : table(table), table_allocator(table_alloc),
elf_mappings(elf_mappings), boot_modules(boot_modules), elf_mappings(elf_mappings), boot_modules(boot_modules),
mmio_space(mmio_space), acpi_rsdp(acpi_rsdp), framebuffer(fb), mmio_space(mmio_space), cpus(cpus), plat_info(plat_info) {}
cpus(cpus) {}
}; };
#endif /* _SRC__LIB__HW__BOOT_INFO_H_ */ #endif /* _SRC__LIB__HW__BOOT_INFO_H_ */

View File

@ -16,6 +16,7 @@
#include <drivers/defs/arndale.h> #include <drivers/defs/arndale.h>
#include <drivers/uart/exynos.h> #include <drivers/uart/exynos.h>
#include <hw/spec/arm/boot_info.h>
#include <hw/spec/arm/cortex_a15.h> #include <hw/spec/arm/cortex_a15.h>
namespace Hw::Arndale_board { namespace Hw::Arndale_board {

View File

@ -0,0 +1,19 @@
/*
* \brief Boot information for ARM
* \author Stefan Kalkowski
* \date 2019-05-16
*/
/*
* Copyright (C) 2019 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _SRC__LIB__HW__SPEC__ARM__BOOT_INFO_H_
#define _SRC__LIB__HW__SPEC__ARM__BOOT_INFO_H_
namespace Board { struct Boot_info {}; }
#endif /* _SRC__LIB__HW__SPEC__ARM__BOOT_INFO_H_ */

View File

@ -16,6 +16,7 @@
#include <drivers/defs/imx53_qsb.h> #include <drivers/defs/imx53_qsb.h>
#include <drivers/uart/imx.h> #include <drivers/uart/imx.h>
#include <hw/spec/arm/boot_info.h>
namespace Hw::Imx53_qsb_board { namespace Hw::Imx53_qsb_board {
using namespace Imx53_qsb; using namespace Imx53_qsb;

View File

@ -16,6 +16,7 @@
#include <drivers/defs/imx6q_sabrelite.h> #include <drivers/defs/imx6q_sabrelite.h>
#include <drivers/uart/imx.h> #include <drivers/uart/imx.h>
#include <hw/spec/arm/boot_info.h>
#include <hw/spec/arm/cortex_a9.h> #include <hw/spec/arm/cortex_a9.h>
#include <hw/spec/arm/pl310.h> #include <hw/spec/arm/pl310.h>

View File

@ -16,7 +16,7 @@
#include <drivers/defs/imx7d_sabre.h> #include <drivers/defs/imx7d_sabre.h>
#include <drivers/uart/imx.h> #include <drivers/uart/imx.h>
#include <hw/spec/arm/boot_info.h>
#include <hw/spec/arm/cortex_a15.h> #include <hw/spec/arm/cortex_a15.h>
namespace Hw::Imx7d_sabre_board { namespace Hw::Imx7d_sabre_board {

View File

@ -16,6 +16,7 @@
#include <drivers/defs/nit6_solox.h> #include <drivers/defs/nit6_solox.h>
#include <drivers/uart/imx.h> #include <drivers/uart/imx.h>
#include <hw/spec/arm/boot_info.h>
#include <hw/spec/arm/cortex_a9.h> #include <hw/spec/arm/cortex_a9.h>
#include <hw/spec/arm/pl310.h> #include <hw/spec/arm/pl310.h>

View File

@ -16,7 +16,7 @@
#include <drivers/defs/odroid_xu.h> #include <drivers/defs/odroid_xu.h>
#include <drivers/uart/exynos.h> #include <drivers/uart/exynos.h>
#include <hw/spec/arm/boot_info.h>
#include <hw/spec/arm/cortex_a15.h> #include <hw/spec/arm/cortex_a15.h>
namespace Hw::Odroid_xu_board { namespace Hw::Odroid_xu_board {

View File

@ -17,6 +17,7 @@
#include <base/stdint.h> #include <base/stdint.h>
#include <drivers/defs/panda.h> #include <drivers/defs/panda.h>
#include <drivers/uart/tl16c750.h> #include <drivers/uart/tl16c750.h>
#include <hw/spec/arm/boot_info.h>
#include <hw/spec/arm/cortex_a9.h> #include <hw/spec/arm/cortex_a9.h>
#include <hw/spec/arm/pl310.h> #include <hw/spec/arm/pl310.h>

View File

@ -16,6 +16,7 @@
#include <drivers/defs/pbxa9.h> #include <drivers/defs/pbxa9.h>
#include <drivers/uart/pl011.h> #include <drivers/uart/pl011.h>
#include <hw/spec/arm/boot_info.h>
#include <hw/spec/arm/cortex_a9.h> #include <hw/spec/arm/cortex_a9.h>
#include <hw/spec/arm/pl310.h> #include <hw/spec/arm/pl310.h>

View File

@ -16,6 +16,7 @@
#include <drivers/defs/rpi.h> #include <drivers/defs/rpi.h>
#include <drivers/uart/pl011.h> #include <drivers/uart/pl011.h>
#include <hw/spec/arm/boot_info.h>
namespace Hw::Rpi_board { namespace Hw::Rpi_board {
using namespace Rpi; using namespace Rpi;

View File

@ -16,6 +16,7 @@
#include <drivers/defs/usb_armory.h> #include <drivers/defs/usb_armory.h>
#include <drivers/uart/imx.h> #include <drivers/uart/imx.h>
#include <hw/spec/arm/boot_info.h>
namespace Hw::Usb_armory_board { namespace Hw::Usb_armory_board {
using namespace Usb_armory; using namespace Usb_armory;

View File

@ -18,6 +18,7 @@
#include <drivers/uart/imx.h> #include <drivers/uart/imx.h>
#include <hw/spec/arm/cortex_a9.h> #include <hw/spec/arm/cortex_a9.h>
#include <hw/spec/arm/pl310.h> #include <hw/spec/arm/pl310.h>
#include <hw/spec/arm/boot_info.h>
namespace Hw::Wand_quad_board { namespace Hw::Wand_quad_board {

View File

@ -18,6 +18,7 @@
#include <drivers/uart/xilinx.h> #include <drivers/uart/xilinx.h>
#include <hw/spec/arm/cortex_a9.h> #include <hw/spec/arm/cortex_a9.h>
#include <hw/spec/arm/pl310.h> #include <hw/spec/arm/pl310.h>
#include <hw/spec/arm/boot_info.h>
namespace Hw::Zynq_qemu_board { namespace Hw::Zynq_qemu_board {
using namespace Zynq_qemu; using namespace Zynq_qemu;

View File

@ -14,6 +14,7 @@
#ifndef _SRC__INCLUDE__HW__SPEC__RISCV__BOARD_H_ #ifndef _SRC__INCLUDE__HW__SPEC__RISCV__BOARD_H_
#define _SRC__INCLUDE__HW__SPEC__RISCV__BOARD_H_ #define _SRC__INCLUDE__HW__SPEC__RISCV__BOARD_H_
#include <hw/spec/riscv/boot_info.h>
#include <hw/spec/riscv/page_table.h> #include <hw/spec/riscv/page_table.h>
#include <hw/spec/riscv/uart.h> #include <hw/spec/riscv/uart.h>
#include <drivers/defs/riscv.h> #include <drivers/defs/riscv.h>

View File

@ -0,0 +1,19 @@
/*
* \brief Boot information for RISCV
* \author Stefan Kalkowski
* \date 2019-05-16
*/
/*
* Copyright (C) 2019 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _SRC__LIB__HW__SPEC__RISCV__BOOT_INFO_H_
#define _SRC__LIB__HW__SPEC__RISCV__BOOT_INFO_H_
namespace Board { struct Boot_info {}; }
#endif /* _SRC__LIB__HW__SPEC__RISCV__BOOT_INFO_H_ */

View File

@ -11,8 +11,8 @@
* under the terms of the GNU Affero General Public License version 3. * under the terms of the GNU Affero General Public License version 3.
*/ */
#ifndef _SRC__LIB__HW__ACPI_RSDP_H #ifndef _SRC__LIB__HW__SPEC__X86_64__ACPI_RSDP_H
#define _SRC__LIB__HW__ACPI_RSDP_H #define _SRC__LIB__HW__SPEC__X86_64__ACPI_RSDP_H
#include <base/fixed_stdint.h> #include <base/fixed_stdint.h>
@ -37,4 +37,4 @@ struct Hw::Acpi_rsdp
} }
} __attribute__((packed)); } __attribute__((packed));
#endif /* _SRC__LIB__HW__ACPI_RSDP_H */ #endif /* _SRC__LIB__HW__SPEC__X86_64__ACPI_RSDP_H */

View File

@ -11,8 +11,8 @@
* under the terms of the GNU Affero General Public License version 3. * under the terms of the GNU Affero General Public License version 3.
*/ */
#ifndef _SRC__LIB__HW__FRAMEBUFFER_H #ifndef _SRC__LIB__HW__SPEC__X86_64__FRAMEBUFFER_H
#define _SRC__LIB__HW__FRAMEBUFFER_H #define _SRC__LIB__HW__SPEC__X86_64__FRAMEBUFFER_H
#include <base/fixed_stdint.h> #include <base/fixed_stdint.h>
@ -30,4 +30,4 @@ struct Hw::Framebuffer
Genode::uint8_t type; Genode::uint8_t type;
} __attribute__((packed)); } __attribute__((packed));
#endif /* _SRC__LIB__HW__FRAMEBUFFER_H */ #endif /* _SRC__LIB__HW__SPEC__X86_64__FRAMEBUFFER_H */

View File

@ -15,8 +15,11 @@
#define _SRC__INCLUDE__HW__SPEC__X86_64__PC_BOARD_H_ #define _SRC__INCLUDE__HW__SPEC__X86_64__PC_BOARD_H_
#include <drivers/uart/x86_pc.h> #include <drivers/uart/x86_pc.h>
#include <hw/spec/x86_64/acpi_rsdp.h>
#include <hw/spec/x86_64/framebuffer.h>
namespace Hw::Pc_board { namespace Hw::Pc_board {
struct Boot_info;
struct Serial; struct Serial;
enum Dummies { UART_BASE, UART_CLOCK }; enum Dummies { UART_BASE, UART_CLOCK };
} }
@ -27,4 +30,16 @@ struct Hw::Pc_board::Serial : Genode::X86_uart
Serial(Genode::addr_t, Genode::size_t, unsigned); Serial(Genode::addr_t, Genode::size_t, unsigned);
}; };
struct Hw::Pc_board::Boot_info
{
Acpi_rsdp acpi_rsdp { };
Framebuffer framebuffer { };
Boot_info() {}
Boot_info(Acpi_rsdp const &acpi_rsdp,
Framebuffer const &fb)
: acpi_rsdp(acpi_rsdp), framebuffer(fb) {}
};
#endif /* _SRC__BOOTSTRAP__SPEC__X86_64__BOARD_H_ */ #endif /* _SRC__BOOTSTRAP__SPEC__X86_64__BOARD_H_ */