-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* first stab * patmos fixes * Patmos: fix function names * clean up * remove patmos examples, because they are in the template * clean up * clang19 formatting * Some small fixes --------- Co-authored-by: Martin Schoeberl <[email protected]> Co-authored-by: erlingrj <[email protected]>
- Loading branch information
1 parent
6e90658
commit b3c391a
Showing
8 changed files
with
137 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef REACTOR_UC_PLATFORM_PATMOS_H | ||
#define REACTOR_UC_PLATFORM_PATMOS_H | ||
|
||
#include "reactor-uc/platform.h" | ||
#include "stdbool.h" | ||
|
||
typedef struct { | ||
Platform super; | ||
bool async_event; | ||
} PlatformPatmos; | ||
|
||
void PlatformPatmos_ctor(Platform *self); | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#include "reactor-uc/platform/patmos/patmos.h" | ||
#include <assert.h> | ||
#include <stdbool.h> | ||
#include <string.h> | ||
|
||
#include <machine/rtc.h> | ||
#include <machine/exceptions.h> | ||
|
||
static PlatformPatmos platform; | ||
|
||
void Platform_vprintf(const char *fmt, va_list args) { vprintf(fmt, args); } | ||
|
||
lf_ret_t PlatformPatmos_initialize(Platform *self) { | ||
(void)self; | ||
return LF_OK; | ||
} | ||
|
||
instant_t PlatformPatmos_get_physical_time(Platform *self) { | ||
(void)self; | ||
return USEC(get_cpu_usecs()); | ||
} | ||
|
||
lf_ret_t PlatformPatmos_wait_until_interruptible(Platform *untyped_self, instant_t wakeup_time) { | ||
PlatformPatmos *self = (PlatformPatmos *)untyped_self; | ||
self->async_event = false; | ||
untyped_self->leave_critical_section(untyped_self); // turing on interrupts | ||
|
||
instant_t now = untyped_self->get_physical_time(untyped_self); | ||
|
||
// Do busy sleep | ||
do { | ||
now = untyped_self->get_physical_time(untyped_self); | ||
} while ((now < wakeup_time) && !self->async_event); | ||
|
||
untyped_self->enter_critical_section(untyped_self); | ||
|
||
if (self->async_event) { | ||
self->async_event = false; | ||
return LF_ERR; | ||
} else { | ||
return LF_OK; | ||
} | ||
|
||
interval_t sleep_duration = wakeup_time - untyped_self->get_physical_time(untyped_self); | ||
if (sleep_duration < 0) { | ||
return LF_OK; | ||
} | ||
|
||
untyped_self->leave_critical_section(untyped_self); | ||
|
||
return LF_OK; | ||
} | ||
|
||
lf_ret_t PlatformPatmos_wait_until(Platform *untyped_self, instant_t wakeup_time) { | ||
interval_t sleep_duration = wakeup_time - untyped_self->get_physical_time(untyped_self); | ||
if (sleep_duration < 0) { | ||
return LF_OK; | ||
} | ||
|
||
instant_t now = untyped_self->get_physical_time(untyped_self); | ||
|
||
// Do busy sleep | ||
do { | ||
now = untyped_self->get_physical_time(untyped_self); | ||
} while (now < wakeup_time); | ||
return LF_OK; | ||
} | ||
|
||
lf_ret_t PlatformPatmos_wait_for(Platform *self, interval_t duration) { | ||
(void)self; | ||
if (duration <= 0) { | ||
return LF_OK; | ||
} | ||
|
||
instant_t now = self->get_physical_time(self); | ||
instant_t wakeup = now + duration; | ||
|
||
// Do busy sleep | ||
do { | ||
now = self->get_physical_time(self); | ||
} while ((now < wakeup)); | ||
|
||
return LF_OK; | ||
} | ||
|
||
void PlatformPatmos_leave_critical_section(Platform *self) { | ||
(void)self; | ||
intr_enable(); | ||
} | ||
|
||
void PlatformPatmos_enter_critical_section(Platform *self) { | ||
(void)self; | ||
intr_disable(); | ||
} | ||
|
||
void PlatformPatmos_new_async_event(Platform *self) { ((PlatformPatmos *)self)->async_event = true; } | ||
|
||
void Platform_ctor(Platform *self) { | ||
self->initialize = PlatformPatmos_initialize; | ||
self->enter_critical_section = PlatformPatmos_enter_critical_section; | ||
self->leave_critical_section = PlatformPatmos_leave_critical_section; | ||
self->get_physical_time = PlatformPatmos_get_physical_time; | ||
self->wait_until = PlatformPatmos_wait_until; | ||
self->wait_for = PlatformPatmos_wait_for; | ||
self->wait_until_interruptible = PlatformPatmos_wait_until_interruptible; | ||
self->new_async_event = PlatformPatmos_new_async_event; | ||
} | ||
|
||
Platform *Platform_new(void) { return (Platform *)&platform; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
|
||
|
||
#if defined(SCHEDULER_DYNAMIC) | ||
#include "./schedulers/dynamic/scheduler.c" | ||
#elif defined(SCHEDULER_STATIC) | ||
|