Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
rcore-os
RCore Tutorial V3
提交
f2318967
R
RCore Tutorial V3
项目概览
rcore-os
/
RCore Tutorial V3
上一次同步 1 年多
通知
15
Star
793
Fork
260
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
RCore Tutorial V3
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
f2318967
编写于
12月 14, 2022
作者:
Y
Yifan Wu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove K210 support.
上级
e2709203
变更
17
展开全部
隐藏空白更改
内联
并排
Showing
17 changed file
with
10 addition
and
994 deletion
+10
-994
bootloader/rustsbi-k210.bin
bootloader/rustsbi-k210.bin
+0
-0
os/Cargo.toml
os/Cargo.toml
+0
-7
os/Makefile
os/Makefile
+5
-37
os/src/boards/k210.rs
os/src/boards/k210.rs
+0
-30
os/src/console.rs
os/src/console.rs
+0
-6
os/src/drivers/block/mod.rs
os/src/drivers/block/mod.rs
+0
-2
os/src/drivers/block/sdcard.rs
os/src/drivers/block/sdcard.rs
+0
-767
os/src/drivers/chardev/mod.rs
os/src/drivers/chardev/mod.rs
+1
-2
os/src/drivers/input/mod.rs
os/src/drivers/input/mod.rs
+0
-1
os/src/drivers/mod.rs
os/src/drivers/mod.rs
+1
-7
os/src/fs/stdio.rs
os/src/fs/stdio.rs
+0
-27
os/src/gui/mod.rs
os/src/gui/mod.rs
+1
-0
os/src/linker-k210.ld
os/src/linker-k210.ld
+0
-53
os/src/main.rs
os/src/main.rs
+1
-9
os/src/sbi.rs
os/src/sbi.rs
+1
-7
os/src/syscall/mod.rs
os/src/syscall/mod.rs
+0
-37
os/src/task/mod.rs
os/src/task/mod.rs
+0
-2
未找到文件。
bootloader/rustsbi-k210.bin
已删除
100755 → 0
浏览文件 @
e2709203
文件已删除
os/Cargo.toml
浏览文件 @
f2318967
...
...
@@ -14,17 +14,10 @@ bitflags = "1.2.1"
xmas-elf
=
"0.7.0"
volatile
=
"0.3"
virtio-drivers
=
{
git
=
"https://github.com/rcore-os/virtio-drivers"
,
rev
=
"4ee80e5"
}
k210-pac
=
{
git
=
"https://github.com/wyfcyx/k210-pac"
}
k210-hal
=
{
git
=
"https://github.com/wyfcyx/k210-hal"
}
k210-soc
=
{
git
=
"https://github.com/wyfcyx/k210-soc"
}
easy-fs
=
{
path
=
"../easy-fs"
}
virtio-input-decoder
=
"0.1.4"
embedded-graphics
=
"0.7.1"
tinybmp
=
"0.3.1"
[features]
board_qemu
=
[]
board_k210
=
[]
[profile.release]
debug
=
true
os/Makefile
浏览文件 @
f2318967
...
...
@@ -5,14 +5,12 @@ KERNEL_ELF := target/$(TARGET)/$(MODE)/os
KERNEL_BIN
:=
$(KERNEL_ELF)
.bin
DISASM_TMP
:=
target/
$(TARGET)
/
$(MODE)
/asm
FS_IMG
:=
../user/target/
$(TARGET)
/
$(MODE)
/fs.img
SDCARD
:=
/dev/sdb
APPS
:=
../user/src/bin/
*
# BOARD
BOARD
?
=
qemu
BOARD
:
=
qemu
SBI
?=
rustsbi
BOOTLOADER
:=
../bootloader/
$(SBI)
-
$(BOARD)
.bin
K210_BOOTLOADER_SIZE
:=
131072
# Building mode argument
ifeq
($(MODE), release)
...
...
@@ -20,15 +18,7 @@ ifeq ($(MODE), release)
endif
# KERNEL ENTRY
ifeq
($(BOARD), qemu)
KERNEL_ENTRY_PA
:=
0x80200000
else
ifeq
($(BOARD), k210)
KERNEL_ENTRY_PA
:=
0x80020000
endif
# Run K210
K210-SERIALPORT
=
/dev/ttyUSB0
K210-BURNER
=
../tools/kflash.py
KERNEL_ENTRY_PA
:=
0x80200000
# Binutils
OBJDUMP
:=
rust-objdump
--arch-name
=
riscv64
...
...
@@ -40,14 +30,7 @@ DISASM ?= -x
# Run usertests or usershell
TEST
?=
build
:
env switch-check $(KERNEL_BIN) fs-img
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
build
:
env $(KERNEL_BIN) fs-img
env
:
(
rustup target list |
grep
"riscv64gc-unknown-none-elf (installed)"
)
||
rustup target add
$(TARGET)
...
...
@@ -55,11 +38,6 @@ env:
rustup component add rust-src
rustup component add llvm-tools-preview
sdcard
:
fs-img
@
echo
"Are you sure write to
$(SDCARD)
? [y/N] "
&&
read
ans
&&
[
$
${
ans
:-
N
}
=
y
]
@
sudo dd
if
=
/dev/zero
of
=
$(SDCARD)
bs
=
1048576
count
=
32
@
sudo dd
if
=
$(FS_IMG)
of
=
$(SDCARD)
$(KERNEL_BIN)
:
kernel
@
$(OBJCOPY)
$(KERNEL_ELF)
--strip-all
-O
binary
$@
...
...
@@ -73,7 +51,7 @@ $(APPS):
kernel
:
@
echo
Platform:
$(BOARD)
@
cp
src/linker-
$(BOARD)
.ld src/linker.ld
@
cargo build
--release
--features
"board_
$(BOARD)
"
@
cargo build
--release
@
rm
src/linker.ld
clean
:
...
...
@@ -105,7 +83,6 @@ ifeq ($(BOARD),qemu)
endif
run-inner
:
build
ifeq
($(BOARD),qemu)
@
qemu-system-riscv64
\
-M
128m
\
-machine
virt
\
...
...
@@ -118,15 +95,6 @@ ifeq ($(BOARD),qemu)
-device
virtio-keyboard-device
\
-device
virtio-mouse-device
\
-serial
stdio
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
@
tmux new-session
-d
\
...
...
@@ -141,4 +109,4 @@ gdbserver: build
gdbclient
:
@
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
fs-img gdbserver gdbclient
.PHONY
:
build env kernel clean disasm disasm-vim run-inner fs-img gdbserver gdbclient
os/src/boards/k210.rs
已删除
100644 → 0
浏览文件 @
e2709203
pub
const
CLOCK_FREQ
:
usize
=
403000000
/
62
;
pub
const
MMIO
:
&
[(
usize
,
usize
)]
=
&
[
// we don't need clint in S priv when running
// we only need claim/complete for target0 after initializing
(
0x0C00_0000
,
0x3000
),
/* PLIC */
(
0x0C20_0000
,
0x1000
),
/* PLIC */
(
0x3800_0000
,
0x1000
),
/* UARTHS */
(
0x3800_1000
,
0x1000
),
/* GPIOHS */
(
0x5020_0000
,
0x1000
),
/* GPIO */
(
0x5024_0000
,
0x1000
),
/* SPI_SLAVE */
(
0x502B_0000
,
0x1000
),
/* FPIOA */
(
0x502D_0000
,
0x1000
),
/* TIMER0 */
(
0x502E_0000
,
0x1000
),
/* TIMER1 */
(
0x502F_0000
,
0x1000
),
/* TIMER2 */
(
0x5044_0000
,
0x1000
),
/* SYSCTL */
(
0x5200_0000
,
0x1000
),
/* SPI0 */
(
0x5300_0000
,
0x1000
),
/* SPI1 */
(
0x5400_0000
,
0x1000
),
/* SPI2 */
];
pub
type
BlockDeviceImpl
=
crate
::
drivers
::
block
::
SDCardWrapper
;
pub
fn
device_init
()
{
unimplemented!
();
}
pub
fn
irq_handler
()
{
unimplemented!
();
}
os/src/console.rs
浏览文件 @
f2318967
use
crate
::
drivers
::
chardev
::
CharDevice
;
#[cfg(feature
=
"board_qemu"
)]
use
crate
::
drivers
::
chardev
::
UART
;
#[cfg(feature
=
"board_k210"
)]
use
crate
::
sbi
::
console_putchar
;
use
core
::
fmt
::{
self
,
Write
};
struct
Stdout
;
...
...
@@ -10,10 +7,7 @@ struct Stdout;
impl
Write
for
Stdout
{
fn
write_str
(
&
mut
self
,
s
:
&
str
)
->
fmt
::
Result
{
for
c
in
s
.chars
()
{
#[cfg(feature
=
"board_qemu"
)]
UART
.write
(
c
as
u8
);
#[cfg(feature
=
"board_k210"
)]
console_putchar
(
c
as
usize
);
}
Ok
(())
}
...
...
os/src/drivers/block/mod.rs
浏览文件 @
f2318967
mod
sdcard
;
mod
virtio_blk
;
pub
use
sdcard
::
SDCardWrapper
;
pub
use
virtio_blk
::
VirtIOBlock
;
use
crate
::
board
::
BlockDeviceImpl
;
...
...
os/src/drivers/block/sdcard.rs
已删除
100644 → 0
浏览文件 @
e2709203
此差异已折叠。
点击以展开。
os/src/drivers/chardev/mod.rs
浏览文件 @
f2318967
mod
ns16550a
;
#[cfg(feature
=
"board_qemu"
)]
use
crate
::
board
::
CharDeviceImpl
;
use
alloc
::
sync
::
Arc
;
use
lazy_static
::
*
;
...
...
@@ -11,7 +10,7 @@ pub trait CharDevice {
fn
write
(
&
self
,
ch
:
u8
);
fn
handle_irq
(
&
self
);
}
#[cfg(feature
=
"board_qemu"
)]
lazy_static!
{
pub
static
ref
UART
:
Arc
<
CharDeviceImpl
>
=
Arc
::
new
(
CharDeviceImpl
::
new
());
}
os/src/drivers/input/mod.rs
浏览文件 @
f2318967
...
...
@@ -9,7 +9,6 @@ use embedded_graphics::{
prelude
::{
Point
,
Size
},
text
::
Text
,
};
use
k210_hal
::
cache
::
Uncache
;
use
virtio_drivers
::{
VirtIOHeader
,
VirtIOInput
};
use
crate
::
drivers
::
bus
::
virtio
::
VirtioHal
;
use
virtio_input_decoder
::{
Decoder
,
Key
,
KeyType
};
...
...
os/src/drivers/mod.rs
浏览文件 @
f2318967
pub
mod
block
;
pub
mod
chardev
;
#[cfg(feature
=
"board_qemu"
)]
pub
mod
gpu
;
#[cfg(feature
=
"board_qemu"
)]
pub
mod
input
;
#[cfg(feature
=
"board_qemu"
)]
pub
mod
bus
;
pub
mod
plic
;
pub
use
block
::
BLOCK_DEVICE
;
#[cfg(feature
=
"board_qemu"
)]
pub
use
chardev
::
UART
;
#[cfg(feature
=
"board_qemu"
)]
pub
use
gpu
::
*
;
#[cfg(feature
=
"board_qemu"
)]
pub
use
input
::
*
;
#[cfg(feature
=
"board_qemu"
)]
pub
use
bus
::
*
;
os/src/fs/stdio.rs
浏览文件 @
f2318967
use
super
::
File
;
use
crate
::
drivers
::
chardev
::
CharDevice
;
#[cfg(feature
=
"board_qemu"
)]
use
crate
::
drivers
::
chardev
::
UART
;
use
crate
::
mm
::
UserBuffer
;
#[cfg(feature
=
"board_k210"
)]
use
crate
::
sbi
::
console_getchar
;
#[cfg(feature
=
"board_k210"
)]
use
crate
::
task
::
suspend_current_and_run_next
;
pub
struct
Stdin
;
pub
struct
Stdout
;
...
...
@@ -18,7 +13,6 @@ impl File for Stdin {
fn
writable
(
&
self
)
->
bool
{
false
}
#[cfg(feature
=
"board_qemu"
)]
fn
read
(
&
self
,
mut
user_buf
:
UserBuffer
)
->
usize
{
assert_eq!
(
user_buf
.len
(),
1
);
//println!("before UART.read() in Stdin::read()");
...
...
@@ -28,27 +22,6 @@ impl File for Stdin {
}
1
}
#[cfg(feature
=
"board_k210"
)]
fn
read
(
&
self
,
mut
user_buf
:
UserBuffer
)
->
usize
{
assert_eq!
(
user_buf
.len
(),
1
);
// busy loop
let
mut
c
:
usize
;
loop
{
c
=
console_getchar
();
if
c
==
0
{
suspend_current_and_run_next
();
continue
;
}
else
{
break
;
}
}
let
ch
=
c
as
u8
;
unsafe
{
user_buf
.buffers
[
0
]
.as_mut_ptr
()
.write_volatile
(
ch
);
}
1
}
fn
write
(
&
self
,
_u
ser_buf
:
UserBuffer
)
->
usize
{
panic!
(
"Cannot write to stdin!"
);
}
...
...
os/src/gui/mod.rs
浏览文件 @
f2318967
...
...
@@ -4,6 +4,7 @@ mod icon;
mod
image
;
mod
panel
;
mod
terminal
;
use
alloc
::
sync
::
Arc
;
pub
use
button
::
*
;
use
core
::
any
::
Any
;
...
...
os/src/linker-k210.ld
已删除
100644 → 0
浏览文件 @
e2709203
OUTPUT_ARCH(riscv)
ENTRY(_start)
BASE_ADDRESS = 0x80020000;
SECTIONS
{
. = BASE_ADDRESS;
skernel = .;
stext = .;
.text : {
*(.text.entry)
. = ALIGN(4K);
strampoline = .;
*(.text.trampoline);
. = ALIGN(4K);
*(.text .text.*)
}
. = ALIGN(4K);
etext = .;
srodata = .;
.rodata : {
*(.rodata .rodata.*)
*(.srodata .srodata.*)
}
. = ALIGN(4K);
erodata = .;
sdata = .;
.data : {
*(.data .data.*)
*(.sdata .sdata.*)
}
. = ALIGN(4K);
edata = .;
sbss_with_stack = .;
.bss : {
*(.bss.stack)
sbss = .;
*(.bss .bss.*)
*(.sbss .sbss.*)
}
. = ALIGN(4K);
ebss = .;
ekernel = .;
/DISCARD/ : {
*(.eh_frame)
}
}
\ No newline at end of file
os/src/main.rs
浏览文件 @
f2318967
...
...
@@ -2,7 +2,7 @@
#![no_main]
#![feature(panic_info_message)]
#![feature(alloc_error_handler)]
#[cfg(feature
=
"board_qemu"
)]
use
crate
::
drivers
::{
GPU_DEVICE
,
KEYBOARD_DEVICE
,
MOUSE_DEVICE
};
extern
crate
alloc
;
...
...
@@ -10,10 +10,6 @@ extern crate alloc;
#[macro_use]
extern
crate
bitflags
;
#[cfg(feature
=
"board_k210"
)]
#[path
=
"boards/k210.rs"
]
mod
board
;
#[cfg(not(any(feature
=
"board_k210"
)))]
#[path
=
"boards/qemu.rs"
]
mod
board
;
...
...
@@ -22,7 +18,6 @@ mod console;
mod
config
;
mod
drivers
;
mod
fs
;
#[cfg(feature
=
"board_qemu"
)]
mod
gui
;
mod
lang_items
;
mod
mm
;
...
...
@@ -61,13 +56,10 @@ pub fn rust_main() -> ! {
clear_bss
();
mm
::
init
();
println!
(
"KERN: init gpu"
);
#[cfg(feature
=
"board_qemu"
)]
GPU_DEVICE
.clone
();
println!
(
"KERN: init keyboard"
);
#[cfg(feature
=
"board_qemu"
)]
KEYBOARD_DEVICE
.clone
();
println!
(
"KERN: init mouse"
);
#[cfg(feature
=
"board_qemu"
)]
MOUSE_DEVICE
.clone
();
println!
(
"KERN: init trap"
);
trap
::
init
();
...
...
os/src/sbi.rs
浏览文件 @
f2318967
...
...
@@ -40,13 +40,7 @@ pub fn console_getchar() -> usize {
sbi_call
(
SBI_CONSOLE_GETCHAR
,
0
,
0
,
0
)
}
#[cfg(feature
=
"board_qemu"
)]
use
crate
::
board
::
QEMUExit
;
pub
fn
shutdown
(
exit_code
:
usize
)
->
!
{
#[cfg(feature
=
"board_k210"
)]
sbi_call
(
SBI_SHUTDOWN
,
exit_code
,
0
,
0
);
#[cfg(feature
=
"board_qemu"
)]
crate
::
board
::
QEMU_EXIT_HANDLE
.exit_failure
();
#[cfg(feature
=
"board_k210"
)]
panic!
(
"It should shutdown!"
);
crate
::
board
::
QEMU_EXIT_HANDLE
.exit_failure
()
}
os/src/syscall/mod.rs
浏览文件 @
f2318967
...
...
@@ -27,22 +27,18 @@ const SYSCALL_CONDVAR_SIGNAL: usize = 1031;
const
SYSCALL_CONDVAR_WAIT
:
usize
=
1032
;
const
SYSCALL_CREATE_DESKTOP
:
usize
=
2000
;
mod
fs
;
#[cfg(feature
=
"board_qemu"
)]
mod
gui
;
mod
process
;
mod
sync
;
mod
thread
;
#[cfg(feature
=
"board_qemu"
)]
pub
use
self
::
gui
::
create_desktop
;
use
fs
::
*
;
#[cfg(feature
=
"board_qemu"
)]
pub
use
gui
::
PAD
;
use
process
::
*
;
use
sync
::
*
;
use
thread
::
*
;
#[cfg(feature
=
"board_qemu"
)]
pub
fn
syscall
(
syscall_id
:
usize
,
args
:
[
usize
;
3
])
->
isize
{
match
syscall_id
{
SYSCALL_DUP
=>
sys_dup
(
args
[
0
]),
...
...
@@ -77,36 +73,3 @@ pub fn syscall(syscall_id: usize, args: [usize; 3]) -> isize {
}
}
#[cfg(feature
=
"board_k210"
)]
pub
fn
syscall
(
syscall_id
:
usize
,
args
:
[
usize
;
3
])
->
isize
{
match
syscall_id
{
SYSCALL_DUP
=>
sys_dup
(
args
[
0
]),
SYSCALL_OPEN
=>
sys_open
(
args
[
0
]
as
*
const
u8
,
args
[
1
]
as
u32
),
SYSCALL_CLOSE
=>
sys_close
(
args
[
0
]),
SYSCALL_PIPE
=>
sys_pipe
(
args
[
0
]
as
*
mut
usize
),
SYSCALL_READ
=>
sys_read
(
args
[
0
],
args
[
1
]
as
*
const
u8
,
args
[
2
]),
SYSCALL_WRITE
=>
sys_write
(
args
[
0
],
args
[
1
]
as
*
const
u8
,
args
[
2
]),
SYSCALL_EXIT
=>
sys_exit
(
args
[
0
]
as
i32
),
SYSCALL_SLEEP
=>
sys_sleep
(
args
[
0
]),
SYSCALL_YIELD
=>
sys_yield
(),
SYSCALL_KILL
=>
sys_kill
(
args
[
0
],
args
[
1
]
as
u32
),
SYSCALL_GET_TIME
=>
sys_get_time
(),
SYSCALL_GETPID
=>
sys_getpid
(),
SYSCALL_FORK
=>
sys_fork
(),
SYSCALL_EXEC
=>
sys_exec
(
args
[
0
]
as
*
const
u8
,
args
[
1
]
as
*
const
usize
),
SYSCALL_WAITPID
=>
sys_waitpid
(
args
[
0
]
as
isize
,
args
[
1
]
as
*
mut
i32
),
SYSCALL_THREAD_CREATE
=>
sys_thread_create
(
args
[
0
],
args
[
1
]),
SYSCALL_GETTID
=>
sys_gettid
(),
SYSCALL_WAITTID
=>
sys_waittid
(
args
[
0
])
as
isize
,
SYSCALL_MUTEX_CREATE
=>
sys_mutex_create
(
args
[
0
]
==
1
),
SYSCALL_MUTEX_LOCK
=>
sys_mutex_lock
(
args
[
0
]),
SYSCALL_MUTEX_UNLOCK
=>
sys_mutex_unlock
(
args
[
0
]),
SYSCALL_SEMAPHORE_CREATE
=>
sys_semaphore_create
(
args
[
0
]),
SYSCALL_SEMAPHORE_UP
=>
sys_semaphore_up
(
args
[
0
]),
SYSCALL_SEMAPHORE_DOWN
=>
sys_semaphore_down
(
args
[
0
]),
SYSCALL_CONDVAR_CREATE
=>
sys_condvar_create
(
args
[
0
]),
SYSCALL_CONDVAR_SIGNAL
=>
sys_condvar_signal
(
args
[
0
]),
SYSCALL_CONDVAR_WAIT
=>
sys_condvar_wait
(
args
[
0
],
args
[
1
]),
_
=>
panic!
(
"Unsupported syscall_id: {}"
,
syscall_id
),
}
}
os/src/task/mod.rs
浏览文件 @
f2318967
...
...
@@ -56,7 +56,6 @@ pub fn block_current_and_run_next() {
let
task_cx_ptr
=
block_current_task
();
schedule
(
task_cx_ptr
);
}
#[cfg(feature
=
"board_qemu"
)]
use
crate
::
board
::
QEMUExit
;
pub
fn
exit_current_and_run_next
(
exit_code
:
i32
)
{
...
...
@@ -75,7 +74,6 @@ pub fn exit_current_and_run_next(exit_code: i32) {
// the process should terminate at once
if
tid
==
0
{
let
pid
=
process
.getpid
();
#[cfg(feature
=
"board_qemu"
)]
if
pid
==
IDLE_PID
{
println!
(
"[kernel] Idle process exit with exit_code {} ..."
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录