From 8cbde8389f89039f2075af143633d40b6b0891d9 Mon Sep 17 00:00:00 2001 From: Mark Poliakov Date: Thu, 6 Feb 2025 12:24:03 +0200 Subject: [PATCH] dev: pass DeviceInitContext into Device::init() --- kernel/driver/block/ahci/src/lib.rs | 6 ++- kernel/driver/block/nvme/src/lib.rs | 7 ++- kernel/driver/bus/pci/src/lib.rs | 11 +++- kernel/driver/net/rtl81xx/src/rtl8139.rs | 7 ++- kernel/driver/net/rtl81xx/src/rtl8168.rs | 6 ++- kernel/driver/usb/xhci/src/controller.rs | 7 ++- kernel/driver/virtio/gpu/src/lib.rs | 6 ++- kernel/driver/virtio/net/src/lib.rs | 6 ++- kernel/lib/device-api/src/device.rs | 9 +++- kernel/lib/device-api/src/dma.rs | 1 + kernel/lib/device-api/src/lib.rs | 2 + kernel/lib/device-tree/src/driver/tree.rs | 17 ++++-- kernel/libk/src/device/block/partition/mod.rs | 12 ----- kernel/libk/src/device/manager.rs | 52 +++++++++---------- kernel/libk/src/dma.rs | 5 ++ kernel/libk/src/lib.rs | 2 + kernel/src/arch/aarch64/gic/gicv2m.rs | 4 +- kernel/src/arch/aarch64/gic/mod.rs | 4 +- kernel/src/arch/aarch64/timer.rs | 4 +- kernel/src/device/bus/simple_bus.rs | 7 ++- kernel/src/device/clock/bcm2835_aux.rs | 7 ++- kernel/src/device/power/arm_psci.rs | 7 ++- kernel/src/device/serial/bcm2835_aux_uart.rs | 4 +- kernel/src/device/serial/pl011.rs | 4 +- 24 files changed, 122 insertions(+), 75 deletions(-) create mode 100644 kernel/lib/device-api/src/dma.rs create mode 100644 kernel/libk/src/dma.rs diff --git a/kernel/driver/block/ahci/src/lib.rs b/kernel/driver/block/ahci/src/lib.rs index 4ab0967e..a34fbf92 100644 --- a/kernel/driver/block/ahci/src/lib.rs +++ b/kernel/driver/block/ahci/src/lib.rs @@ -8,7 +8,7 @@ use alloc::{format, sync::Arc, vec::Vec}; use bytemuck::Zeroable; use data::ReceivedFis; use device_api::{ - device::Device, + device::{Device, DeviceInitContext}, interrupt::{InterruptAffinity, InterruptHandler, IrqVector}, }; use error::AhciError; @@ -181,7 +181,9 @@ impl InterruptHandler for AhciController { } impl Device for AhciController { - unsafe fn init(self: Arc) -> Result<(), Error> { + unsafe fn init(self: Arc, cx: DeviceInitContext) -> Result<(), Error> { + // TODO use DmaAllocator instead of PageBox + let _ = cx; // Do the init in background runtime::spawn(self.late_init())?; Ok(()) diff --git a/kernel/driver/block/nvme/src/lib.rs b/kernel/driver/block/nvme/src/lib.rs index 54bfa14b..54e893a1 100644 --- a/kernel/driver/block/nvme/src/lib.rs +++ b/kernel/driver/block/nvme/src/lib.rs @@ -15,7 +15,7 @@ use core::{ use alloc::{collections::BTreeMap, format, sync::Arc, vec::Vec}; use command::{IdentifyActiveNamespaceIdListRequest, IdentifyControllerRequest}; use device_api::{ - device::Device, + device::{Device, DeviceInitContext}, interrupt::{InterruptAffinity, InterruptHandler, IrqVector}, }; use drive::NvmeNamespace; @@ -345,7 +345,10 @@ impl InterruptHandler for NvmeController { } impl Device for NvmeController { - unsafe fn init(self: Arc) -> Result<(), Error> { + unsafe fn init(self: Arc, cx: DeviceInitContext) -> Result<(), Error> { + // TODO use DmaAllocator instead of PageBox + let _ = cx; + let regs = self.regs.lock(); let timeout = Duration::from_millis(regs.CAP.read(CAP::TO) * 500); diff --git a/kernel/driver/bus/pci/src/lib.rs b/kernel/driver/bus/pci/src/lib.rs index b23cb956..6a1da2ed 100644 --- a/kernel/driver/bus/pci/src/lib.rs +++ b/kernel/driver/bus/pci/src/lib.rs @@ -13,8 +13,12 @@ use alloc::{format, sync::Arc, vec::Vec}; use bitflags::bitflags; use device::{PciBusDevice, PciDeviceInfo}; +use device_api::device::DeviceInitContext; use interrupt::{PciInterruptMap, PciMsiMap}; -use libk::fs::sysfs::{self, object::KObject}; +use libk::{ + dma::DummyDmaAllocator, + fs::sysfs::{self, object::KObject}, +}; use libk_mm::address::PhysicalAddress; use libk_util::{sync::IrqSafeSpinlock, OneTimeInit}; use space::legacy; @@ -614,8 +618,11 @@ fn setup_bus_device(device: &mut PciBusDevice) -> Result<(), Error> { if let Some(driver) = driver::lookup_driver(&device.info) { log::info!("{} -> {}", device.info.address, driver.driver_name()); let instance = driver.probe(&device.info)?; + let cx = DeviceInitContext { + dma_allocator: Arc::new(DummyDmaAllocator), + }; - unsafe { instance.clone().init() }?; + unsafe { instance.clone().init(cx) }?; device.device.replace(instance); device.driver_name.replace(driver.driver_name()); diff --git a/kernel/driver/net/rtl81xx/src/rtl8139.rs b/kernel/driver/net/rtl81xx/src/rtl8139.rs index 3ab09490..3cf04238 100644 --- a/kernel/driver/net/rtl81xx/src/rtl8139.rs +++ b/kernel/driver/net/rtl81xx/src/rtl8139.rs @@ -2,7 +2,7 @@ use core::mem::MaybeUninit; use alloc::sync::Arc; use device_api::{ - device::Device, + device::{Device, DeviceInitContext}, interrupt::{InterruptHandler, IrqVector}, }; use libk::error::Error; @@ -342,7 +342,10 @@ impl InterruptHandler for Rtl8139 { } impl Device for Rtl8139 { - unsafe fn init(self: Arc) -> Result<(), Error> { + unsafe fn init(self: Arc, cx: DeviceInitContext) -> Result<(), Error> { + // TODO use DmaAllocator instead of PageBox + let _ = cx; + log::info!("Initialize rtl8139 driver"); log::info!("MAC: {}", self.mac); diff --git a/kernel/driver/net/rtl81xx/src/rtl8168.rs b/kernel/driver/net/rtl81xx/src/rtl8168.rs index 3c96d63a..6d5ca0ef 100644 --- a/kernel/driver/net/rtl81xx/src/rtl8168.rs +++ b/kernel/driver/net/rtl81xx/src/rtl8168.rs @@ -5,7 +5,7 @@ use core::{ use alloc::{sync::Arc, vec::Vec}; use device_api::{ - device::Device, + device::{Device, DeviceInitContext}, interrupt::{InterruptHandler, IrqVector}, }; use libk::error::Error; @@ -592,7 +592,9 @@ impl InterruptHandler for Rtl8168 { } impl Device for Rtl8168 { - unsafe fn init(self: Arc) -> Result<(), Error> { + unsafe fn init(self: Arc, cx: DeviceInitContext) -> Result<(), Error> { + // TODO use DmaAllocator instead of PageBox + let _ = cx; log::info!("Initialize rtl8168"); log::info!("MAC: {}", self.mac); diff --git a/kernel/driver/usb/xhci/src/controller.rs b/kernel/driver/usb/xhci/src/controller.rs index 30dae9bb..4838d384 100644 --- a/kernel/driver/usb/xhci/src/controller.rs +++ b/kernel/driver/usb/xhci/src/controller.rs @@ -3,7 +3,7 @@ use core::sync::atomic::{AtomicU8, Ordering}; use alloc::{boxed::Box, collections::btree_map::BTreeMap, sync::Arc, vec::Vec}; use async_trait::async_trait; use device_api::{ - device::Device, + device::{Device, DeviceInitContext}, interrupt::{InterruptHandler, IrqVector}, }; use libk::{error::Error, task::runtime}; @@ -443,7 +443,10 @@ impl CommandExecutor for Xhci { } impl Device for Xhci { - unsafe fn init(self: Arc) -> Result<(), Error> { + unsafe fn init(self: Arc, cx: DeviceInitContext) -> Result<(), Error> { + // TODO use DmaAllocator instead of PageBox + let _ = cx; + self.regs.hc_reset(10000000)?; log::info!("xHC reset complete"); diff --git a/kernel/driver/virtio/gpu/src/lib.rs b/kernel/driver/virtio/gpu/src/lib.rs index 622c4e10..39eb93c3 100644 --- a/kernel/driver/virtio/gpu/src/lib.rs +++ b/kernel/driver/virtio/gpu/src/lib.rs @@ -6,7 +6,7 @@ use core::mem::MaybeUninit; use alloc::{sync::Arc, vec::Vec}; use command::{ControlLock, ScanoutInfo}; -use device_api::device::Device; +use device_api::device::{Device, DeviceInitContext}; use libk::device::{ display::{ DisplayDevice, DisplayMode, DisplayOwner, DriverFlags, FramebufferInfo, PixelFormat, @@ -253,7 +253,9 @@ impl VirtioGpu { } impl Device for VirtioGpu { - unsafe fn init(self: Arc) -> Result<(), Error> { + unsafe fn init(self: Arc, cx: DeviceInitContext) -> Result<(), Error> { + // TODO use DmaAllocator instead of PageBox + let _ = cx; let status = self.begin_init()?; self.setup_queues()?; self.finish_init(status); diff --git a/kernel/driver/virtio/net/src/lib.rs b/kernel/driver/virtio/net/src/lib.rs index 3e846ce3..377e2600 100644 --- a/kernel/driver/virtio/net/src/lib.rs +++ b/kernel/driver/virtio/net/src/lib.rs @@ -8,7 +8,7 @@ use core::mem::size_of; use alloc::{collections::BTreeMap, sync::Arc}; use bytemuck::{Pod, Zeroable}; use device_api::{ - device::Device, + device::{Device, DeviceInitContext}, interrupt::{InterruptAffinity, InterruptHandler, IrqVector}, }; use libk_mm::PageBox; @@ -253,7 +253,9 @@ impl Device for VirtioNet { "VirtIO Network Device" } - unsafe fn init(self: Arc) -> Result<(), Error> { + unsafe fn init(self: Arc, cx: DeviceInitContext) -> Result<(), Error> { + // TODO use DmaAllocator instead of PageBox + let _ = cx; let status = self.begin_init()?; // TODO multiqueue diff --git a/kernel/lib/device-api/src/device.rs b/kernel/lib/device-api/src/device.rs index 198b1511..70e21115 100644 --- a/kernel/lib/device-api/src/device.rs +++ b/kernel/lib/device-api/src/device.rs @@ -1,7 +1,11 @@ use alloc::sync::Arc; use yggdrasil_abi::error::Error; -use crate::{bus::Bus, clock::ClockController}; +use crate::{bus::Bus, clock::ClockController, dma::DmaAllocator}; + +pub struct DeviceInitContext { + pub dma_allocator: Arc, +} pub trait Device: Sync + Send { fn display_name(&self) -> &str; @@ -13,7 +17,8 @@ pub trait Device: Sync + Send { /// # Safety /// /// The caller must make sure the function is only called once. - unsafe fn init(self: Arc) -> Result<(), Error> { + unsafe fn init(self: Arc, cx: DeviceInitContext) -> Result<(), Error> { + let _ = cx; Ok(()) } diff --git a/kernel/lib/device-api/src/dma.rs b/kernel/lib/device-api/src/dma.rs new file mode 100644 index 00000000..e3990350 --- /dev/null +++ b/kernel/lib/device-api/src/dma.rs @@ -0,0 +1 @@ +pub trait DmaAllocator {} diff --git a/kernel/lib/device-api/src/lib.rs b/kernel/lib/device-api/src/lib.rs index 5dbe75e8..0243116b 100644 --- a/kernel/lib/device-api/src/lib.rs +++ b/kernel/lib/device-api/src/lib.rs @@ -11,6 +11,8 @@ pub mod interrupt; pub mod serial; pub mod timer; +pub mod dma; + use device::Device; use yggdrasil_abi::error::Error; diff --git a/kernel/lib/device-tree/src/driver/tree.rs b/kernel/lib/device-tree/src/driver/tree.rs index 7e3e52f5..7eabd1cb 100644 --- a/kernel/lib/device-tree/src/driver/tree.rs +++ b/kernel/lib/device-tree/src/driver/tree.rs @@ -8,10 +8,11 @@ use alloc::{ use device_api::{ bus::Bus, clock::ClockController, - device::Device, + device::{Device, DeviceInitContext}, interrupt::{ExternalInterruptController, FullIrq, MessageInterruptController}, }; use fdt_rs::spec::Phandle; +use libk::dma::DummyDmaAllocator; use libk_mm::address::PhysicalAddress; use libk_util::OneTimeInit; use yggdrasil_abi::error::Error; @@ -188,7 +189,8 @@ impl Node { pub fn lazy_init(self: Arc) -> Option> { let device = self.clone().probe()?; let result = self.init_token.or_try_init_with(|| { - unsafe { device.init() }?; + let cx = self.make_init_context(); + unsafe { device.init(cx) }?; Ok(()) }); match result { @@ -233,12 +235,21 @@ impl Node { .inspect_err(|_| log::error!("Does not exist: probe({:?})", self.name))?; self.init_token.try_init_with_opt(|| { - unsafe { device.init() }?; + let cx = self.make_init_context(); + unsafe { device.init(cx) }?; Ok(()) })?; Ok(()) } + fn make_init_context(&self) -> DeviceInitContext { + let cx = DeviceInitContext { + dma_allocator: Arc::new(DummyDmaAllocator), + }; + + cx + } + /// Returns an iterator over the node's children pub fn children(&self) -> impl Iterator> { self.children.get().iter() diff --git a/kernel/libk/src/device/block/partition/mod.rs b/kernel/libk/src/device/block/partition/mod.rs index 0c76eca2..a5c38d85 100644 --- a/kernel/libk/src/device/block/partition/mod.rs +++ b/kernel/libk/src/device/block/partition/mod.rs @@ -49,18 +49,6 @@ impl PageProvider for Partition { } impl Device for Partition { - unsafe fn init(self: Arc) -> Result<(), Error> { - todo!() - } - - unsafe fn deinit(&self) -> Result<(), Error> { - todo!() - } - - unsafe fn init_irq(self: Arc) -> Result<(), Error> { - todo!() - } - fn display_name(&self) -> &str { "Partition" } diff --git a/kernel/libk/src/device/manager.rs b/kernel/libk/src/device/manager.rs index 20605c79..ed05fb33 100644 --- a/kernel/libk/src/device/manager.rs +++ b/kernel/libk/src/device/manager.rs @@ -162,36 +162,36 @@ impl DeviceRegistry { }); } - pub fn run_initialization(&self) { - let mut devices = self.pending_initialization.write(); + // pub fn run_initialization(&self) { + // let mut devices = self.pending_initialization.write(); - for pending in devices.iter_mut() { - if pending.irq_only { - continue; - } + // for pending in devices.iter_mut() { + // if pending.irq_only { + // continue; + // } - log::debug!("Init device: {:?}", pending.device.display_name()); - if let Err(error) = unsafe { pending.device.clone().init() } { - log::error!("{:?} init error: {error:?}", pending.device.display_name()); - pending.failed = true; - continue; - } - } + // log::debug!("Init device: {:?}", pending.device.display_name()); + // if let Err(error) = unsafe { pending.device.clone().init() } { + // log::error!("{:?} init error: {error:?}", pending.device.display_name()); + // pending.failed = true; + // continue; + // } + // } - for pending in devices.drain(..) { - if pending.failed { - continue; - } + // for pending in devices.drain(..) { + // if pending.failed { + // continue; + // } - log::debug!("Init IRQ: {:?}", pending.device.display_name()); - if let Err(error) = unsafe { pending.device.clone().init_irq() } { - log::error!( - "{:?} IRQ init error: {error:?}", - pending.device.display_name() - ); - } - } - } + // log::debug!("Init IRQ: {:?}", pending.device.display_name()); + // if let Err(error) = unsafe { pending.device.clone().init_irq() } { + // log::error!( + // "{:?} IRQ init error: {error:?}", + // pending.device.display_name() + // ); + // } + // } + // } } async fn probe_partition_table( diff --git a/kernel/libk/src/dma.rs b/kernel/libk/src/dma.rs new file mode 100644 index 00000000..cc1ad8fd --- /dev/null +++ b/kernel/libk/src/dma.rs @@ -0,0 +1,5 @@ +use device_api::dma::DmaAllocator; + +pub struct DummyDmaAllocator; + +impl DmaAllocator for DummyDmaAllocator {} diff --git a/kernel/libk/src/lib.rs b/kernel/libk/src/lib.rs index d7a25786..28d014ed 100644 --- a/kernel/libk/src/lib.rs +++ b/kernel/libk/src/lib.rs @@ -44,6 +44,8 @@ pub mod random; pub mod time; pub mod vfs; +pub mod dma; + #[cfg(any(target_os = "none", rust_analyzer))] pub mod panic; diff --git a/kernel/src/arch/aarch64/gic/gicv2m.rs b/kernel/src/arch/aarch64/gic/gicv2m.rs index b8a82e80..ec0571b7 100644 --- a/kernel/src/arch/aarch64/gic/gicv2m.rs +++ b/kernel/src/arch/aarch64/gic/gicv2m.rs @@ -4,7 +4,7 @@ use core::{mem::offset_of, ops::Range}; use abi::error::Error; use alloc::{sync::Arc, vec::Vec}; use device_api::{ - device::Device, + device::{Device, DeviceInitContext}, interrupt::{ ExternalInterruptController, InterruptAffinity, InterruptHandler, Irq, IrqLevel, IrqOptions, IrqTrigger, IrqVector, MessageInterruptController, MsiInfo, @@ -83,7 +83,7 @@ pub struct Gicv2m { } impl Device for Gicv2m { - unsafe fn init(self: Arc) -> Result<(), Error> { + unsafe fn init(self: Arc, _cx: DeviceInitContext) -> Result<(), Error> { let regs = self.regs.lock(); log::info!("gicv2m: init @ {:#x}", self.base); diff --git a/kernel/src/arch/aarch64/gic/mod.rs b/kernel/src/arch/aarch64/gic/mod.rs index efe9987b..61075f76 100644 --- a/kernel/src/arch/aarch64/gic/mod.rs +++ b/kernel/src/arch/aarch64/gic/mod.rs @@ -6,7 +6,7 @@ use aarch64_cpu::asm::barrier; use abi::error::Error; use alloc::sync::Arc; use device_api::{ - device::Device, + device::{Device, DeviceInitContext}, interrupt::{ ExternalInterruptController, FixedInterruptTable, FullIrq, InterruptHandler, InterruptTable, IpiDeliveryTarget, IpiMessage, Irq, IrqLevel, IrqOptions, IrqTrigger, @@ -58,7 +58,7 @@ impl Device for Gic { "ARM Generic Interrupt Controller v2" } - unsafe fn init(self: Arc) -> Result<(), Error> { + unsafe fn init(self: Arc, _cx: DeviceInitContext) -> Result<(), Error> { log::debug!( "Init GIC: gicd={:#x}, gicc={:#x}", self.gicd_base, diff --git a/kernel/src/arch/aarch64/timer.rs b/kernel/src/arch/aarch64/timer.rs index 3154ed67..fbda12d5 100644 --- a/kernel/src/arch/aarch64/timer.rs +++ b/kernel/src/arch/aarch64/timer.rs @@ -6,7 +6,7 @@ use aarch64_cpu::registers::{CNTFRQ_EL0, CNTPCT_EL0, CNTP_CTL_EL0, CNTP_TVAL_EL0 use abi::{error::Error, time::NANOSECONDS_IN_SECOND}; use alloc::sync::Arc; use device_api::{ - device::Device, + device::{Device, DeviceInitContext}, interrupt::{FullIrq, InterruptHandler, IrqVector}, }; use device_tree::driver::{device_tree_driver, Node, ProbeContext}; @@ -55,7 +55,7 @@ impl Device for ArmTimer { "ARM Generic Timer" } - unsafe fn init(self: Arc) -> Result<(), Error> { + unsafe fn init(self: Arc, _cx: DeviceInitContext) -> Result<(), Error> { CNTP_CTL_EL0.write(CNTP_CTL_EL0::ENABLE::SET + CNTP_CTL_EL0::IMASK::SET); Ok(()) } diff --git a/kernel/src/device/bus/simple_bus.rs b/kernel/src/device/bus/simple_bus.rs index d6216767..b97e8a2e 100644 --- a/kernel/src/device/bus/simple_bus.rs +++ b/kernel/src/device/bus/simple_bus.rs @@ -7,7 +7,10 @@ use core::ops::Range; use abi::error::Error; use alloc::{sync::Arc, vec::Vec}; -use device_api::{bus::Bus, device::Device}; +use device_api::{ + bus::Bus, + device::{Device, DeviceInitContext}, +}; use device_tree::{ driver::{device_tree_driver, Node, ProbeContext}, DeviceTreePropertyRead, @@ -18,7 +21,7 @@ struct SimpleBus { } impl Device for SimpleBus { - unsafe fn init(self: Arc) -> Result<(), Error> { + unsafe fn init(self: Arc, _cx: DeviceInitContext) -> Result<(), Error> { Ok(()) } diff --git a/kernel/src/device/clock/bcm2835_aux.rs b/kernel/src/device/clock/bcm2835_aux.rs index eaa9869a..925cf7d9 100644 --- a/kernel/src/device/clock/bcm2835_aux.rs +++ b/kernel/src/device/clock/bcm2835_aux.rs @@ -2,7 +2,10 @@ use aarch64_cpu::registers::ReadWriteable; use abi::error::Error; use alloc::sync::Arc; -use device_api::{clock::ClockController, device::Device}; +use device_api::{ + clock::ClockController, + device::{Device, DeviceInitContext}, +}; use device_tree::driver::{device_tree_driver, Node, ProbeContext}; use libk_mm::{address::PhysicalAddress, device::DeviceMemoryIo}; use libk_util::{sync::IrqSafeSpinlock, OneTimeInit}; @@ -52,7 +55,7 @@ impl ClockController for Bcm2835Aux { } impl Device for Bcm2835Aux { - unsafe fn init(self: Arc) -> Result<(), Error> { + unsafe fn init(self: Arc, _cx: DeviceInitContext) -> Result<(), Error> { let regs = DeviceMemoryIo::map(self.base, Default::default())?; self.regs.init(IrqSafeSpinlock::new(regs)); Ok(()) diff --git a/kernel/src/device/power/arm_psci.rs b/kernel/src/device/power/arm_psci.rs index 9f7454d3..09d783cd 100644 --- a/kernel/src/device/power/arm_psci.rs +++ b/kernel/src/device/power/arm_psci.rs @@ -2,7 +2,10 @@ use abi::error::Error; use alloc::sync::Arc; -use device_api::{device::Device, CpuBringupDevice, ResetDevice}; +use device_api::{ + device::{Device, DeviceInitContext}, + CpuBringupDevice, ResetDevice, +}; use device_tree::{ driver::{device_tree_driver, Node, ProbeContext}, DeviceTreePropertyRead, @@ -31,7 +34,7 @@ impl Device for Psci { "ARM PSCI" } - unsafe fn init(self: Arc) -> Result<(), Error> { + unsafe fn init(self: Arc, _cx: DeviceInitContext) -> Result<(), Error> { PLATFORM.psci.init(self.clone()); Ok(()) } diff --git a/kernel/src/device/serial/bcm2835_aux_uart.rs b/kernel/src/device/serial/bcm2835_aux_uart.rs index dbb97a1e..1c35412d 100644 --- a/kernel/src/device/serial/bcm2835_aux_uart.rs +++ b/kernel/src/device/serial/bcm2835_aux_uart.rs @@ -8,7 +8,7 @@ use abi::{ }; use alloc::sync::Arc; use device_api::{ - device::Device, + device::{Device, DeviceInitContext}, interrupt::{FullIrq, InterruptHandler, IrqVector}, }; use device_tree::{ @@ -148,7 +148,7 @@ impl InterruptHandler for Bcm2835AuxUart { } impl Device for Bcm2835AuxUart { - unsafe fn init(self: Arc) -> Result<(), Error> { + unsafe fn init(self: Arc, _cx: DeviceInitContext) -> Result<(), Error> { // TODO initialize pinctrl // NOTE: might as well make it an error if clock cannot be initialized diff --git a/kernel/src/device/serial/pl011.rs b/kernel/src/device/serial/pl011.rs index 96d036fb..4179338b 100644 --- a/kernel/src/device/serial/pl011.rs +++ b/kernel/src/device/serial/pl011.rs @@ -2,7 +2,7 @@ use abi::{error::Error, io::TerminalOptions}; use alloc::sync::Arc; use device_api::{ - device::Device, + device::{Device, DeviceInitContext}, interrupt::{FullIrq, InterruptHandler, IrqVector}, }; use device_tree::driver::{device_tree_driver, Node, ProbeContext}; @@ -139,7 +139,7 @@ impl Device for Pl011 { "Primecell PL011 UART" } - unsafe fn init(self: Arc) -> Result<(), Error> { + unsafe fn init(self: Arc, _cx: DeviceInitContext) -> Result<(), Error> { let mut io = Io { regs: DeviceMemoryIo::map(self.base, Default::default())?, };