Use library call for iopl.
This commit is contained in:
Generated
-2
@@ -1164,8 +1164,6 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.5.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b8c0c260b63a8219631167be35e6a988e9554dbd323f8bd08439c8ed1302bd1"
|
||||
dependencies = [
|
||||
"bitflags 2.9.0",
|
||||
]
|
||||
|
||||
@@ -56,3 +56,4 @@ lto = "fat"
|
||||
mio = { git = "https://gitlab.redox-os.org/redox-os/mio.git", branch = "redox-unix" }
|
||||
orbclient = { git = "https://gitlab.redox-os.org/redox-os/orbclient.git", version = "0.3.44" }
|
||||
redox-daemon = { git = "https://gitlab.redox-os.org/redox-os/redox-daemon.git" }
|
||||
redox_syscall = { path = "/home/dev/Projects/syscall3" }
|
||||
|
||||
+1
-1
@@ -10,5 +10,5 @@ license = "MIT"
|
||||
[dependencies]
|
||||
libredox = "0.1.3"
|
||||
log = "0.4"
|
||||
redox_syscall = { version = "0.5", features = ["std"] }
|
||||
redox_syscall = { version = "0.5.10", features = ["std"] }
|
||||
redox-log = "0.1.2"
|
||||
|
||||
+15
-3
@@ -7,7 +7,7 @@
|
||||
use libredox::call::MmapArgs;
|
||||
use libredox::flag::{self, O_CLOEXEC, O_RDONLY, O_RDWR, O_WRONLY};
|
||||
use libredox::{errno::EINVAL, error::*, Fd};
|
||||
use syscall::PAGE_SIZE;
|
||||
use syscall::{ProcSchemeVerb, PAGE_SIZE};
|
||||
|
||||
/// The Direct Memory Access (DMA) API for drivers
|
||||
pub mod dma;
|
||||
@@ -250,8 +250,20 @@ impl Drop for PhysBorrowed {
|
||||
/// prevent system instability caused by a faulty driver. Processes with ring 3 IOPL have access to
|
||||
/// I/O ports.
|
||||
pub fn acquire_port_io_rights() -> Result<()> {
|
||||
unsafe {
|
||||
syscall::iopl(3)?;
|
||||
extern "C" {
|
||||
fn redox_cur_thrfd_v0() -> usize;
|
||||
}
|
||||
let fd = unsafe { redox_cur_thrfd_v0() };
|
||||
let metadata = [ProcSchemeVerb::Iopl as u64];
|
||||
let _ = unsafe {
|
||||
syscall::syscall5(
|
||||
syscall::SYS_CALL,
|
||||
fd,
|
||||
0,
|
||||
0,
|
||||
metadata.len(),
|
||||
metadata.as_ptr() as usize,
|
||||
)?
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use common::acquire_port_io_rights;
|
||||
use inputd::ProducerHandle;
|
||||
use pcid_interface::PciFunctionHandle;
|
||||
use redox_scheme::{RequestKind, SignalBehavior, Socket};
|
||||
use syscall::call::iopl;
|
||||
|
||||
use crate::bga::Bga;
|
||||
use crate::scheme::BgaScheme;
|
||||
@@ -19,7 +19,7 @@ fn main() {
|
||||
println!(" + BGA {}", pci_config.func.display());
|
||||
|
||||
redox_daemon::Daemon::new(move |daemon| {
|
||||
unsafe { iopl(3).unwrap() };
|
||||
acquire_port_io_rights().expect("bgad: failed to get port IO permission");
|
||||
|
||||
let socket = Socket::create("bga").expect("bgad: failed to create bga scheme");
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ bitflags = "1"
|
||||
log = "0.4"
|
||||
orbclient = "0.3.27"
|
||||
redox_event = "0.4.1"
|
||||
redox_syscall = "0.5"
|
||||
redox_syscall = "0.5.10"
|
||||
redox-daemon = "0.1"
|
||||
libredox = "0.1.3"
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ use std::os::unix::fs::OpenOptionsExt;
|
||||
use std::os::unix::io::AsRawFd;
|
||||
use std::{env, process};
|
||||
|
||||
use common::acquire_port_io_rights;
|
||||
use event::{user_data, EventQueue};
|
||||
use inputd::ProducerHandle;
|
||||
use log::info;
|
||||
use syscall::call::iopl;
|
||||
|
||||
use crate::state::Ps2d;
|
||||
|
||||
@@ -30,9 +30,7 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
|
||||
log::LevelFilter::Info,
|
||||
);
|
||||
|
||||
unsafe {
|
||||
iopl(3).expect("ps2d: failed to get I/O permission");
|
||||
}
|
||||
acquire_port_io_rights().expect("ps2d: failed to get I/O permission");
|
||||
|
||||
let (keymap, keymap_name): (fn(u8, bool) -> char, &str) = match env::args().skip(1).next() {
|
||||
Some(k) => match k.to_lowercase().as_ref() {
|
||||
|
||||
Reference in New Issue
Block a user