misc: format sources

This commit is contained in:
2021-11-05 14:06:38 +02:00
parent e8e8032adb
commit 41706c5676
27 changed files with 94 additions and 69 deletions
+6 -2
View File
@@ -4,10 +4,14 @@ use crate::arch::{
aarch64::reg::{CNTKCTL_EL1, CPACR_EL1},
machine,
};
use crate::config::{ConfigKey, CONFIG};
use crate::dev::{
fdt::{find_prop, DeviceTree},
irq::IntSource,
Device,
};
use crate::fs::devfs;
use crate::dev::{fdt::{DeviceTree, find_prop}, irq::IntSource, Device};
use error::Errno;
use crate::config::{CONFIG, ConfigKey};
//use crate::debug::Level;
use crate::mem::{
self, heap,
+2 -2
View File
@@ -1,10 +1,10 @@
//! Thread context
use crate::arch::aarch64::exception::ExceptionFrame;
use crate::mem::{
self,
phys::{self, PageUsage},
};
use crate::arch::aarch64::exception::ExceptionFrame;
use core::mem::size_of;
struct Stack {
@@ -86,7 +86,7 @@ impl Context {
k_sp: stack.sp,
stack_base_phys: stack.bp,
stack_page_count: 8
stack_page_count: 8,
}
}
+3 -3
View File
@@ -4,9 +4,9 @@ use crate::arch::machine;
use crate::debug::Level;
use crate::dev::irq::{IntController, IrqContext};
use crate::syscall;
use ::syscall::abi;
use cortex_a::registers::{ESR_EL1, FAR_EL1};
use tock_registers::interfaces::Readable;
use ::syscall::abi;
/// Trapped SIMD/FP functionality
pub const EC_FP_TRAP: u64 = 0b000111;
@@ -96,7 +96,7 @@ extern "C" fn __aa64_exc_sync_handler(exc: &mut ExceptionFrame) {
Err(err) => {
warnln!("fork() syscall failed: {:?}", err);
exc.x[0] = usize::MAX;
},
}
}
return;
}
@@ -106,7 +106,7 @@ extern "C" fn __aa64_exc_sync_handler(exc: &mut ExceptionFrame) {
Err(err) => {
warnln!("syscall {} failed: {:?}", exc.x[8], err);
exc.x[0] = usize::MAX
},
}
}
}
return;
@@ -2,9 +2,9 @@ use crate::arch::machine::{self, IrqNumber};
use crate::dev::{
irq::{IntController, IntSource},
serial::SerialDevice,
tty::CharRing, Device,
tty::CharRing,
Device,
};
use vfs::CharDevice;
use crate::mem::virt::DeviceMemoryIo;
use crate::sync::IrqSafeSpinLock;
use crate::util::InitOnce;
@@ -12,6 +12,7 @@ use error::Errno;
use tock_registers::interfaces::{ReadWriteable, Readable, Writeable};
use tock_registers::registers::{Aliased, ReadOnly, ReadWrite};
use tock_registers::{register_bitfields, register_structs};
use vfs::CharDevice;
register_bitfields! [
u32,
+6 -2
View File
@@ -1,10 +1,14 @@
use crate::arch::aarch64::timer::GenericTimer;
use crate::dev::{Device, serial::{SerialDevice, pl011::Pl011}, irq::IntSource};
use crate::dev::{
irq::IntSource,
serial::{pl011::Pl011, SerialDevice},
Device,
};
use crate::mem::phys;
use error::Errno;
pub mod irqchip;
pub use irqchip::{IrqNumber, Bcm283xIrqchip};
pub use irqchip::{Bcm283xIrqchip, IrqNumber};
pub mod emmc;
pub use emmc::MassMediaController;
pub mod mailbox;
+10 -10
View File
@@ -20,7 +20,7 @@ pub enum ConfigKey {
Console,
MemLimit,
InitrdBase,
InitrdSize
InitrdSize,
}
struct ConfigString<const N: usize> {
@@ -38,7 +38,7 @@ impl const Default for Config {
console: ConfigString::empty(),
mem_limit: usize::MAX,
initrd_base: 0,
initrd_size: 0
initrd_size: 0,
}
}
}
@@ -47,18 +47,18 @@ impl Config {
/// Sets a config key to [usize] value
pub fn set_usize(&mut self, key: ConfigKey, value: usize) {
match key {
ConfigKey::InitrdBase => { self.initrd_base = value }
ConfigKey::InitrdSize => { self.initrd_size = value }
ConfigKey::MemLimit => { self.mem_limit = value }
_ => panic!("Invalid usize key: {:?}", key)
ConfigKey::InitrdBase => self.initrd_base = value,
ConfigKey::InitrdSize => self.initrd_size = value,
ConfigKey::MemLimit => self.mem_limit = value,
_ => panic!("Invalid usize key: {:?}", key),
}
}
/// Sets a config key to [str] value
pub fn set_str(&mut self, key: ConfigKey, value: &str) {
match key {
ConfigKey::Cmdline => { self.cmdline.set_from_str(value) }
_ => panic!("Invalid str key: {:?}", key)
ConfigKey::Cmdline => self.cmdline.set_from_str(value),
_ => panic!("Invalid str key: {:?}", key),
}
}
@@ -68,7 +68,7 @@ impl Config {
ConfigKey::InitrdBase => self.initrd_base,
ConfigKey::InitrdSize => self.initrd_size,
ConfigKey::MemLimit => self.mem_limit,
_ => panic!("Invalid usize key: {:?}", key)
_ => panic!("Invalid usize key: {:?}", key),
}
}
@@ -77,7 +77,7 @@ impl Config {
match key {
ConfigKey::Cmdline => self.cmdline.as_str(),
ConfigKey::Console => self.console.as_str(),
_ => panic!("Invalid str key: {:?}", key)
_ => panic!("Invalid str key: {:?}", key),
}
}
+1 -1
View File
@@ -6,9 +6,9 @@ use error::Errno;
pub mod fdt;
pub mod gpio;
pub mod irq;
pub mod sd;
pub mod pci;
pub mod rtc;
pub mod sd;
pub mod serial;
pub mod timer;
pub mod tty;
+4 -1
View File
@@ -423,7 +423,10 @@ impl SdCommand<'_> {
/// Returns `true` if cmd is application-specific
pub const fn is_acmd(&self) -> bool {
matches!(self.number, SdCommandNumber::Acmd41 | SdCommandNumber::Acmd51)
matches!(
self.number,
SdCommandNumber::Acmd41 | SdCommandNumber::Acmd51
)
}
/// Returns the command index
+2 -1
View File
@@ -4,7 +4,8 @@ use crate::arch::machine::{self, IrqNumber};
use crate::dev::{
irq::{IntController, IntSource},
serial::SerialDevice,
tty::CharRing, Device,
tty::CharRing,
Device,
};
use crate::mem::virt::DeviceMemoryIo;
use crate::sync::IrqSafeSpinLock;
+4 -4
View File
@@ -1,7 +1,7 @@
//! Teletype (TTY) device facilities
use error::Errno;
use crate::proc::wait::Wait;
use crate::sync::IrqSafeSpinLock;
use error::Errno;
use vfs::CharDevice;
#[derive(Debug)]
@@ -9,7 +9,7 @@ struct CharRingInner<const N: usize> {
rd: usize,
wr: usize,
data: [u8; N],
flags: u8
flags: u8,
}
/// Ring buffer for TTYs
@@ -51,7 +51,7 @@ impl<const N: usize> CharRing<N> {
rd: 0,
wr: 0,
data: [0; N],
flags: 0
flags: 0,
}),
wait_read: Wait::new(),
wait_write: Wait::new(),
@@ -99,7 +99,7 @@ impl<const N: usize> CharRing<N> {
Ok(ch) => ch,
Err(Errno::Interrupt) => {
todo!()
},
}
Err(e) => return Err(e),
};
+1 -1
View File
@@ -31,12 +31,12 @@ pub mod arch;
pub mod config;
pub mod dev;
pub mod fs;
pub mod init;
pub mod mem;
pub mod proc;
pub mod sync;
pub mod syscall;
pub mod util;
pub mod init;
#[panic_handler]
fn panic_handler(pi: &core::panic::PanicInfo) -> ! {
+1 -1
View File
@@ -4,10 +4,10 @@ use crate::mem::{
phys::{self, PageUsage},
virt::{MapAttributes, Space},
};
use vfs::FileRef;
use core::mem::{size_of, MaybeUninit};
use error::Errno;
use libcommon::{Read, Seek, SeekDir};
use vfs::FileRef;
trait Elf {
type Addr;
+1 -1
View File
@@ -2,9 +2,9 @@
use crate::arch::platform::{irq_mask_save, irq_restore};
use core::cell::UnsafeCell;
use core::fmt;
use core::ops::{Deref, DerefMut};
use core::sync::atomic::{AtomicBool, Ordering};
use core::fmt;
/// Lock structure ensuring IRQs are disabled when inner value is accessed
pub struct IrqSafeSpinLock<T> {
+5 -1
View File
@@ -61,7 +61,11 @@ pub fn validate_user_ptr_null<'a>(base: usize, len: usize) -> Result<Option<&'a
pub fn validate_user_str<'a>(base: usize, len: usize) -> Result<&'a str, Errno> {
let bytes = validate_user_ptr(base, len)?;
core::str::from_utf8(bytes).map_err(|_| {
warnln!("User string contains invalid UTF-8 characters: base={:#x}, len={:#x}", base, len);
warnln!(
"User string contains invalid UTF-8 characters: base={:#x}, len={:#x}",
base,
len
);
Errno::InvalidArgument
})
}
+1 -1
View File
@@ -2,7 +2,7 @@
use crate::arch::platform::exception::ExceptionFrame;
use crate::debug::Level;
use crate::proc::{elf, ProcessIo, wait, Pid, Process};
use crate::proc::{elf, wait, Pid, Process, ProcessIo};
use core::mem::size_of;
use core::ops::DerefMut;
use core::time::Duration;