Make clippy happy

This commit is contained in:
guillaume didier 2019-11-13 14:12:07 +01:00
parent 578904198c
commit 6da5f5c956
7 changed files with 23 additions and 24 deletions

View File

@ -34,7 +34,7 @@ pub struct SerialPort {
line_status: Port<u8>, // 5
/// Modem Status Register.
modem_status: Port<u8>, // 6
//modem_status: Port<u8>, // 6
/// Scratch Register.
scratch: Port<u8>, // 7
@ -70,7 +70,7 @@ impl SerialPort {
line_ctrl: Port::new(base + 3),
modem_ctrl: Port::new(base + 4),
line_status: Port::new(base + 5),
modem_status: Port::new(base + 6),
//modem_status: Port::new(base + 6),
scratch: Port::new(base + 7),
};
@ -139,7 +139,7 @@ impl fmt::Write for SerialPort {
lazy_static! {
pub static ref SERIAL1: Mutex<SerialPort> = {
let mut serial_port = unsafe { SerialPort::init_new(0x3F8).unwrap() };
let serial_port = unsafe { SerialPort::init_new(0x3F8).unwrap() };
Mutex::new(serial_port)
};
}

View File

@ -18,8 +18,7 @@ lazy_static! {
static mut STACK: [u8; STACK_SIZE] = [0; STACK_SIZE];
let stack_start = VirtAddr::from_ptr(unsafe { &STACK });
// FIXME once we have page allocation available.
let stack_end = stack_start + STACK_SIZE;
stack_end
stack_start + STACK_SIZE
};
tss
};

View File

@ -4,7 +4,7 @@ use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame};
use crate::gdt;
use crate::hlt_loop;
use polling_serial::serial_println;
use vga_buffer::{print, println, set_colors, Color, ForegroundColor};
use vga_buffer::println;
lazy_static! {
static ref IDT: InterruptDescriptorTable = {
@ -40,7 +40,7 @@ extern "x86-interrupt" fn double_fault_handler(sf: &mut InterruptStackFrame, e:
unsafe {
asm!("push rax" :::: "intel");
let s = (sf as *mut InterruptStackFrame);
let s = sf as *mut InterruptStackFrame;
stack_frame = &mut *((s as *mut u64).offset(1) as *mut InterruptStackFrame);
error_code = *(&e as *const u64).offset(1);
}
@ -72,7 +72,7 @@ extern "x86-interrupt" fn page_fault_handler(sf: &mut InterruptStackFrame, e: Pa
unsafe {
asm!("push rax" :::: "intel");
let s = (sf as *mut InterruptStackFrame);
let s = sf as *mut InterruptStackFrame;
stack_frame = &mut *((s as *mut u64).offset(1) as *mut InterruptStackFrame);
error_code = *(&e as *const PageFaultErrorCode).offset(1) as PageFaultErrorCode;
}

View File

@ -8,8 +8,8 @@
use core::panic::PanicInfo;
use polling_serial::{serial_print, serial_println};
use vga_buffer::{print, println};
use polling_serial::serial_println;
use vga_buffer::println;
use x86_64::instructions::bochs_breakpoint;
pub mod gdt;
@ -38,7 +38,9 @@ pub fn exit_qemu(exit_code: QemuExitCode) -> ! {
let mut port = Port::new(0xf4);
port.write(exit_code as u32);
}
loop {}
loop {
bochs_breakpoint();
}
}
pub fn test_runner(tests: &[&dyn Fn()]) {
@ -89,6 +91,6 @@ fn trivial_assertion() {
fn printf_test() {
serial_print!("Testing VGA print/println... ");
println!("Are frogs blue?");
print!("Yes\n");
println!("Yes");
serial_println!("[ok]");
}

View File

@ -7,10 +7,9 @@
#![test_runner(dendrobates_tinctoreus_azureus::test_runner)]
#![reexport_test_harness_main = "test_main"]
use polling_serial::{serial_print, serial_println};
use vga_buffer::{print, println, set_colors, Color, ForegroundColor};
use polling_serial::serial_println;
use vga_buffer::{println, set_colors, Color, ForegroundColor};
use core::fmt::Write;
use core::panic::PanicInfo;
use vga_buffer; // required for custom panic handler
@ -63,7 +62,7 @@ fn kernel_main(boot_info: &'static BootInfo) -> ! {
serial_println!("Preparing nasty fault...");
unsafe {
*(0xdeadbeef as *mut u64) = 42;
*(0xdead_beef as *mut u64) = 42;
}
serial_println!("Survived ? oO");

View File

@ -57,17 +57,16 @@ use x86_64::structures::idt::InterruptStackFrame;
extern "x86-interrupt" fn test_double_fault_handler(sf: &mut InterruptStackFrame, e: u64) {
// LLVM bug causing misaligned stacks when error codes are present.
// This code realigns the stack and then grabs the correct values by doing some pointer arithmetic
let stack_frame: &mut InterruptStackFrame;
let error_code: u64;
let _stack_frame: &mut InterruptStackFrame;
let _error_code: u64;
unsafe {
asm!("push rax" :::: "intel");
let s = (sf as *mut InterruptStackFrame);
stack_frame = &mut *((s as *mut u64).offset(1) as *mut InterruptStackFrame);
error_code = *(&e as *const u64).offset(1);
let s = sf as *mut InterruptStackFrame;
_stack_frame = &mut *((s as *mut u64).offset(1) as *mut InterruptStackFrame);
_error_code = *(&e as *const u64).offset(1);
}
// End Hack
serial_println!("[ok]");
exit_qemu(QemuExitCode::Success);
loop {}
}

View File

@ -116,8 +116,8 @@ impl Writer {
let mut w = Writer {
column_position: 0,
row_position: 0,
color_code: color_code,
buffer: buffer,
color_code,
buffer,
};
w.clear_screen();
w