Added port of MxTasking with sample application.

This commit is contained in:
Michael Müller
2022-07-06 15:32:47 +02:00
parent 6b7fae0643
commit 142ef47861
6 changed files with 140 additions and 0 deletions

View File

@@ -0,0 +1 @@
INC_DIR += $(call select_from_ports,mxtasking)/include/mxtasking

View File

@@ -0,0 +1,17 @@
MXTASKING_DIR := $(call select_from_ports,mxtasking)/src/lib/mxtasking
vpath %.cpp $(MXTASKING_DIR)/src/mx
INC_DIR += $(MXTASKING_DIR)/src/mx $(MXTASKING_DIR)/lib
vpath %.h ${INC_DIR}
CC_OPT += -pedantic -Wall -Wextra -Werror \
-Wno-invalid-offsetof -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization \
-Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Woverloaded-virtual \
-Wredundant-decls -Wshadow -Wsign-promo -Wstrict-overflow=5 -Wswitch-default -Wundef \
-Wno-unused -Wold-style-cast -Wno-uninitialized -O1 -g3
CC_OPT += $(addprefix -I ,$(INC_DIR))
LIBS += libm libc stdcxx
SHARED_LIB = yes

View File

@@ -0,0 +1,11 @@
LICENSE := MIT
VERSION := 0.1
DOWNLOADS := mxtasking.archive
URL(mxtasking) := https://github.com/mmmueller41/mxtasking.git
SHA(mxtasking :=
DIR(mxtasking) := src/lib/mxtasking
DIRS := include/mxtasking
DIR_CONTENT(include/mxtasking) := $(addprefix src/lib/mxtasking/,*.h)
#PATCHES :=

View File

@@ -0,0 +1,43 @@
build "core init timer app/hello_mxtask"
create_boot_directory
install_config {
<config>
<parent-provides>
<service name="LOG"/>
<service name="PD"/>
<service name="CPU"/>
<service name="ROM"/>
<service name="RAM"/>
<service name="IRQ"/>
<service name="IO_MEM"/>
<service name="IO_PORT"/>
<service name="CAP"/>
<service name="RM"/>
<service name="SIGNAL"/>
</parent-provides>
<default-route>
<any-service><parent/><any-child/></any-service>
</default-route>
<default caps="200"/>
<start name="timer">
<resource name="RAM" quantum="1M"/>
<provides><service name="Timer"/></provides>
<route>
<any-service><parent/><any-child/></any-service>
</route>
</start>
<start name="hello_mxtask">
<resource name="RAM" quantum="10M"/>
<route>
<service name="Timer"> <child name="timer"/> </service>
<any-service><parent/><any-child/></any-service>
</route>
</start>
</config>
}
set boot_modules {
core init timer vfs.lib.so ld.lib.so libm.lib.so libc.lib.so stdcxx.lib.so mxtasking.lib.so hello_mxtask
}
build_boot_image $boot_modules
append qemu_args "-nographic -m 64"

View File

@@ -0,0 +1,64 @@
/* Hello world appication from https://github.com/jmuehlig/mxtasking/src/application/hello_world */
/* MIT License
Copyright (c) 2021 Jan Mühlig <jan.muehlig@tu-dortmund.de>
Modified by Michael Müller <michael.mueller@uos.de> for use on Genode OS.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. */
#include <base/component.h>
#include <mxtasking/runtime.h>
class HelloWorldTask : public mx::tasking::TaskInterface
{
public:
constexpr HelloWorldTask() = default;
~HelloWorldTask() override = default;
mx::tasking::TaskResult execute(const std::uint16_t /*core_id*/, const std::uint16_t /*channel_id*/) override
{
std::cout << "Hello World" << std::endl;
// Stop MxTasking runtime after this task.
return mx::tasking::TaskResult::make_stop();
}
};
void Component::construct(Genode::Env &env)
{
// Define which cores will be used (1 core here).
const auto cores = mx::util::core_set::build(1);
mx::system::Environment::env = env;
{ // Scope for the MxTasking runtime.
// Create a runtime for the given cores.
mx::tasking::runtime_guard _{cores};
// Create an instance of the HelloWorldTask with the current core as first
// parameter. The core is required for memory allocation.
auto *hello_world_task = mx::tasking::runtime::new_task<HelloWorldTask>(cores.front());
// Annotate the task to run on the first core.
hello_world_task->annotate(cores.front());
// Schedule the task.
mx::tasking::runtime::spawn(*hello_world_task);
}
}

View File

@@ -0,0 +1,4 @@
TARGET = hello_mxtask
SRC_CC = main.cc
LIBS += base libm libc stdcxx mxtasking
CXXFLAGS += -Wno-error