rustfmt
This commit is contained in:
parent
5befd11f8d
commit
700b8a4e00
6 changed files with 14 additions and 14 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
use super::{check_signature, ACPISDTHeader};
|
use super::{check_signature, ACPISDTHeader};
|
||||||
use core::mem;
|
use core::mem;
|
||||||
use io::{Pio,Io};
|
use io::{Io, Pio};
|
||||||
|
|
||||||
static mut DSDT: DSDT = DSDT {
|
static mut DSDT: DSDT = DSDT {
|
||||||
valid: false,
|
valid: false,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use super::{ACPISDTHeader, ACPISDTIter};
|
use super::{ACPISDTHeader, ACPISDTIter};
|
||||||
use io::{Io,Pio};
|
use io::{Io, Pio};
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
@ -131,7 +131,7 @@ pub fn is_enable() -> Result<bool, &'static str> {
|
||||||
let pin: Pio<u16> = Pio::new(pm1_cnt[0]);
|
let pin: Pio<u16> = Pio::new(pm1_cnt[0]);
|
||||||
if pm1_cnt[1] == 0 {
|
if pm1_cnt[1] == 0 {
|
||||||
Ok(pin.read() & 0x1 == 0x1)
|
Ok(pin.read() & 0x1 == 0x1)
|
||||||
// Ok(cpuio::inw(pm1_cnt[0]) & 0x1 == 0x1)
|
// Ok(cpuio::inw(pm1_cnt[0]) & 0x1 == 0x1)
|
||||||
} else {
|
} else {
|
||||||
let pin2: Pio<u8> = Pio::new(pm1_cnt[1]);
|
let pin2: Pio<u8> = Pio::new(pm1_cnt[1]);
|
||||||
Ok(pin.read() & 0x1 == 0x1 || pin2.read() & 0x1 == 0x1)
|
Ok(pin.read() & 0x1 == 0x1 || pin2.read() & 0x1 == 0x1)
|
||||||
|
|
@ -153,7 +153,10 @@ pub fn reboot() -> Result<(), &'static str> {
|
||||||
Err("ACPI is not enabled")
|
Err("ACPI is not enabled")
|
||||||
} else {
|
} else {
|
||||||
let fadt = is_init()?;
|
let fadt = is_init()?;
|
||||||
println!("fadt on {} ({}), value is {}", fadt.resetreg.address as u32, fadt.resetreg.address as u16, fadt.resetvalue);
|
println!(
|
||||||
|
"fadt on {} ({}), value is {}",
|
||||||
|
fadt.resetreg.address as u32, fadt.resetreg.address as u16, fadt.resetvalue
|
||||||
|
);
|
||||||
let mut pin: Pio<u8> = Pio::new(fadt.resetreg.address as u16);
|
let mut pin: Pio<u8> = Pio::new(fadt.resetreg.address as u16);
|
||||||
pin.write(fadt.resetvalue);
|
pin.write(fadt.resetvalue);
|
||||||
// cpuio::outb(fadt.resetreg.address as u16, fadt.resetvalue); //TODO do it work
|
// cpuio::outb(fadt.resetreg.address as u16, fadt.resetvalue); //TODO do it work
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ pub fn shutdown() -> Result<(), &'static str> {
|
||||||
/// This function need ACPI in v2
|
/// This function need ACPI in v2
|
||||||
pub fn reboot() -> Result<(), &'static str> {
|
pub fn reboot() -> Result<(), &'static str> {
|
||||||
is_init()?;
|
is_init()?;
|
||||||
if unsafe {ACPI.v2} {
|
if unsafe { ACPI.v2 } {
|
||||||
fadt::reboot()
|
fadt::reboot()
|
||||||
} else {
|
} else {
|
||||||
Err("ACPI reboot only available in ACPI v2+")
|
Err("ACPI reboot only available in ACPI v2+")
|
||||||
|
|
|
||||||
|
|
@ -61,11 +61,11 @@ fn help() -> Result<(), &'static str> {
|
||||||
///
|
///
|
||||||
fn reboot() -> ! {
|
fn reboot() -> ! {
|
||||||
match acpi::reboot() {
|
match acpi::reboot() {
|
||||||
Err(msg) => println!("{}", msg),
|
Err(msg) => println!("{}", msg),
|
||||||
_ => println!("Unable to perform ACPI reboot."),
|
_ => println!("Unable to perform ACPI reboot."),
|
||||||
}
|
}
|
||||||
flush!();
|
flush!();
|
||||||
unsafe {PS2.ps2_8042_reset()};// TODO unsafe
|
unsafe { PS2.ps2_8042_reset() }; // TODO unsafe
|
||||||
println!("Unable to perform 8042 reboot. Kernel will be halted");
|
println!("Unable to perform 8042 reboot. Kernel will be halted");
|
||||||
flush!();
|
flush!();
|
||||||
io::halt();
|
io::halt();
|
||||||
|
|
@ -78,8 +78,8 @@ fn reboot() -> ! {
|
||||||
///
|
///
|
||||||
fn shutdown() -> ! {
|
fn shutdown() -> ! {
|
||||||
match acpi::shutdown() {
|
match acpi::shutdown() {
|
||||||
Err(msg) => println!("{}", msg),
|
Err(msg) => println!("{}", msg),
|
||||||
_ => println!("Unable to perform ACPI shutdown. Kernel will be halted"),
|
_ => println!("Unable to perform ACPI shutdown. Kernel will be halted"),
|
||||||
}
|
}
|
||||||
flush!();
|
flush!();
|
||||||
io::halt();
|
io::halt();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
extern crate core;
|
extern crate core;
|
||||||
|
|
||||||
use vga;
|
use vga;
|
||||||
use io::{self,Pio,Io};
|
use io::{self, Io, Pio};
|
||||||
|
|
||||||
const MAX_KEYS: usize = 59;
|
const MAX_KEYS: usize = 59;
|
||||||
const KEYMAP_US: [[u8; 2]; MAX_KEYS] = [
|
const KEYMAP_US: [[u8; 2]; MAX_KEYS] = [
|
||||||
|
|
@ -66,7 +66,6 @@ const KEYMAP_US: [[u8; 2]; MAX_KEYS] = [
|
||||||
*b"\0\0",//capslock
|
*b"\0\0",//capslock
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
pub static mut PS2: Ps2 = Ps2::new();
|
pub static mut PS2: Ps2 = Ps2::new();
|
||||||
|
|
||||||
pub struct Ps2 {
|
pub struct Ps2 {
|
||||||
|
|
|
||||||
|
|
@ -61,8 +61,6 @@ pub fn kmain() -> ! {
|
||||||
// *(0xdead as *mut u32) = 42;
|
// *(0xdead as *mut u32) = 42;
|
||||||
// };
|
// };
|
||||||
|
|
||||||
println!("tss: {:?}");
|
|
||||||
|
|
||||||
// vga is *not* cpu specific
|
// vga is *not* cpu specific
|
||||||
vga::init();
|
vga::init();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue