maually remove warning, pt5

toolchain_update
Ben Pig Chu 6 years ago
parent 7eb9f7abcf
commit 6eb49a0106

@ -134,11 +134,7 @@ fn log2(x: u16) -> usize {
#[inline(always)]
#[cfg(not(target_arch = "x86_64"))]
fn log2(x: u16) -> usize {
log2_naive(x)
}
#[inline(always)]
fn log2_naive(mut x: u16) -> usize {
//a naive implement
assert_ne!(x, 0);
let mut pos = -1;
while x != 0 {

@ -18,7 +18,7 @@ pub fn id() -> usize {
pub fn send_ipi(cpu_id: usize) {
let mut lapic = unsafe { XApic::new(0xffffff00_fee00000) };
unsafe { lapic.send_ipi(cpu_id as u8, 0x30); } // TODO: Find a IPI trap num
lapic.send_ipi(cpu_id as u8, 0x30); // TODO: Find a IPI trap num
}
pub fn init() {

@ -88,7 +88,7 @@ impl IDE {
}
// ???
let mut data = [0; SECTOR_SIZE];
let data = [0; SECTOR_SIZE];
asm!("rep insl" :: "{dx}"(self.base + ISA_DATA), "{rdi}"(data.as_ptr()), "{cx}"(SECTOR_SIZE) : "rdi" : "volatile");
}
}

@ -25,7 +25,7 @@ pub fn receive() -> Option<char> {
if let Some(key) = keyboard.process_keyevent(key_event) {
match key {
DecodedKey::Unicode(character) => return Some(character),
DecodedKey::RawKey(key) => {}, // TODO: handle RawKey from keyboard
DecodedKey::RawKey(_key) => {}, // TODO: handle RawKey from keyboard
}
}
}

@ -1,6 +1,5 @@
// Copy from Redox
use core::fmt::{self, Write};
use x86_64::instructions::port::Port;
use spin::Mutex;
use uart_16550::SerialPort;
@ -27,7 +26,7 @@ impl SerialRead for SerialPort {
fn receive(&mut self) -> u8 {
unsafe {
let ports = self as *mut _ as *mut [Port<u8>; 6];
let line_sts = &(*ports)[5];
let _line_sts = &(*ports)[5];
let data = &(*ports)[0];
data.read()
}

@ -1,7 +1,5 @@
use alloc::boxed::Box;
use crate::consts::MAX_CPU_NUM;
use core::fmt;
use core::fmt::Debug;
use spin::{Mutex, MutexGuard, Once};
use x86_64::{PrivilegeLevel, VirtAddr};
use x86_64::structures::gdt::*;

@ -6,7 +6,7 @@ pub fn init() {
}
lazy_static! {
static ref IDT: Idt = {
static ref IDT: InterruptDescriptorTable = {
use crate::arch::interrupt::consts::*;
use crate::arch::gdt::DOUBLE_FAULT_IST_INDEX;
use x86_64::PrivilegeLevel;
@ -21,10 +21,10 @@ lazy_static! {
let ring3 = [T_SWITCH_TOK, T_SYSCALL, T_SYSCALL32];
let mut idt = Idt::new();
let entries = unsafe{ &mut *(&mut idt as *mut _ as *mut [IdtEntry<HandlerFunc>; 256]) };
let mut idt = InterruptDescriptorTable::new();
let entries = unsafe{ &mut *(&mut idt as *mut _ as *mut [Entry<HandlerFunc>; 256]) };
for i in 0..256 {
let mut opt = entries[i].set_handler_fn(unsafe { transmute(__vectors[i]) });
let opt = entries[i].set_handler_fn(unsafe { transmute(__vectors[i]) });
if ring3.contains(&(i as u8)) {
opt.set_privilege_level(PrivilegeLevel::Ring3);
opt.disable_interrupts(false);

@ -43,7 +43,7 @@ pub fn enable_irq(irq: u8) {
}
#[inline(always)]
pub fn ack(irq: u8) {
pub fn ack(_irq: u8) {
let mut lapic = unsafe { XApic::new(KERNEL_OFFSET + LAPIC_ADDR) };
lapic.eoi();
}

@ -119,7 +119,7 @@ impl Context {
/// Pop all callee-saved registers, then return to the target.
#[naked]
#[inline(never)]
pub unsafe extern fn switch(&mut self, target: &mut Self) {
pub unsafe extern fn switch(&mut self, _target: &mut Self) {
asm!(
"
// push rip (by caller)

@ -3,7 +3,6 @@ use crate::consts::KERNEL_OFFSET;
// Depends on kernel
use crate::memory::{FRAME_ALLOCATOR, init_heap, active_table};
use super::{BootInfo, MemoryRegionType};
use ucore_memory::PAGE_SIZE;
use ucore_memory::paging::*;
use once::*;
use log::*;

@ -1,7 +1,6 @@
use bootloader::bootinfo::{BootInfo, MemoryRegionType};
use core::sync::atomic::*;
use log::*;
use crate::consts::KERNEL_OFFSET;
pub mod driver;
pub mod cpu;

@ -1,16 +1,11 @@
// Depends on kernel
use crate::memory::{active_table, alloc_frame, dealloc_frame};
use spin::{Mutex, MutexGuard};
use ucore_memory::cow::CowExt;
use ucore_memory::memory_set::*;
use ucore_memory::PAGE_SIZE;
use ucore_memory::paging::*;
use x86_64::instructions::tlb;
use x86_64::PhysAddr;
use x86_64::registers::control::{Cr3, Cr3Flags};
use x86_64::structures::paging::{Mapper, PageTable as x86PageTable, PageTableEntry, PageTableFlags as EF, RecursivePageTable};
use x86_64::structures::paging::{FrameAllocator, FrameDeallocator, Page, PageRange, PhysFrame as Frame, Size4KiB};
use x86_64::ux::u9;
use log::*;
pub trait PageExt {
@ -51,7 +46,7 @@ impl PageTable for ActivePageTable {
}
fn unmap(&mut self, addr: usize) {
let (frame, flush) = self.0.unmap(Page::of_addr(addr)).unwrap();
let (_, flush) = self.0.unmap(Page::of_addr(addr)).unwrap();
flush.flush();
}
@ -117,7 +112,7 @@ impl Entry for PageEntry {
fn execute(&self) -> bool { !self.0.flags().contains(EF::NO_EXECUTE) }
fn set_execute(&mut self, value: bool) { self.as_flags().set(EF::NO_EXECUTE, !value); }
fn mmio(&self) -> bool { false }
fn set_mmio(&mut self, value: bool) { }
fn set_mmio(&mut self, _value: bool) { }
}
fn get_entry_ptr(addr: usize, level: u8) -> *mut PageEntry {
@ -152,7 +147,7 @@ impl InactivePageTable for InactivePageTable0 {
}
fn map_kernel(&mut self) {
let mut table = unsafe { &mut *(0xffffffff_fffff000 as *mut x86PageTable) };
let table = unsafe { &mut *(0xffffffff_fffff000 as *mut x86PageTable) };
// Kernel at 0xffff_ff00_0000_0000
// Kernel stack at 0x0000_57ac_0000_0000 (defined in bootloader crate)
let e510 = table[510].clone();

@ -26,8 +26,10 @@ lazy_static! {
};
}
#[cfg(not(target_arch = "x86_64"))]
struct MemBuf(&'static [u8]);
#[cfg(not(target_arch = "x86_64"))]
impl MemBuf {
unsafe fn new(begin: unsafe extern fn(), end: unsafe extern fn()) -> Self {
use core::slice;
@ -35,6 +37,7 @@ impl MemBuf {
}
}
#[cfg(not(target_arch = "x86_64"))]
impl Device for MemBuf {
fn read_at(&mut self, offset: usize, buf: &mut [u8]) -> Option<usize> {
let slice = self.0;
@ -51,11 +54,13 @@ impl Device for MemBuf {
impl BlockedDevice for ide::IDE {
const BLOCK_SIZE_LOG2: u8 = 9;
fn read_at(&mut self, block_id: usize, buf: &mut [u8]) -> bool {
use core::slice;
assert!(buf.len() >= ide::BLOCK_SIZE);
let buf = unsafe { slice::from_raw_parts_mut(buf.as_ptr() as *mut u32, ide::BLOCK_SIZE / 4) };
self.read(block_id as u64, 1, buf).is_ok()
}
fn write_at(&mut self, block_id: usize, buf: &[u8]) -> bool {
use core::slice;
assert!(buf.len() >= ide::BLOCK_SIZE);
let buf = unsafe { slice::from_raw_parts(buf.as_ptr() as *mut u32, ide::BLOCK_SIZE / 4) };
self.write(block_id as u64, 1, buf).is_ok()

Loading…
Cancel
Save