Skip to content

Commit 79dec37

Browse files
authored
acpi: Clone impl for PlatformInfo and ManagedSlice (#239)
1 parent 448f318 commit 79dec37

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

acpi/src/managed_slice.rs

+8
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,11 @@ where
7373
self.slice
7474
}
7575
}
76+
77+
impl<T: Clone, A: Allocator + Clone> Clone for ManagedSlice<'_, T, A> {
78+
fn clone(&self) -> Self {
79+
let mut new_managed_slice = ManagedSlice::new_in(self.len(), self.allocator.clone()).unwrap();
80+
new_managed_slice.clone_from_slice(self);
81+
new_managed_slice
82+
}
83+
}

acpi/src/platform/interrupt.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::ManagedSlice;
22
use core::alloc::Allocator;
33

4-
#[derive(Debug)]
4+
#[derive(Debug, Clone, Copy)]
55
pub struct IoApic {
66
pub id: u8,
77
/// The physical address at which to access this I/O APIC.
@@ -10,7 +10,7 @@ pub struct IoApic {
1010
pub global_system_interrupt_base: u32,
1111
}
1212

13-
#[derive(Debug)]
13+
#[derive(Debug, Clone, Copy)]
1414
pub struct NmiLine {
1515
pub processor: NmiProcessor,
1616
pub line: LocalInterruptLine,
@@ -59,7 +59,7 @@ pub enum TriggerMode {
5959
/// models. For example, if a device is connected to ISA IRQ 0 and IOAPIC input 2, an override will
6060
/// appear mapping source 0 to GSI 2. Currently these will only be created for ISA interrupt
6161
/// sources.
62-
#[derive(Debug)]
62+
#[derive(Debug, Clone, Copy)]
6363
pub struct InterruptSourceOverride {
6464
pub isa_source: u8,
6565
pub global_system_interrupt: u32,
@@ -69,14 +69,14 @@ pub struct InterruptSourceOverride {
6969

7070
/// Describes a Global System Interrupt that should be enabled as non-maskable. Any source that is
7171
/// non-maskable can not be used by devices.
72-
#[derive(Debug)]
72+
#[derive(Debug, Clone, Copy)]
7373
pub struct NmiSource {
7474
pub global_system_interrupt: u32,
7575
pub polarity: Polarity,
7676
pub trigger_mode: TriggerMode,
7777
}
7878

79-
#[derive(Debug)]
79+
#[derive(Debug, Clone)]
8080
pub struct Apic<'a, A>
8181
where
8282
A: Allocator,
@@ -116,7 +116,7 @@ where
116116
}
117117
}
118118

119-
#[derive(Debug)]
119+
#[derive(Debug, Clone)]
120120
#[non_exhaustive]
121121
pub enum InterruptModel<'a, A>
122122
where

acpi/src/platform/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub struct Processor {
4545
pub is_ap: bool,
4646
}
4747

48-
#[derive(Debug)]
48+
#[derive(Debug, Clone)]
4949
pub struct ProcessorInfo<'a, A>
5050
where
5151
A: Allocator,
@@ -65,7 +65,7 @@ where
6565
}
6666

6767
/// Information about the ACPI Power Management Timer (ACPI PM Timer).
68-
#[derive(Debug)]
68+
#[derive(Debug, Clone)]
6969
pub struct PmTimer {
7070
/// A generic address to the register block of ACPI PM Timer.
7171
pub base: GenericAddress,
@@ -85,7 +85,7 @@ impl PmTimer {
8585
/// `PlatformInfo` allows the collection of some basic information about the platform from some of the fixed-size
8686
/// tables in a nice way. It requires access to the `FADT` and `MADT`. It is the easiest way to get information
8787
/// about the processors and interrupt controllers on a platform.
88-
#[derive(Debug)]
88+
#[derive(Debug, Clone)]
8989
pub struct PlatformInfo<'a, A>
9090
where
9191
A: Allocator,

0 commit comments

Comments
 (0)