Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
rcore-os
RCore Tutorial V3
提交
f613fa12
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,发现更多精彩内容 >>
提交
f613fa12
编写于
11月 18, 2020
作者:
Y
Yifan Wu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Working on app data auto linking.
上级
d1fcf2fc
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
62 addition
and
18 deletion
+62
-18
.gitignore
.gitignore
+2
-1
os/build.rs
os/build.rs
+34
-0
os/src/main.rs
os/src/main.rs
+6
-16
os/src/syscall/mod.rs
os/src/syscall/mod.rs
+2
-0
os/src/trap.rs
os/src/trap.rs
+0
-0
user/.cargo/config
user/.cargo/config
+1
-1
user/Makefile
user/Makefile
+17
-0
未找到文件。
.gitignore
浏览文件 @
f613fa12
.idea/*
os/target/*
os/.idea/*
os/src/link_app.S
user/target/*
user/.idea/*
\ No newline at end of file
os/build.rs
0 → 100644
浏览文件 @
f613fa12
use
std
::
io
::{
Result
,
Write
};
use
std
::
fs
::{
File
,
read_dir
};
fn
main
()
{
println!
(
"cargo:rerun-if-changed=../user"
);
insert_app_data
()
.unwrap
();
}
static
TARGET_PATH
:
&
'static
str
=
"../user/target/riscv64gc-unknown-none-elf/release/"
;
fn
insert_app_data
()
->
Result
<
()
>
{
let
mut
f
=
File
::
create
(
"src/link_app.S"
)
.unwrap
();
let
apps
:
Vec
<
_
>
=
read_dir
(
"../user/src/bin"
)
.unwrap
()
.into_iter
()
.map
(|
dir_entry
|
{
let
mut
name_with_ext
=
dir_entry
.unwrap
()
.file_name
()
.into_string
()
.unwrap
();
name_with_ext
.drain
(
name_with_ext
.find
(
'.'
)
.unwrap
()
..
name_with_ext
.len
());
name_with_ext
})
.collect
();
for
(
idx
,
app_with_extension
)
in
apps
.iter
()
.enumerate
()
{
writeln!
(
f
,
r#"
.section .data
.global app_{0}_start
.global app_{0}_end
app_{0}_start:
.incbin "{2}{1}"
app_{0}_end:
"#
,
idx
,
app_with_extension
,
TARGET_PATH
)
?
;
}
Ok
(())
}
\ No newline at end of file
os/src/main.rs
浏览文件 @
f613fa12
...
...
@@ -8,9 +8,11 @@
mod
console
;
mod
lang_items
;
mod
sbi
;
mod
syscall
;
mod
trap
;
global_asm!
(
include_str!
(
"entry.asm"
));
global_asm!
(
include_str!
(
"link_app.S"
));
fn
clear_bss
()
{
extern
"C"
{
...
...
@@ -25,23 +27,11 @@ fn clear_bss() {
#[no_mangle]
pub
fn
rust_main
()
->
!
{
extern
"C"
{
fn
stext
();
fn
etext
();
fn
srodata
();
fn
erodata
();
fn
sdata
();
fn
edata
();
fn
sbss
();
fn
ebss
();
fn
boot_stack
();
fn
boot_stack_top
();
fn
app_0_start
();
fn
app_0_end
();
};
clear_bss
();
println!
(
"Hello, world!"
);
println!
(
".text [{:#x}, {:#x})"
,
stext
as
usize
,
etext
as
usize
);
println!
(
".rodata [{:#x}, {:#x})"
,
srodata
as
usize
,
erodata
as
usize
);
println!
(
".data [{:#x}, {:#x})"
,
sdata
as
usize
,
edata
as
usize
);
println!
(
"boot_stack [{:#x}, {:#x})"
,
boot_stack
as
usize
,
boot_stack_top
as
usize
);
println!
(
".bss [{:#x}, {:#x})"
,
sbss
as
usize
,
ebss
as
usize
);
println!
(
"app_0 [{:#x}, {:#x})"
,
app_0_start
as
usize
,
app_0_end
as
usize
);
panic!
(
"Shutdown machine!"
);
}
\ No newline at end of file
os/src/syscall/mod.rs
0 → 100644
浏览文件 @
f613fa12
const
SYSCALL_WRITE
:
usize
=
64
;
os/src/trap.rs
0 → 100644
浏览文件 @
f613fa12
user/.cargo/config
浏览文件 @
f613fa12
user/Makefile
0 → 100644
浏览文件 @
f613fa12
TARGET
:=
riscv64gc-unknown-none-elf
MODE
:=
release
APP_DIR
:=
src/bin
TARGET_DIR
:=
target/
$(TARGET)
/
$(MODE)
ELFS
:=
$(
patsubst
$(APP_DIR)
/
*
.rs,
$(TARGET_DIR)
/
*
,
$(
wildcard
$(APP_DIR)
/
*
.rs
))
BINS
:=
$(
patsubst
$(APP_DIR)
/
*
.rs,
$(TARGET_DIR)
/
*
.bin,
$(
wildcard
$(APP_DIR)
/
*
.rs
))
OBJDUMP
:=
rust-objdump
--arch-name
=
riscv64
OBJCOPY
:=
rust-objcopy
--binary-architecture
=
riscv64
elf
:
@
cargo build
--release
binary
:
elf
$(
foreach
elf,
$(ELFS)
,
$(OBJCOPY)
$(elf)
--strip-all
-O
binary
$(
patsubst
$(TARGET_DIR)
/
*
,
$(TARGET_DIR)
/
*
.bin,
$(elf)
))
build
:
binary
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录