Skip to content

Commit 41edbac

Browse files
committed
aml: monomorphise over Handler type
1 parent b8cb18f commit 41edbac

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

aml/src/lib.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ pub mod pci_routing;
1111
pub mod resource;
1212

1313
use alloc::{
14-
boxed::Box,
1514
string::{String, ToString},
1615
sync::Arc,
1716
vec,
@@ -24,23 +23,26 @@ use object::{MethodFlags, Object, ObjectType, ReferenceKind};
2423
use op_region::{OpRegion, RegionSpace};
2524
use spinning_top::Spinlock;
2625

27-
pub struct Interpreter {
28-
handler: Box<dyn Handler>,
26+
pub struct Interpreter<H>
27+
where
28+
H: Handler,
29+
{
30+
handler: H,
2931
pub namespace: Spinlock<Namespace>,
3032
context_stack: Spinlock<Vec<MethodContext>>,
3133
}
3234

33-
unsafe impl Send for Interpreter {}
34-
unsafe impl Sync for Interpreter {}
35+
unsafe impl<H> Send for Interpreter<H> where H: Handler + Send {}
36+
unsafe impl<H> Sync for Interpreter<H> where H: Handler + Send {}
3537

36-
impl Interpreter {
37-
pub fn new<H>(handler: H) -> Interpreter
38-
where
39-
H: Handler + 'static,
40-
{
38+
impl<H> Interpreter<H>
39+
where
40+
H: Handler,
41+
{
42+
pub fn new(handler: H) -> Interpreter<H> {
4143
Interpreter {
44+
handler,
4245
namespace: Spinlock::new(Namespace::new()),
43-
handler: Box::new(handler),
4446
context_stack: Spinlock::new(Vec::new()),
4547
}
4648
}

aml/src/pci_routing.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::{
22
AmlError,
3+
Handler,
34
Interpreter,
45
namespace::AmlName,
56
object::{Object, ReferenceKind},
@@ -56,7 +57,10 @@ impl PciRoutingTable {
5657
/// `AmlError::InvalidOperationOnObject` if the value passed is not a package, or if any of the
5758
/// values within it are not packages. Returns the various `AmlError::Prt*` errors if the
5859
/// internal structure of the entries is invalid.
59-
pub fn from_prt_path(prt_path: AmlName, interpreter: &Interpreter) -> Result<PciRoutingTable, AmlError> {
60+
pub fn from_prt_path(
61+
prt_path: AmlName,
62+
interpreter: &Interpreter<impl Handler>,
63+
) -> Result<PciRoutingTable, AmlError> {
6064
let mut entries = Vec::new();
6165

6266
let prt = interpreter.invoke_method(prt_path.clone(), vec![])?;
@@ -149,7 +153,7 @@ impl PciRoutingTable {
149153
device: u16,
150154
function: u16,
151155
pin: Pin,
152-
interpreter: &Interpreter,
156+
interpreter: &Interpreter<impl Handler>,
153157
) -> Result<IrqDescriptor, AmlError> {
154158
let entry = self
155159
.entries

0 commit comments

Comments
 (0)