Compare commits

..

No commits in common. "ea60891ef5f4ca20ab64a9bc82dd4a22e4fd21ac" and "94fbea02ca96a60c6aec1cd4c2466a7067b457e3" have entirely different histories.

3 changed files with 74 additions and 53 deletions

View file

@ -1,7 +1,6 @@
elf = executable( elf = executable(
'kernel.elf', 'kernel.elf',
arch_sources, arch_sources,
include_directories: includes,
link_args: [ link_args: [
'-Wl,-T,' + meson.current_source_dir() + '/platform.ld', '-Wl,-T,' + meson.current_source_dir() + '/platform.ld',
'-static' '-static'

View file

@ -4,23 +4,23 @@
namespace drivers { namespace drivers {
namespace opensbi { namespace opensbi {
sbiret_t ecall( sbiret_t call(
uintptr_t extension, uintmax_t extension,
uintptr_t function, uintmax_t function,
uintptr_t a0, uintmax_t a0,
uintptr_t a1, uintmax_t a1,
uintptr_t a2, uintmax_t a2,
uintptr_t a3, uintmax_t a3,
uintptr_t a4, uintmax_t a4,
uintptr_t a5) { uintmax_t a5) {
register uintptr_t r_a7 asm("a7") = extension; register uintmax_t r_a7 asm("a7") = extension;
register uintptr_t r_a6 asm("a6") = function; register uintmax_t r_a6 asm("a6") = function;
register uintptr_t r_a0 asm("a0") = a0; register uintmax_t r_a0 asm("a0") = a0;
register uintptr_t r_a1 asm("a1") = a1; register uintmax_t r_a1 asm("a1") = a1;
register uintptr_t r_a2 asm("a2") = a2; register uintmax_t r_a2 asm("a2") = a2;
register uintptr_t r_a3 asm("a3") = a3; register uintmax_t r_a3 asm("a3") = a3;
register uintptr_t r_a4 asm("a4") = a4; register uintmax_t r_a4 asm("a4") = a4;
register uintptr_t r_a5 asm("a5") = a5; register uintmax_t r_a5 asm("a5") = a5;
asm volatile("ecall" : // Instruction asm volatile("ecall" : // Instruction
"=r"(r_a0), "=r"(r_a1) : // Inputs "=r"(r_a0), "=r"(r_a1) : // Inputs
"r"(r_a7), "r"(r_a6), // Outputs "r"(r_a7), "r"(r_a6), // Outputs
@ -29,49 +29,49 @@ namespace opensbi {
return {.error = a0, .value = a1}; return {.error = a0, .value = a1};
} }
sbiret_t ecall( sbiret_t call(
uintptr_t extension, uintmax_t extension,
uintptr_t function, uintmax_t function,
uintptr_t a0, uintmax_t a0,
uintptr_t a1, uintmax_t a1,
uintptr_t a2, uintmax_t a2,
uintptr_t a3, uintmax_t a3,
uintptr_t a4) { uintmax_t a4) {
return ecall(extension, function, a0, a1, a2, a3, a4, 0); return call(extension, function, a0, a1, a2, a3, a4, 0);
} }
sbiret_t ecall( sbiret_t call(
uintptr_t extension, uintmax_t extension,
uintptr_t function, uintmax_t function,
uintptr_t a0, uintmax_t a0,
uintptr_t a1, uintmax_t a1,
uintptr_t a2, uintmax_t a2,
uintptr_t a3) { uintmax_t a3) {
return ecall(extension, function, a0, a1, a2, a3, 0, 0); return call(extension, function, a0, a1, a2, a3, 0, 0);
} }
sbiret_t ecall( sbiret_t call(
uintptr_t extension, uintmax_t extension,
uintptr_t function, uintmax_t function,
uintptr_t a0, uintmax_t a0,
uintptr_t a1, uintmax_t a1,
uintptr_t a2) { uintmax_t a2) {
return ecall(extension, function, a0, a1, a2, 0, 0, 0); return call(extension, function, a0, a1, a2, 0, 0, 0);
} }
sbiret_t ecall( sbiret_t call(
uintptr_t extension, uintmax_t extension,
uintptr_t function, uintmax_t function,
uintptr_t a0, uintmax_t a0,
uintptr_t a1) { uintmax_t a1) {
return ecall(extension, function, a0, a1, 0, 0, 0, 0); return call(extension, function, a0, a1, 0, 0, 0, 0);
} }
sbiret_t ecall( sbiret_t call(
uintptr_t extension, uintmax_t extension,
uintptr_t function, uintmax_t function,
uintptr_t a0) { uintmax_t a0) {
return ecall(extension, function, a0, 0, 0, 0, 0, 0); return call(extension, function, a0, 0, 0, 0, 0, 0);
} }
} // End namespace opensbi } // End namespace opensbi

View file

@ -30,6 +30,28 @@
typedef unsigned long sbi_word; typedef unsigned long sbi_word;
/*
void sbi_call1(int ext, int func, sbi_word arg0) {
register sbi_word rExt asm("a7") = ext;
register sbi_word rFunc asm("a6") = func;
register sbi_word rArg0 asm("a0") = arg0;
register sbi_word rArg1 asm("a1");
asm volatile("ecall" : "+r"(rArg0), "=r"(rArg1) : "r"(rExt), "r"(rFunc));
if(rArg0)
__builtin_trap();
}
void sbi_call2(int ext, int func, sbi_word arg0, sbi_word arg1) {
register sbi_word rExt asm("a7") = ext;
register sbi_word rFunc asm("a6") = func;
register sbi_word rArg0 asm("a0") = arg0;
register sbi_word rArg1 asm("a1") = arg1;
asm volatile("ecall" : "+r"(rArg0), "+r"(rArg1) : "r"(rExt), "r"(rFunc));
if(rArg0)
__builtin_trap();
}
*/
void fmt(const char *f, ...) { void fmt(const char *f, ...) {
va_list va; va_list va;
va_start(va, f); va_start(va, f);