OpenSBI: Added timer extension

NOTE: I didn't switch to the new functions in the kernel because for
some reason we get a page fault when trying to fetch the first
instruction of set_timer(addi sp, sp, -48). I doubt this is related to
the set_timer funcion itself and is instead some kind of paging or
linking problem because it works fine with paging disabled and really
just doesnt make sense.
This commit is contained in:
Thomas Muller 2022-01-23 23:56:46 -05:00
parent dd373fca85
commit dbfd13630d
Signed by: thomas
GPG key ID: AF006EB730564952
3 changed files with 39 additions and 1 deletions

View file

@ -0,0 +1,25 @@
#include "opensbi/extensions/timer.h"
namespace drivers {
namespace opensbi::timer {
namespace {
enum class ExtensionId {
TIMER = 0x54494D45
};
enum class FunctionId {
SET_TIMER,
};
}
SbiRet set_timer(uint64_t stime_value) {
return ecall(
static_cast<sbiword_t>(ExtensionId::TIMER),
static_cast<sbiword_t>(FunctionId::SET_TIMER),
stime_value);
}
} // End namespace opensbi::timer
} // End namespace drivers

View file

@ -0,0 +1,11 @@
#pragma once
#include "opensbi/opensbi.h"
namespace drivers {
namespace opensbi::timer {
SbiRet set_timer(uint64_t stime_value);
} // End namespace opensbi::timer
} // End namespace drivers

View file

@ -1,7 +1,9 @@
kernel_sources += [
files(
'opensbi.cpp',
'extensions/legacy.cpp'
'extensions/legacy.cpp',
'extensions/base.cpp',
'extensions/timer.cpp'
),
]