commit
3eddda4000
@ -1,6 +1,3 @@
|
||||
[submodule "riscv-pk"]
|
||||
path = riscv-pk
|
||||
url = https://github.com/rcore-os/riscv-pk.git
|
||||
[submodule "user"]
|
||||
path = user
|
||||
url = https://github.com/rcore-os/rcore-user.git
|
||||
|
@ -1,49 +0,0 @@
|
||||
/* Copy from bbl-ucore : https://ring00.github.io/bbl-ucore */
|
||||
|
||||
/* Simple linker script for the ucore kernel.
|
||||
See the GNU ld 'info' manual ("info ld") to learn the syntax. */
|
||||
|
||||
OUTPUT_ARCH(riscv)
|
||||
ENTRY(_start)
|
||||
|
||||
BASE_ADDRESS = 0xffffffffc0020000;
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
/* Load the kernel at this address: "." means the current address */
|
||||
. = BASE_ADDRESS;
|
||||
start = .;
|
||||
|
||||
.text : {
|
||||
stext = .;
|
||||
*(.text.entry)
|
||||
*(.text .text.*)
|
||||
. = ALIGN(4K);
|
||||
etext = .;
|
||||
}
|
||||
|
||||
.rodata : {
|
||||
srodata = .;
|
||||
*(.rodata .rodata.*)
|
||||
. = ALIGN(4K);
|
||||
erodata = .;
|
||||
}
|
||||
|
||||
.data : {
|
||||
sdata = .;
|
||||
*(.data .data.*)
|
||||
edata = .;
|
||||
}
|
||||
|
||||
.stack : {
|
||||
*(.bss.stack)
|
||||
}
|
||||
|
||||
.bss : {
|
||||
sbss = .;
|
||||
*(.bss .bss.*)
|
||||
ebss = .;
|
||||
}
|
||||
|
||||
PROVIDE(end = .);
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
use super::consts::KERNEL_OFFSET;
|
||||
|
||||
/// Mask all external interrupt except serial.
|
||||
pub unsafe fn init_external_interrupt() {
|
||||
// By default:
|
||||
// riscv-pk (bbl) enables all S-Mode IRQs (ref: machine/minit.c)
|
||||
// OpenSBI v0.3 disables all IRQs (ref: platform/common/irqchip/plic.c)
|
||||
|
||||
const HART0_S_MODE_INTERRUPT_ENABLES: *mut u32 = (KERNEL_OFFSET + 0x0C00_2080) as *mut u32;
|
||||
const SERIAL: u32 = 0xa;
|
||||
HART0_S_MODE_INTERRUPT_ENABLES.write_volatile(1 << SERIAL);
|
||||
}
|
||||
|
||||
pub unsafe fn enable_serial_interrupt() {
|
||||
const UART16550: *mut u8 = (KERNEL_OFFSET + 0x10000000) as *mut u8;
|
||||
UART16550.add(4).write_volatile(0x0B);
|
||||
UART16550.add(1).write_volatile(0x01);
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
.section .text.entry
|
||||
.globl _start
|
||||
_start:
|
||||
add t0, a0, 1
|
||||
slli t0, t0, 16
|
||||
|
||||
lui sp, %hi(bootstack)
|
||||
addi sp, sp, %lo(bootstack)
|
||||
add sp, sp, t0
|
||||
|
||||
call rust_main
|
||||
|
||||
.section .bss.stack
|
||||
.align 12 #PGSHIFT
|
||||
.global bootstack
|
||||
bootstack:
|
||||
.space 4096 * 16 * 8
|
||||
.global bootstacktop
|
||||
bootstacktop:
|
@ -0,0 +1,55 @@
|
||||
.section .text.entry
|
||||
.globl _start
|
||||
_start:
|
||||
# a0 == hartid
|
||||
# pc == 0x80200000
|
||||
# sp == 0x800xxxxx
|
||||
|
||||
# 1. set sp
|
||||
# sp = bootstack + (hartid + 1) * 0x10000
|
||||
add t0, a0, 1
|
||||
slli t0, t0, 16
|
||||
lui sp, %hi(bootstack)
|
||||
add sp, sp, t0
|
||||
|
||||
# 2. enable paging
|
||||
# satp = (1 << 31) | PPN(boot_page_table_sv32)
|
||||
lui t0, %hi(boot_page_table_sv32)
|
||||
li t1, 0xc0000000 - 0x80000000
|
||||
sub t0, t0, t1
|
||||
srli t0, t0, 12
|
||||
li t1, 1 << 31
|
||||
or t0, t0, t1
|
||||
csrw satp, t0
|
||||
sfence.vma
|
||||
|
||||
# 3. jump to rust_main (absolute address)
|
||||
lui t0, %hi(rust_main)
|
||||
addi t0, t0, %lo(rust_main)
|
||||
jr t0
|
||||
|
||||
.section .bss.stack
|
||||
.align 12 # page align
|
||||
.global bootstack
|
||||
bootstack:
|
||||
.space 4096 * 16 * 8
|
||||
.global bootstacktop
|
||||
bootstacktop:
|
||||
|
||||
.section .data
|
||||
.align 12 # page align
|
||||
boot_page_table_sv32:
|
||||
# NOTE: assume kernel image < 16M
|
||||
# 0x80000000 -> 0x80000000 (4M * 4)
|
||||
# 0xc0000000 -> 0x80000000 (4M * 4)
|
||||
.zero 4 * 512
|
||||
.word (0x80000 << 10) | 0xcf # VRWXAD
|
||||
.word (0x80400 << 10) | 0xcf # VRWXAD
|
||||
.word (0x80800 << 10) | 0xcf # VRWXAD
|
||||
.word (0x80c00 << 10) | 0xcf # VRWXAD
|
||||
.zero 4 * 252
|
||||
.word (0x80000 << 10) | 0xcf # VRWXAD
|
||||
.word (0x80400 << 10) | 0xcf # VRWXAD
|
||||
.word (0x80800 << 10) | 0xcf # VRWXAD
|
||||
.word (0x80c00 << 10) | 0xcf # VRWXAD
|
||||
.zero 4 * 252
|
@ -0,0 +1,48 @@
|
||||
.section .text.entry
|
||||
.globl _start
|
||||
_start:
|
||||
# a0 == hartid
|
||||
# pc == 0x80200000
|
||||
# sp == 0x800xxxxx
|
||||
|
||||
# 1. set sp
|
||||
# sp = bootstack + (hartid + 1) * 0x10000
|
||||
add t0, a0, 1
|
||||
slli t0, t0, 16
|
||||
lui sp, %hi(bootstack)
|
||||
add sp, sp, t0
|
||||
|
||||
# 2. enable paging
|
||||
# satp = (8 << 60) | PPN(boot_page_table_sv39)
|
||||
lui t0, %hi(boot_page_table_sv39)
|
||||
li t1, 0xffffffffc0000000 - 0x80000000
|
||||
sub t0, t0, t1
|
||||
srli t0, t0, 12
|
||||
li t1, 8 << 60
|
||||
or t0, t0, t1
|
||||
csrw satp, t0
|
||||
sfence.vma
|
||||
|
||||
# 3. jump to rust_main (absolute address)
|
||||
lui t0, %hi(rust_main)
|
||||
addi t0, t0, %lo(rust_main)
|
||||
jr t0
|
||||
|
||||
.section .bss.stack
|
||||
.align 12 # page align
|
||||
.global bootstack
|
||||
bootstack:
|
||||
.space 4096 * 16 * 8
|
||||
.global bootstacktop
|
||||
bootstacktop:
|
||||
|
||||
.section .data
|
||||
.align 12 # page align
|
||||
boot_page_table_sv39:
|
||||
# 0x00000000_80000000 -> 0x80000000 (1G)
|
||||
# 0xffffffff_c0000000 -> 0x80000000 (1G)
|
||||
.quad 0
|
||||
.quad 0
|
||||
.quad (0x80000 << 10) | 0xcf # VRWXAD
|
||||
.zero 8 * 508
|
||||
.quad (0x80000 << 10) | 0xcf # VRWXAD
|
@ -1 +0,0 @@
|
||||
Subproject commit 405ea59dd7dd2762c5883822f21d9995bea32b0c
|
@ -0,0 +1,9 @@
|
||||
# OpenSBI
|
||||
|
||||
These are binary release of OpenSBI on this [commit](https://github.com/riscv/opensbi/tree/194dbbe5a13dff2255411c26d249f3ad4ef42c0b) at 2019.04.15.
|
||||
|
||||
- fu540.elf: opensbi-0.3-rv64-bin/platform/sifive/fu540/firmware/fw_jump.elf
|
||||
- virt_rv32.elf: opensbi-0.3-rv32-bin/platform/qemu/virt/firmware/fw_jump.elf
|
||||
- virt_rv64.elf: opensbi-0.3-rv64-bin/platform/qemu/virt/firmware/fw_jump.elf
|
||||
|
||||
NOTE: The [official v0.3 release](https://github.com/riscv/opensbi/releases/tag/v0.3) has bug on serial interrupt.
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue