hw_x86_64: use 'muen' SPEC to implement aspect

This commit is contained in:
Stefan Kalkowski 2015-06-02 12:11:50 +02:00 committed by Christian Helmuth
parent 750c4ad81d
commit 9f1beaa036
21 changed files with 124 additions and 99 deletions

View File

@ -0,0 +1,10 @@
#
# \brief Build config for parts of core that depend on Muen status
# \author Stefan Kalkowski
# \date 2015-06-02
#
REQUIRES = x86_64
# add library dependencies
LIBS += core-muen_off

View File

@ -0,0 +1,8 @@
#
# \brief Build config for parts of core that depend on Muen status
# \author Stefan Kalkowski
# \date 2015-06-02
#
# add library dependencies
LIBS += core-muen_on

View File

@ -10,8 +10,6 @@ INC_DIR += $(REP_DIR)/src/core/include/spec/x86
# add C++ sources # add C++ sources
SRC_CC += spec/x86/platform_support.cc SRC_CC += spec/x86/platform_support.cc
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/kernel/pd.cc
SRC_CC += spec/x86/cpu.cc SRC_CC += spec/x86/cpu.cc
SRC_CC += spec/x86/bios_data_area.cc SRC_CC += spec/x86/bios_data_area.cc

View File

@ -0,0 +1,17 @@
#
# \brief Build config for Genodes core process
# \author Stefan Kalkowski
# \date 2015-06-02
#
# add assembly sources
SRC_S += spec/x86_64/kernel/crt0_translation_table.s
# add C++ sources
SRC_CC += spec/x86/kernel/thread.cc
SRC_CC += spec/x86/kernel/cpu.cc
SRC_CC += spec/x86/pic.cc
SRC_CC += spec/x86_64/platform_support.cc
# include less specific configuration
include $(REP_DIR)/lib/mk/x86_64/core.inc

View File

@ -0,0 +1,20 @@
#
# \brief Build config for Genodes core process
# \author Stefan Kalkowski
# \date 2015-06-02
#
# add include paths
INC_DIR += $(REP_DIR)/src/core/include/spec/x86_64/muen
# add assembly sources
SRC_S += spec/x86_64/muen/kernel/crt0_translation_table.s
# add C++ sources
SRC_CC += spec/x86_64/muen/kernel/thread.cc
SRC_CC += spec/x86_64/muen/kernel/cpu.cc
SRC_CC += spec/x86_64/muen/platform_support.cc
SRC_CC += spec/x86_64/muen/sinfo.cc
# include less specific configuration
include $(REP_DIR)/lib/mk/x86_64/core.inc

View File

@ -0,0 +1,22 @@
#
# \brief Build config for Genodes core process
# \author Stefan Kalkowski
# \author Martin Stein
# \date 2012-10-04
#
# add include paths
INC_DIR += $(REP_DIR)/src/core/include/spec/x86_64
# add assembly sources
SRC_S += spec/x86_64/mode_transition.s
SRC_S += spec/x86_64/kernel/crt0.s
SRC_S += spec/x86_64/crt0.s
# add C++ sources
SRC_CC += spec/x86_64/kernel/thread_base.cc
SRC_CC += spec/x86_64/idt.cc
SRC_CC += spec/x86_64/tss.cc
# include less specific configuration
include $(REP_DIR)/lib/mk/x86/core.inc

View File

@ -1,25 +1,7 @@
# #
# \brief Build config for Genodes core process # \brief Build config for Genodes core process
# \author Stefan Kalkowski # \author Stefan Kalkowski
# \author Martin Stein # \date 2015-06-02
# \date 2012-10-04
# #
# add include paths LIBS += core-muen
INC_DIR += $(REP_DIR)/src/core/include/spec/x86_64
# add assembly sources
SRC_S += spec/x86_64/mode_transition.s
SRC_S += spec/x86_64/kernel/crt0.s
SRC_S += spec/x86_64/kernel/crt0_translation_table.s
SRC_S += spec/x86_64/crt0.s
# add C++ sources
SRC_CC += spec/x86/pic.cc
SRC_CC += spec/x86_64/kernel/thread_base.cc
SRC_CC += spec/x86_64/platform_support.cc
SRC_CC += spec/x86_64/idt.cc
SRC_CC += spec/x86_64/tss.cc
# include less specific configuration
include $(REP_DIR)/lib/mk/x86/core.inc

View File

@ -1,3 +0,0 @@
include $(REP_DIR)/lib/mk/base-common.inc
vpath kernel/interface.cc $(REP_DIR)/src/base/x86_64

View File

@ -1,35 +0,0 @@
#
# \brief Build config for Genodes core process
# \author Stefan Kalkowski
# \author Martin Stein
# \date 2012-10-04
#
# add include paths
INC_DIR += $(REP_DIR)/src/core/include/spec/x86_64_muen
INC_DIR += $(REP_DIR)/src/core/include/spec/x86_64
INC_DIR += $(REP_DIR)/src/core/include/spec/x86
# add assembly sources
SRC_S += spec/x86_64/mode_transition.s
SRC_S += spec/x86_64/kernel/crt0.s
SRC_S += spec/x86_64_muen/kernel/crt0_translation_table.s
SRC_S += spec/x86_64/crt0.s
# add C++ sources
SRC_CC += spec/x86_64_muen/platform_support.cc
SRC_CC += spec/x86_64_muen/sinfo.cc
SRC_CC += spec/x86_64_muen/kernel/thread.cc
SRC_CC += spec/x86_64_muen/kernel/cpu.cc
SRC_CC += spec/x86_64/kernel/thread_base.cc
SRC_CC += spec/x86_64/idt.cc
SRC_CC += spec/x86_64/tss.cc
SRC_CC += spec/x86/platform_support.cc
SRC_CC += spec/x86/kernel/pd.cc
SRC_CC += spec/x86/cpu.cc
SRC_CC += x86/io_port_session_component.cc
SRC_CC += x86/platform_services.cc
SRC_CC += kernel/vm_thread.cc
# include less specific configuration
include $(REP_DIR)/lib/mk/core.inc

View File

@ -1,19 +1,11 @@
# #
# \brief Build configs that are specific to base-hw/x86_64 on the Muen SK # \brief Build configs that are specific to base-hw/x86_64 on the Muen SK
# \author Martin Stein # \author Reto Buerki
# \date 2011-12-20 # \date 2015-04-14
# #
# denote wich specs are also fullfilled by this spec # denote wich specs are also fullfilled by this spec
SPECS += hw x86_64_muen SPECS += hw_x86_64 muen
SPECS += pci ps2 vesa framebuffer
# configure multiprocessor mode
NR_OF_CPUS = 1
# set address where to link text segment at
LD_TEXT_ADDR ?= 0x200000
# include implied specs # include implied specs
include $(call select_from_repositories,mk/spec-hw.mk) include $(call select_from_repositories,mk/spec-hw_x86_64.mk)
include $(call select_from_repositories,mk/spec-x86_64.mk)

View File

@ -68,7 +68,7 @@ class Genode::Timer
_timer_page = (Subject_timer *)region.address; _timer_page = (Subject_timer *)region.address;
_timer_page->vector = Board::TIMER_VECTOR_KERNEL; _timer_page->vector = Board::TIMER_VECTOR_KERNEL;
PINF("muen-timer: page @0x%llx, frequency %llu kHz, vector %u", PINF("muen-timer: page @0x%llx, frequency %llu kHz, vector %u",
region.address, _tics_per_ms, _timer_page->vector); region.address, _tics_per_ms, _timer_page->vector);
} }
static unsigned interrupt_id(int) static unsigned interrupt_id(int)
@ -90,7 +90,7 @@ class Genode::Timer
{ {
const uint64_t now = rdtsc(); const uint64_t now = rdtsc();
if (_timer_page->value != TIMER_DISABLED if (_timer_page->value != TIMER_DISABLED
&& _timer_page->value > now) { && _timer_page->value > now) {
return _timer_page->value - now; return _timer_page->value - now;
} }
return 0; return 0;

View File

@ -30,13 +30,14 @@ Cpu_idle::Cpu_idle(Cpu * const cpu) : Cpu_job(Cpu_priority::MIN, 0)
void Cpu_idle::exception(unsigned const cpu) void Cpu_idle::exception(unsigned const cpu)
{ {
if (trapno == RESET) { if (trapno == RESET) return;
return;
} else if (trapno >= INTERRUPTS_START && trapno <= INTERRUPTS_END) { if (trapno >= INTERRUPTS_START && trapno <= INTERRUPTS_END) {
pic()->irq_occurred(trapno); pic()->irq_occurred(trapno);
_interrupt(cpu); _interrupt(cpu);
return; return;
} }
PWRN("Unknown exception %lu with error code %lu at ip=%p", trapno, PWRN("Unknown exception %lu with error code %lu at ip=%p", trapno,
errcode, (void *)ip); errcode, (void *)ip);
assert(0); assert(0);

View File

@ -24,6 +24,7 @@ enum {
static const subject_info_type * static const subject_info_type *
const sinfo = ((subject_info_type *)SINFO_BASE_ADDR); const sinfo = ((subject_info_type *)SINFO_BASE_ADDR);
/* Log channel information */ /* Log channel information */
static bool log_channel( static bool log_channel(
const struct Genode::Sinfo::Channel_info * const channel, const struct Genode::Sinfo::Channel_info * const channel,
@ -31,36 +32,37 @@ static bool log_channel(
{ {
if (channel->has_event || channel->has_vector) { if (channel->has_event || channel->has_vector) {
PDBG("muen-sinfo: [%s with %s %03d] %s\n", PDBG("muen-sinfo: [%s with %s %03d] %s\n",
channel->writable ? "writer" : "reader", channel->writable ? "writer" : "reader",
channel->has_event ? "event " : "vector", channel->has_event ? "event " : "vector",
channel->has_event ? channel->event_number : channel->vector, channel->has_event ? channel->event_number : channel->vector,
channel->name); channel->name);
} else { } else {
PDBG("muen-sinfo: [%s with no %s ] %s\n", PDBG("muen-sinfo: [%s with no %s ] %s\n",
channel->writable ? "writer" : "reader", channel->writable ? "writer" : "reader",
channel->writable ? "event " : "vector", channel->writable ? "event " : "vector",
channel->name); channel->name);
} }
return true; return true;
} }
/* Log memory region information */ /* Log memory region information */
static bool log_memregion( static bool log_memregion(
const struct Genode::Sinfo::Memregion_info * const region, const struct Genode::Sinfo::Memregion_info * const region,
void *data) void *data)
{ {
PDBG("muen-sinfo: [addr 0x%016llx size 0x%016llx %s%s] %s\n", PDBG("muen-sinfo: [addr 0x%016llx size 0x%016llx %s%s] %s\n",
region->address, region->size, region->address, region->size,
region->writable ? "rw" : "ro", region->writable ? "rw" : "ro",
region->executable ? "x" : "-", region->name); region->executable ? "x" : "-", region->name);
return true; return true;
} }
/* Fill channel struct with channel information from resource given by index */ /* Fill channel struct with channel information from resource given by index */
static void fill_channel_data( static void fill_channel_data(uint8_t idx,
uint8_t idx, struct Genode::Sinfo::Channel_info *channel)
struct Genode::Sinfo::Channel_info *channel)
{ {
const struct resource_type resource = sinfo->resources[idx]; const struct resource_type resource = sinfo->resources[idx];
const struct memregion_type memregion = const struct memregion_type memregion =
@ -81,10 +83,10 @@ static void fill_channel_data(
channel->vector = channel_info.vector; channel->vector = channel_info.vector;
} }
/* Fill memregion struct with memory region info from resource given by index */ /* Fill memregion struct with memory region info from resource given by index */
static void fill_memregion_data( static void fill_memregion_data(uint8_t idx,
uint8_t idx, struct Genode::Sinfo::Memregion_info *region)
struct Genode::Sinfo::Memregion_info *region)
{ {
const struct resource_type resource = sinfo->resources[idx]; const struct resource_type resource = sinfo->resources[idx];
const struct memregion_type memregion = const struct memregion_type memregion =
@ -99,18 +101,21 @@ static void fill_memregion_data(
region->executable = memregion.flags & MEM_EXECUTABLE_FLAG; region->executable = memregion.flags & MEM_EXECUTABLE_FLAG;
} }
/* Returns true if the given resource is a memory region */ /* Returns true if the given resource is a memory region */
static bool is_memregion(const struct resource_type * const resource) static bool is_memregion(const struct resource_type * const resource)
{ {
return resource->memregion_idx != NO_RESOURCE; return resource->memregion_idx != NO_RESOURCE;
} }
/* Returns true if the given resource is a channel */ /* Returns true if the given resource is a channel */
static bool is_channel(const struct resource_type * const resource) static bool is_channel(const struct resource_type * const resource)
{ {
return is_memregion(resource) && resource->channel_info_idx != NO_RESOURCE; return is_memregion(resource) && resource->channel_info_idx != NO_RESOURCE;
} }
Sinfo::Sinfo() Sinfo::Sinfo()
{ {
if (!check_magic()) { if (!check_magic()) {
@ -119,20 +124,22 @@ Sinfo::Sinfo()
} }
PINF("muen-sinfo: Subject information exports %d memory region(s)\n", PINF("muen-sinfo: Subject information exports %d memory region(s)\n",
sinfo->memregion_count); sinfo->memregion_count);
for_each_memregion(log_memregion, 0); for_each_memregion(log_memregion, 0);
PINF("muen-sinfo: Subject information exports %d channel(s)\n", PINF("muen-sinfo: Subject information exports %d channel(s)\n",
sinfo->channel_info_count); sinfo->channel_info_count);
for_each_channel(log_channel, 0); for_each_channel(log_channel, 0);
} }
bool Sinfo::check_magic(void) bool Sinfo::check_magic(void)
{ {
return sinfo != 0 && sinfo->magic == MUEN_SUBJECT_INFO_MAGIC; return sinfo != 0 && sinfo->magic == MUEN_SUBJECT_INFO_MAGIC;
} }
bool Sinfo::get_channel_info(const char * const name, bool Sinfo::get_channel_info(const char * const name,
struct Channel_info *channel) struct Channel_info *channel)
{ {
int i; int i;
@ -149,8 +156,9 @@ bool Sinfo::get_channel_info(const char * const name,
return false; return false;
} }
bool Sinfo::get_memregion_info(const char * const name, bool Sinfo::get_memregion_info(const char * const name,
struct Memregion_info *memregion) struct Memregion_info *memregion)
{ {
int i; int i;
@ -167,6 +175,7 @@ bool Sinfo::get_memregion_info(const char * const name,
return false; return false;
} }
bool Sinfo::for_each_channel(Channel_cb func, void *data) bool Sinfo::for_each_channel(Channel_cb func, void *data)
{ {
int i; int i;
@ -185,6 +194,7 @@ bool Sinfo::for_each_channel(Channel_cb func, void *data)
return true; return true;
} }
bool Sinfo::for_each_memregion(Memregion_cb func, void *data) bool Sinfo::for_each_memregion(Memregion_cb func, void *data)
{ {
int i; int i;
@ -203,6 +213,7 @@ bool Sinfo::for_each_memregion(Memregion_cb func, void *data)
return true; return true;
} }
uint64_t Sinfo::get_tsc_khz(void) uint64_t Sinfo::get_tsc_khz(void)
{ {
if (!check_magic()) if (!check_magic())
@ -211,6 +222,7 @@ uint64_t Sinfo::get_tsc_khz(void)
return sinfo->tsc_khz; return sinfo->tsc_khz;
} }
uint64_t Sinfo::get_sched_start(void) uint64_t Sinfo::get_sched_start(void)
{ {
if (!check_magic()) if (!check_magic())
@ -219,6 +231,7 @@ uint64_t Sinfo::get_sched_start(void)
return sinfo->tsc_schedule_start; return sinfo->tsc_schedule_start;
} }
uint64_t Sinfo::get_sched_end(void) uint64_t Sinfo::get_sched_end(void)
{ {
if (!check_magic()) if (!check_magic())

View File

@ -146,13 +146,13 @@ proc run_boot_dir {binaries} {
set elf_img "[run_dir]/image.elf" set elf_img "[run_dir]/image.elf"
# Use raw binary object for base-hw on Muen # Use raw binary object for base-hw on Muen
if {[have_spec "hw_x86_64_muen"]} { if {[have_spec "muen"]} {
set raw_img "[run_dir]/image.raw" set raw_img "[run_dir]/image.raw"
exec [cross_dev_prefix]objcopy -O binary bin/$core_bin $raw_img exec [cross_dev_prefix]objcopy -O binary bin/$core_bin $raw_img
exit 0 exit 0
} }
if {[have_spec "x86_64"]} { if {[have_spec "x86_64"] && ![have_spec "muen"]} {
# as startup is done in 32 bit mode, GRUB expects a 32 bit image # as startup is done in 32 bit mode, GRUB expects a 32 bit image
exec [cross_dev_prefix]objcopy -O elf32-i386 bin/$core_bin $elf_img exec [cross_dev_prefix]objcopy -O elf32-i386 bin/$core_bin $elf_img
} }