From 270e300920df28fa4506bc9cdc28469a8a37e12b Mon Sep 17 00:00:00 2001 From: Martin Hughes Date: Mon, 12 Oct 2026 14:59:32 +0100 Subject: [PATCH] Default _OSI can be passed a string reference --- src/aml/namespace.rs | 2 +- tests/osi.asl | 60 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 tests/osi.asl diff --git a/src/aml/namespace.rs b/src/aml/namespace.rs index 2c95fbd3..e261afd0 100644 --- a/src/aml/namespace.rs +++ b/src/aml/namespace.rs @@ -69,7 +69,7 @@ impl Namespace { if args.len() != 1 { return Err(AmlError::MethodArgCountIncorrect); } - let Object::String(ref feature) = *args[0] else { + let Object::String(ref feature) = *args[0].clone().unwrap_reference() else { return Err(AmlError::ObjectNotOfExpectedType { expected: ObjectType::String, got: args[0].typ(), diff --git a/tests/osi.asl b/tests/osi.asl new file mode 100644 index 00000000..84a852c9 --- /dev/null +++ b/tests/osi.asl @@ -0,0 +1,60 @@ +// Check a variety of _OSI parameters and formats. These are a fairly random selection. +// +// Most of these call _OSI by reference, but also check that a native string works +// +// Adapted from the uACPI test of the same name. +DefinitionBlock ("", "DSDT", 2, "RSCAPI", "OSI", 0xF0F0F0F0) +{ + Method (CHEK, 2) { + Local0 = _OSI(Arg0) + + If (Local0 != Arg1) { + Printf("_OSI(%o) failed (expected %o, got %o)", Arg0, Arg1, Local0) + Return (1) + } + + Return (0) + } + + Method (MAIN, 0, NotSerialized) + { + Local0 = 0 + + If (!CondRefOf(_OSI)) { + Debug = "No _OSI method!" + Return (1111111) + } + + if (_OSI("Windows 2000") != Ones) { + Local0 += 1 + } + + Local0 += CHEK("Windows 2000", Ones) + Local0 += CHEK("Windows 2001", Ones) + Local0 += CHEK("Windows 2001 SP1", Ones) + Local0 += CHEK("Windows 2001.1", Ones) + Local0 += CHEK("Windows 2001 SP2", Ones) + Local0 += CHEK("Windows 2001.1 SP1", Ones) + Local0 += CHEK("Windows 2006.1", Ones) + Local0 += CHEK("Windows 2006 SP1", Ones) + Local0 += CHEK("Windows 2006 SP2", Ones) + Local0 += CHEK("Windows 2009", Ones) + Local0 += CHEK("Windows 2012", Ones) + Local0 += CHEK("Windows 2013", Ones) + Local0 += CHEK("Windows 2015", Ones) + Local0 += CHEK("Windows 2016", Ones) + Local0 += CHEK("Windows 2017", Ones) + Local0 += CHEK("Windows 2017.2", Ones) + Local0 += CHEK("Windows 2018", Ones) + Local0 += CHEK("Windows 2018.2", Ones) + Local0 += CHEK("Windows 2019", Ones) + + Local0 += CHEK("Processor Device", Zero) + Local0 += CHEK("", Zero) + Local0 += CHEK("Windows 99999", Zero) + Local0 += CHEK("Windows 2014", Zero) + Local0 += CHEK("Linux", Zero) + + Return (Local0) + } +}