From 4f3a5c176776e920d4653426cceb4ea169719123 Mon Sep 17 00:00:00 2001 From: German Date: Sun, 5 Jan 2025 15:42:09 +0300 Subject: [PATCH] acpi: Clone impl for PlatformInfo and ManagedSlice --- acpi/src/managed_slice.rs | 8 ++++++++ acpi/src/platform/interrupt.rs | 12 ++++++------ acpi/src/platform/mod.rs | 6 +++--- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/acpi/src/managed_slice.rs b/acpi/src/managed_slice.rs index a46c514f..d6a8a287 100644 --- a/acpi/src/managed_slice.rs +++ b/acpi/src/managed_slice.rs @@ -73,3 +73,11 @@ where self.slice } } + +impl Clone for ManagedSlice<'_, T, A> { + fn clone(&self) -> Self { + let mut new_managed_slice = ManagedSlice::new_in(self.len(), self.allocator.clone()).unwrap(); + new_managed_slice.clone_from_slice(self); + new_managed_slice + } +} diff --git a/acpi/src/platform/interrupt.rs b/acpi/src/platform/interrupt.rs index 75d2effd..a83fcefe 100644 --- a/acpi/src/platform/interrupt.rs +++ b/acpi/src/platform/interrupt.rs @@ -1,7 +1,7 @@ use crate::ManagedSlice; use core::alloc::Allocator; -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub struct IoApic { pub id: u8, /// The physical address at which to access this I/O APIC. @@ -10,7 +10,7 @@ pub struct IoApic { pub global_system_interrupt_base: u32, } -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub struct NmiLine { pub processor: NmiProcessor, pub line: LocalInterruptLine, @@ -59,7 +59,7 @@ pub enum TriggerMode { /// models. For example, if a device is connected to ISA IRQ 0 and IOAPIC input 2, an override will /// appear mapping source 0 to GSI 2. Currently these will only be created for ISA interrupt /// sources. -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub struct InterruptSourceOverride { pub isa_source: u8, pub global_system_interrupt: u32, @@ -69,14 +69,14 @@ pub struct InterruptSourceOverride { /// Describes a Global System Interrupt that should be enabled as non-maskable. Any source that is /// non-maskable can not be used by devices. -#[derive(Debug)] +#[derive(Debug, Clone, Copy)] pub struct NmiSource { pub global_system_interrupt: u32, pub polarity: Polarity, pub trigger_mode: TriggerMode, } -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct Apic<'a, A> where A: Allocator, @@ -116,7 +116,7 @@ where } } -#[derive(Debug)] +#[derive(Debug, Clone)] #[non_exhaustive] pub enum InterruptModel<'a, A> where diff --git a/acpi/src/platform/mod.rs b/acpi/src/platform/mod.rs index c3b29cf5..1e8df4c8 100644 --- a/acpi/src/platform/mod.rs +++ b/acpi/src/platform/mod.rs @@ -45,7 +45,7 @@ pub struct Processor { pub is_ap: bool, } -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct ProcessorInfo<'a, A> where A: Allocator, @@ -65,7 +65,7 @@ where } /// Information about the ACPI Power Management Timer (ACPI PM Timer). -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct PmTimer { /// A generic address to the register block of ACPI PM Timer. pub base: GenericAddress, @@ -85,7 +85,7 @@ impl PmTimer { /// `PlatformInfo` allows the collection of some basic information about the platform from some of the fixed-size /// tables in a nice way. It requires access to the `FADT` and `MADT`. It is the easiest way to get information /// about the processors and interrupt controllers on a platform. -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct PlatformInfo<'a, A> where A: Allocator,