79 lines
2.2 KiB
C++
79 lines
2.2 KiB
C++
|
#include <cstdint>
|
||
|
#include <opensbi.h>
|
||
|
|
||
|
namespace drivers {
|
||
|
namespace opensbi {
|
||
|
|
||
|
sbiret_t call(
|
||
|
uintmax_t extension,
|
||
|
uintmax_t function,
|
||
|
uintmax_t a0,
|
||
|
uintmax_t a1,
|
||
|
uintmax_t a2,
|
||
|
uintmax_t a3,
|
||
|
uintmax_t a4,
|
||
|
uintmax_t a5) {
|
||
|
register uintmax_t r_a7 asm("a7") = extension;
|
||
|
register uintmax_t r_a6 asm("a6") = function;
|
||
|
register uintmax_t r_a0 asm("a0") = a0;
|
||
|
register uintmax_t r_a1 asm("a1") = a1;
|
||
|
register uintmax_t r_a2 asm("a2") = a2;
|
||
|
register uintmax_t r_a3 asm("a3") = a3;
|
||
|
register uintmax_t r_a4 asm("a4") = a4;
|
||
|
register uintmax_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_t call(
|
||
|
uintmax_t extension,
|
||
|
uintmax_t function,
|
||
|
uintmax_t a0,
|
||
|
uintmax_t a1,
|
||
|
uintmax_t a2,
|
||
|
uintmax_t a3,
|
||
|
uintmax_t a4) {
|
||
|
return call(extension, function, a0, a1, a2, a3, a4, 0);
|
||
|
}
|
||
|
|
||
|
sbiret_t call(
|
||
|
uintmax_t extension,
|
||
|
uintmax_t function,
|
||
|
uintmax_t a0,
|
||
|
uintmax_t a1,
|
||
|
uintmax_t a2,
|
||
|
uintmax_t a3) {
|
||
|
return call(extension, function, a0, a1, a2, a3, 0, 0);
|
||
|
}
|
||
|
|
||
|
sbiret_t call(
|
||
|
uintmax_t extension,
|
||
|
uintmax_t function,
|
||
|
uintmax_t a0,
|
||
|
uintmax_t a1,
|
||
|
uintmax_t a2) {
|
||
|
return call(extension, function, a0, a1, a2, 0, 0, 0);
|
||
|
}
|
||
|
|
||
|
sbiret_t call(
|
||
|
uintmax_t extension,
|
||
|
uintmax_t function,
|
||
|
uintmax_t a0,
|
||
|
uintmax_t a1) {
|
||
|
return call(extension, function, a0, a1, 0, 0, 0, 0);
|
||
|
}
|
||
|
|
||
|
sbiret_t call(
|
||
|
uintmax_t extension,
|
||
|
uintmax_t function,
|
||
|
uintmax_t a0) {
|
||
|
return call(extension, function, a0, 0, 0, 0, 0, 0);
|
||
|
}
|
||
|
|
||
|
} // End namespace opensbi
|
||
|
} // End namespace drivers
|