Commit 90b113f0 authored by Jeremy Soller's avatar Jeremy Soller

Add lpss_debug

parent 331590e1
......@@ -36,6 +36,7 @@ acpi = []
doc = []
graphical_debug = []
live = []
lpss_debug = []
multi_core = ["acpi"]
pti = []
qemu_debug = []
......
......@@ -8,11 +8,15 @@ use crate::log::{LOG, Log};
use syscall::io::Io;
#[cfg(any(feature = "qemu_debug", feature = "serial_debug"))]
use crate::syscall::io::Pio;
#[cfg(feature = "serial_debug")]
#[cfg(feature = "lpss_debug")]
use crate::syscall::io::Mmio;
#[cfg(any(feature = "lpss_debug", feature = "serial_debug"))]
use crate::devices::uart_16550::SerialPort;
#[cfg(feature = "graphical_debug")]
use super::graphical_debug::{DEBUG_DISPLAY, DebugDisplay};
#[cfg(feature = "lpss_debug")]
use super::device::serial::LPSS;
#[cfg(feature = "serial_debug")]
use super::device::serial::COM1;
......@@ -23,6 +27,8 @@ pub struct Writer<'a> {
log: MutexGuard<'a, Option<Log>>,
#[cfg(feature = "graphical_debug")]
display: MutexGuard<'a, Option<DebugDisplay>>,
#[cfg(feature = "lpss_debug")]
lpss: MutexGuard<'a, Option<&'static mut SerialPort<Mmio<u32>>>>,
#[cfg(feature = "qemu_debug")]
qemu: MutexGuard<'a, Pio<u8>>,
#[cfg(feature = "serial_debug")]
......@@ -35,6 +41,8 @@ impl<'a> Writer<'a> {
log: LOG.lock(),
#[cfg(feature = "graphical_debug")]
display: DEBUG_DISPLAY.lock(),
#[cfg(feature = "lpss_debug")]
lpss: LPSS.lock(),
#[cfg(feature = "qemu_debug")]
qemu: QEMU.lock(),
#[cfg(feature = "serial_debug")]
......@@ -56,6 +64,13 @@ impl<'a> Writer<'a> {
}
}
#[cfg(feature = "lpss_debug")]
{
if let Some(ref mut lpss) = *self.lpss {
lpss.write(buf);
}
}
#[cfg(feature = "qemu_debug")]
{
for &b in buf {
......
use crate::devices::uart_16550::SerialPort;
use crate::syscall::io::Pio;
use crate::syscall::io::{Mmio, Pio};
use spin::Mutex;
pub static COM1: Mutex<SerialPort<Pio<u8>>> = Mutex::new(SerialPort::<Pio<u8>>::new(0x3F8));
......@@ -7,9 +7,36 @@ pub static COM2: Mutex<SerialPort<Pio<u8>>> = Mutex::new(SerialPort::<Pio<u8>>::
pub static COM3: Mutex<SerialPort<Pio<u8>>> = Mutex::new(SerialPort::<Pio<u8>>::new(0x3E8));
pub static COM4: Mutex<SerialPort<Pio<u8>>> = Mutex::new(SerialPort::<Pio<u8>>::new(0x2E8));
#[cfg(feature = "lpss_debug")]
pub static LPSS: Mutex<Option<&'static mut SerialPort<Mmio<u32>>>> = Mutex::new(None);
pub unsafe fn init() {
COM1.lock().init();
COM2.lock().init();
COM3.lock().init();
COM4.lock().init();
#[cfg(feature = "lpss_debug")]
{
// TODO: Make this configurable
let address = crate::KERNEL_OFFSET + 0xFE032000;
{
use crate::paging::{ActivePageTable, Page, VirtualAddress, entry::EntryFlags};
use crate::memory::{Frame, PhysicalAddress};
let mut active_table = ActivePageTable::new();
let page = Page::containing_address(VirtualAddress::new(address));
let frame = Frame::containing_address(PhysicalAddress::new(address - crate::KERNEL_OFFSET));
let result = active_table.map_to(page, frame, EntryFlags::PRESENT | EntryFlags::WRITABLE | EntryFlags::NO_EXECUTE);
result.flush(&mut active_table);
}
let lpss = SerialPort::<Mmio<u32>>::new(
crate::KERNEL_OFFSET + 0xFE032000
);
lpss.init();
*LPSS.lock() = Some(lpss);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment