diff --git a/Cargo.lock b/Cargo.lock index 8736b257e6..fa19866677 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -935,6 +935,7 @@ dependencies = [ "drm", "libredox", "log", + "plain", "redox-ioctl", "redox_syscall 0.7.3", ] diff --git a/drivers/graphics/graphics-ipc/Cargo.toml b/drivers/graphics/graphics-ipc/Cargo.toml index 34aef775fe..2bfaadf9f5 100644 --- a/drivers/graphics/graphics-ipc/Cargo.toml +++ b/drivers/graphics/graphics-ipc/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" drm.workspace = true log.workspace = true libredox.workspace = true +plain = "0.2" redox-ioctl.workspace = true redox_syscall.workspace = true diff --git a/drivers/graphics/graphics-ipc/src/v2.rs b/drivers/graphics/graphics-ipc/src/v2.rs index fc368ccb89..7e132351b3 100644 --- a/drivers/graphics/graphics-ipc/src/v2.rs +++ b/drivers/graphics/graphics-ipc/src/v2.rs @@ -1,41 +1,15 @@ use std::fs::File; +use std::io; use std::os::fd::{AsFd, BorrowedFd}; use std::os::unix::io::AsRawFd; -use std::{io, mem}; use drm::control::connector::{self, State}; use drm::control::Device as _; use drm::{ClientCapability, Device as _, DriverCapability}; +use syscall::CallFlags; pub use crate::common::Damage; -extern "C" { - fn redox_sys_call_v0( - fd: usize, - payload: *mut u8, - payload_len: usize, - flags: usize, - metadata: *const u64, - metadata_len: usize, - ) -> usize; -} - -unsafe fn sys_call( - fd: &impl AsRawFd, - payload: &mut T, - flags: usize, - metadata: &[u64], -) -> libredox::error::Result { - libredox::error::Error::demux(redox_sys_call_v0( - fd.as_raw_fd() as usize, - payload as *mut T as *mut u8, - mem::size_of::(), - flags, - metadata.as_ptr(), - metadata.len(), - )) -} - /// A graphics handle using the v2 graphics API. /// /// The v2 graphics API allows creating framebuffers on the fly, using them for page flipping and @@ -74,14 +48,17 @@ impl V2GraphicsHandle { } pub fn update_plane(&self, display_id: usize, fb_id: u32, damage: Damage) -> io::Result<()> { - let mut cmd = ipc::UpdatePlane { + let cmd = ipc::UpdatePlane { display_id, fb_id, damage, }; - unsafe { - sys_call(&self.file, &mut cmd, 0, &[ipc::UPDATE_PLANE, 0, 0])?; - } + libredox::call::call_wo( + self.file.as_raw_fd() as usize, + unsafe { plain::as_bytes(&cmd) }, + CallFlags::empty(), + &[ipc::UPDATE_PLANE, 0, 0], + )?; Ok(()) } } diff --git a/drivers/graphics/ihdgd/src/main.rs b/drivers/graphics/ihdgd/src/main.rs index d2a2a458a3..02451ba719 100644 --- a/drivers/graphics/ihdgd/src/main.rs +++ b/drivers/graphics/ihdgd/src/main.rs @@ -35,7 +35,7 @@ fn daemon(daemon: daemon::Daemon, mut pcid_handle: PciFunctionHandle) -> ! { let irq_file = pci_allocate_interrupt_vector(&mut pcid_handle, "ihdgd"); - let mut inputd_display_handle = DisplayHandle::new(format!("ihdg.{}", name)).unwrap(); + let mut inputd_display_handle = DisplayHandle::new(format!("display.ihdg.{}", name)).unwrap(); let mut scheme = GraphicsScheme::new(device, format!("display.ihdg.{}", name)); diff --git a/drivers/graphics/vesad/src/main.rs b/drivers/graphics/vesad/src/main.rs index ac87e0b9db..5b3fc7e34c 100644 --- a/drivers/graphics/vesad/src/main.rs +++ b/drivers/graphics/vesad/src/main.rs @@ -84,7 +84,7 @@ fn daemon(daemon: daemon::Daemon) -> ! { }; } - let mut inputd_display_handle = DisplayHandle::new_early("vesa").unwrap(); + let mut inputd_display_handle = DisplayHandle::new_early("display.vesa").unwrap(); let mut scheme = GraphicsScheme::new(FbAdapter { framebuffers }, "display.vesa".to_owned()); diff --git a/drivers/graphics/virtio-gpud/src/scheme.rs b/drivers/graphics/virtio-gpud/src/scheme.rs index 9e05cf3db5..fc9b3ff3db 100644 --- a/drivers/graphics/virtio-gpud/src/scheme.rs +++ b/drivers/graphics/virtio-gpud/src/scheme.rs @@ -571,7 +571,7 @@ impl<'a> GpuScheme { }; let scheme = GraphicsScheme::new(adapter, "display.virtio-gpu".to_owned()); - let handle = DisplayHandle::new("virtio-gpu").unwrap(); + let handle = DisplayHandle::new("display.virtio-gpu").unwrap(); Ok((scheme, handle)) } } diff --git a/drivers/inputd/src/lib.rs b/drivers/inputd/src/lib.rs index 0a8fffa2c2..c2015ae646 100644 --- a/drivers/inputd/src/lib.rs +++ b/drivers/inputd/src/lib.rs @@ -153,13 +153,13 @@ pub struct KeymapActivate { pub struct DisplayHandle(File); impl DisplayHandle { - pub fn new>(device_name: S) -> io::Result { - let path = format!("/scheme/input/handle/display/{}", device_name.into()); + pub fn new>(scheme_name: S) -> io::Result { + let path = format!("/scheme/input/handle/{}", scheme_name.into()); Ok(Self(File::open(path)?)) } - pub fn new_early>(device_name: S) -> io::Result { - let path = format!("/scheme/input/handle_early/display/{}", device_name.into()); + pub fn new_early>(scheme_name: S) -> io::Result { + let path = format!("/scheme/input/handle_early/{}", scheme_name.into()); Ok(Self(File::open(path)?)) } diff --git a/drivers/inputd/src/main.rs b/drivers/inputd/src/main.rs index 614b109224..f5501137a1 100644 --- a/drivers/inputd/src/main.rs +++ b/drivers/inputd/src/main.rs @@ -176,7 +176,6 @@ impl SchemeSync for InputScheme { let mut path_parts = path.split('/'); let command = path_parts.next().ok_or(SysError::new(EINVAL))?; - let fd = self.next_id.fetch_add(1, Ordering::SeqCst); let handle_ty = match command { "producer" => Handle::Producer, @@ -210,7 +209,7 @@ impl SchemeSync for InputScheme { } } "handle" | "handle_early" => { - let display = path_parts.collect::>().join("."); + let display = path_parts.next().ok_or(SysError::new(EINVAL))?; let needs_handoff = match command { "handle_early" => self.display.is_none(), @@ -228,7 +227,7 @@ impl SchemeSync for InputScheme { if needs_handoff { self.has_new_events = true; - self.display = Some(display.clone()); + self.display = Some(display.to_owned()); for handle in self.handles.values_mut() { match handle { @@ -259,7 +258,7 @@ impl SchemeSync for InputScheme { vec![] }, notified: false, - device: display, + device: display.to_owned(), is_earlyfb: command == "handle_early", } } @@ -273,6 +272,7 @@ impl SchemeSync for InputScheme { log::debug!("{path} channel has been opened"); + let fd = self.next_id.fetch_add(1, Ordering::SeqCst); self.handles.insert(fd, handle_ty); Ok(OpenResult::ThisScheme { number: fd,