Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove superfluous use of lazy_static #364

Merged
merged 1 commit into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/sys/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ use alloc::string::String;
use alloc::string::ToString;
use core::fmt;
use core::sync::atomic::{AtomicBool, Ordering};
use lazy_static::lazy_static;
use spin::Mutex;
use x86_64::instructions::interrupts;

lazy_static! {
pub static ref STDIN: Mutex<String> = Mutex::new(String::new());
}

pub static STDIN: Mutex<String> = Mutex::new(String::new());
pub static ECHO: AtomicBool = AtomicBool::new(true);
pub static RAW: AtomicBool = AtomicBool::new(false);

Expand Down
5 changes: 1 addition & 4 deletions src/sys/fs/block_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@ use crate::sys;

use alloc::vec;
use alloc::vec::Vec;
use lazy_static::lazy_static;
use spin::Mutex;

lazy_static! {
pub static ref BLOCK_DEVICE: Mutex<Option<BlockDevice>> = Mutex::new(None);
}
pub static BLOCK_DEVICE: Mutex<Option<BlockDevice>> = Mutex::new(None);

pub enum BlockDevice {
Mem(MemBlockDevice),
Expand Down
2 changes: 1 addition & 1 deletion src/sys/gdt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use x86_64::instructions::tables::load_tss;
use x86_64::structures::gdt::{Descriptor, GlobalDescriptorTable, SegmentSelector};
use x86_64::structures::tss::TaskStateSegment;

const STACK_SIZE: usize = 8192;
const STACK_SIZE: usize = 1024 * 8;
pub const DOUBLE_FAULT_IST_INDEX: u16 = 0;
pub const PAGE_FAULT_IST_INDEX: u16 = 1;
pub const GENERAL_PROTECTION_FAULT_IST_INDEX: u16 = 2;
Expand Down
6 changes: 2 additions & 4 deletions src/sys/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ use crate::sys;
use crate::api::syscall;

use core::sync::atomic::{AtomicBool, Ordering};
use lazy_static::lazy_static;
use pc_keyboard::{layouts, DecodedKey, Error, HandleControl, KeyState, KeyCode, KeyEvent, Keyboard, ScancodeSet1};
use spin::Mutex;
use x86_64::instructions::port::Port;

lazy_static! {
pub static ref KEYBOARD: Mutex<Option<KeyboardLayout>> = Mutex::new(None);
}
pub static KEYBOARD: Mutex<Option<KeyboardLayout>> = Mutex::new(None);

pub static ALT: AtomicBool = AtomicBool::new(false);
pub static CTRL: AtomicBool = AtomicBool::new(false);
pub static SHIFT: AtomicBool = AtomicBool::new(false);
Expand Down
5 changes: 1 addition & 4 deletions src/sys/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use alloc::sync::Arc;
use alloc::vec::Vec;
use alloc::vec;
use core::sync::atomic::{AtomicBool, AtomicU64, Ordering};
use lazy_static::lazy_static;
use smoltcp::iface::{InterfaceBuilder, NeighborCache, Routes};
use smoltcp::phy::DeviceCapabilities;
use smoltcp::phy::{Device, Medium};
Expand All @@ -18,9 +17,7 @@ mod pcnet;

pub type Interface = smoltcp::iface::Interface<'static, EthernetDevice>;

lazy_static! {
pub static ref IFACE: Mutex<Option<Interface>> = Mutex::new(None);
}
pub static IFACE: Mutex<Option<Interface>> = Mutex::new(None);

#[derive(Clone)]
pub enum EthernetDevice {
Expand Down
5 changes: 3 additions & 2 deletions src/sys/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ const MAX_FILE_HANDLES: usize = 64;
const MAX_PROCS: usize = 2; // TODO: Update this when more than one process can run at once
const MAX_PROC_SIZE: usize = 1 << 20; // 1 MB

pub static PID: AtomicUsize = AtomicUsize::new(0);
pub static MAX_PID: AtomicUsize = AtomicUsize::new(1);

lazy_static! {
pub static ref PID: AtomicUsize = AtomicUsize::new(0);
pub static ref MAX_PID: AtomicUsize = AtomicUsize::new(1);
pub static ref PROCESS_TABLE: RwLock<[Box<Process>; MAX_PROCS]> = RwLock::new([(); MAX_PROCS].map(|_| Box::new(Process::new(0))));
}

Expand Down