Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sbi/sbi_console.h>
- void kmain()
- {
- sbi_puts("Hello C Kernel!");
- }
- How can I get a program like this to run using `qemu-system-riscv64 -kernel kmain`?
- I have libsbi.a and libplatsbi.a in /usr/local/lib64/lp64 and /usr/local/lib64/lp64/opensbi/generic/lib/.
- I have all kinds of header files in /usr/local/include/sbi.
- I am compiling with `riscv64-linux-gnu-gcc -ffreestanding -I/usr/local/include -march=rv64gc -mabi=lp64` and linking with `riscv64-linux-gnu-gcc -ffreestanding -nostdlib -T linker.ld -L/usr/local/lib64/lp64 -march=rv64gc -mabi=lp64`
- This is my boot.S file:
- .section .text.start
- .global _start
- _start:
- # Set up stack pointer
- la sp, stack_top
- # Jump to C code
- call kmain
- .section .bss
- .align 4
- stack_bottom:
- .space 4096
- stack_top:
- This is my linker script:
- OUTPUT_ARCH(riscv)
- ENTRY(_start)
- SECTIONS
- {
- . = 0x80200000;
- .text : {
- *(.text.start)
- *(.text)
- }
- .data : {
- *(.data)
- }
- .bss : {
- *(.bss)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement