mirror of
https://github.com/rcore-os/rCore-Tutorial-v3.git
synced 2024-11-25 19:03:35 +04:00
Remove K210 support.
This commit is contained in:
parent
4d92fe4bc4
commit
452ef021ae
Binary file not shown.
@ -10,9 +10,6 @@ edition = "2021"
|
|||||||
riscv = { git = "https://github.com/rcore-os/riscv", features = ["inline-asm"] }
|
riscv = { git = "https://github.com/rcore-os/riscv", features = ["inline-asm"] }
|
||||||
lazy_static = { version = "1.4.0", features = ["spin_no_std"] }
|
lazy_static = { version = "1.4.0", features = ["spin_no_std"] }
|
||||||
|
|
||||||
[features]
|
|
||||||
board_qemu = []
|
|
||||||
board_k210 = []
|
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
debug = true
|
debug = true
|
||||||
|
38
os/Makefile
38
os/Makefile
@ -6,10 +6,9 @@ KERNEL_BIN := $(KERNEL_ELF).bin
|
|||||||
DISASM_TMP := target/$(TARGET)/$(MODE)/asm
|
DISASM_TMP := target/$(TARGET)/$(MODE)/asm
|
||||||
|
|
||||||
# BOARD
|
# BOARD
|
||||||
BOARD ?= qemu
|
BOARD := qemu
|
||||||
SBI ?= rustsbi
|
SBI ?= rustsbi
|
||||||
BOOTLOADER := ../bootloader/$(SBI)-$(BOARD).bin
|
BOOTLOADER := ../bootloader/$(SBI)-$(BOARD).bin
|
||||||
K210_BOOTLOADER_SIZE := 131072
|
|
||||||
|
|
||||||
# Building mode argument
|
# Building mode argument
|
||||||
ifeq ($(MODE), release)
|
ifeq ($(MODE), release)
|
||||||
@ -17,15 +16,7 @@ ifeq ($(MODE), release)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
# KERNEL ENTRY
|
# KERNEL ENTRY
|
||||||
ifeq ($(BOARD), qemu)
|
KERNEL_ENTRY_PA := 0x80200000
|
||||||
KERNEL_ENTRY_PA := 0x80200000
|
|
||||||
else ifeq ($(BOARD), k210)
|
|
||||||
KERNEL_ENTRY_PA := 0x80020000
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Run K210
|
|
||||||
K210-SERIALPORT = /dev/ttyUSB0
|
|
||||||
K210-BURNER = ../tools/kflash.py
|
|
||||||
|
|
||||||
# Binutils
|
# Binutils
|
||||||
OBJDUMP := rust-objdump --arch-name=riscv64
|
OBJDUMP := rust-objdump --arch-name=riscv64
|
||||||
@ -34,14 +25,7 @@ OBJCOPY := rust-objcopy --binary-architecture=riscv64
|
|||||||
# Disassembly
|
# Disassembly
|
||||||
DISASM ?= -x
|
DISASM ?= -x
|
||||||
|
|
||||||
build: env switch-check $(KERNEL_BIN)
|
build: env $(KERNEL_BIN)
|
||||||
|
|
||||||
switch-check:
|
|
||||||
ifeq ($(BOARD), qemu)
|
|
||||||
(which last-qemu) || (rm -f last-k210 && touch last-qemu && make clean)
|
|
||||||
else ifeq ($(BOARD), k210)
|
|
||||||
(which last-k210) || (rm -f last-qemu && touch last-k210 && make clean)
|
|
||||||
endif
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
(rustup target list | grep "riscv64gc-unknown-none-elf (installed)") || rustup target add $(TARGET)
|
(rustup target list | grep "riscv64gc-unknown-none-elf (installed)") || rustup target add $(TARGET)
|
||||||
@ -57,7 +41,7 @@ kernel:
|
|||||||
@cd ../user && make build
|
@cd ../user && make build
|
||||||
@echo Platform: $(BOARD)
|
@echo Platform: $(BOARD)
|
||||||
@cp src/linker-$(BOARD).ld src/linker.ld
|
@cp src/linker-$(BOARD).ld src/linker.ld
|
||||||
@cargo build $(MODE_ARG) --features "board_$(BOARD)"
|
@cargo build $(MODE_ARG)
|
||||||
@rm src/linker.ld
|
@rm src/linker.ld
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@ -73,24 +57,12 @@ disasm-vim: kernel
|
|||||||
|
|
||||||
run: run-inner
|
run: run-inner
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
run-inner: build
|
run-inner: build
|
||||||
ifeq ($(BOARD),qemu)
|
|
||||||
@qemu-system-riscv64 \
|
@qemu-system-riscv64 \
|
||||||
-machine virt \
|
-machine virt \
|
||||||
-nographic \
|
-nographic \
|
||||||
-bios $(BOOTLOADER) \
|
-bios $(BOOTLOADER) \
|
||||||
-device loader,file=$(KERNEL_BIN),addr=$(KERNEL_ENTRY_PA)
|
-device loader,file=$(KERNEL_BIN),addr=$(KERNEL_ENTRY_PA)
|
||||||
else
|
|
||||||
(which $(K210-BURNER)) || (cd .. && git clone https://github.com/sipeed/kflash.py.git && mv kflash.py tools)
|
|
||||||
@cp $(BOOTLOADER) $(BOOTLOADER).copy
|
|
||||||
@dd if=$(KERNEL_BIN) of=$(BOOTLOADER).copy bs=$(K210_BOOTLOADER_SIZE) seek=1
|
|
||||||
@mv $(BOOTLOADER).copy $(KERNEL_BIN)
|
|
||||||
@sudo chmod 777 $(K210-SERIALPORT)
|
|
||||||
python3 $(K210-BURNER) -p $(K210-SERIALPORT) -b 1500000 $(KERNEL_BIN)
|
|
||||||
python3 -m serial.tools.miniterm --eol LF --dtr 0 --rts 0 --filter direct $(K210-SERIALPORT) 115200
|
|
||||||
endif
|
|
||||||
|
|
||||||
debug: build
|
debug: build
|
||||||
@tmux new-session -d \
|
@tmux new-session -d \
|
||||||
@ -104,4 +76,4 @@ gdbserver: build
|
|||||||
gdbclient:
|
gdbclient:
|
||||||
@riscv64-unknown-elf-gdb -ex 'file $(KERNEL_ELF)' -ex 'set arch riscv:rv64' -ex 'target remote localhost:1234'
|
@riscv64-unknown-elf-gdb -ex 'file $(KERNEL_ELF)' -ex 'set arch riscv:rv64' -ex 'target remote localhost:1234'
|
||||||
|
|
||||||
.PHONY: build env kernel clean disasm disasm-vim run-inner switch-check gdbserver gdbclient
|
.PHONY: build env kernel clean disasm disasm-vim run-inner gdbserver gdbclient
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
OUTPUT_ARCH(riscv)
|
|
||||||
ENTRY(_start)
|
|
||||||
BASE_ADDRESS = 0x80020000;
|
|
||||||
|
|
||||||
SECTIONS
|
|
||||||
{
|
|
||||||
. = BASE_ADDRESS;
|
|
||||||
skernel = .;
|
|
||||||
|
|
||||||
stext = .;
|
|
||||||
.text : {
|
|
||||||
*(.text.entry)
|
|
||||||
*(.text .text.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
. = ALIGN(4K);
|
|
||||||
etext = .;
|
|
||||||
srodata = .;
|
|
||||||
.rodata : {
|
|
||||||
*(.rodata .rodata.*)
|
|
||||||
*(.srodata .srodata.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
. = ALIGN(4K);
|
|
||||||
erodata = .;
|
|
||||||
sdata = .;
|
|
||||||
.data : {
|
|
||||||
*(.data .data.*)
|
|
||||||
*(.sdata .sdata.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
. = ALIGN(4K);
|
|
||||||
edata = .;
|
|
||||||
.bss : {
|
|
||||||
*(.bss.stack)
|
|
||||||
sbss = .;
|
|
||||||
*(.bss .bss.*)
|
|
||||||
*(.sbss .sbss.*)
|
|
||||||
}
|
|
||||||
|
|
||||||
. = ALIGN(4K);
|
|
||||||
ebss = .;
|
|
||||||
ekernel = .;
|
|
||||||
|
|
||||||
/DISCARD/ : {
|
|
||||||
*(.eh_frame)
|
|
||||||
}
|
|
||||||
}
|
|
@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
use core::arch::global_asm;
|
use core::arch::global_asm;
|
||||||
|
|
||||||
#[cfg(feature = "board_qemu")]
|
|
||||||
#[path = "boards/qemu.rs"]
|
#[path = "boards/qemu.rs"]
|
||||||
mod board;
|
mod board;
|
||||||
|
|
||||||
|
@ -4,8 +4,6 @@ use core::arch::asm;
|
|||||||
|
|
||||||
const SBI_CONSOLE_PUTCHAR: usize = 1;
|
const SBI_CONSOLE_PUTCHAR: usize = 1;
|
||||||
|
|
||||||
#[cfg(feature = "board_k210")]
|
|
||||||
const SBI_SHUTDOWN: usize = 8;
|
|
||||||
// const SBI_SET_TIMER: usize = 0;
|
// const SBI_SET_TIMER: usize = 0;
|
||||||
// const SBI_CONSOLE_GETCHAR: usize = 2;
|
// const SBI_CONSOLE_GETCHAR: usize = 2;
|
||||||
// const SBI_CLEAR_IPI: usize = 3;
|
// const SBI_CLEAR_IPI: usize = 3;
|
||||||
@ -13,6 +11,7 @@ const SBI_SHUTDOWN: usize = 8;
|
|||||||
// const SBI_REMOTE_FENCE_I: usize = 5;
|
// const SBI_REMOTE_FENCE_I: usize = 5;
|
||||||
// const SBI_REMOTE_SFENCE_VMA: usize = 6;
|
// const SBI_REMOTE_SFENCE_VMA: usize = 6;
|
||||||
// const SBI_REMOTE_SFENCE_VMA_ASID: usize = 7;
|
// const SBI_REMOTE_SFENCE_VMA_ASID: usize = 7;
|
||||||
|
// const SBI_SHUTDOWN: usize = 8;
|
||||||
|
|
||||||
/// handle SBI call with `which` SBI_id and other arguments
|
/// handle SBI call with `which` SBI_id and other arguments
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
@ -41,16 +40,8 @@ pub fn console_putchar(c: usize) {
|
|||||||
// sbi_call(SBI_CONSOLE_GETCHAR, 0, 0, 0)
|
// sbi_call(SBI_CONSOLE_GETCHAR, 0, 0, 0)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
#[cfg(feature = "board_qemu")]
|
|
||||||
use crate::board::QEMUExit;
|
use crate::board::QEMUExit;
|
||||||
/// use sbi call to shutdown the kernel
|
/// use sbi call to shutdown the kernel
|
||||||
pub fn shutdown() -> ! {
|
pub fn shutdown() -> ! {
|
||||||
#[cfg(feature = "board_k210")]
|
|
||||||
sbi_call(SBI_SHUTDOWN, 0, 0, 0);
|
|
||||||
|
|
||||||
#[cfg(feature = "board_qemu")]
|
|
||||||
crate::board::QEMU_EXIT_HANDLE.exit_failure();
|
crate::board::QEMU_EXIT_HANDLE.exit_failure();
|
||||||
|
|
||||||
#[cfg(feature = "board_k210")]
|
|
||||||
panic!("It should shutdown!");
|
|
||||||
}
|
}
|
||||||
|
@ -134,14 +134,8 @@ impl TaskManager {
|
|||||||
// go back to user mode
|
// go back to user mode
|
||||||
} else {
|
} else {
|
||||||
println!("All applications completed!");
|
println!("All applications completed!");
|
||||||
|
|
||||||
#[cfg(feature = "board_qemu")]
|
|
||||||
use crate::board::QEMUExit;
|
use crate::board::QEMUExit;
|
||||||
#[cfg(feature = "board_qemu")]
|
|
||||||
crate::board::QEMU_EXIT_HANDLE.exit_success();
|
crate::board::QEMU_EXIT_HANDLE.exit_success();
|
||||||
|
|
||||||
#[cfg(feature = "board_k210")]
|
|
||||||
panic!("All applications completed!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user