mirror of
https://github.com/rcore-os/rCore-Tutorial-v3.git
synced 2024-11-22 09:26:26 +04:00
fix rust-analyzer warning
This commit is contained in:
parent
07c6cb366b
commit
e4e089f2c5
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
@ -7,7 +7,7 @@
|
|||||||
// For Rust Analyzer plugin users:
|
// For Rust Analyzer plugin users:
|
||||||
"rust-analyzer.cargo.target": "riscv64gc-unknown-none-elf",
|
"rust-analyzer.cargo.target": "riscv64gc-unknown-none-elf",
|
||||||
"rust-analyzer.checkOnSave.allTargets": false,
|
"rust-analyzer.checkOnSave.allTargets": false,
|
||||||
"rust-analyzer.cargo.features": [
|
// "rust-analyzer.cargo.features": [
|
||||||
"board_qemu"
|
// "board_qemu"
|
||||||
]
|
// ]
|
||||||
}
|
}
|
@ -11,6 +11,6 @@ clap = "2.33.3"
|
|||||||
easy-fs = { path = "../easy-fs" }
|
easy-fs = { path = "../easy-fs" }
|
||||||
rand = "0.8.0"
|
rand = "0.8.0"
|
||||||
|
|
||||||
[features]
|
# [features]
|
||||||
board_qemu = []
|
# board_qemu = []
|
||||||
board_k210 = []
|
# board_k210 = []
|
@ -14,6 +14,6 @@ riscv = { git = "https://github.com/rcore-os/riscv", features = ["inline-asm"] }
|
|||||||
[profile.release]
|
[profile.release]
|
||||||
debug = true
|
debug = true
|
||||||
|
|
||||||
[features]
|
# [features]
|
||||||
board_qemu = []
|
# board_qemu = []
|
||||||
board_k210 = []
|
# board_k210 = []
|
@ -4,7 +4,7 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
#![feature(naked_functions)]
|
#![feature(naked_functions)]
|
||||||
#![feature(asm)]
|
//#![feature(asm)]
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
@ -12,7 +12,7 @@ extern crate user_lib;
|
|||||||
|
|
||||||
use core::arch::asm;
|
use core::arch::asm;
|
||||||
|
|
||||||
#[macro_use]
|
//#[macro_use]
|
||||||
use alloc::vec;
|
use alloc::vec;
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ impl Task {
|
|||||||
// we can allocate memory for it later, but it keeps complexity down and lets us focus on more interesting parts
|
// we can allocate memory for it later, but it keeps complexity down and lets us focus on more interesting parts
|
||||||
// to do it here. The important part is that once allocated it MUST NOT move in memory.
|
// to do it here. The important part is that once allocated it MUST NOT move in memory.
|
||||||
Task {
|
Task {
|
||||||
id,
|
id:id,
|
||||||
stack: vec![0_u8; DEFAULT_STACK_SIZE],
|
stack: vec![0_u8; DEFAULT_STACK_SIZE],
|
||||||
ctx: TaskContext::default(),
|
ctx: TaskContext::default(),
|
||||||
state: State::Available,
|
state: State::Available,
|
||||||
@ -185,6 +185,7 @@ impl Runtime {
|
|||||||
.find(|t| t.state == State::Available)
|
.find(|t| t.state == State::Available)
|
||||||
.expect("no available task.");
|
.expect("no available task.");
|
||||||
|
|
||||||
|
println!("RUNTIME: spawning task {}\n", available.id);
|
||||||
let size = available.stack.len();
|
let size = available.stack.len();
|
||||||
unsafe {
|
unsafe {
|
||||||
let s_ptr = available.stack.as_mut_ptr().offset(size as isize);
|
let s_ptr = available.stack.as_mut_ptr().offset(size as isize);
|
||||||
@ -259,7 +260,7 @@ pub fn yield_task() {
|
|||||||
/// see: https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html
|
/// see: https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html
|
||||||
#[naked]
|
#[naked]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
unsafe fn switch(old: *mut TaskContext, new: *const TaskContext) {
|
unsafe extern "C" fn switch(old: *mut TaskContext, new: *const TaskContext) {
|
||||||
// a0: _old, a1: _new
|
// a0: _old, a1: _new
|
||||||
asm!(
|
asm!(
|
||||||
"
|
"
|
||||||
|
Loading…
Reference in New Issue
Block a user