Skip to content

acpi: Clone impl for PlatformInfo and ManagedSlice #239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions acpi/src/managed_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,11 @@ where
self.slice
}
}

impl<T: Clone, A: Allocator + Clone> 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
}
}
12 changes: 6 additions & 6 deletions acpi/src/platform/interrupt.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -116,7 +116,7 @@ where
}
}

#[derive(Debug)]
#[derive(Debug, Clone)]
#[non_exhaustive]
pub enum InterruptModel<'a, A>
where
Expand Down
6 changes: 3 additions & 3 deletions acpi/src/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub struct Processor {
pub is_ap: bool,
}

#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct ProcessorInfo<'a, A>
where
A: Allocator,
Expand All @@ -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,
Expand All @@ -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,
Expand Down