Skip to content

Commit 864f1e9

Browse files
committed
fix(lab/1): use target_os = "none" for panic_handler
1 parent 1426fc2 commit 864f1e9

File tree

3 files changed

+2
-12
lines changed

3 files changed

+2
-12
lines changed

docs/labs/0x00/tasks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ targets = [ "x86_64-unknown-uefi" ]
291291

292292
```json
293293
{
294-
"rust-analyzer.cargo.target": "x86_64-unknown-none"
294+
"rust-analyzer.cargo.target": "x86_64-unknown-uefi"
295295
}
296296
```
297297

docs/labs/0x01/tasks.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -219,16 +219,6 @@ unsafe {
219219

220220
## UART 与日志输出
221221

222-
!!! tip "rust-analyzer 总是提示有重复 `panic_handler` 的错误?"
223-
224-
通过 VSCode 配置项:`rust-analyzer.cargo.target` 来指定目标平台,避免 rust-analyzer 猜测你的目标架构为 `uefi`:
225-
226-
```json
227-
{
228-
"rust-analyzer.cargo.target": "x86_64-unknown-none"
229-
}
230-
```
231-
232222
### 串口驱动
233223

234224
[UART 串口通信](../../wiki/uart.md) 部分中介绍了 UART 的基本原理,以及相关的基础知识。在这一部分实验中,你将会实现一个简单的串口驱动,并将其用于内核的日志输出。

src/0x01/pkg/kernel/src/utils/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub fn print_internal(args: Arguments) {
6464
}
6565

6666
#[allow(dead_code)]
67-
#[cfg_attr(not(test), panic_handler)]
67+
#[cfg_attr(target_os = "none", panic_handler)]
6868
fn panic(info: &core::panic::PanicInfo) -> ! {
6969
// force unlock serial for panic output
7070
unsafe { SERIAL.get().unwrap().force_unlock() };

0 commit comments

Comments
 (0)