Format sources
This commit is contained in:
parent
e023ef11c2
commit
f5aa2d3467
@ -1,19 +1,14 @@
|
|||||||
//! Type-safe wrappers for different address kinds
|
//! Type-safe wrappers for different address kinds
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![feature(
|
#![feature(step_trait, const_fn_trait_bound, const_trait_impl, const_panic)]
|
||||||
step_trait,
|
|
||||||
const_fn_trait_bound,
|
|
||||||
const_trait_impl,
|
|
||||||
const_panic
|
|
||||||
)]
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate std;
|
extern crate std;
|
||||||
|
|
||||||
pub mod virt;
|
|
||||||
#[deny(missing_docs)]
|
#[deny(missing_docs)]
|
||||||
pub mod phys;
|
pub mod phys;
|
||||||
|
pub mod virt;
|
||||||
|
|
||||||
trait Address {}
|
trait Address {}
|
||||||
|
|
||||||
|
@ -231,10 +231,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_trivial_convert() {
|
fn test_trivial_convert() {
|
||||||
let v0 = VirtualAddress::<S0>::from(0x8123usize);
|
let v0 = VirtualAddress::<S0>::from(0x8123usize);
|
||||||
assert_eq!(
|
assert_eq!(PhysicalAddress::from(v0), PhysicalAddress::from(0x123usize));
|
||||||
PhysicalAddress::from(v0),
|
|
||||||
PhysicalAddress::from(0x123usize)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
fn __aa64_bsp_main() {
|
fn __aa64_bsp_main() {
|
||||||
debugln!("Test");
|
debugln!("Test");
|
||||||
use crate::arch::machine;
|
use crate::arch::machine;
|
||||||
use crate::dev::{Device, timer::TimestampSource, serial::SerialDevice};
|
use crate::dev::{serial::SerialDevice, timer::TimestampSource, Device};
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
machine::console().lock().enable().unwrap();
|
machine::console().lock().enable().unwrap();
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
//! QEMU virt machine
|
//! QEMU virt machine
|
||||||
|
|
||||||
|
use crate::arch::aarch64::timer::GenericTimer;
|
||||||
use crate::dev::serial::{pl011::Pl011, SerialDevice};
|
use crate::dev::serial::{pl011::Pl011, SerialDevice};
|
||||||
use crate::dev::timer::TimestampSource;
|
use crate::dev::timer::TimestampSource;
|
||||||
use crate::arch::aarch64::timer::GenericTimer;
|
|
||||||
use crate::sync::Spin;
|
use crate::sync::Spin;
|
||||||
|
|
||||||
const UART0_BASE: usize = 0x09000000;
|
const UART0_BASE: usize = 0x09000000;
|
||||||
|
@ -19,8 +19,8 @@ cfg_if! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO move to mod io
|
// TODO move to mod io
|
||||||
use core::ops::Deref;
|
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
|
use core::ops::Deref;
|
||||||
|
|
||||||
/// Wrapper for setting up memory-mapped registers and IO
|
/// Wrapper for setting up memory-mapped registers and IO
|
||||||
pub struct MemoryIo<T> {
|
pub struct MemoryIo<T> {
|
||||||
@ -37,7 +37,7 @@ impl<T> MemoryIo<T> {
|
|||||||
pub const unsafe fn new(base: usize) -> Self {
|
pub const unsafe fn new(base: usize) -> Self {
|
||||||
Self {
|
Self {
|
||||||
base,
|
base,
|
||||||
_pd: PhantomData
|
_pd: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,5 +41,9 @@ pub fn _debug(args: fmt::Arguments) {
|
|||||||
use crate::arch::machine;
|
use crate::arch::machine;
|
||||||
use fmt::Write;
|
use fmt::Write;
|
||||||
|
|
||||||
SerialOutput { inner: machine::console() }.write_fmt(args).ok();
|
SerialOutput {
|
||||||
|
inner: machine::console(),
|
||||||
|
}
|
||||||
|
.write_fmt(args)
|
||||||
|
.ok();
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
)]
|
)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//! Synchronization facilities module
|
//! Synchronization facilities module
|
||||||
|
|
||||||
use core::ops::{Deref, DerefMut};
|
|
||||||
use core::cell::UnsafeCell;
|
use core::cell::UnsafeCell;
|
||||||
|
use core::ops::{Deref, DerefMut};
|
||||||
|
|
||||||
/// Dummy lock implementation, does not do any locking.
|
/// Dummy lock implementation, does not do any locking.
|
||||||
///
|
///
|
||||||
@ -9,26 +9,30 @@ use core::cell::UnsafeCell;
|
|||||||
/// interrupts are enabled.
|
/// interrupts are enabled.
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct NullLock<T: ?Sized> {
|
pub struct NullLock<T: ?Sized> {
|
||||||
value: UnsafeCell<T>
|
value: UnsafeCell<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Dummy lock guard for [NullLock].
|
/// Dummy lock guard for [NullLock].
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct NullLockGuard<'a, T: ?Sized> {
|
pub struct NullLockGuard<'a, T: ?Sized> {
|
||||||
value: &'a mut T
|
value: &'a mut T,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> NullLock<T> {
|
impl<T> NullLock<T> {
|
||||||
/// Constructs a new instance of the lock, wrapping `value`
|
/// Constructs a new instance of the lock, wrapping `value`
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub const fn new(value: T) -> Self {
|
pub const fn new(value: T) -> Self {
|
||||||
Self { value: UnsafeCell::new(value) }
|
Self {
|
||||||
|
value: UnsafeCell::new(value),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns [NullLockGuard] for this lock
|
/// Returns [NullLockGuard] for this lock
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn lock(&self) -> NullLockGuard<T> {
|
pub fn lock(&self) -> NullLockGuard<T> {
|
||||||
NullLockGuard { value: unsafe { &mut *self.value.get() } }
|
NullLockGuard {
|
||||||
|
value: unsafe { &mut *self.value.get() },
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user