base: re-sync ACPI userspace with upstream master
Phase B of the ACPI fork-sync plan (local/docs/ACPI-FORK-SYNC-STRATEGY-2026-06-30.md).
Pairs with the kernel fork-sync commit 4f2a043.
Restores the base fork to match upstream Redox OS base master for the
ACPI userspace:
- Cargo.toml (workspace):
* Add acpi = { git = "...redox-os/acpi.git", branch = "redox-6.x" }
workspace dependency. The jackpot51/acpi GitHub fork was
deprecated in favor of the gitlab.redox-os.org fork that
tracks the redox-6.x branch (has AcpiVerb-style AML updates,
PIIX4 fixes, VirtualBox boot fix per upstream MR #243).
* Switch redox_syscall from crates.io 0.8.1 to a git ref of
gitlab.redox-os.org/redox-os/syscall.git, with [patch.crates-io]
redirecting crates.io consumers to the gitlab fork. The
crates.io 0.8.1 release predates AcpiVerb (commit 79cb6d9)
that the kernel MR #613 / base MR #275 introduce.
- drivers/acpid/Cargo.toml: acpi.workspace = true.
- drivers/amlserde/Cargo.toml: acpi.workspace = true.
- drivers/hwd/Cargo.toml: add redox_syscall.workspace = true
dependency. HWD now needs the AcpiVerb enum to construct Fd-based
calls into the kernel ACPI scheme.
- drivers/amlserde/src/lib.rs: split AmlSerdeReferenceKind::LocalOrArg
into 4 separate variants matching the new gitlab acpi crate
ReferenceKind enum:
Local, Arg, Index, Named
Required by upstream commit "Update ACPI crate" (f2f834d4).
- drivers/acpid/src/main.rs: rewrite the RXSDT and kstop acquisition
to use the new Fd::open + call_ro(AcpiVerb::*) interface:
kernel_acpi_handle = Fd::open("/scheme/kernel.acpi", O_CLOEXEC, 0)
rxsdt = kernel_acpi_handle.call_ro(buf, READ, &[ReadRxsdt])
shutdown_pipe = kernel_acpi_handle.openat("kstop", O_CLOEXEC, 0)
Also fixes the nsmgr deadlock by moving setrens(0, 0) BEFORE
daemon.ready() (upstream commit 9dd6901d).
- drivers/hwd/src/backend/acpi.rs: rewrite AcpiBackend::new() to use
the new Fd::open + call_ro(AcpiVerb::ReadRxsdt) interface, matching
the kernel ACPI scheme rewrite.
Verified by: CI=1 ./local/scripts/build-redbear.sh redbear-mini
succeeded with exit 0, producing build/x86_64/redbear-mini.iso
(512 MB) at 2026-06-30 04:54.
This commit is contained in:
Generated
+3
-3
@@ -21,7 +21,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "acpi"
|
||||
version = "6.1.1"
|
||||
source = "git+https://github.com/jackpot51/acpi.git#3dc8a2d98a7a164cbf87e7a86855c4d3bed4de75"
|
||||
source = "git+https://gitlab.redox-os.org/redox-os/acpi.git?branch=redox-6.x#90cbe88e13468c7cc80a68c801a3dd2ea8f51d02"
|
||||
dependencies = [
|
||||
"bit_field",
|
||||
"bitflags 2.13.0",
|
||||
@@ -1041,6 +1041,7 @@ dependencies = [
|
||||
"fdt 0.1.5",
|
||||
"libredox",
|
||||
"log",
|
||||
"redox_syscall 0.8.1",
|
||||
"ron",
|
||||
]
|
||||
|
||||
@@ -2001,8 +2002,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b44b894f2a6e36457d665d1e08c3866add6ed5e70050c1b4ba8a8ddedb02ce7"
|
||||
source = "git+https://gitlab.redox-os.org/redox-os/syscall.git#79cb6d9057642be31623677458a93aa88145864f"
|
||||
dependencies = [
|
||||
"bitflags 2.13.0",
|
||||
]
|
||||
|
||||
+5
-1
@@ -90,6 +90,7 @@ exclude = ["bootstrap"]
|
||||
# Low-level Redox OS crates should be kept in sync using workspace dependencies
|
||||
# Remember to also update bootstrap dependencies, those are not in the workspace
|
||||
[workspace.dependencies]
|
||||
acpi = { git = "https://gitlab.redox-os.org/redox-os/acpi.git", branch = "redox-6.x" }
|
||||
anyhow = "1"
|
||||
bitflags = "2"
|
||||
clap = "4"
|
||||
@@ -110,7 +111,7 @@ redox-ioctl = { git = "https://gitlab.redox-os.org/redox-os/relibc.git" }
|
||||
redox-log = { git = "https://gitlab.redox-os.org/redox-os/redox-log.git" }
|
||||
redox-rt = { git = "https://gitlab.redox-os.org/redox-os/relibc.git", default-features = false }
|
||||
redox-scheme = "0.11.0"
|
||||
redox_syscall = { version = "0.8.1", features = ["std"] }
|
||||
redox_syscall = { git = "https://gitlab.redox-os.org/redox-os/syscall.git", features = ["std"] }
|
||||
redox_termios = "0.1.3"
|
||||
ron = "0.8.1"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
@@ -129,5 +130,8 @@ missing_docs = "allow" #TODO: set to deny when all public functions are document
|
||||
missing_safety_doc = "warn" #TODO: set to deny when all safety documentation is completed
|
||||
precedence = "deny"
|
||||
|
||||
[patch.crates-io]
|
||||
redox_syscall = { git = "https://gitlab.redox-os.org/redox-os/syscall.git" }
|
||||
|
||||
[patch."https://gitlab.redox-os.org/redox-os/relibc.git"]
|
||||
#redox-ioctl = { path = "../../relibc/source/redox-ioctl" }
|
||||
|
||||
@@ -8,7 +8,7 @@ edition = "2018"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
acpi = { git = "https://github.com/jackpot51/acpi.git" }
|
||||
acpi.workspace = true
|
||||
arrayvec = "0.7.6"
|
||||
log.workspace = true
|
||||
num-derive = "0.3"
|
||||
|
||||
+23
-12
@@ -1,14 +1,14 @@
|
||||
use std::convert::TryFrom;
|
||||
use std::fs::File;
|
||||
use std::mem;
|
||||
use std::ops::ControlFlow;
|
||||
use std::os::unix::io::AsRawFd;
|
||||
use std::sync::Arc;
|
||||
|
||||
use ::acpi::aml::op_region::{RegionHandler, RegionSpace};
|
||||
use event::{EventFlags, RawEventQueue};
|
||||
use libredox::Fd;
|
||||
use redox_scheme::{scheme::register_sync_scheme, Socket};
|
||||
use scheme_utils::Blocking;
|
||||
use syscall::flag::{AcpiVerb, CallFlags};
|
||||
|
||||
mod acpi;
|
||||
mod aml_physmem;
|
||||
@@ -29,9 +29,19 @@ fn daemon(daemon: daemon::Daemon) -> ! {
|
||||
|
||||
log::info!("acpid start");
|
||||
|
||||
let rxsdt_raw_data: Arc<[u8]> = std::fs::read("/scheme/kernel.acpi/rxsdt")
|
||||
.expect("acpid: failed to read `/scheme/kernel.acpi/rxsdt`")
|
||||
.into();
|
||||
let kernel_acpi_handle = Fd::open("/scheme/kernel.acpi", libredox::flag::O_CLOEXEC, 0)
|
||||
.expect("acpid: failed to open kernel ACPI handle");
|
||||
|
||||
let rxsdt_raw_data: Arc<[u8]> = {
|
||||
let len = kernel_acpi_handle
|
||||
.call_ro(&mut [], CallFlags::READ, &[AcpiVerb::ReadRxsdt as u64])
|
||||
.expect("acpid: failed to get rxsdt length");
|
||||
let mut buf = vec![0_u8; len];
|
||||
kernel_acpi_handle
|
||||
.call_ro(&mut buf, CallFlags::READ, &[AcpiVerb::ReadRxsdt as u64])
|
||||
.expect("acpid: failed to read rxsdt");
|
||||
buf.into()
|
||||
};
|
||||
|
||||
if rxsdt_raw_data.is_empty() {
|
||||
log::info!("System doesn't use ACPI");
|
||||
@@ -78,8 +88,9 @@ fn daemon(daemon: daemon::Daemon) -> ! {
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
common::acquire_port_io_rights().expect("acpid: failed to set I/O privilege level to Ring 3");
|
||||
|
||||
let shutdown_pipe = File::open("/scheme/kernel.acpi/kstop")
|
||||
.expect("acpid: failed to open `/scheme/kernel.acpi/kstop`");
|
||||
let shutdown_pipe = kernel_acpi_handle
|
||||
.openat("kstop", libredox::flag::O_CLOEXEC, 0)
|
||||
.expect("acpid: failed to open kstop handle");
|
||||
|
||||
let mut event_queue = RawEventQueue::new().expect("acpid: failed to create event queue");
|
||||
let socket = Socket::nonblock().expect("acpid: failed to create disk scheme");
|
||||
@@ -88,7 +99,7 @@ fn daemon(daemon: daemon::Daemon) -> ! {
|
||||
let mut handler = Blocking::new(&socket, 16);
|
||||
|
||||
event_queue
|
||||
.subscribe(shutdown_pipe.as_raw_fd() as usize, 0, EventFlags::READ)
|
||||
.subscribe(shutdown_pipe.raw() as usize, 0, EventFlags::READ)
|
||||
.expect("acpid: failed to register shutdown pipe for event queue");
|
||||
event_queue
|
||||
.subscribe(socket.inner().raw(), 1, EventFlags::READ)
|
||||
@@ -97,10 +108,10 @@ fn daemon(daemon: daemon::Daemon) -> ! {
|
||||
register_sync_scheme(&socket, "acpi", &mut scheme)
|
||||
.expect("acpid: failed to register acpi scheme to namespace");
|
||||
|
||||
daemon.ready();
|
||||
|
||||
libredox::call::setrens(0, 0).expect("acpid: failed to enter null namespace");
|
||||
|
||||
daemon.ready();
|
||||
|
||||
let mut mounted = true;
|
||||
while mounted {
|
||||
let Some(event) = event_queue
|
||||
@@ -121,7 +132,7 @@ fn daemon(daemon: daemon::Daemon) -> ! {
|
||||
ControlFlow::Break(()) => break,
|
||||
}
|
||||
}
|
||||
} else if event.fd == shutdown_pipe.as_raw_fd() as usize {
|
||||
} else if event.fd == shutdown_pipe.raw() as usize {
|
||||
log::info!("Received shutdown request from kernel.");
|
||||
mounted = false;
|
||||
} else {
|
||||
@@ -141,4 +152,4 @@ fn daemon(daemon: daemon::Daemon) -> ! {
|
||||
fn main() {
|
||||
common::init();
|
||||
daemon::Daemon::new(daemon);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,6 @@ license = "MIT/Apache-2.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
acpi = { git = "https://github.com/jackpot51/acpi.git" }
|
||||
acpi.workspace = true
|
||||
serde.workspace = true
|
||||
toml.workspace = true
|
||||
|
||||
@@ -152,7 +152,10 @@ pub enum AmlSerdeFieldUpdateRule {
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub enum AmlSerdeReferenceKind {
|
||||
RefOf,
|
||||
LocalOrArg,
|
||||
Local,
|
||||
Arg,
|
||||
Index,
|
||||
Named,
|
||||
Unresolved,
|
||||
}
|
||||
|
||||
@@ -292,7 +295,10 @@ impl AmlSerdeValue {
|
||||
Object::Reference { kind, inner } => AmlSerdeValue::Reference {
|
||||
kind: match kind {
|
||||
ReferenceKind::RefOf => AmlSerdeReferenceKind::RefOf,
|
||||
ReferenceKind::LocalOrArg => AmlSerdeReferenceKind::LocalOrArg,
|
||||
ReferenceKind::Local => AmlSerdeReferenceKind::Local,
|
||||
ReferenceKind::Arg => AmlSerdeReferenceKind::Arg,
|
||||
ReferenceKind::Index => AmlSerdeReferenceKind::Index,
|
||||
ReferenceKind::Named => AmlSerdeReferenceKind::Named,
|
||||
ReferenceKind::Unresolved => AmlSerdeReferenceKind::Unresolved,
|
||||
},
|
||||
inner: AmlSerdeValue::from_aml_value(inner.deref()).map(Box::new)?,
|
||||
@@ -415,7 +421,10 @@ impl AmlSerdeValue {
|
||||
AmlSerdeValue::Reference { kind, inner } => Object::Reference {
|
||||
kind: match kind {
|
||||
AmlSerdeReferenceKind::RefOf => ReferenceKind::RefOf,
|
||||
AmlSerdeReferenceKind::LocalOrArg => ReferenceKind::LocalOrArg,
|
||||
AmlSerdeReferenceKind::Local => ReferenceKind::Local,
|
||||
AmlSerdeReferenceKind::Arg => ReferenceKind::Arg,
|
||||
AmlSerdeReferenceKind::Index => ReferenceKind::Index,
|
||||
AmlSerdeReferenceKind::Named => ReferenceKind::Named,
|
||||
AmlSerdeReferenceKind::Unresolved => ReferenceKind::Unresolved,
|
||||
},
|
||||
inner: inner.to_aml_object()?.wrap(),
|
||||
|
||||
@@ -9,6 +9,7 @@ fdt.workspace = true
|
||||
log.workspace = true
|
||||
ron.workspace = true
|
||||
libredox = { workspace = true, default-features = false, features = ["std", "call"] }
|
||||
redox_syscall.workspace = true
|
||||
|
||||
amlserde = { path = "../amlserde" }
|
||||
common = { path = "../common" }
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
use amlserde::{AmlSerde, AmlSerdeValue};
|
||||
use libredox::Fd;
|
||||
use std::{error::Error, fs, process::Command};
|
||||
use syscall::flag::{AcpiVerb, CallFlags};
|
||||
|
||||
use super::Backend;
|
||||
|
||||
@@ -9,10 +11,14 @@ pub struct AcpiBackend {
|
||||
|
||||
impl Backend for AcpiBackend {
|
||||
fn new() -> Result<Self, Box<dyn Error>> {
|
||||
let rxsdt = fs::read("/scheme/kernel.acpi/rxsdt")?;
|
||||
let kernel_handle = Fd::open("/scheme/kernel.acpi", libredox::flag::O_CLOEXEC, 0)?;
|
||||
let len = kernel_handle.call_ro(&mut [], CallFlags::empty(), &[AcpiVerb::ReadRxsdt as u64])?;
|
||||
let mut rxsdt = vec![0_u8; len];
|
||||
kernel_handle.call_ro(&mut rxsdt, CallFlags::empty(), &[AcpiVerb::ReadRxsdt as u64])?;
|
||||
|
||||
// Spawn acpid
|
||||
//TODO: pass rxsdt data to acpid?
|
||||
// TODO: rather than put it in the namespace, have init pass the acpi handle to hwd, and
|
||||
// then pass it to acpid?
|
||||
#[allow(deprecated, reason = "we can't yet move this to init")]
|
||||
daemon::Daemon::spawn(Command::new("acpid"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user