Commit 5c5a7ea2 authored by Christian Dietrich's avatar Christian Dietrich

osek-v: bench-coptermock workz!

A few changes had to be done at the osek-v port in order to support
bench-coptermock application:

- interrupt support
- slower timer interrupt
- arch_startup has to return normally
- implement interrupt control system calls

Change-Id: I6fe5c046a9bd1fc6422c5abcc9aa2041cceae990
parent e24cffbe
#ifndef __OSEK_V_DISPATCHER_H__
#define __OSEK_V_DISPATCHER_H__
#include "os/scheduler/task.h"
namespace arch {
struct Dispatcher {
static void ResumeToTask(const os::scheduler::Task &x) {};
};
}
#endif
......@@ -32,7 +32,6 @@ extern "C" void interrupt_handler(long long mcause, uintptr_t sp) {
kout << "htif interrupt " << hex << fromhost << endl;
bad_trap();
} else if (device == 1) {
kout << ":";
arch::Timer::tick();
return;
} else if (device == 0) {
......
#ifndef __OSEKOS_INTERRUPT_H__
#define __OSEKOS_INTERRUPT_H__
namespace arch{
typedef void (*interrupt_handler_t)(unsigned char);
extern interrupt_handler_t isr_table[];
void bad_soft_irq(unsigned char);
}
#endif
......@@ -85,7 +85,12 @@ public:
* The static ACPI values used work for QEMU and Bochs but probably not on real PCs!
*/
static forceinline void shutdown(void) {
do { write_csr(mtohost, 1); } while(1);
asm volatile (
"1:\n"
" csrwi mtohost, 1\n"
" j 1b\n"
);
}
static forceinline void * exchange_saved_ip(unsigned id, void *pc) {
......
......@@ -13,7 +13,7 @@ void Timer::init() {
void Timer::reload() {
uintptr_t time = Machine::read_csr(mtime);
Machine::write_csr(mtimecmp, time + 2);
Machine::write_csr(mtimecmp, time + 50);
}
void Timer::tick() {
......
......@@ -46,7 +46,8 @@ class _toCHeader:
def key(self, path):
if path[-1] == "self":
path = path[:-1]
return "CONFIG_" + ("_".join([x.replace("-", "_") for x in path])).upper()
ret = "CONFIG_" + ("_".join([x.replace("-", "_") for x in path])).upper()
return ret
def cmake_value(self, value, ty):
if isinstance(ty, Boolean):
......@@ -72,7 +73,7 @@ class _toCHeader:
if sym == v:
ret += "#define %s_%s 1\n" % (macro, sym.upper().replace("-", "_"))
else:
ret += "#undef %s_%s\n" % (macro, sym.upper())
ret += "#undef %s_%s\n" % (macro, sym.upper().replace("-", "_"))
return "#ifndef __CONFIG_HEADER_H\n#define __CONFIG_HEADER_H\n" \
+ ret \
+ "#endif\n"
......
......@@ -45,14 +45,6 @@ inlinehint void test_main(void)
// run tests
test();
// finish tests
test_finish();
// halt system
debug.setcolor(Color::RED, Color::WHITE);
debug << "dOSEK halt" << endl;
Machine::shutdown();
}
inlinehint void test_trace(uint32_t val)\
......
......@@ -25,6 +25,8 @@ class OSEKVArch(GenericArch):
self.generate_dataobjects_task_descriptors()
self.generate_rocket_config()
# For dummy ResumeToTask
self.generator.source_file.include("dispatch.h")
def generate_dataobjects_task_descriptors(self):
self.generator.source_file.include("os/scheduler/task.h")
......@@ -132,3 +134,4 @@ class OSEKVArch(GenericArch):
def get_syscall_argument(self, block, i):
name, typename = block.arguments()[i]
return VariableDefinition(typename, name)
......@@ -19,6 +19,13 @@ class WiredSystemCalls(BaseCoder):
self.syscall_map = {}
self.alarms = AlarmTemplate
def task_desc(self, subtask):
"""Returns a string that generates the task id"""
task_desc = subtask.impl.task_descriptor.name
return task_desc
def get_calling_task_desc(self, abb):
return self.task_desc(abb.function.subtask)
def generate_system_code(self):
self.generator.source_file.include("output.h")
......@@ -142,52 +149,59 @@ class WiredSystemCalls(BaseCoder):
# Do not overwrite: AcquireCheckedObject
# Do not overwrite: ReleaseCheckedObject
# def SetRelAlarm(self, syscall, userspace, kernelspace):
# self.fsm_event(syscall, userspace, kernelspace)
# FullSystemCalls.SetRelAlarm(self, syscall, userspace, kernelspace)
#
# def GetAlarm(self, syscall, userspace, kernelspace):
# self.fsm_event(syscall, userspace, kernelspace)
# FullSystemCalls.GetAlarm(self, syscall, userspace, kernelspace)
#
# def CancelAlarm(self, syscall, userspace, kernelspace):
# self.fsm_event(syscall, userspace, kernelspace)
# FullSystemCalls.CancelAlarm(self, syscall, userspace, kernelspace)
#
# def DisableAllInterrupts(self, syscall, userspace, kernelspace):
# self.fsm_event(syscall, userspace, kernelspace)
# FullSystemCalls.DisableAllInterrupts(self, syscall, userspace, kernelspace)
#
# def SuspendAllInterrupts(self, syscall, userspace, kernelspace):
# self.fsm_event(syscall, userspace, kernelspace)
# FullSystemCalls.SuspendAllInterrupts(self, syscall, userspace, kernelspace)
#
# def SuspendOSInterrupts(self, syscall, userspace, kernelspace):
# self.fsm_event(syscall, userspace, kernelspace)
# FullSystemCalls.SuspendOSInterrupts(self, syscall, userspace, kernelspace)
#
# def EnableAllInterrupts(self, syscall, userspace, kernelspace):
# self.fsm_event(syscall, userspace, kernelspace)
# FullSystemCalls.EnableAllInterrupts(self, syscall, userspace, kernelspace)
#
# def ResumeAllInterrupts(self, syscall, userspace, kernelspace):
# self.fsm_event(syscall, userspace, kernelspace)
# FullSystemCalls.ResumeAllInterrupts(self, syscall, userspace, kernelspace)
#
# def ResumeOSInterrupts(self, syscall, userspace, kernelspace):
# self.fsm_event(syscall, userspace, kernelspace)
# FullSystemCalls.ResumeOSInterrupts(self, syscall, userspace, kernelspace)
#
# def AcquireCheckedObject(self, syscall, userspace, kernelspace):
# self.fsm_event(syscall, userspace, kernelspace)
# FullSystemCalls.AcquireCheckedObject(self, syscall, userspace, kernelspace)
#
# def ReleaseCheckedObject(self, syscall, userspace, kernelspace):
# self.fsm_event(syscall, userspace, kernelspace)
# FullSystemCalls.ReleaseCheckedObject(self, syscall, userspace, kernelspace)
def SetRelAlarm(self, syscall, userspace, kernelspace):
self.fsm_schedule(syscall, userspace, kernelspace)
FullSystemCalls.SetRelAlarm(self, syscall, userspace, kernelspace)
def GetAlarm(self, syscall, userspace, kernelspace):
self.fsm_schedule(syscall, userspace, kernelspace)
FullSystemCalls.GetAlarm(self, syscall, userspace, kernelspace)
def CancelAlarm(self, syscall, userspace, kernelspace):
self.fsm_schedule(syscall, userspace, kernelspace)
FullSystemCalls.CancelAlarm(self, syscall, userspace, kernelspace)
def DisableAllInterrupts(self, syscall, userspace, kernelspace):
self.fsm_schedule(syscall, userspace, kernelspace)
FullSystemCalls.DisableAllInterrupts(self, syscall, userspace, kernelspace)
def SuspendAllInterrupts(self, syscall, userspace, kernelspace):
self.fsm_schedule(syscall, userspace, kernelspace)
FullSystemCalls.SuspendAllInterrupts(self, syscall, userspace, kernelspace)
def SuspendOSInterrupts(self, syscall, userspace, kernelspace):
self.fsm_schedule(syscall, userspace, kernelspace)
FullSystemCalls.SuspendOSInterrupts(self, syscall, userspace, kernelspace)
def EnableAllInterrupts(self, syscall, userspace, kernelspace):
self.fsm_schedule(syscall, userspace, kernelspace)
FullSystemCalls.EnableAllInterrupts(self, syscall, userspace, kernelspace)
def ResumeAllInterrupts(self, syscall, userspace, kernelspace):
self.fsm_schedule(syscall, userspace, kernelspace)
FullSystemCalls.ResumeAllInterrupts(self, syscall, userspace, kernelspace)
def ResumeOSInterrupts(self, syscall, userspace, kernelspace):
self.fsm_schedule(syscall, userspace, kernelspace)
FullSystemCalls.ResumeOSInterrupts(self, syscall, userspace, kernelspace)
def AcquireCheckedObject(self, syscall, userspace, kernelspace):
self.fsm_schedule(syscall, userspace, kernelspace)
FullSystemCalls.AcquireCheckedObject(self, syscall, userspace, kernelspace)
def ReleaseCheckedObject(self, syscall, userspace, kernelspace):
self.fsm_schedule(syscall, userspace, kernelspace)
FullSystemCalls.ReleaseCheckedObject(self, syscall, userspace, kernelspace)
def do_assertions(self, block, assertions):
"""We do not support assertions for a FSM kernel"""
logging.error("Assertions are not implemented for the FSM coder")
def enable_irq(self, *args):
FullSystemCalls.enable_irq(self, *args)
def disable_irq(self, *args):
FullSystemCalls.disable_irq(self, *args)
......@@ -12,9 +12,11 @@
//
//===----------------------------------------------------------------------===//
#define llvm33 (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MAJOR == 3)
#define llvm34 (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MAJOR == 4)
#define llvm33 (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR == 3)
#define llvm34 (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR == 4)
#ifndef __CLANG_MAX_ALIGN_T_DEFINED
#if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L
typedef struct {
long long __clang_max_align_nonce1
......@@ -24,6 +26,7 @@ typedef struct {
} max_align_t;
#define __CLANG_MAX_ALIGN_T_DEFINED
#endif
#endif
//3.6 #include <llvm/Linker/Linker.h>
//3.6 #include <llvm/IR/Verifier.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment