misc: format sources
This commit is contained in:
+2
-5
@@ -1,5 +1,5 @@
|
||||
use vfs::VnodeKind;
|
||||
use error::Errno;
|
||||
use vfs::VnodeKind;
|
||||
|
||||
#[repr(packed)]
|
||||
#[allow(dead_code)]
|
||||
@@ -28,10 +28,7 @@ pub struct TarIterator {
|
||||
}
|
||||
|
||||
impl TarIterator {
|
||||
pub const fn new(
|
||||
address: *const u8,
|
||||
limit: *const u8,
|
||||
) -> Self {
|
||||
pub const fn new(address: *const u8, limit: *const u8) -> Self {
|
||||
Self {
|
||||
address,
|
||||
limit,
|
||||
|
||||
+1
-1
@@ -80,8 +80,8 @@ impl File {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{node::VnodeData, Filesystem, Vnode, VnodeImpl, VnodeKind, VnodeRef};
|
||||
use alloc::rc::Rc;
|
||||
use alloc::boxed::Box;
|
||||
use alloc::rc::Rc;
|
||||
use core::ffi::c_void;
|
||||
|
||||
pub struct DummyInode;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
//! aarch64 common boot logic
|
||||
|
||||
use crate::arch::{aarch64::reg::{CPACR_EL1, CNTKCTL_EL1}, machine};
|
||||
use crate::arch::{
|
||||
aarch64::reg::{CNTKCTL_EL1, CPACR_EL1},
|
||||
machine,
|
||||
};
|
||||
use crate::dev::{fdt::DeviceTree, irq::IntSource, Device};
|
||||
//use crate::debug::Level;
|
||||
use crate::mem::{
|
||||
|
||||
@@ -97,7 +97,7 @@ impl IntController for Gic {
|
||||
Some(handler) => {
|
||||
drop(table);
|
||||
handler.handle_irq().expect("irq handler failed")
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,7 @@
|
||||
|
||||
use crate::mem;
|
||||
use crate::sync::IrqSafeSpinLock;
|
||||
use alloc::{
|
||||
boxed::Box,
|
||||
collections::{BTreeMap},
|
||||
};
|
||||
use alloc::{boxed::Box, collections::BTreeMap};
|
||||
|
||||
pub mod elf;
|
||||
pub mod process;
|
||||
|
||||
@@ -44,7 +44,7 @@ struct ProcessInner {
|
||||
space: Option<&'static mut Space>,
|
||||
state: State,
|
||||
id: Pid,
|
||||
exit: Option<ExitCode>
|
||||
exit: Option<ExitCode>,
|
||||
}
|
||||
|
||||
/// Structure describing an operating system process
|
||||
@@ -224,7 +224,11 @@ impl Process {
|
||||
/// Waits for a process to finish and reaps it
|
||||
pub fn waitpid(pid: Pid) -> Result<ExitCode, Errno> {
|
||||
loop {
|
||||
let proc = PROCESSES.lock().get(&pid).cloned().ok_or(Errno::DoesNotExist)?;
|
||||
let proc = PROCESSES
|
||||
.lock()
|
||||
.get(&pid)
|
||||
.cloned()
|
||||
.ok_or(Errno::DoesNotExist)?;
|
||||
|
||||
if let Some(r) = proc.collect() {
|
||||
PROCESSES.lock().remove(&proc.id());
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//!
|
||||
use crate::proc::{Pid, Process, ProcessRef, PROCESSES};
|
||||
use crate::util::InitOnce;
|
||||
use crate::sync::IrqSafeSpinLock;
|
||||
use alloc::{rc::Rc, collections::VecDeque};
|
||||
use crate::util::InitOnce;
|
||||
use alloc::{collections::VecDeque, rc::Rc};
|
||||
|
||||
struct SchedulerInner {
|
||||
queue: VecDeque<Pid>,
|
||||
@@ -103,7 +103,7 @@ impl Scheduler {
|
||||
let lock = PROCESSES.lock();
|
||||
(
|
||||
lock.get(¤t).unwrap().clone(),
|
||||
lock.get(&next).unwrap().clone()
|
||||
lock.get(&next).unwrap().clone(),
|
||||
)
|
||||
};
|
||||
|
||||
|
||||
+6
-5
@@ -1,14 +1,14 @@
|
||||
//! Synchronization facilities module
|
||||
|
||||
use crate::arch::platform::{irq_mask_save, irq_restore};
|
||||
use core::sync::atomic::{AtomicBool, Ordering};
|
||||
use core::cell::UnsafeCell;
|
||||
use core::ops::{Deref, DerefMut};
|
||||
use core::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
/// Lock structure ensuring IRQs are disabled when inner value is accessed
|
||||
pub struct IrqSafeSpinLock<T> {
|
||||
value: UnsafeCell<T>,
|
||||
state: AtomicBool
|
||||
state: AtomicBool,
|
||||
}
|
||||
|
||||
/// Guard-structure wrapping a reference to value owned by [IrqSafeSpinLock].
|
||||
@@ -24,13 +24,14 @@ impl<T> IrqSafeSpinLock<T> {
|
||||
pub const fn new(value: T) -> Self {
|
||||
Self {
|
||||
value: UnsafeCell::new(value),
|
||||
state: AtomicBool::new(false)
|
||||
state: AtomicBool::new(false),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn try_lock(&self) -> Result<bool, bool> {
|
||||
self.state.compare_exchange_weak(false, true, Ordering::Acquire, Ordering::Relaxed)
|
||||
self.state
|
||||
.compare_exchange_weak(false, true, Ordering::Acquire, Ordering::Relaxed)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
@@ -50,7 +51,7 @@ impl<T> IrqSafeSpinLock<T> {
|
||||
|
||||
IrqSafeSpinLockGuard {
|
||||
lock: self,
|
||||
irq_state
|
||||
irq_state,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,11 @@ fn translate(virt: usize) -> Option<usize> {
|
||||
|
||||
fn validate_user_ptr(base: usize, len: usize) -> Result<(), Errno> {
|
||||
if base > mem::KERNEL_OFFSET || base + len > mem::KERNEL_OFFSET {
|
||||
warnln!("User region refers to kernel memory: base={:#x}, len={:#x}", base, len);
|
||||
warnln!(
|
||||
"User region refers to kernel memory: base={:#x}, len={:#x}",
|
||||
base,
|
||||
len
|
||||
);
|
||||
return Err(Errno::InvalidArgument);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,5 +38,4 @@ pub fn path_component_right(path: &str) -> (&str, &str) {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
}
|
||||
mod tests {}
|
||||
|
||||
+2
-5
@@ -1,14 +1,11 @@
|
||||
#![feature(
|
||||
asm,
|
||||
alloc_error_handler,
|
||||
)]
|
||||
#![feature(asm, alloc_error_handler)]
|
||||
#![no_std]
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
|
||||
mod sys;
|
||||
pub mod mem;
|
||||
pub mod os;
|
||||
mod sys;
|
||||
|
||||
#[link_section = ".text._start"]
|
||||
#[no_mangle]
|
||||
|
||||
Reference in New Issue
Block a user