fixed setting in riscv-pk to enable rv32ia, added smp option in Makefile

toolchain_update
maoyuchaxue 6 years ago
parent 528c919626
commit 6cf0d6db23

@ -12,11 +12,13 @@
# d = int | in_asm | ... QEMU debug info # d = int | in_asm | ... QEMU debug info
# mode = debug | release # mode = debug | release
# LOG = off | error | warn | info | debug | trace # LOG = off | error | warn | info | debug | trace
# smp SMP core number
# board Only available on riscv32, build without bbl, run on board # board Only available on riscv32, build without bbl, run on board
arch ?= riscv32 arch ?= riscv32
mode ?= debug mode ?= debug
LOG ?= debug LOG ?= debug
smp ?= 1
target := $(arch)-blog_os target := $(arch)-blog_os
kernel := target/$(target)/$(mode)/ucore kernel := target/$(target)/$(mode)/ucore
@ -31,12 +33,12 @@ ifeq ($(arch), x86_64)
qemu_opts := \ qemu_opts := \
-drive format=raw,file=$(bootimage) \ -drive format=raw,file=$(bootimage) \
-drive format=raw,file=$(SFSIMG),media=disk,cache=writeback \ -drive format=raw,file=$(SFSIMG),media=disk,cache=writeback \
-smp 4 \ -smp $(smp) \
-serial mon:stdio \ -serial mon:stdio \
-device isa-debug-exit -device isa-debug-exit
endif endif
ifeq ($(arch), riscv32) ifeq ($(arch), riscv32)
qemu_opts := -machine virt -kernel $(bin) -nographic qemu_opts := -machine virt -kernel $(bin) -nographic -smp cpus=$(smp)
endif endif
ifdef board ifdef board
@ -69,7 +71,7 @@ ifeq ($(uname), Darwin)
prefix := x86_64-elf- prefix := x86_64-elf-
endif endif
ifeq ($(arch), riscv32) ifeq ($(arch), riscv32)
prefix := riscv64-unknown-elf- prefix := riscv32-unknown-elf-
endif endif
ld := $(prefix)ld ld := $(prefix)ld
@ -118,7 +120,7 @@ else
--enable-32bit \ --enable-32bit \
--enable-logo \ --enable-logo \
--disable-fp-emulation \ --disable-fp-emulation \
--host=riscv64-unknown-elf \ --host=riscv32-unknown-elf \
--with-payload=$(abspath $(kernel)) && \ --with-payload=$(abspath $(kernel)) && \
make && \ make && \
cp bbl ../../kernel/$@ cp bbl ../../kernel/$@

@ -1,14 +1,19 @@
.section .text.entry .section .text.entry
.globl _start .globl _start
_start: _start:
lui sp, %hi(bootstacktop) add t0, a0, 1
addi sp, sp, %lo(bootstacktop) slli t0, t0, 16
lui sp, %hi(bootstack)
addi sp, sp, %lo(bootstack)
add sp, sp, t0
call rust_main call rust_main
.section .bss .section .bss
.align 12 #PGSHIFT .align 12 #PGSHIFT
.global bootstack .global bootstack
bootstack: bootstack:
.space 4096 * 16 #KSTACKSIZE .space 4096 * 16 * 8
.global bootstacktop .global bootstacktop
bootstacktop: bootstacktop:

@ -7,10 +7,11 @@ pub mod timer;
pub mod paging; pub mod paging;
pub mod memory; pub mod memory;
pub mod compiler_rt; pub mod compiler_rt;
pub mod smp;
#[no_mangle] #[no_mangle]
pub extern fn rust_main() -> ! { pub extern fn rust_main(hartid: usize) -> ! {
println!("Hello RISCV! {}", 123); println!("Hello RISCV! {}", hartid);
::logging::init(); ::logging::init();
interrupt::init(); interrupt::init();
memory::init(); memory::init();

@ -4084,8 +4084,8 @@ fi
case "${BUILD_32BIT}" in case "${BUILD_32BIT}" in
yes|default) yes|default)
echo "Building 32-bit pk" echo "Building 32-bit pk"
CFLAGS="$default_CFLAGS -march=rv32i -mabi=ilp32" CFLAGS="$default_CFLAGS -march=rv32ia -mabi=ilp32"
LDFLAGS="-march=rv32i -mabi=ilp32" LDFLAGS="-march=rv32ia -mabi=ilp32"
install_subdir="riscv32-unknown-elf" install_subdir="riscv32-unknown-elf"
;; ;;
*) *)

@ -88,8 +88,8 @@ AC_ARG_ENABLE([32bit],
case "${BUILD_32BIT}" in case "${BUILD_32BIT}" in
yes|default) yes|default)
echo "Building 32-bit pk" echo "Building 32-bit pk"
CFLAGS="$default_CFLAGS -march=rv32i -mabi=ilp32" CFLAGS="$default_CFLAGS -march=rv32ia -mabi=ilp32"
LDFLAGS="-march=rv32i -mabi=ilp32" LDFLAGS="-march=rv32ia -mabi=ilp32"
install_subdir="riscv32-unknown-elf" install_subdir="riscv32-unknown-elf"
;; ;;
*) *)

Loading…
Cancel
Save