Skip to content

Commit 698d755

Browse files
authored
Merge pull request #59 from Yakkhini/main
Fix: Used but undeclared macro 'asm!'.
2 parents ca8f42e + a158acb commit 698d755

File tree

4 files changed

+61
-39
lines changed

4 files changed

+61
-39
lines changed

QA.md

+50-28
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
# 常见问题解答
22

3-
## Q0:GitHub classroom是啥?如何使用?
3+
## Q0:GitHub classroom 是啥?如何使用?
44

5-
### A:
5+
### A
66

7-
- [B站的GitHub Classroom 视频介绍](https://www.bilibili.com/video/BV12L41147r7?spm_id_from=333.337.search-card.all.click&vd_source=8e19ee6e49f598fda8c17e306d8b3726)
8-
- [Youtube的GitHub Classroom视频介绍](https://www.youtube.com/playlist?list=PLIRjfNq867bewk3ZGV6Z7a16YDNRCpK3u)
9-
- [github文档:使用 GitHub Classroom 教学](https://docs.github.com/cn/education/manage-coursework-with-github-classroom/get-started-with-github-classroom)
7+
- [B 站的 GitHub Classroom 视频介绍](https://www.bilibili.com/video/BV12L41147r7?spm_id_from=333.337.search-card.all.click&vd_source=8e19ee6e49f598fda8c17e306d8b3726)
8+
- [Youtube 的 GitHub Classroom 视频介绍](https://www.youtube.com/playlist?list=PLIRjfNq867bewk3ZGV6Z7a16YDNRCpK3u)
9+
- [GitHub 文档:使用 GitHub Classroom 教学](https://docs.github.com/cn/education/manage-coursework-with-github-classroom/get-started-with-github-classroom)
1010

11-
## Q1:已经在classroom中建立了自己的仓库(例如 “LearningOS/lab0-0-setup-env-run-os1-chyyuu2022"),但是源仓库“LearningOS/rust-based-os-comp2022更新了,如何处理?
11+
## Q1:已经在 classroom 中建立了自己的仓库(例如“LearningOS/lab0-0-setup-env-run-os1-chyyuu2022),但是源仓库“LearningOS/rust-based-os-comp2022更新了,如何处理?
1212

1313
### A:
1414

1515
**方法一:**
1616

17-
重新点击加入课程的链接,在页面下方会有一行字“We've configured the repository associated with this assignment (update)”,“update”是一个链接,点击update就可以把自己的仓库更新到与最新状态的repository template一致
17+
重新点击加入课程的链接,在页面下方会有一行字“We've configured the repository associated with this assignment (update)”,“update”是一个链接,点击 update 就可以把自己的仓库更新到与最新状态的 repository template 一致
1818

1919
2020
**方法二:**
2121

22-
在自己构建的仓库根目录下执行以下命令:
22+
在自己构建的仓库根目录下执行以下命令
2323

2424
```makefile
2525
git remote add upstream "https://github.com/LearningOS/rust-based-os-comp2022.git"
@@ -35,49 +35,71 @@ git push -f
3535

3636
向管理员“助教许善朴”申请删除已生成仓库,再点击 链接重新创建仓库。
3737

38-
## Q2:在classroom中建立了自己的仓库中,进行提交 `git push` 后,触发 CI后,出现 Annotations 错误“The job was not stared because recent account payments have failed or your spending limit needs to be increased. Please check the 'Billing & plans' section in your settings”,无法完成自动CI功能,比如 `Autograding` 等。
38+
## Q2:在 classroom 中建立了自己的仓库中,进行提交 `git push` 后,触发 CI 后,出现 Annotations 错误“The job was not stared because recent account payments have failed or your spending limit needs to be increased. Please check the 'Billing & plans' section in your settings”,无法完成自动 CI 功能,比如 `Autograding` 等。
3939

40-
### A:
40+
### A
4141

4242
**方法一:**
4343

44-
这是由于对用户的私有仓库进行CI 相关的github action是需要付费的。用户可通过给自己的github账户充值来解决https://docs.github.com/cn/billing/managing-billing-for-github-actions/about-billing-for-github-actions 给出了具体信息。
44+
这是由于对用户的私有仓库进行 CI 相关的 GitHub Action 是需要付费的。用户可通过给自己的 github 账户充值来解决https://docs.github.com/cn/billing/managing-billing-for-github-actions/about-billing-for-github-actions 给出了具体信息。
4545

4646
**方法二:**
4747

48-
对用户的公开仓库进行CI github action是不需要付费的。在项目的 `Settings` -> `Change visibility` 将项目改成Public, 重新触发Action
49-
目前设置了让用户具有修改自己的项目从private --> public的能力
48+
对用户的公开仓库进行 CI GitHub Action 是不需要付费的。在项目的 `Settings` -> `Change visibility` 将项目改成 Public, 重新触发 Action
49+
目前设置了让用户具有修改自己的项目从 private --> public 的能力
5050
如果用户还是发现自己的权限不够,或看不到 `Settings` 这个选项,可以通过联系助教帮助来解决。
5151

52-
## Q3:我刚开始准备学习Rust,是Rust新手,我应该如何入门?
52+
## Q3:我刚开始准备学习 Rust,是 Rust 新手,我应该如何入门?
5353

54-
### A:
54+
### A
5555

5656
- [Rust 大佬给初学者的学习建议](https://github.com/rustlang-cn/Rustt/blob/main/Articles/%5B2022-04-02%5D%20Rust%20%E5%A4%A7%E4%BD%AC%E7%BB%99%E5%88%9D%E5%AD%A6%E8%80%85%E7%9A%84%E5%AD%A6%E4%B9%A0%E5%BB%BA%E8%AE%AE.md)
5757
- [张汉东:学习 Rust 你需要一个认知框架](https://zhuanlan.zhihu.com/p/494001676)
58-
- [Rust语言圣经(Rust Course)](https://course.rs/)
59-
- [Rust速查表(cheatsheet)](https://cheats.rs/) 该项目不仅提供了基础的语法速查,还有执行顺序详解和编写时需要关注的注意事项。项目还包含了示例代码(EX)、书籍(BK)、标准(STD)等相关资料的扩展。
58+
- [Rust 语言圣经(Rust Course](https://course.rs/)
59+
- [Rust 速查表(cheatsheet)](https://cheats.rs/) 该项目不仅提供了基础的语法速查,还有执行顺序详解和编写时需要关注的注意事项。项目还包含了示例代码(EX)、书籍(BK)、标准(STD)等相关资料的扩展。
6060

61-
## Q4:我不熟悉GitHub和Git,有啥快速入门的资源吗?
61+
## Q4:我不熟悉 GitHub 和 Git,有啥快速入门的资源吗?
6262

63-
### A:
63+
### A
6464

65-
- [包括:从 0 开始学习 GitHub 系列1-7](https://jtxiao.com/main/categories/%E5%B7%A5%E5%85%B7/)
66-
- [超级简单的Git入门](https://backlog.com/git-tutorial/cn/)
65+
- [包括:从 0 开始学习 GitHub 系列 1-7](https://jtxiao.com/main/categories/%E5%B7%A5%E5%85%B7/)
66+
- [超级简单的 Git 入门](https://backlog.com/git-tutorial/cn/)
6767
- [git - 简明指南](https://rogerdudler.github.io/git-guide/index.zh.html)
68-
- [中文git-tips](https://github.com/521xueweihan/git-tips)
68+
- [中文 git-tips](https://github.com/521xueweihan/git-tips)
6969
- [GitHub 官方制作的 Git 速查表](https://education.github.com/git-cheat-sheet-education.pdf)
7070

71-
## Q5:我不熟悉Linux的各种命令,有啥快速入门的资源吗?
71+
## Q5:我不熟悉 Linux 的各种命令,有啥快速入门的资源吗?
7272

73-
### A:
73+
### A
7474

75-
- [中文Linux命令(linux-command)搜索引擎](https://wangchujiang.com/linux-command/)随用随搜Linux命令,而且还支持中文搜索
75+
- [中文 Linux 命令(linux-command)搜索引擎](https://wangchujiang.com/linux-command/)随用随搜 Linux 命令,而且还支持中文搜索
7676
- [新版 Linux 命令百科全书》(英文)](https://github.com/tldr-pages/tldr)
7777

78-
## Q6:我碰到一些命令/应用(比如vim, curl)、操作(比如vscode)或语言用法(比如Makefile)等不知到哪里能快速查找,怎么办?
78+
## Q6:我碰到一些命令/应用(比如 vim, curl、操作(比如 vscode)或语言用法(比如 Makefile)等不知到哪里能快速查找,怎么办?
7979

80-
### A:
80+
### A
8181

8282
- [Rico's cheatsheets](https://devhints.io/) 开源、全面的速查表网站,涵盖了前端、后端、运维、IDE 多个方面,而且界面友好简洁支持在线查看
83-
- [所有与命令行相关的cheatsheet](http://cheat.sh/):号称「你唯一需要的命令行相关速查表」
83+
- [所有与命令行相关的 cheatsheet](http://cheat.sh/):号称「你唯一需要的命令行相关速查表」
84+
85+
## Q7:我可以正常 `make run`,但使用 `make test` 命令后,构件过程报了许多错(`asm!` not found in scope),Autograding 也无法通过,怎么办?
86+
87+
### A:
88+
89+
这是由于内置的 `ci-user/riscv` 代码有错误,在 Autograding 时远程的 `riscv` 依赖被替换,导致编译失败。
90+
91+
**方法一:**
92+
93+
替换内置的 riscv 至正常版本,直接删除本地 `ci-user/riscv` 文件夹,替换为 [ Yakkhini / rust-based-os-comp2022](https://github.com/Yakkhini/rust-based-os-comp2022/tree/main/ci-user) 同位置的修复版本 `/riscv`。
94+
95+
**方法二:**
96+
97+
删除 `ci-user/overwrite.py` 21 行以下部分的依赖替换脚本。
98+
99+
**方法三:**
100+
101+
替换你实验文件夹中 `Cargo.toml` 的 riscv 依赖网址为 `https://GitHub.com/rcore-os/riscv`(修改了网址的大小写)或 `https://gitee.com/rcore-os/riscv`(改为 Gitee 源),使脚本中的替换匹配失效。
102+
103+
**方法四:**
104+
105+
如果你能看到这个 QA,说明相关 Pull request 已被 merge,可以按 QA1 中方法更新仓库。

ci-user/riscv/src/asm.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ macro_rules! instruction {
77
pub unsafe fn $fnname() {
88
match () {
99
#[cfg(all(riscv, feature = "inline-asm"))]
10-
() => asm!($asm),
10+
() => core::arch::asm!($asm),
1111

1212
#[cfg(all(riscv, not(feature = "inline-asm")))]
1313
() => {
@@ -58,7 +58,7 @@ instruction!(
5858
pub unsafe fn sfence_vma(asid: usize, addr: usize) {
5959
match () {
6060
#[cfg(all(riscv, feature = "inline-asm"))]
61-
() => asm!("sfence.vma {0}, {1}", in(reg) asid, in(reg) addr),
61+
() => core::arch::asm!("sfence.vma {0}, {1}", in(reg) asid, in(reg) addr),
6262

6363
#[cfg(all(riscv, not(feature = "inline-asm")))]
6464
() => {
@@ -87,7 +87,7 @@ mod hypervisor_extension {
8787
match () {
8888
#[cfg(all(riscv, feature = "inline-asm"))]
8989
// Since LLVM does not recognize the two registers, we assume they are placed in a0 and a1, correspondingly.
90-
() => asm!($asm, in("x10") rs1, in("x11") rs2),
90+
() => core::arch::asm!($asm, in("x10") rs1, in("x11") rs2),
9191

9292
#[cfg(all(riscv, not(feature = "inline-asm")))]
9393
() => {
@@ -112,7 +112,7 @@ mod hypervisor_extension {
112112
#[cfg(all(riscv, feature = "inline-asm"))]
113113
() => {
114114
let mut result : usize;
115-
asm!($asm, inlateout("x10") rs1 => result);
115+
core::arch::asm!($asm, inlateout("x10") rs1 => result);
116116
return result;
117117
}
118118

ci-user/riscv/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//! - Wrappers around assembly instructions like `WFI`.
1515
1616
#![no_std]
17-
#![cfg_attr(feature = "inline-asm", feature(asm))]
17+
#![cfg_attr(feature = "inline-asm", feature(asm_const))]
1818
extern crate bare_metal;
1919
#[macro_use]
2020
extern crate bitflags;

ci-user/riscv/src/register/macros.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ macro_rules! read_csr {
77
#[cfg(all(riscv, feature = "inline-asm"))]
88
() => {
99
let r: usize;
10-
asm!("csrrs {0}, {1}, x0", out(reg) r, const $csr_number);
10+
core::arch::asm!("csrrs {0}, {1}, x0", out(reg) r, const $csr_number);
1111
r
1212
}
1313

@@ -36,7 +36,7 @@ macro_rules! read_csr_rv32 {
3636
#[cfg(all(riscv32, feature = "inline-asm"))]
3737
() => {
3838
let r: usize;
39-
asm!("csrrs {0}, {1}, x0", out(reg) r, const $csr_number);
39+
core::arch::asm!("csrrs {0}, {1}, x0", out(reg) r, const $csr_number);
4040
r
4141
}
4242

@@ -102,7 +102,7 @@ macro_rules! write_csr {
102102
unsafe fn _write(bits: usize) {
103103
match () {
104104
#[cfg(all(riscv, feature = "inline-asm"))]
105-
() => asm!("csrrw x0, {1}, {0}", in(reg) bits, const $csr_number),
105+
() => core::arch::asm!("csrrw x0, {1}, {0}", in(reg) bits, const $csr_number),
106106

107107
#[cfg(all(riscv, not(feature = "inline-asm")))]
108108
() => {
@@ -128,7 +128,7 @@ macro_rules! write_csr_rv32 {
128128
unsafe fn _write(bits: usize) {
129129
match () {
130130
#[cfg(all(riscv32, feature = "inline-asm"))]
131-
() => asm!("csrrw x0, {1}, {0}", in(reg) bits, const $csr_number),
131+
() => core::arch::asm!("csrrw x0, {1}, {0}", in(reg) bits, const $csr_number),
132132

133133
#[cfg(all(riscv32, not(feature = "inline-asm")))]
134134
() => {
@@ -178,7 +178,7 @@ macro_rules! set {
178178
unsafe fn _set(bits: usize) {
179179
match () {
180180
#[cfg(all(riscv, feature = "inline-asm"))]
181-
() => asm!("csrrs x0, {1}, {0}", in(reg) bits, const $csr_number),
181+
() => core::arch::asm!("csrrs x0, {1}, {0}", in(reg) bits, const $csr_number),
182182

183183
#[cfg(all(riscv, not(feature = "inline-asm")))]
184184
() => {
@@ -204,7 +204,7 @@ macro_rules! clear {
204204
unsafe fn _clear(bits: usize) {
205205
match () {
206206
#[cfg(all(riscv, feature = "inline-asm"))]
207-
() => asm!("csrrc x0, {1}, {0}", in(reg) bits, const $csr_number),
207+
() => core::arch::asm!("csrrc x0, {1}, {0}", in(reg) bits, const $csr_number),
208208

209209
#[cfg(all(riscv, not(feature = "inline-asm")))]
210210
() => {

0 commit comments

Comments
 (0)