QTechOS/kernel/drivers/opensbi/opensbi.cpp

84 lines
2.3 KiB
C++
Raw Normal View History

#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;
2022-04-09 14:02:41 -04:00
asm volatile(
"ecall" :
"=r"(r_a0), "=r"(r_a1) :
"r"(r_a0), "r"(r_a1), "r"(r_a2), "r"(r_a3),
"r"(r_a4), "r"(r_a5), "r"(r_a7), "r"(r_a6));
return {.error = r_a0, .value = r_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