Last active
October 23, 2023 08:21
-
-
Save lupyuen/4cd98a4075d5b528940095b39fd5b445 to your computer and use it in GitHub Desktop.
RISC-V Disassembly of NuttX ecall to OpenSBI. See https://lupyuen.github.io/articles/sbi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Make an ecall to OpenSBI. Based on | |
// https://github.com/apache/nuttx/blob/master/arch/risc-v/src/common/supervisor/riscv_sbi.c#L52-L77 | |
// https://github.com/riscv-software-src/opensbi/blob/master/firmware/payloads/test_main.c | |
static struct sbiret sbi_ecall(unsigned int extid, unsigned int fid, | |
4020f0cc: 88aa mv a7,a0 | |
4020f0ce: 882e mv a6,a1 | |
nuttx/boards/risc-v/jh7110/star64/src/jh7110_appinit.c:284 | |
register long r1 asm("a1") = (long)(parm1); | |
register long r2 asm("a2") = (long)(parm2); | |
register long r3 asm("a3") = (long)(parm3); | |
register long r4 asm("a4") = (long)(parm4); | |
register long r5 asm("a5") = (long)(parm5); | |
register long r6 asm("a6") = (long)(fid); | |
4020f0d0: 1802 slli a6,a6,0x20 | |
nuttx/boards/risc-v/jh7110/star64/src/jh7110_appinit.c:285 | |
register long r7 asm("a7") = (long)(extid); | |
4020f0d2: 1882 slli a7,a7,0x20 | |
nuttx/boards/risc-v/jh7110/star64/src/jh7110_appinit.c:272 | |
static struct sbiret sbi_ecall(unsigned int extid, unsigned int fid, | |
4020f0d4: 1141 addi sp,sp,-16 | |
nuttx/boards/risc-v/jh7110/star64/src/jh7110_appinit.c:278 | |
register long r0 asm("a0") = (long)(parm0); | |
4020f0d6: 8532 mv a0,a2 | |
nuttx/boards/risc-v/jh7110/star64/src/jh7110_appinit.c:279 | |
register long r1 asm("a1") = (long)(parm1); | |
4020f0d8: 85b6 mv a1,a3 | |
nuttx/boards/risc-v/jh7110/star64/src/jh7110_appinit.c:280 | |
register long r2 asm("a2") = (long)(parm2); | |
4020f0da: 4601 li a2,0 | |
nuttx/boards/risc-v/jh7110/star64/src/jh7110_appinit.c:281 | |
register long r3 asm("a3") = (long)(parm3); | |
4020f0dc: 4681 li a3,0 | |
nuttx/boards/risc-v/jh7110/star64/src/jh7110_appinit.c:282 | |
register long r4 asm("a4") = (long)(parm4); | |
4020f0de: 4701 li a4,0 | |
nuttx/boards/risc-v/jh7110/star64/src/jh7110_appinit.c:283 | |
register long r5 asm("a5") = (long)(parm5); | |
4020f0e0: 4781 li a5,0 | |
nuttx/boards/risc-v/jh7110/star64/src/jh7110_appinit.c:284 | |
register long r6 asm("a6") = (long)(fid); | |
4020f0e2: 02085813 srli a6,a6,0x20 | |
nuttx/boards/risc-v/jh7110/star64/src/jh7110_appinit.c:285 | |
register long r7 asm("a7") = (long)(extid); | |
4020f0e6: 0208d893 srli a7,a7,0x20 | |
nuttx/boards/risc-v/jh7110/star64/src/jh7110_appinit.c:287 | |
asm volatile | |
4020f0ea: 00000073 ecall | |
nuttx/boards/risc-v/jh7110/star64/src/jh7110_appinit.c:298 | |
); | |
ret.error = r0; | |
ret.value = r1; | |
return ret; | |
} | |
4020f0ee: 0141 addi sp,sp,16 | |
4020f0f0: 8082 ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment