Run cargo fmt

Signed-off-by: Harry Chen <i@harrychen.xyz>
master
Harry Chen 6 years ago
parent 5b53e86c41
commit 887a207c8b

@ -75,10 +75,7 @@ static mut __page_table_with_mode: bool = false;
impl ActivePageTable { impl ActivePageTable {
pub unsafe fn new() -> Self { pub unsafe fn new() -> Self {
ActivePageTable( ActivePageTable(get_root_page_table_ptr(), ::core::mem::uninitialized())
get_root_page_table_ptr(),
::core::mem::uninitialized(),
)
} }
unsafe fn get_raw_table(&mut self) -> *mut MIPSPageTable { unsafe fn get_raw_table(&mut self) -> *mut MIPSPageTable {
@ -90,9 +87,7 @@ impl ActivePageTable {
} }
fn get_table(&mut self) -> TwoLevelPageTable<'static> { fn get_table(&mut self) -> TwoLevelPageTable<'static> {
unsafe { unsafe { TwoLevelPageTable::new(&mut *self.get_raw_table()) }
TwoLevelPageTable::new(&mut *self.get_raw_table())
}
} }
} }
@ -208,13 +203,12 @@ impl InactivePageTable for InactivePageTable0 {
clear_all_tlb(); clear_all_tlb();
} }
debug!("edit table {:x?} -> {:x?}", Self::active_token(), self.token()); debug!(
let mut active = unsafe { "edit table {:x?} -> {:x?}",
ActivePageTable( Self::active_token(),
self.token(), self.token()
::core::mem::uninitialized(), );
) let mut active = unsafe { ActivePageTable(self.token(), ::core::mem::uninitialized()) };
};
let ret = f(&mut active); let ret = f(&mut active);
debug!("finish table"); debug!("finish table");
@ -230,7 +224,7 @@ impl InactivePageTable for InactivePageTable0 {
let new_token = self.token(); let new_token = self.token();
let old_mode = unsafe { __page_table_with_mode }; let old_mode = unsafe { __page_table_with_mode };
unsafe { unsafe {
__page_table_with_mode = true; __page_table_with_mode = true;
} }

@ -19,7 +19,6 @@ pub unsafe fn init_external_interrupt() {
// enable all interrupts // enable all interrupts
AXI_INTC_IER.write_volatile(0xffffffff); AXI_INTC_IER.write_volatile(0xffffffff);
} }
/// Claim and complete external interrupt by reading and writing to /// Claim and complete external interrupt by reading and writing to
@ -43,4 +42,4 @@ pub unsafe fn enable_serial_interrupt() {
// Intr enable | rx reset | tx reset // Intr enable | rx reset | tx reset
const UART_IE: u32 = 0x13; const UART_IE: u32 = 0x13;
SERIAL_BASE.add(UART_CTRL_REG).write_volatile(UART_IE); SERIAL_BASE.add(UART_CTRL_REG).write_volatile(UART_IE);
} }

@ -30,7 +30,6 @@ pub extern "C" fn rust_main(hartid: usize, device_tree_paddr: usize) -> ! {
unsafe { unsafe {
cpu::set_cpu_id(hartid); cpu::set_cpu_id(hartid);
} }
#[cfg(feature = "board_rocket_chip")] #[cfg(feature = "board_rocket_chip")]

@ -1,3 +1,6 @@
#[cfg(any(target_arch = "x86_64", all(target_arch = "mips", feature = "board_malta")))] #[cfg(any(
target_arch = "x86_64",
all(target_arch = "mips", feature = "board_malta")
))]
pub mod pci; pub mod pci;
pub mod virtio_mmio; pub mod virtio_mmio;

@ -37,4 +37,4 @@ pub const FIOCLEX: usize = 0x6601;
// rustc using pipe and ioctl pipe file with this request id // rustc using pipe and ioctl pipe file with this request id
// for non-blocking/blocking IO control setting // for non-blocking/blocking IO control setting
pub const FIONBIO: usize = 0x5421; pub const FIONBIO: usize = 0x5421;

@ -13,19 +13,19 @@
//! mipssim/malta(MIPS) -- 10MB //! mipssim/malta(MIPS) -- 10MB
use super::HEAP_ALLOCATOR; use super::HEAP_ALLOCATOR;
use core::mem;
pub use crate::arch::paging::*; pub use crate::arch::paging::*;
use crate::consts::{KERNEL_OFFSET, MEMORY_OFFSET}; use crate::consts::{KERNEL_OFFSET, MEMORY_OFFSET};
use crate::process::current_thread;
use crate::sync::SpinNoIrqLock; use crate::sync::SpinNoIrqLock;
use alloc::boxed::Box; use alloc::boxed::Box;
use bitmap_allocator::BitAlloc; use bitmap_allocator::BitAlloc;
use buddy_system_allocator::Heap; use buddy_system_allocator::Heap;
use core::mem;
use lazy_static::*; use lazy_static::*;
use log::*; use log::*;
pub use rcore_memory::memory_set::{handler::*, MemoryArea, MemoryAttr}; pub use rcore_memory::memory_set::{handler::*, MemoryArea, MemoryAttr};
use rcore_memory::paging::PageTable; use rcore_memory::paging::PageTable;
use rcore_memory::*; use rcore_memory::*;
use crate::process::current_thread;
pub type MemorySet = rcore_memory::memory_set::MemorySet<InactivePageTable0>; pub type MemorySet = rcore_memory::memory_set::MemorySet<InactivePageTable0>;

@ -185,7 +185,11 @@ impl Syscall<'_> {
iovs.write_all_from_slice(&buf[..len]); iovs.write_all_from_slice(&buf[..len]);
let sockaddr_in = SockAddr::from(endpoint); let sockaddr_in = SockAddr::from(endpoint);
unsafe { unsafe {
sockaddr_in.write_to(&mut self.vm(), hdr.msg_name, &mut hdr.msg_namelen as *mut u32)?; sockaddr_in.write_to(
&mut self.vm(),
hdr.msg_name,
&mut hdr.msg_namelen as *mut u32,
)?;
} }
} }
result result
@ -427,17 +431,13 @@ fn sockaddr_to_endpoint(
Ok(Endpoint::Ip((addr, port).into())) Ok(Endpoint::Ip((addr, port).into()))
} }
AddressFamily::Unix => Err(SysError::EINVAL), AddressFamily::Unix => Err(SysError::EINVAL),
AddressFamily::Packet => { AddressFamily::Packet => Ok(Endpoint::LinkLevel(LinkLevelEndpoint::new(
Ok(Endpoint::LinkLevel(LinkLevelEndpoint::new( addr.addr_ll.sll_ifindex as usize,
addr.addr_ll.sll_ifindex as usize, ))),
))) AddressFamily::Netlink => Ok(Endpoint::Netlink(NetlinkEndpoint::new(
} addr.addr_nl.nl_pid,
AddressFamily::Netlink => { addr.addr_nl.nl_groups,
Ok(Endpoint::Netlink(NetlinkEndpoint::new( ))),
addr.addr_nl.nl_pid,
addr.addr_nl.nl_groups,
)))
}
_ => Err(SysError::EINVAL), _ => Err(SysError::EINVAL),
} }
} }
@ -456,12 +456,7 @@ impl SockAddr {
/// Write to user sockaddr /// Write to user sockaddr
/// Check mutability for user /// Check mutability for user
unsafe fn write_to( unsafe fn write_to(self, vm: &MemorySet, addr: *mut SockAddr, addr_len: *mut u32) -> SysResult {
self,
vm: &MemorySet,
addr: *mut SockAddr,
addr_len: *mut u32,
) -> SysResult {
// Ignore NULL // Ignore NULL
if addr.is_null() { if addr.is_null() {
return Ok(0); return Ok(0);

@ -7,7 +7,6 @@ use super::color::ConsoleColor;
use heapless::consts::U8; use heapless::consts::U8;
use heapless::Vec; use heapless::Vec;
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]
#[repr(align(4))] #[repr(align(4))]
pub struct CharacterAttribute { pub struct CharacterAttribute {

Loading…
Cancel
Save