QTechOS/kernel/drivers/opensbi/opensbi.cpp
Quantum 464a61102e
OpenSBI memes
Added legacy extension

Fixed typing memes by just define a sbiword_t typedef

Renamed sbiret_t to SbiRet, I think i'll only use _t for typedefs

Added ecall() variant that takes no additional arguments

Moved opensbi includes to includes/opensbi/...

kernel.cpp uses the legacy extensions instead of raw ecalls

All legacy extension calls are marked as deprecated
2022-01-23 20:15:53 -05:00

83 lines
2.3 KiB
C++

#include "opensbi/opensbi.h"
namespace drivers {
namespace opensbi {
SbiRet ecall(
sbiword_t extension,
sbiword_t function,
sbiword_t a0,
sbiword_t a1,
sbiword_t a2,
sbiword_t a3,
sbiword_t a4,
sbiword_t a5) {
register sbiword_t r_a7 asm("a7") = extension;
register sbiword_t r_a6 asm("a6") = function;
register sbiword_t r_a0 asm("a0") = a0;
register sbiword_t r_a1 asm("a1") = a1;
register sbiword_t r_a2 asm("a2") = a2;
register sbiword_t r_a3 asm("a3") = a3;
register sbiword_t r_a4 asm("a4") = a4;
register sbiword_t r_a5 asm("a5") = a5;
asm volatile("ecall" : // Instruction
"=r"(r_a0), "=r"(r_a1) : // Inputs
"r"(r_a7), "r"(r_a6), // Outputs
"r"(r_a0), "r"(r_a1), "r"(r_a2),
"r"(r_a3), "r"(r_a4), "r"(r_a5));
return {.error = a0, .value = a1};
}
SbiRet ecall(
sbiword_t extension,
sbiword_t function,
sbiword_t a0,
sbiword_t a1,
sbiword_t a2,
sbiword_t a3,
sbiword_t a4) {
return ecall(extension, function, a0, a1, a2, a3, a4, 0);
}
SbiRet ecall(
sbiword_t extension,
sbiword_t function,
sbiword_t a0,
sbiword_t a1,
sbiword_t a2,
sbiword_t a3) {
return ecall(extension, function, a0, a1, a2, a3, 0, 0);
}
SbiRet ecall(
sbiword_t extension,
sbiword_t function,
sbiword_t a0,
sbiword_t a1,
sbiword_t a2) {
return ecall(extension, function, a0, a1, a2, 0, 0, 0);
}
SbiRet ecall(
sbiword_t extension,
sbiword_t function,
sbiword_t a0,
sbiword_t a1) {
return ecall(extension, function, a0, a1, 0, 0, 0, 0);
}
SbiRet ecall(
sbiword_t extension,
sbiword_t function,
sbiword_t a0) {
return ecall(extension, function, a0, 0, 0, 0, 0, 0);
}
SbiRet ecall(
sbiword_t extension,
sbiword_t function) {
return ecall(extension, function, 0, 0, 0, 0, 0, 0);
}
} // End namespace opensbi
} // End namespace drivers