Use cfg!() rather than #[cfg] for configuring lpss_debug
This commit is contained in:
@@ -13,7 +13,6 @@ use crate::syscall::io::Pio;
|
||||
use syscall::io::Io;
|
||||
|
||||
use super::device::serial::COM1;
|
||||
#[cfg(feature = "lpss_debug")]
|
||||
use super::device::serial::LPSS;
|
||||
#[cfg(feature = "system76_ec_debug")]
|
||||
use super::device::system76_ec::{System76Ec, SYSTEM76_EC};
|
||||
@@ -22,7 +21,6 @@ use super::device::system76_ec::{System76Ec, SYSTEM76_EC};
|
||||
pub static QEMU: Mutex<Pio<u8>> = Mutex::new(Pio::<u8>::new(0x402));
|
||||
|
||||
pub struct Writer<'a> {
|
||||
#[cfg(feature = "lpss_debug")]
|
||||
lpss: MutexGuard<'a, SerialKind>,
|
||||
#[cfg(feature = "qemu_debug")]
|
||||
qemu: MutexGuard<'a, Pio<u8>>,
|
||||
@@ -34,7 +32,6 @@ pub struct Writer<'a> {
|
||||
impl<'a> Writer<'a> {
|
||||
pub fn new() -> Writer<'a> {
|
||||
Writer {
|
||||
#[cfg(feature = "lpss_debug")]
|
||||
lpss: LPSS.lock(),
|
||||
#[cfg(feature = "qemu_debug")]
|
||||
qemu: QEMU.lock(),
|
||||
@@ -45,7 +42,6 @@ impl<'a> Writer<'a> {
|
||||
}
|
||||
|
||||
pub fn write(&mut self, buf: &[u8]) {
|
||||
#[cfg(feature = "lpss_debug")]
|
||||
self.lpss.write(buf);
|
||||
|
||||
#[cfg(feature = "qemu_debug")]
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
#[cfg(feature = "lpss_debug")]
|
||||
use crate::syscall::io::Mmio;
|
||||
use crate::{
|
||||
devices::{serial::SerialKind, uart_16550::SerialPort},
|
||||
syscall::io::Pio,
|
||||
syscall::io::{Mmio, Pio},
|
||||
};
|
||||
use spin::Mutex;
|
||||
|
||||
pub static COM1: Mutex<SerialKind> = Mutex::new(SerialKind::NotPresent);
|
||||
pub static COM2: Mutex<SerialKind> = Mutex::new(SerialKind::NotPresent);
|
||||
|
||||
#[cfg(feature = "lpss_debug")]
|
||||
pub static LPSS: Mutex<SerialKind> = Mutex::new(SerialKind::NotPresent);
|
||||
|
||||
pub unsafe fn init() {
|
||||
@@ -26,36 +23,37 @@ pub unsafe fn init() {
|
||||
*COM2.lock() = SerialKind::Ns16550Pio(com2);
|
||||
|
||||
// FIXME remove explicit LPSS handling once ACPI SPCR is supported
|
||||
#[cfg(feature = "lpss_debug")]
|
||||
{
|
||||
// TODO: Make this configurable
|
||||
let address = crate::PHYS_OFFSET + 0xFE032000;
|
||||
|
||||
{
|
||||
use rmm::PageFlags;
|
||||
|
||||
use crate::{
|
||||
memory::{KernelMapper, PhysicalAddress},
|
||||
paging::VirtualAddress,
|
||||
};
|
||||
|
||||
let mut mapper = KernelMapper::lock();
|
||||
let virt = VirtualAddress::new(address);
|
||||
let phys = PhysicalAddress::new(address - crate::PHYS_OFFSET);
|
||||
let flags = PageFlags::new().write(true).execute(false);
|
||||
unsafe {
|
||||
mapper
|
||||
.get_mut()
|
||||
.unwrap()
|
||||
.map_phys(virt, phys, flags)
|
||||
.expect("failed to map frame")
|
||||
.flush();
|
||||
}
|
||||
}
|
||||
|
||||
let lpss = unsafe { SerialPort::<Mmio<u32>>::new(crate::PHYS_OFFSET + 0xFE032000) };
|
||||
lpss.init();
|
||||
|
||||
*LPSS.lock() = SerialKind::Ns16550u32(lpss);
|
||||
if cfg!(not(feature = "lpss_debug")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Make this configurable
|
||||
let address = crate::PHYS_OFFSET + 0xFE032000;
|
||||
|
||||
{
|
||||
use rmm::PageFlags;
|
||||
|
||||
use crate::{
|
||||
memory::{KernelMapper, PhysicalAddress},
|
||||
paging::VirtualAddress,
|
||||
};
|
||||
|
||||
let mut mapper = KernelMapper::lock();
|
||||
let virt = VirtualAddress::new(address);
|
||||
let phys = PhysicalAddress::new(address - crate::PHYS_OFFSET);
|
||||
let flags = PageFlags::new().write(true).execute(false);
|
||||
unsafe {
|
||||
mapper
|
||||
.get_mut()
|
||||
.unwrap()
|
||||
.map_phys(virt, phys, flags)
|
||||
.expect("failed to map frame")
|
||||
.flush();
|
||||
}
|
||||
}
|
||||
|
||||
let lpss = unsafe { SerialPort::<Mmio<u32>>::new(crate::PHYS_OFFSET + 0xFE032000) };
|
||||
lpss.init();
|
||||
|
||||
*LPSS.lock() = SerialKind::Ns16550u32(lpss);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user