x86: fix i686/x86_64 build

This commit is contained in:
Mark Poliakov 2024-12-14 13:10:46 +02:00
parent 60164fedca
commit a2adff85a7
17 changed files with 18 additions and 92 deletions

View File

@ -1,8 +1,7 @@
use fixed::FixedTables;
use kernel_arch_interface::{
mem::{DeviceMemoryAttributes, KernelTableManager, RawDeviceMemoryMapping},
sync::split_spinlock,
KERNEL_VIRT_OFFSET,
split_spinlock, KERNEL_VIRT_OFFSET,
};
use libk_mm_interface::{
address::{AsPhysicalAddress, PhysicalAddress},
@ -26,7 +25,7 @@ split_spinlock! {
use crate::ArchitectureImpl;
#[link_section = ".data.tables"]
static KERNEL_TABLES @ inner<lock: ArchitectureImpl>: KernelImageObject<FixedTables> = unsafe {
static KERNEL_TABLES: KernelImageObject<FixedTables> = unsafe {
KernelImageObject::new(FixedTables::zeroed())
};
}

View File

@ -7,14 +7,13 @@ use core::{
use kernel_arch_interface::{
mem::{DeviceMemoryAttributes, KernelTableManager, RawDeviceMemoryMapping},
sync::split_spinlock,
split_spinlock,
};
use kernel_arch_x86::registers::CR3;
use libk_mm_interface::{
address::PhysicalAddress,
table::{page_index, EntryLevel, EntryLevelExt},
};
use memtables::x86_64::FixedTables;
use static_assertions::{const_assert_eq, const_assert_ne};
use yggdrasil_abi::error::Error;
@ -51,12 +50,12 @@ const RAM_MAPPING_L0I: usize = KERNEL_L0_INDEX - 1;
const DEVICE_MAPPING_L3_COUNT: usize = 4;
split_spinlock! {
use crate::ArchitectureImpl;
use crate::mem::FixedTables;
use libk_mm_interface::KernelImageObject;
use memtables::x86_64::FixedTables;
use crate::ArchitectureImpl;
#[link_section = ".data.tables"]
static KERNEL_TABLES @ inner<lock: ArchitectureImpl>: KernelImageObject<FixedTables> =
static KERNEL_TABLES: KernelImageObject<FixedTables> =
unsafe { KernelImageObject::new(FixedTables::zeroed()) };
}

View File

@ -177,10 +177,6 @@ impl InterruptHandler for AhciController {
false
}
fn display_name(&self) -> &str {
"AHCI IRQ"
}
}
impl Device for AhciController {

View File

@ -337,10 +337,6 @@ impl InterruptHandler for NvmeController {
false
}
}
fn display_name(&self) -> &str {
"NVMe IRQ"
}
}
impl Device for NvmeController {

View File

@ -378,8 +378,4 @@ impl InterruptHandler for Xhci {
false
}
}
fn display_name(&self) -> &str {
"xHCI IRQ"
}
}

View File

@ -253,10 +253,6 @@ impl<T: Transport + 'static> InterruptHandler for VirtioNet<T> {
queue_irq || config_irq
}
}
fn display_name(&self) -> &str {
"virtio-net transport IRQ"
}
}
// impl<T: Transport + 'static> MsiHandler for VirtioNet<T> {

View File

@ -66,9 +66,8 @@ pub enum IpiMessage {
Shutdown,
}
pub trait InterruptHandler: Sync + Send {
pub trait InterruptHandler: Device {
fn handle_irq(self: Arc<Self>, vector: Option<usize>) -> bool;
fn display_name(&self) -> &str;
}
pub trait InterruptTable: Sync {
@ -143,16 +142,6 @@ pub struct FixedInterruptTable<const N: usize> {
rows: [Option<Arc<dyn InterruptHandler>>; N],
}
impl<F: Fn(Option<usize>) -> bool + Sync + Send> InterruptHandler for F {
fn handle_irq(self: Arc<Self>, vector: Option<usize>) -> bool {
self(vector)
}
fn display_name(&self) -> &str {
"<closure>"
}
}
impl<const N: usize> FixedInterruptTable<N> {
pub const fn new() -> Self {
Self {
@ -190,13 +179,6 @@ impl<const N: usize> InterruptTable for FixedInterruptTable<N> {
}
}
// pub trait LocalInterruptController {
// }
//
// pub struct FixedInterruptTable<const SIZE: usize> {
// entries: [Option<&'static dyn InterruptHandler>; SIZE],
// }
//
impl IrqLevel {
pub fn override_default(self, value: IrqLevel) -> Self {
match self {

View File

@ -48,10 +48,6 @@ impl InterruptHandler for ArmTimer {
true
}
fn display_name(&self) -> &str {
"ARM Generic Timer"
}
}
impl Device for ArmTimer {

View File

@ -119,10 +119,6 @@ impl InterruptHandler for HpetTimer {
true
}
fn display_name(&self) -> &str {
self.name.as_str()
}
}
impl Device for HpetTimer {

View File

@ -32,10 +32,6 @@ pub struct I8253 {
}
impl InterruptHandler for I8253 {
fn display_name(&self) -> &str {
"i8253 PIT"
}
fn handle_irq(self: Arc<Self>, _vector: Option<usize>) -> bool {
self.irq_handler_fastpath();
true

View File

@ -106,10 +106,6 @@ impl InterruptHandler for PS2Controller {
count != 0
}
fn display_name(&self) -> &str {
"PS/2 Keyboard Interrupt"
}
}
impl Device for PS2Controller {

View File

@ -141,10 +141,6 @@ impl InterruptHandler for Rtc {
}
true
}
fn display_name(&self) -> &str {
"x86 RTC IRQ"
}
}
impl Device for Rtc {

View File

@ -97,17 +97,6 @@ impl DebugSink for Port {
}
}
// impl SerialDevice for Port {
// fn send_byte(&self, byte: u8) -> Result<(), Error> {
// let mut inner = self.inner.lock();
// inner.write(byte)
// }
//
// fn is_terminal(&self) -> bool {
// false
// }
// }
impl InterruptHandler for Port {
fn handle_irq(self: Arc<Self>, _vector: Option<usize>) -> bool {
let inner = self.terminal.output();
@ -118,10 +107,6 @@ impl InterruptHandler for Port {
false
}
}
fn display_name(&self) -> &str {
"x86 COM port IRQ"
}
}
impl Device for Port {

View File

@ -11,7 +11,10 @@ use acpi_system::{
AcpiInterruptMethod, AcpiSleepState, AcpiSystem, AcpiSystemError, EventAction, FixedEvent,
};
use alloc::{boxed::Box, sync::Arc};
use device_api::interrupt::{InterruptHandler, IpiDeliveryTarget, IpiMessage, Irq};
use device_api::{
device::Device,
interrupt::{InterruptHandler, IpiDeliveryTarget, IpiMessage, Irq},
};
use kernel_arch_x86_64::CPU_COUNT;
use libk::device::external_interrupt_controller;
use libk_mm::{
@ -48,16 +51,18 @@ static ACPI_SYSTEM: OneTimeInit<IrqSafeSpinlock<AcpiSystem<AcpiHandlerImpl>>> =
// }
// }
impl Device for SciHandler {
fn display_name(&self) -> &str {
"ACPI SCI Handler"
}
}
impl InterruptHandler for SciHandler {
fn handle_irq(self: Arc<Self>, _vector: Option<usize>) -> bool {
log::trace!("ACPI SCI received");
ACPI_SYSTEM.get().lock().handle_sci();
true
}
fn display_name(&self) -> &str {
"ACPI SCI Handler"
}
}
unsafe impl Allocator for AcpiAllocator {

View File

@ -139,10 +139,6 @@ impl InterruptHandler for Bcm2835AuxUart {
status
}
fn display_name(&self) -> &str {
"BCM283x mini-UART IRQ"
}
}
impl Device for Bcm2835AuxUart {

View File

@ -134,10 +134,6 @@ impl InterruptHandler for Pl011 {
true
}
fn display_name(&self) -> &str {
"PL011 IRQ"
}
}
impl Device for Pl011 {

View File

@ -129,7 +129,7 @@ impl BuildEnv {
(Arch::aarch64, Board::virt | Board::default) => "aarch64-unknown-qemu",
(Arch::aarch64, Board::raspi4b) => "aarch64-unknown-raspi4b",
(Arch::x86_64, Board::default) => "x86_64-unknown-none",
(Arch::i686, Board::default) => "x86_64-unknown-none",
(Arch::i686, Board::default) => "i686-unknown-none",
_ => {
log::error!("Invalid arch/board combination: {arch:?}/{board:?}");
panic!();