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:
parent
dd373fca85
commit
dbfd13630d
3 changed files with 39 additions and 1 deletions
25
kernel/drivers/opensbi/extensions/timer.cpp
Normal file
25
kernel/drivers/opensbi/extensions/timer.cpp
Normal 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
|
||||
|
11
kernel/drivers/opensbi/include/opensbi/extensions/timer.h
Normal file
11
kernel/drivers/opensbi/include/opensbi/extensions/timer.h
Normal 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
|
|
@ -1,7 +1,9 @@
|
|||
kernel_sources += [
|
||||
files(
|
||||
'opensbi.cpp',
|
||||
'extensions/legacy.cpp'
|
||||
'extensions/legacy.cpp',
|
||||
'extensions/base.cpp',
|
||||
'extensions/timer.cpp'
|
||||
),
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in a new issue