2022-01-23 20:15:53 -05:00
|
|
|
#include "opensbi/opensbi.h"
|
2022-01-05 02:47:30 -05:00
|
|
|
|
|
|
|
namespace drivers {
|
|
|
|
namespace opensbi {
|
|
|
|
|
2022-01-23 20:15:53 -05:00
|
|
|
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));
|
2022-01-23 22:32:19 -05:00
|
|
|
return {.error = r_a0, .value = r_a1};
|
2022-01-05 02:47:30 -05:00
|
|
|
}
|
|
|
|
|
2022-01-23 20:15:53 -05:00
|
|
|
SbiRet ecall(
|
|
|
|
sbiword_t extension,
|
|
|
|
sbiword_t function,
|
|
|
|
sbiword_t a0,
|
|
|
|
sbiword_t a1,
|
|
|
|
sbiword_t a2,
|
|
|
|
sbiword_t a3,
|
|
|
|
sbiword_t a4) {
|
2022-01-23 15:35:18 -05:00
|
|
|
return ecall(extension, function, a0, a1, a2, a3, a4, 0);
|
2022-01-05 02:47:30 -05:00
|
|
|
}
|
|
|
|
|
2022-01-23 20:15:53 -05:00
|
|
|
SbiRet ecall(
|
|
|
|
sbiword_t extension,
|
|
|
|
sbiword_t function,
|
|
|
|
sbiword_t a0,
|
|
|
|
sbiword_t a1,
|
|
|
|
sbiword_t a2,
|
|
|
|
sbiword_t a3) {
|
2022-01-23 15:35:18 -05:00
|
|
|
return ecall(extension, function, a0, a1, a2, a3, 0, 0);
|
2022-01-05 02:47:30 -05:00
|
|
|
}
|
|
|
|
|
2022-01-23 20:15:53 -05:00
|
|
|
SbiRet ecall(
|
|
|
|
sbiword_t extension,
|
|
|
|
sbiword_t function,
|
|
|
|
sbiword_t a0,
|
|
|
|
sbiword_t a1,
|
|
|
|
sbiword_t a2) {
|
2022-01-23 15:35:18 -05:00
|
|
|
return ecall(extension, function, a0, a1, a2, 0, 0, 0);
|
2022-01-05 02:47:30 -05:00
|
|
|
}
|
|
|
|
|
2022-01-23 20:15:53 -05:00
|
|
|
SbiRet ecall(
|
|
|
|
sbiword_t extension,
|
|
|
|
sbiword_t function,
|
|
|
|
sbiword_t a0,
|
|
|
|
sbiword_t a1) {
|
2022-01-23 15:35:18 -05:00
|
|
|
return ecall(extension, function, a0, a1, 0, 0, 0, 0);
|
2022-01-05 02:47:30 -05:00
|
|
|
}
|
|
|
|
|
2022-01-23 20:15:53 -05:00
|
|
|
SbiRet ecall(
|
|
|
|
sbiword_t extension,
|
|
|
|
sbiword_t function,
|
|
|
|
sbiword_t a0) {
|
2022-01-23 15:35:18 -05:00
|
|
|
return ecall(extension, function, a0, 0, 0, 0, 0, 0);
|
2022-01-05 02:47:30 -05:00
|
|
|
}
|
|
|
|
|
2022-01-23 20:15:53 -05:00
|
|
|
SbiRet ecall(
|
|
|
|
sbiword_t extension,
|
|
|
|
sbiword_t function) {
|
|
|
|
return ecall(extension, function, 0, 0, 0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
2022-01-05 02:47:30 -05:00
|
|
|
} // End namespace opensbi
|
|
|
|
} // End namespace drivers
|