Browse Source

Use ticket mutex for legacy stdio handler

Remove dependency on `lazy_static`
luojia65 3 years ago
parent
commit
d21efc4bb4
3 changed files with 4 additions and 7 deletions
  1. 1 0
      CHANGELOG.md
  2. 1 2
      Cargo.toml
  3. 2 5
      src/legacy_stdio.rs

+ 1 - 0
CHANGELOG.md

@@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - Use `embedded-hal` dependency version `0.2.6`
 - Use `embedded-hal` dependency version `0.2.6`
 - Change to asynchronous lock structure trait style
 - Change to asynchronous lock structure trait style
 - Function `num_counters` returns `usize` and its SBI call must return `SBI_SUCCESS`
 - Function `num_counters` returns `usize` and its SBI call must return `SBI_SUCCESS`
+- Use ticket mutex for legacy stdio handler; remove dependency on `lazy_static`
 
 
 ### Fixed
 ### Fixed
 - Test kernel console now will lock before `println` line is finished
 - Test kernel console now will lock before `println` line is finished

+ 1 - 2
Cargo.toml

@@ -28,5 +28,4 @@ targets = [
 embedded-hal = "0.2.6"
 embedded-hal = "0.2.6"
 nb = "1.0"
 nb = "1.0"
 riscv = "0.7"
 riscv = "0.7"
-spin = "0.9"
-lazy_static = { version = "1", features = ["spin_no_std"] }
+spin = { version = "0.9", features = ["ticket_mutex"] } 

+ 2 - 5
src/legacy_stdio.rs

@@ -60,12 +60,9 @@ where
 }
 }
 
 
 use alloc::boxed::Box;
 use alloc::boxed::Box;
-use spin::Mutex;
+use spin::mutex::TicketMutex;
 
 
-lazy_static::lazy_static! {
-    static ref LEGACY_STDIO: Mutex<Option<Box<dyn LegacyStdio>>> =
-        Mutex::new(None);
-}
+static LEGACY_STDIO: TicketMutex<Option<Box<dyn LegacyStdio>>> = TicketMutex::new(None);
 
 
 #[doc(hidden)] // use through a macro
 #[doc(hidden)] // use through a macro
 pub fn init_legacy_stdio_embedded_hal<T: Read<u8> + Write<u8> + Send + 'static>(serial: T) {
 pub fn init_legacy_stdio_embedded_hal<T: Read<u8> + Write<u8> + Send + 'static>(serial: T) {