Switch to libredox where applicable (fixed)

This commit is contained in:
Jacob Lorentzon
2024-03-18 22:09:25 +00:00
committed by Jeremy Soller
parent 98078650f8
commit ff956fd3bb
83 changed files with 349 additions and 263 deletions
Generated
+76 -26
View File
@@ -8,12 +8,13 @@ version = "0.1.0"
dependencies = [
"bitflags 1.3.2",
"common",
"libredox 0.1.3",
"log",
"pcid",
"redox-daemon",
"redox-log",
"redox_event 0.1.0",
"redox_syscall 0.4.1",
"redox_syscall 0.5.1",
"spin",
]
@@ -24,6 +25,7 @@ dependencies = [
"aml",
"amlserde",
"common",
"libredox 0.1.3",
"log",
"num-derive",
"num-traits",
@@ -31,7 +33,7 @@ dependencies = [
"plain",
"redox-daemon",
"redox-log",
"redox_syscall 0.4.1",
"redox_syscall 0.5.1",
"rustc-hash",
"serde_json",
"thiserror",
@@ -45,11 +47,12 @@ dependencies = [
"byteorder",
"common",
"driver-block",
"libredox 0.1.3",
"log",
"pcid",
"redox-daemon",
"redox-log",
"redox_syscall 0.4.1",
"redox_syscall 0.5.1",
]
[[package]]
@@ -58,9 +61,10 @@ version = "0.1.0"
dependencies = [
"bitflags 1.3.2",
"common",
"libredox 0.1.3",
"redox-daemon",
"redox_event 0.1.0",
"redox_syscall 0.4.1",
"redox_syscall 0.5.1",
]
[[package]]
@@ -151,6 +155,7 @@ dependencies = [
"common",
"driver-block",
"fdt 0.1.5",
"libredox 0.1.3",
"redox-daemon",
"redox_syscall 0.4.1",
]
@@ -159,6 +164,7 @@ dependencies = [
name = "bgad"
version = "0.1.0"
dependencies = [
"libredox 0.1.3",
"orbclient",
"pcid",
"redox-daemon",
@@ -280,7 +286,8 @@ dependencies = [
name = "common"
version = "0.1.0"
dependencies = [
"redox_syscall 0.4.1",
"libredox 0.1.3",
"redox_syscall 0.5.1",
]
[[package]]
@@ -349,15 +356,16 @@ name = "driver-block"
version = "0.1.0"
dependencies = [
"partitionlib",
"redox_syscall 0.4.1",
"redox_syscall 0.5.1",
]
[[package]]
name = "driver-network"
version = "0.1.0"
dependencies = [
"libredox 0.1.3",
"redox_event 0.1.0",
"redox_syscall 0.4.1",
"redox_syscall 0.5.1",
]
[[package]]
@@ -367,10 +375,11 @@ dependencies = [
"bitflags 1.3.2",
"common",
"driver-network",
"libredox 0.1.3",
"pcid",
"redox-daemon",
"redox_event 0.1.0",
"redox_syscall 0.4.1",
"redox_syscall 0.5.1",
]
[[package]]
@@ -384,11 +393,12 @@ name = "fbcond"
version = "0.1.0"
dependencies = [
"inputd",
"libredox 0.1.3",
"orbclient",
"ransid",
"redox-daemon",
"redox_event 0.2.1",
"redox_syscall 0.4.1",
"redox_syscall 0.5.1",
]
[[package]]
@@ -582,11 +592,12 @@ version = "0.1.0"
dependencies = [
"common",
"driver-block",
"libredox 0.1.3",
"log",
"pcid",
"redox-daemon",
"redox-log",
"redox_syscall 0.4.1",
"redox_syscall 0.5.1",
]
[[package]]
@@ -595,6 +606,7 @@ version = "0.1.0"
dependencies = [
"bitflags 1.3.2",
"common",
"libredox 0.1.3",
"log",
"pcid",
"redox-daemon",
@@ -619,11 +631,12 @@ name = "inputd"
version = "0.1.0"
dependencies = [
"anyhow",
"libredox 0.1.3",
"log",
"orbclient",
"redox-daemon",
"redox-log",
"redox_syscall 0.4.1",
"redox_syscall 0.5.1",
"spin",
]
@@ -649,10 +662,11 @@ dependencies = [
"bitflags 1.3.2",
"common",
"driver-network",
"libredox 0.1.3",
"pcid",
"redox-daemon",
"redox_event 0.1.0",
"redox_syscall 0.4.1",
"redox_syscall 0.5.1",
]
[[package]]
@@ -689,12 +703,13 @@ dependencies = [
[[package]]
name = "libredox"
version = "0.1.0"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "138adbe77ccf68e1925b6ed3cc45e83a6845f17a687d6061ddeb518e9b756440"
checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
dependencies = [
"bitflags 2.4.2",
"libc",
"redox_syscall 0.5.1",
]
[[package]]
@@ -702,6 +717,7 @@ name = "lived"
version = "0.1.0"
dependencies = [
"anyhow",
"libredox 0.1.3",
"redox-daemon",
"redox_syscall 0.4.1",
"slab",
@@ -771,12 +787,13 @@ dependencies = [
"crossbeam-channel",
"driver-block",
"futures",
"libredox 0.1.3",
"log",
"partitionlib",
"pcid",
"redox-daemon",
"redox-log",
"redox_syscall 0.4.1",
"redox_syscall 0.5.1",
"smallvec 1.11.0",
]
@@ -917,6 +934,7 @@ dependencies = [
"common",
"fdt 0.1.0",
"libc",
"libredox 0.1.3",
"log",
"paw",
"pci_types",
@@ -934,6 +952,7 @@ dependencies = [
name = "pcspkrd"
version = "0.1.0"
dependencies = [
"libredox 0.1.3",
"redox-daemon",
"redox_syscall 0.4.1",
]
@@ -994,6 +1013,7 @@ name = "ps2d"
version = "0.1.0"
dependencies = [
"bitflags 1.3.2",
"libredox 0.1.3",
"orbclient",
"redox-daemon",
"redox_syscall 0.4.1",
@@ -1067,7 +1087,7 @@ version = "0.1.3"
source = "git+https://gitlab.redox-os.org/redox-os/redox-daemon.git#31ab115cf17d6fe333515bfe19ac477352a1dcc0"
dependencies = [
"libc",
"libredox 0.1.0",
"libredox 0.1.3",
]
[[package]]
@@ -1101,6 +1121,16 @@ dependencies = [
"redox_syscall 0.4.1",
]
[[package]]
name = "redox_event"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69609faa5d5992247a4ef379917bb3e39be281405d6a0ccd4f942429400b956f"
dependencies = [
"bitflags 2.4.2",
"libredox 0.1.3",
]
[[package]]
name = "redox_syscall"
version = "0.2.16"
@@ -1128,6 +1158,15 @@ dependencies = [
"bitflags 1.3.2",
]
[[package]]
name = "redox_syscall"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e"
dependencies = [
"bitflags 2.4.2",
]
[[package]]
name = "redox_termios"
version = "0.1.2"
@@ -1144,12 +1183,13 @@ dependencies = [
"bitflags 1.3.2",
"common",
"driver-network",
"libredox 0.1.3",
"log",
"pcid",
"redox-daemon",
"redox-log",
"redox_event 0.1.0",
"redox_syscall 0.4.1",
"redox_syscall 0.5.1",
]
[[package]]
@@ -1159,12 +1199,13 @@ dependencies = [
"bitflags 1.3.2",
"common",
"driver-network",
"libredox 0.1.3",
"log",
"pcid",
"redox-daemon",
"redox-log",
"redox_event 0.1.0",
"redox_syscall 0.4.1",
"redox_syscall 0.5.1",
]
[[package]]
@@ -1185,6 +1226,7 @@ version = "0.1.0"
dependencies = [
"bitflags 1.3.2",
"common",
"libredox 0.1.3",
"log",
"redox-daemon",
"redox-log",
@@ -1526,6 +1568,7 @@ name = "usbscsid"
version = "0.1.0"
dependencies = [
"base64",
"libredox 0.1.3",
"plain",
"redox-daemon",
"redox_syscall 0.4.1",
@@ -1559,11 +1602,12 @@ name = "vboxd"
version = "0.1.0"
dependencies = [
"common",
"libredox 0.1.3",
"orbclient",
"pcid",
"redox-daemon",
"redox_event 0.1.0",
"redox_syscall 0.4.1",
"redox_syscall 0.5.1",
]
[[package]]
@@ -1590,10 +1634,11 @@ version = "0.1.0"
dependencies = [
"common",
"inputd",
"libredox 0.1.3",
"orbclient",
"ransid",
"redox-daemon",
"redox_syscall 0.4.1",
"redox_syscall 0.5.1",
]
[[package]]
@@ -1604,12 +1649,13 @@ dependencies = [
"common",
"driver-block",
"futures",
"libredox 0.1.3",
"log",
"partitionlib",
"pcid",
"redox-daemon",
"redox-log",
"redox_syscall 0.4.1",
"redox_syscall 0.5.1",
"spin",
"static_assertions",
"thiserror",
@@ -1624,11 +1670,12 @@ dependencies = [
"common",
"crossbeam-queue",
"futures",
"libredox 0.1.3",
"log",
"pcid",
"redox-log",
"redox_event 0.1.0",
"redox_syscall 0.4.1",
"redox_syscall 0.5.1",
"static_assertions",
"thiserror",
]
@@ -1641,12 +1688,13 @@ dependencies = [
"common",
"futures",
"inputd",
"libredox 0.1.3",
"log",
"orbclient",
"paste",
"pcid",
"redox-daemon",
"redox_syscall 0.4.1",
"redox_syscall 0.5.1",
"spin",
"static_assertions",
"virtio-core",
@@ -1659,10 +1707,11 @@ dependencies = [
"common",
"driver-network",
"futures",
"libredox 0.1.3",
"log",
"pcid",
"redox-daemon",
"redox_syscall 0.4.1",
"redox_syscall 0.5.1",
"static_assertions",
"virtio-core",
]
@@ -1852,13 +1901,14 @@ dependencies = [
"crossbeam-channel",
"futures",
"lazy_static",
"libredox 0.1.3",
"log",
"pcid",
"plain",
"redox-daemon",
"redox-log",
"redox_event 0.1.0",
"redox_syscall 0.4.1",
"redox_event 0.4.1",
"redox_syscall 0.5.1",
"serde",
"serde_json",
"smallvec 1.11.0",
+2 -1
View File
@@ -15,10 +15,11 @@ parking_lot = "0.11.1"
plain = "0.2.3"
redox-daemon = "0.1"
redox-log = "0.1.1"
redox_syscall = "0.4"
redox_syscall = "0.5"
rustc-hash = "1.1.0"
thiserror = "1"
serde_json = "1.0.94"
amlserde = { path = "../amlserde" }
common = { path = "../common" }
libredox = "0.1.3"
+2 -2
View File
@@ -105,7 +105,7 @@ impl PhysmapGuard {
let size = page_count * PAGE_SIZE;
let virt = unsafe {
common::physmap(page, size, common::Prot::RO, common::MemoryType::default())
.map_err(|error| std::io::Error::from_raw_os_error(error.errno))?
.map_err(|error| std::io::Error::from_raw_os_error(error.errno()))?
};
Ok(Self {
@@ -124,7 +124,7 @@ impl Deref for PhysmapGuard {
impl Drop for PhysmapGuard {
fn drop(&mut self) {
unsafe {
let _ = syscall::funmap(self.virt as usize, self.size);
let _ = libredox::call::munmap(self.virt as *mut (), self.size);
}
}
}
+1 -1
View File
@@ -35,7 +35,7 @@ impl DerefMut for DrhdPage {
impl Drop for DrhdPage {
fn drop(&mut self) {
unsafe {
let _ = syscall::funmap(self.virt as usize, crate::acpi::PAGE_SIZE);
let _ = libredox::call::munmap(self.virt.cast(), crate::acpi::PAGE_SIZE);
}
}
}
+3 -3
View File
@@ -17,7 +17,7 @@ impl MappedPage {
fn new(phys_page: usize) -> std::io::Result<Self> {
let virt_page = unsafe {
common::physmap(phys_page, PAGE_SIZE, common::Prot::RO, common::MemoryType::default())
.map_err(|error| std::io::Error::from_raw_os_error(error.errno))?
.map_err(|error| std::io::Error::from_raw_os_error(error.errno()))?
} as usize;
Ok(Self {
phys_page,
@@ -29,7 +29,7 @@ impl MappedPage {
impl Drop for MappedPage {
fn drop(&mut self) {
log::trace!("Drop page {:#x}", self.phys_page);
if let Err(e) = unsafe { syscall::funmap(self.virt_page, PAGE_SIZE) } {
if let Err(e) = unsafe { libredox::call::munmap(self.virt_page as *mut (), PAGE_SIZE) } {
log::error!("funmap (phys): {:?}", e);
}
}
@@ -212,7 +212,7 @@ impl aml::Handler for AmlPhysMemHandler {
}
}
// Pio must be enabled via syscall::iopl(3)
// Pio must be enabled via syscall::iopl
fn read_io_u8(&self, port: u16) -> u8 {
Pio::<u8>::new(port).read()
}
+3 -3
View File
@@ -113,8 +113,8 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
let acpi_context = self::acpi::AcpiContext::init(physaddrs_iter);
// TODO: I/O permission bitmap
unsafe { syscall::iopl(3) }.expect("acpid: failed to set I/O privilege level to Ring 3");
// TODO: I/O permission bitmap?
common::acquire_port_io_rights().expect("acpid: failed to set I/O privilege level to Ring 3");
let shutdown_pipe = File::open("kernel.acpi:kstop")
.expect("acpid: failed to open `kernel.acpi:kstop`");
@@ -136,7 +136,7 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
daemon.ready().expect("acpid: failed to notify parent");
syscall::setrens(0, 0).expect("acpid: failed to enter null namespace");
libredox::call::setrens(0, 0).expect("acpid: failed to enter null namespace");
let _ = event_queue.write(&Event {
id: shutdown_pipe.as_raw_fd() as usize,
+2 -1
View File
@@ -10,7 +10,8 @@ log = "0.4"
redox-daemon = "0.1"
redox-log = "0.1"
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox_syscall = "0.4"
redox_syscall = "0.5"
spin = "0.9"
pcid = { path = "../../pcid" }
libredox = "0.1.3"
+5 -4
View File
@@ -13,6 +13,7 @@ use std::sync::Arc;
use std::usize;
use event::EventQueue;
use libredox::flag;
use pcid_interface::{PciBar, PcidServerHandle};
use redox_log::{OutputBuilder, RedoxLogger};
use syscall::{EventFlags, Packet, SchemeBlockMut};
@@ -84,19 +85,19 @@ fn main() {
redox_daemon::Daemon::new(move |daemon| {
let _logger_ref = setup_logging();
unsafe { syscall::iopl(3) }.expect("ac97d: failed to set I/O privilege level to Ring 3");
common::acquire_port_io_rights().expect("ac97d: failed to set I/O privilege level to Ring 3");
let mut irq_file = irq.irq_handle("ac97d");
let device = Arc::new(RefCell::new(unsafe { device::Ac97::new(bar0, bar1).expect("ac97d: failed to allocate device") }));
let socket_fd = syscall::open(":audiohw", syscall::O_RDWR | syscall::O_CREAT | syscall::O_NONBLOCK).expect("ac97d: failed to create hda scheme");
let socket_fd = libredox::call::open(":audiohw", flag::O_RDWR | flag::O_CREAT | flag::O_NONBLOCK, 0).expect("ac97d: failed to create hda scheme");
let socket = Arc::new(RefCell::new(unsafe { File::from_raw_fd(socket_fd as RawFd) }));
daemon.ready().expect("ac97d: failed to signal readiness");
let mut event_queue = EventQueue::<usize>::new().expect("ac97d: Could not create event queue.");
syscall::setrens(0, 0).expect("ac97d: failed to enter null namespace");
libredox::call::setrens(0, 0).expect("ac97d: failed to enter null namespace");
let todo = Arc::new(RefCell::new(Vec::<Packet>::new()));
@@ -167,7 +168,7 @@ fn main() {
for event_count in event_queue.trigger_all(event::Event {
fd: 0,
flags: EventFlags::empty(),
flags: Default::default(),
}).expect("ac97d: failed to trigger events") {
socket.borrow_mut().write(&Packet {
id: 0,
Executable → Regular
+1
View File
@@ -14,3 +14,4 @@ spin = "0.9"
common = { path = "../../common" }
pcid = { path = "../../pcid" }
libredox = "0.1.3"
+3 -2
View File
@@ -10,6 +10,7 @@ use std::usize;
use std::fs::File;
use std::io::{ErrorKind, Read, Write, Result};
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use libredox::flag;
use syscall::{Packet, SchemeBlockMut, EventFlags};
use std::cell::RefCell;
use std::sync::Arc;
@@ -162,13 +163,13 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
| (pci_config.func.full_device_id.device_id as u32);
let device = Arc::new(RefCell::new(unsafe { hda::IntelHDA::new(address, vend_prod).expect("ihdad: failed to allocate device") }));
let socket_fd = syscall::open(":audiohw", syscall::O_RDWR | syscall::O_CREAT | syscall::O_NONBLOCK).expect("ihdad: failed to create hda scheme");
let socket_fd = libredox::call::open(":audiohw", flag::O_RDWR | flag::O_CREAT | flag::O_NONBLOCK, 0).expect("ihdad: failed to create hda scheme");
let socket = Arc::new(RefCell::new(unsafe { File::from_raw_fd(socket_fd as RawFd) }));
daemon.ready().expect("ihdad: failed to signal readiness");
let mut event_queue = EventQueue::<usize>::new().expect("ihdad: Could not create event queue.");
syscall::setrens(0, 0).expect("ihdad: failed to enter null namespace");
libredox::call::setrens(0, 0).expect("ihdad: failed to enter null namespace");
let todo = Arc::new(RefCell::new(Vec::<Packet>::new()));
+1
View File
@@ -7,3 +7,4 @@ edition = "2018"
[dependencies]
redox_syscall = "0.4"
redox-daemon = "0.1"
libredox = "0.1.3"
+1 -1
View File
@@ -29,7 +29,7 @@ fn main() {
next_id: 0,
};
syscall::setrens(0, 0).expect("pcspkrd: failed to enter null namespace");
libredox::call::setrens(0, 0).expect("pcspkrd: failed to enter null namespace");
loop {
let mut packet = Packet::default();
+1
View File
@@ -6,6 +6,7 @@ edition = "2018"
[dependencies]
bitflags = "1"
common = { path = "../../common" }
libredox = "0.1.3"
log = "0.4"
redox-daemon = "0.1"
redox-log = "0.1"
+6 -3
View File
@@ -9,6 +9,7 @@ use std::{env, usize};
use std::fs::File;
use std::io::{ErrorKind, Read, Write, Result};
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use libredox::flag;
use syscall::{Packet, SchemeBlockMut, EventFlags};
use std::cell::RefCell;
use std::sync::Arc;
@@ -74,10 +75,10 @@ fn main() {
redox_daemon::Daemon::new(move |daemon| {
let _logger_ref = setup_logging();
unsafe { syscall::iopl(3) }.expect("sb16d: failed to set I/O privilege level to Ring 3");
common::acquire_port_io_rights().expect("sb16d: failed to acquire port IO rights");
let device = Arc::new(RefCell::new(unsafe { device::Sb16::new(addr).expect("sb16d: failed to allocate device") }));
let socket_fd = syscall::open(":audiohw", syscall::O_RDWR | syscall::O_CREAT | syscall::O_NONBLOCK).expect("sb16d: failed to create hda scheme");
let socket_fd = libredox::call::open(":audiohw", flag::O_RDWR | flag::O_CREAT | flag::O_NONBLOCK, 0).expect("sb16d: failed to create hda scheme");
let socket = Arc::new(RefCell::new(unsafe { File::from_raw_fd(socket_fd as RawFd) }));
//TODO: error on multiple IRQs?
@@ -90,7 +91,7 @@ fn main() {
let mut event_queue = EventQueue::<usize>::new().expect("sb16d: Could not create event queue.");
syscall::setrens(0, 0).expect("sb16d: failed to enter null namespace");
libredox::call::setrens(0, 0).expect("sb16d: failed to enter null namespace");
let todo = Arc::new(RefCell::new(Vec::<Packet>::new()));
@@ -98,6 +99,8 @@ fn main() {
let device_irq = device.clone();
let socket_irq = socket.clone();
// TODO: Use new event queue API
event_queue.add(irq_file.as_raw_fd(), move |_event| -> Result<Option<usize>> {
let mut irq = [0; 8];
irq_file.read(&mut irq)?;
+2 -1
View File
@@ -8,4 +8,5 @@ license = "MIT"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
redox_syscall = "0.4"
libredox = "0.1.3"
redox_syscall = "0.5"
+21 -25
View File
@@ -2,10 +2,10 @@ use std::mem::{self, size_of, MaybeUninit};
use std::ops::{Deref, DerefMut};
use std::ptr;
use libredox::call::MmapArgs;
use libredox::{flag, error::Result, Fd};
use syscall::PAGE_SIZE;
use syscall::Result;
use crate::MemoryType;
const DMA_MEMTY: MemoryType = {
@@ -20,30 +20,26 @@ const DMA_MEMTY: MemoryType = {
}
};
fn alloc_and_map(len: usize) -> Result<(usize, *mut ())> {
assert_eq!(len % PAGE_SIZE, 0);
fn alloc_and_map(length: usize) -> Result<(usize, *mut ())> {
assert_eq!(length % PAGE_SIZE, 0);
unsafe {
let fd = syscall::open(
format!("memory:zeroed@{DMA_MEMTY}?phys_contiguous"),
syscall::O_CLOEXEC,
let fd = Fd::open(
&format!("memory:zeroed@{DMA_MEMTY}?phys_contiguous"),
flag::O_CLOEXEC,
0,
)?;
let virt = syscall::fmap(
fd,
&syscall::Map {
offset: 0, // ignored
address: 0, // ignored
size: len,
flags: syscall::MapFlags::MAP_PRIVATE
| syscall::MapFlags::PROT_READ
| syscall::MapFlags::PROT_WRITE,
},
);
let _ = syscall::close(fd);
let virt = virt?;
let phys = syscall::virttophys(virt)?;
/*for i in 1..len.div_ceil(PAGE_SIZE) {
assert_eq!(syscall::virttophys(virt + i * PAGE_SIZE), Ok(phys + i * PAGE_SIZE), "NOT CONTIGUOUS");
}*/
let virt = libredox::call::mmap(MmapArgs {
fd: fd.raw(),
offset: 0, // ignored
addr: core::ptr::null_mut(), // ignored
length,
flags: flag::MAP_PRIVATE,
prot: flag::PROT_READ | flag::PROT_WRITE,
})?;
let phys = syscall::virttophys(virt as usize)?;
for i in 1..length.div_ceil(PAGE_SIZE) {
debug_assert_eq!(syscall::virttophys(virt as usize + i * PAGE_SIZE), Ok(phys + i * PAGE_SIZE), "NOT CONTIGUOUS");
}
Ok((phys, virt as *mut ()))
}
}
@@ -159,7 +155,7 @@ impl<T: ?Sized> Drop for Dma<T> {
fn drop(&mut self) {
unsafe {
ptr::drop_in_place(self.virt);
let _ = syscall::funmap(self.virt as *mut u8 as usize, self.aligned_len);
let _ = libredox::call::munmap(self.virt as *mut (), self.aligned_len);
}
}
}
+27 -19
View File
@@ -1,7 +1,8 @@
#![feature(int_roundings)]
use syscall::error::{Error, Result, EINVAL};
use syscall::flag::{MapFlags, O_CLOEXEC, O_RDONLY, O_RDWR, O_WRONLY};
use libredox::call::MmapArgs;
use libredox::{Fd, error::*, errno::EINVAL};
use libredox::flag::{self, O_CLOEXEC, O_RDONLY, O_RDWR, O_WRONLY};
use syscall::PAGE_SIZE;
pub mod dma;
@@ -63,23 +64,23 @@ pub unsafe fn physmap(
(false, true) => O_WRONLY,
(false, false) => return Err(Error::new(EINVAL)),
};
let mut prot = MapFlags::empty();
prot.set(MapFlags::PROT_READ, read);
prot.set(MapFlags::PROT_WRITE, write);
let mut prot = 0;
if read {
prot |= flag::PROT_READ;
}
if write {
prot |= flag::PROT_WRITE;
}
let file = syscall::open(path, O_CLOEXEC | mode)?;
let base = syscall::fmap(
file,
&syscall::Map {
offset: base_phys,
size: len.next_multiple_of(PAGE_SIZE),
flags: MapFlags::MAP_SHARED | prot,
address: 0,
},
);
let _ = syscall::close(file);
Ok(base? as *mut ())
let fd = Fd::open(&path, O_CLOEXEC | mode, 0)?;
Ok(libredox::call::mmap(MmapArgs {
fd: fd.raw(),
offset: base_phys as u64,
length: len.next_multiple_of(PAGE_SIZE),
flags: flag::MAP_SHARED,
prot,
addr: core::ptr::null_mut(),
})? as *mut ())
}
impl std::fmt::Display for MemoryType {
@@ -119,7 +120,14 @@ impl PhysBorrowed {
impl Drop for PhysBorrowed {
fn drop(&mut self) {
unsafe {
let _ = syscall::funmap(self.mem as usize, self.len);
let _ = libredox::call::munmap(self.mem, self.len);
}
}
}
pub fn acquire_port_io_rights() -> Result<()> {
unsafe {
syscall::iopl(3)?;
}
Ok(())
}
+1
View File
@@ -9,3 +9,4 @@ redox-daemon = "0.1"
redox_syscall = "0.4"
pcid = { path = "../../pcid" }
libredox = "0.1.3"
+1 -1
View File
@@ -42,7 +42,7 @@ fn main() {
scheme.update_size();
syscall::setrens(0, 0).expect("bgad: failed to enter null namespace");
libredox::call::setrens(0, 0).expect("bgad: failed to enter null namespace");
daemon.ready().expect("bgad: failed to notify parent");
+2 -1
View File
@@ -7,10 +7,11 @@ edition = "2021"
orbclient = "0.3.27"
ransid = "0.4"
redox_event = "0.2"
redox_syscall = "0.4"
redox_syscall = "0.5"
redox-daemon = "0.1"
inputd = { path = "../../inputd" }
libredox = "0.1.3"
[features]
default = []
+14 -14
View File
@@ -8,6 +8,7 @@ use std::{
os::unix::io::{AsRawFd, FromRawFd},
slice,
};
use libredox::flag;
use syscall::{O_CLOEXEC, O_NONBLOCK, O_RDWR};
// Keep synced with vesad
@@ -22,15 +23,14 @@ pub struct SyncRect {
fn display_fd_map(width: usize, height: usize, display_fd: usize) -> syscall::Result<*mut [u32]> {
unsafe {
let display_ptr = syscall::fmap(
display_fd,
&syscall::Map {
offset: 0,
size: (width * height * 4),
flags: syscall::PROT_READ | syscall::PROT_WRITE | syscall::MAP_SHARED,
address: 0,
},
)?;
let display_ptr = libredox::call::mmap(libredox::call::MmapArgs {
fd: display_fd,
offset: 0,
length: (width * height * 4),
prot: flag::PROT_READ | flag::PROT_WRITE,
flags: flag::MAP_SHARED,
addr: core::ptr::null_mut(),
})?;
let display_slice = slice::from_raw_parts_mut(display_ptr as *mut u32, width * height);
Ok(display_slice)
}
@@ -38,7 +38,7 @@ fn display_fd_map(width: usize, height: usize, display_fd: usize) -> syscall::Re
unsafe fn display_fd_unmap(image: *mut [u32], size: usize) {
// FIXME use image.len() instead of size once it is stable.
let _ = syscall::funmap(image as *mut u32 as usize, size * 4);
let _ = libredox::call::munmap(image as *mut (), size * 4);
}
pub struct Display {
@@ -59,7 +59,7 @@ impl Display {
.open(format!("input:consumer/{vt}"))?;
let fd = input_handle.as_raw_fd();
let written = syscall::fpath(fd as usize, &mut buffer)
let written = libredox::call::fpath(fd as usize, &mut buffer)
.expect("init: failed to get the path to the display device");
assert!(written <= buffer.len());
@@ -67,7 +67,7 @@ impl Display {
let display_path =
std::str::from_utf8(&buffer[..written]).expect("init: display path UTF-8 check failed");
let display_file = syscall::open(display_path, O_CLOEXEC | O_NONBLOCK | O_RDWR)
let display_file = libredox::call::open(display_path, (O_CLOEXEC | O_NONBLOCK | O_RDWR) as _, 0)
.map(|socket| unsafe { File::from_raw_fd(socket as RawFd) })
.unwrap_or_else(|err| {
panic!("failed to open display {}: {}", display_path, err);
@@ -75,7 +75,7 @@ impl Display {
let mut buf: [u8; 4096] = [0; 4096];
let count =
syscall::fpath(display_file.as_raw_fd() as usize, &mut buf).unwrap_or_else(|e| {
libredox::call::fpath(display_file.as_raw_fd() as usize, &mut buf).unwrap_or_else(|e| {
panic!("Could not read display path with fpath(): {e}");
});
@@ -138,7 +138,7 @@ impl Display {
pub fn sync_rect(&mut self, sync_rect: SyncRect) -> syscall::Result<()> {
unsafe {
syscall::write(
libredox::call::write(
self.display_file.as_raw_fd().as_raw_fd() as usize,
slice::from_raw_parts(
&sync_rect as *const SyncRect as *const u8,
+1 -1
View File
@@ -53,7 +53,7 @@ fn inner(daemon: redox_daemon::Daemon, vt_ids: &[usize]) -> ! {
let mut scheme = FbconScheme::new(vt_ids, &mut event_queue);
syscall::setrens(0, 0).expect("fbcond: failed to enter null namespace");
libredox::call::setrens(0, 0).expect("fbcond: failed to enter null namespace");
daemon.ready().expect("failed to notify parent");
+1 -1
View File
@@ -320,7 +320,7 @@ impl TextScreen {
})?;
}
self.changed.clear();
syscall::fsync(self.display.display_file.as_raw_fd().as_raw_fd() as usize)?;
libredox::call::fsync(self.display.display_file.as_raw_fd().as_raw_fd() as usize)?;
Ok(buf.len())
}
+2 -1
View File
@@ -6,11 +6,12 @@ edition = "2018"
[dependencies]
orbclient = "0.3.27"
ransid = "0.4"
redox_syscall = "0.4"
redox_syscall = "0.5"
redox-daemon = "0.1"
common = { path = "../../common" }
inputd = { path = "../../inputd" }
libredox = "0.1.3"
[features]
default = []
+1 -1
View File
@@ -88,7 +88,7 @@ fn inner(daemon: redox_daemon::Daemon, framebuffers: Vec<FrameBuffer>, spec: &[(
let mut scheme = DisplayScheme::new(framebuffers, &spec);
syscall::setrens(0, 0).expect("vesad: failed to enter null namespace");
libredox::call::setrens(0, 0).expect("vesad: failed to enter null namespace");
daemon.ready().expect("failed to notify parent");
+1 -1
View File
@@ -95,7 +95,7 @@ impl DisplayScheme {
// Unmap old onscreen
unsafe {
let slice = mem::take(&mut self.onscreens[fb_i]);
syscall::funmap(slice.as_mut_ptr() as usize, (slice.len() * 4).next_multiple_of(PAGE_SIZE)).expect("vesad: failed to unmap framebuffer");
libredox::call::munmap(slice.as_mut_ptr().cast(), (slice.len() * 4).next_multiple_of(PAGE_SIZE)).expect("vesad: failed to unmap framebuffer");
}
// Map new onscreen
+2 -1
View File
@@ -17,6 +17,7 @@ pcid = { path = "../../pcid" }
inputd = { path = "../../inputd" }
redox-daemon = "0.1"
redox_syscall = "0.4"
redox_syscall = "0.5"
orbclient = "0.3.27"
spin = "0.9.8"
libredox = "0.1.3"
+1 -1
View File
@@ -117,7 +117,7 @@ impl<'a> Display<'a> {
.next_multiple_of(syscall::PAGE_SIZE);
let mapped = *self.mapped.get().unwrap();
let address = unsafe { syscall::virttophys(mapped) }?;
let address = (unsafe { syscall::virttophys(mapped) }).map_err(libredox::error::Error::from)?;
self.map_screen_with(0, address, fb_size, mapped).await
}
+3 -2
View File
@@ -7,8 +7,9 @@ authors = ["Anhad Singh <andypython@protonmail.com>"]
[dependencies]
anyhow = "1.0.71"
log = "0.4.19"
redox-daemon = "0.1.0"
redox-daemon = "0.1.2"
redox-log = "0.1.1"
redox_syscall = "0.4"
redox_syscall = "0.5"
orbclient = "0.3.27"
spin = "0.9.8"
libredox = "0.1.3"
+2 -2
View File
@@ -91,7 +91,7 @@ impl Cmd {
}
}
pub fn send_comand(file: &mut File, command: Cmd) -> Result<(), syscall::Error> {
pub fn send_comand(file: &mut File, command: Cmd) -> Result<(), libredox::error::Error> {
use std::os::fd::AsRawFd;
let mut result = vec![];
@@ -119,7 +119,7 @@ pub fn send_comand(file: &mut File, command: Cmd) -> Result<(), syscall::Error>
}
};
let written = syscall::write(file.as_raw_fd() as usize, &result)?;
let written = libredox::call::write(file.as_raw_fd() as usize, &result)?;
// XXX: Ensure all of the data is written.
assert_eq!(written, result.len());
+1 -1
View File
@@ -535,7 +535,7 @@ pub fn main() {
.expect("inputd: failed to open consumer handle");
let mut display_path = [0; 4096];
let written = syscall::fpath(handle.as_raw_fd() as usize, &mut display_path)
let written = libredox::call::fpath(handle.as_raw_fd() as usize, &mut display_path)
.expect("inputd: fpath() failed");
assert!(written <= display_path.len());
+2 -1
View File
@@ -6,7 +6,8 @@ edition = "2018"
[dependencies]
bitflags = "1"
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox_syscall = "0.4"
redox_syscall = "0.5"
redox-daemon = "0.1"
common = { path = "../../common" }
libredox = "0.1.3"
+2 -2
View File
@@ -281,7 +281,7 @@ pub struct Alx {
fn dma_array<T, const N: usize>() -> Result<[Dma<T>; N]> {
Ok((0..N)
.map(|_| Dma::zeroed().map(|dma| unsafe { dma.assume_init() }))
.map(|_| Ok(Dma::zeroed().map(|dma| unsafe { dma.assume_init() })?))
.collect::<Result<Vec<_>>>()?
.try_into()
.unwrap_or_else(|_| unreachable!()))
@@ -290,7 +290,7 @@ fn dma_array<T, const N: usize>() -> Result<[Dma<T>; N]> {
impl Alx {
pub unsafe fn new(base: usize) -> Result<Self> {
let mut module = Alx {
base: base,
base,
vendor_id: 0,
device_id: 0,
+4 -3
View File
@@ -14,6 +14,7 @@ use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::sync::Arc;
use event::EventQueue;
use libredox::flag;
use syscall::{EventFlags, Packet, SchemeMut};
use syscall::error::EWOULDBLOCK;
@@ -35,7 +36,7 @@ fn main() {
// Daemonize
redox_daemon::Daemon::new(move |daemon| {
let socket_fd = syscall::open(":network", syscall::O_RDWR | syscall::O_CREAT | syscall::O_NONBLOCK).expect("alxd: failed to create network scheme");
let socket_fd = libredox::call::open(":network", flag::O_RDWR | flag::O_CREAT | flag::O_NONBLOCK, 0).expect("alxd: failed to create network scheme");
let socket = Arc::new(RefCell::new(unsafe { File::from_raw_fd(socket_fd as RawFd) }));
daemon.ready().expect("alxd: failed to signal readiness");
@@ -48,7 +49,7 @@ fn main() {
let mut event_queue = EventQueue::<usize>::new().expect("alxd: failed to create event queue");
syscall::setrens(0, 0).expect("alxd: failed to enter null namespace");
libredox::call::setrens(0, 0).expect("alxd: failed to enter null namespace");
let todo = Arc::new(RefCell::new(Vec::<Packet>::new()));
@@ -111,7 +112,7 @@ fn main() {
for event_count in event_queue.trigger_all(event::Event {
fd: 0,
flags: EventFlags::empty(),
flags: Default::default(),
}).expect("alxd: failed to trigger events") {
socket.borrow_mut().write(&Packet {
id: 0,
+2 -1
View File
@@ -4,5 +4,6 @@ version = "0.1.0"
edition = "2021"
[dependencies]
libredox = "0.1.3"
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox_syscall = "0.4"
redox_syscall = "0.5"
+4 -2
View File
@@ -4,6 +4,7 @@ use std::io::{ErrorKind, Read, Write};
use std::os::fd::{AsRawFd, FromRawFd, RawFd};
use std::{cmp, io};
use libredox::flag;
use syscall::{
Error, EventFlags, Packet, Result, SchemeBlockMut, Stat, EACCES, EBADF, EINVAL, EWOULDBLOCK,
MODE_FILE, O_NONBLOCK,
@@ -46,9 +47,10 @@ enum Handle {
impl<T: NetworkAdapter> NetworkScheme<T> {
pub fn new(adapter: T, scheme_name: String) -> Self {
assert!(scheme_name.starts_with("network"));
let scheme_fd = syscall::open(
let scheme_fd = libredox::call::open(
format!(":{scheme_name}"),
syscall::O_RDWR | syscall::O_CREAT | syscall::O_NONBLOCK,
flag::O_RDWR | flag::O_CREAT | flag::O_NONBLOCK,
0,
)
.expect("failed to create network scheme");
let scheme = unsafe { File::from_raw_fd(scheme_fd as RawFd) };
+2 -1
View File
@@ -7,8 +7,9 @@ edition = "2018"
bitflags = "1"
redox-daemon = "0.1"
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox_syscall = "0.4"
redox_syscall = "0.5"
common = { path = "../../common" }
driver-network = { path = "../driver-network" }
pcid = { path = "../../pcid" }
libredox = "0.1.3"
+1 -1
View File
@@ -208,7 +208,7 @@ impl NetworkAdapter for Intel8254x {
fn dma_array<T, const N: usize>() -> Result<[Dma<T>; N]> {
Ok((0..N)
.map(|_| Dma::zeroed().map(|dma| unsafe { dma.assume_init() }))
.map(|_| Ok(unsafe { Dma::zeroed()?.assume_init() }))
.collect::<Result<Vec<_>>>()?
.try_into()
.unwrap_or_else(|_| unreachable!()))
+2 -2
View File
@@ -43,7 +43,7 @@ fn main() {
let mut event_queue =
EventQueue::<Infallible>::new().expect("e1000d: failed to create event queue");
syscall::setrens(0, 0).expect("e1000d: failed to enter null namespace");
libredox::call::setrens(0, 0).expect("e1000d: failed to enter null namespace");
daemon
.ready()
@@ -79,7 +79,7 @@ fn main() {
event_queue
.trigger_all(event::Event {
fd: 0,
flags: EventFlags::empty(),
flags: Default::default(),
})
.expect("e1000d: failed to trigger events");
+2 -1
View File
@@ -6,9 +6,10 @@ edition = "2021"
[dependencies]
bitflags = "1.0"
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox_syscall = "0.4"
redox_syscall = "0.5"
redox-daemon = "0.1"
common = { path = "../../common" }
driver-network = { path = "../driver-network" }
pcid = { path = "../../pcid" }
libredox = "0.1.3"
+2 -2
View File
@@ -129,13 +129,13 @@ impl Intel8259x {
base,
size,
receive_buffer: (0..32)
.map(|_| Dma::zeroed().map(|dma| unsafe { dma.assume_init() }))
.map(|_| Ok(unsafe { Dma::zeroed()?.assume_init() }))
.collect::<Result<Vec<_>>>()?
.try_into()
.unwrap_or_else(|_| unreachable!()),
receive_ring: unsafe { Dma::zeroed()?.assume_init() },
transmit_buffer: (0..32)
.map(|_| Dma::zeroed().map(|dma| unsafe { dma.assume_init() }))
.map(|_| Ok(unsafe { Dma::zeroed()?.assume_init() }))
.collect::<Result<Vec<_>>>()?
.try_into()
.unwrap_or_else(|_| unreachable!()),
+2 -2
View File
@@ -55,7 +55,7 @@ fn main() {
let mut event_queue =
EventQueue::<Infallible>::new().expect("ixgbed: failed to create event queue");
syscall::setrens(0, 0).expect("ixgbed: failed to enter null namespace");
libredox::call::setrens(0, 0).expect("ixgbed: failed to enter null namespace");
daemon
.ready()
@@ -91,7 +91,7 @@ fn main() {
event_queue
.trigger_all(event::Event {
fd: 0,
flags: EventFlags::empty(),
flags: Default::default(),
})
.expect("ixgbed: failed to trigger events");
+2 -1
View File
@@ -7,10 +7,11 @@ edition = "2018"
bitflags = "1"
log = "0.4"
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox_syscall = "0.4"
redox_syscall = "0.5"
redox-daemon = "0.1"
redox-log = "0.1"
common = { path = "../../common" }
driver-network = { path = "../driver-network" }
pcid = { path = "../../pcid" }
libredox = "0.1.3"
+2 -2
View File
@@ -209,13 +209,13 @@ impl Rtl8139 {
let regs = Regs::from_base(base);
let mut module = Rtl8139 {
regs: regs,
regs,
//TODO: limit to 32-bit
receive_buffer: Dma::zeroed().map(|dma| dma.assume_init())?,
receive_i: 0,
//TODO: limit to 32-bit
transmit_buffer: (0..4)
.map(|_| Dma::zeroed().map(|dma| dma.assume_init()))
.map(|_| Ok(Dma::zeroed()?.assume_init()))
.collect::<Result<Vec<_>>>()?
.try_into()
.unwrap_or_else(|_| unreachable!()),
+2 -2
View File
@@ -242,7 +242,7 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
let mut event_queue =
EventQueue::<Infallible>::new().expect("rtl8139d: failed to create event queue");
syscall::setrens(0, 0).expect("rtl8139d: failed to enter null namespace");
libredox::call::setrens(0, 0).expect("rtl8139d: failed to enter null namespace");
daemon
.ready()
@@ -279,7 +279,7 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
event_queue
.trigger_all(event::Event {
fd: 0,
flags: EventFlags::empty(),
flags: Default::default(),
})
.expect("rtl8139d: failed to trigger events");
+2 -1
View File
@@ -7,10 +7,11 @@ edition = "2018"
bitflags = "1"
log = "0.4"
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox_syscall = "0.4"
redox_syscall = "0.5"
redox-daemon = "0.1"
redox-log = "0.1"
common = { path = "../../common" }
driver-network = { path = "../driver-network" }
pcid = { path = "../../pcid" }
libredox = "0.1.3"
+3 -3
View File
@@ -173,9 +173,9 @@ impl Rtl8168 {
assert_eq!(&regs.mtps as *const _ as usize - base, 0xEC);
let mut module = Rtl8168 {
regs: regs,
regs,
receive_buffer: (0..64)
.map(|_| Dma::zeroed().map(|dma| dma.assume_init()))
.map(|_| Ok(Dma::zeroed()?.assume_init()))
.collect::<Result<Vec<_>>>()?
.try_into()
.unwrap_or_else(|_| unreachable!()),
@@ -183,7 +183,7 @@ impl Rtl8168 {
receive_ring: Dma::zeroed()?.assume_init(),
receive_i: 0,
transmit_buffer: (0..16)
.map(|_| Dma::zeroed().map(|dma| dma.assume_init()))
.map(|_| Ok(Dma::zeroed()?.assume_init()))
.collect::<Result<Vec<_>>>()?
.try_into()
.unwrap_or_else(|_| unreachable!()),
+2 -2
View File
@@ -237,7 +237,7 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
let mut event_queue =
EventQueue::<Infallible>::new().expect("rtl8168d: failed to create event queue");
syscall::setrens(0, 0).expect("rtl8168d: failed to enter null namespace");
libredox::call::setrens(0, 0).expect("rtl8168d: failed to enter null namespace");
daemon
.ready()
@@ -274,7 +274,7 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
event_queue
.trigger_all(event::Event {
fd: 0,
flags: EventFlags::empty(),
flags: Default::default(),
})
.expect("rtl8168d: failed to trigger events");
+2 -1
View File
@@ -14,4 +14,5 @@ common = { path = "../../common" }
driver-network = { path = "../driver-network" }
redox-daemon = "0.1"
redox_syscall = "0.4"
redox_syscall = "0.5"
libredox = "0.1.3"
+1 -1
View File
@@ -102,7 +102,7 @@ fn deamon(daemon: redox_daemon::Daemon) -> Result<(), Box<dyn std::error::Error>
data: 0,
})?;
syscall::setrens(0, 0).expect("virtio-netd: failed to enter null namespace");
libredox::call::setrens(0, 0).expect("virtio-netd: failed to enter null namespace");
daemon.ready().expect("virtio-netd: failed to daemonize");
+1
View File
@@ -31,3 +31,4 @@ thiserror = "1"
toml = "0.5"
common = { path = "../common" }
libredox = "0.1.3"
+1 -3
View File
@@ -33,9 +33,7 @@ impl Pci {
"PCI: couldn't find or access PCIe extended configuration, \
and thus falling back to PCI 3.0 io ports"
);
unsafe {
syscall::iopl(3).expect("pcid: failed to set iopl to 3");
}
common::acquire_port_io_rights().expect("pcid: failed to get IO port rights");
}
});
}
+1
View File
@@ -8,3 +8,4 @@ bitflags = "1"
orbclient = "0.3.27"
redox_syscall = "0.4"
redox-daemon = "0.1"
libredox = "0.1.3"
+1 -1
View File
@@ -80,7 +80,7 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
data: 1
}).expect("ps2d: failed to event irq:12");
syscall::setrens(0, 0).expect("ps2d: failed to enter null namespace");
libredox::call::setrens(0, 0).expect("ps2d: failed to enter null namespace");
daemon.ready().expect("ps2d: failed to mark daemon as ready");
+2 -1
View File
@@ -9,8 +9,9 @@ byteorder = "1.2"
log = "0.4"
redox-daemon = "0.1"
redox-log = "0.1"
redox_syscall = "0.4"
redox_syscall = "0.5"
common = { path = "../../common" }
driver-block = { path = "../driver-block" }
pcid = { path = "../../pcid" }
libredox = "0.1.3"
+1 -1
View File
@@ -36,7 +36,7 @@ impl DiskATA {
let mut clb = unsafe { Dma::zeroed()?.assume_init() };
let mut ctbas: [_; 32] = (0..32)
.map(|_| Dma::zeroed().map(|dma| unsafe { dma.assume_init() }))
.map(|_| Ok(unsafe { Dma::zeroed()?.assume_init() }))
.collect::<Result<Vec<_>>>()?
.try_into()
.unwrap_or_else(|_| unreachable!());
+1 -1
View File
@@ -32,7 +32,7 @@ impl DiskATAPI {
let mut clb = unsafe { Dma::zeroed()?.assume_init() };
let mut ctbas: [_; 32] = (0..32)
.map(|_| Dma::zeroed().map(|dma| unsafe { dma.assume_init() }))
.map(|_| Ok(unsafe { Dma::zeroed()?.assume_init() }))
.collect::<Result<Vec<_>>>()?
.try_into()
.unwrap_or_else(|_| unreachable!());
+7 -5
View File
@@ -10,6 +10,7 @@ use std::os::fd::AsRawFd;
use std::os::unix::io::{FromRawFd, RawFd};
use std::usize;
use libredox::flag;
use pcid_interface::PcidServerHandle;
use syscall::error::{Error, ENODEV};
use syscall::data::{Event, Packet};
@@ -93,9 +94,10 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
let address = unsafe { bar.physmap_mem("ahcid") };
{
let scheme_name = format!("disk.{}", name);
let socket_fd = syscall::open(
let socket_fd = libredox::call::open(
&format!(":{}", scheme_name),
syscall::O_RDWR | syscall::O_CREAT | syscall::O_NONBLOCK
flag::O_RDWR | flag::O_CREAT | flag::O_NONBLOCK,
0,
).expect("ahcid: failed to create disk scheme");
let mut socket = unsafe { File::from_raw_fd(socket_fd as RawFd) };
@@ -104,9 +106,7 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
let mut event_file = File::open("event:").expect("ahcid: failed to open event file");
syscall::setrens(0, 0).expect("ahcid: failed to enter null namespace");
daemon.ready().expect("ahcid: failed to notify parent");
libredox::call::setrens(0, 0).expect("ahcid: failed to enter null namespace");
event_file.write(&Event {
id: socket_fd,
@@ -120,6 +120,8 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
data: 0
}).expect("ahcid: failed to event irq scheme");
daemon.ready().expect("ahcid: failed to notify parent");
let (hba_mem, disks) = ahci::disks(address as usize, &name);
let mut scheme = DiskScheme::new(scheme_name, hba_mem, disks);
+1
View File
@@ -12,3 +12,4 @@ common = { path = "../../common" }
driver-block = { path = "../driver-block" }
redox-daemon = "0.1"
libredox = "0.1.3"
+1 -1
View File
@@ -79,7 +79,7 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
let scheme_name = ":disk.mmc";
let mut socket = File::create(scheme_name).expect("mmc: failed to create disk scheme");
syscall::setrens(0, 0).expect("mmc: failed to enter null namespace");
libredox::call::setrens(0, 0).expect("mmc: failed to enter null namespace");
daemon.ready().expect("mmc: failed to notify parent");
+1 -1
View File
@@ -6,4 +6,4 @@ edition = "2021"
[dependencies]
partitionlib = { git = "https://gitlab.redox-os.org/redox-os/partitionlib.git" }
redox_syscall = "0.4"
redox_syscall = "0.5"
+2 -1
View File
@@ -6,8 +6,9 @@ edition = "2018"
[dependencies]
common = { path = "../../common" }
driver-block = { path = "../driver-block" }
libredox = "0.1.3"
log = "0.4"
pcid = { path = "../../pcid" }
redox-daemon = "0.1"
redox-log = "0.1"
redox_syscall = "0.4"
redox_syscall = "0.5"
+12 -8
View File
@@ -1,4 +1,5 @@
use driver_block::Disk;
use libredox::flag;
use log::{error, info};
use pcid_interface::{PciBar, PcidServerHandle};
use redox_log::{OutputBuilder, RedoxLogger};
@@ -99,7 +100,7 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
(Channel::secondary_compat(busmaster_base + 8).unwrap(), 15)
};
unsafe { syscall::iopl(3).expect("ided: failed to get I/O privilege") };
common::acquire_port_io_rights().expect("ided: failed to get I/O privilege");
//TODO: move this to ide.rs?
let chans = vec![
@@ -231,27 +232,30 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
}
let scheme_name = format!("disk.{}", name);
let socket_fd = syscall::open(
let socket_fd = libredox::call::open(
&format!(":{}", scheme_name),
syscall::O_RDWR | syscall::O_CREAT | syscall::O_NONBLOCK
flag::O_RDWR | flag::O_CREAT | flag::O_NONBLOCK,
0,
).expect("ided: failed to create disk scheme");
let mut socket = unsafe { File::from_raw_fd(socket_fd as RawFd) };
let primary_irq_fd = syscall::open(
let primary_irq_fd = libredox::call::open(
&format!("irq:{}", primary_irq),
syscall::O_RDWR | syscall::O_NONBLOCK
flag::O_RDWR | flag::O_NONBLOCK,
0,
).expect("ided: failed to open irq file");
let mut primary_irq_file = unsafe { File::from_raw_fd(primary_irq_fd as RawFd) };
let secondary_irq_fd = syscall::open(
let secondary_irq_fd = libredox::call::open(
&format!("irq:{}", secondary_irq),
syscall::O_RDWR | syscall::O_NONBLOCK
flag::O_RDWR | flag::O_NONBLOCK,
0,
).expect("ided: failed to open irq file");
let mut secondary_irq_file = unsafe { File::from_raw_fd(secondary_irq_fd as RawFd) };
let mut event_file = File::open("event:").expect("ided: failed to open event file");
syscall::setrens(0, 0).expect("ided: failed to enter null namespace");
libredox::call::setrens(0, 0).expect("ided: failed to enter null namespace");
daemon.ready().expect("ided: failed to notify parent");
+1
View File
@@ -9,6 +9,7 @@ license = "MIT"
[dependencies]
anyhow = "1"
libredox = "0.1.3"
redox-daemon = "0.1"
redox_syscall = "0.4"
slab = "0.4"
+9 -5
View File
@@ -8,6 +8,8 @@ use std::io::{Read, Write};
use std::os::fd::AsRawFd;
use std::str;
use libredox::call::MmapArgs;
use libredox::flag;
use slab::Slab;
use syscall::data::Stat;
use syscall::{error::*, MapFlags, SchemeMut, Packet};
@@ -63,11 +65,13 @@ impl DiskScheme {
let the_data = unsafe {
let file = File::open("memory:physical")?;
let base = syscall::fmap(file.as_raw_fd() as usize, &syscall::Map {
address: 0,
offset: start,
size,
flags: MapFlags::PROT_READ | MapFlags::PROT_WRITE | MapFlags::MAP_SHARED,
let base = libredox::call::mmap(MmapArgs {
fd: file.as_raw_fd() as usize,
addr: core::ptr::null_mut(),
offset: start as u64,
length: size,
prot: flag::PROT_READ | flag::PROT_WRITE,
flags: flag::MAP_SHARED,
}).map_err(|err| anyhow!("failed to mmap livedisk: {}", err))?;
std::slice::from_raw_parts_mut(base as *mut u8, size)
+2 -1
View File
@@ -11,13 +11,14 @@ futures = "0.3"
log = "0.4"
redox-daemon = "0.1"
redox-log = "0.1"
redox_syscall = "0.4"
redox_syscall = "0.5"
partitionlib = { git = "https://gitlab.redox-os.org/redox-os/partitionlib.git" }
smallvec = "1"
common = { path = "../../common" }
driver-block = { path = "../driver-block" }
pcid = { path = "../../pcid" }
libredox = "0.1.3"
[features]
default = ["async"]
+7 -5
View File
@@ -9,6 +9,7 @@ use std::ptr::NonNull;
use std::sync::{Arc, Mutex};
use std::{slice, usize};
use libredox::flag;
use pcid_interface::{PciFeature, PciFeatureInfo, PciFunction, PcidServerHandle};
use syscall::{
Event, Mmio, Packet, Result, SchemeBlockMut,
@@ -49,8 +50,8 @@ impl Bar {
impl Drop for Bar {
fn drop(&mut self) {
let _ = unsafe {
syscall::funmap(
self.ptr.as_ptr() as usize,
libredox::call::munmap(
self.ptr.as_ptr().cast(),
self.bar_size.next_multiple_of(PAGE_SIZE),
)
};
@@ -275,9 +276,10 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
ptr: NonNull::new(address as *mut u8).expect("Physmapping BAR gave nullptr"),
});
let socket_fd = syscall::open(
let socket_fd = libredox::call::open(
&format!(":{}", scheme_name),
syscall::O_RDWR | syscall::O_CREAT | syscall::O_CLOEXEC,
flag::O_RDWR | flag::O_CREAT | flag::O_CLOEXEC,
0,
)
.expect("nvmed: failed to create disk scheme");
let mut socket_file = unsafe { File::from_raw_fd(socket_fd as RawFd) };
@@ -297,7 +299,7 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
let reactor_thread = nvme::cq_reactor::start_cq_reactor_thread(Arc::clone(&nvme), interrupt_sources, reactor_receiver);
let namespaces = nvme.init_with_queues();
syscall::setrens(0, 0).expect("nvmed: failed to enter null namespace");
libredox::call::setrens(0, 0).expect("nvmed: failed to enter null namespace");
let mut scheme = DiskScheme::new(scheme_name, nvme, namespaces);
let mut todo = Vec::new();
+2 -2
View File
@@ -65,8 +65,8 @@ struct CqReactor {
}
impl CqReactor {
fn create_event_queue(int_sources: &mut InterruptSources) -> Result<File> {
use syscall::flag::*;
let fd = syscall::open("event:", O_CLOEXEC | O_RDWR)?;
use libredox::flag::*;
let fd = libredox::call::open("event:", O_CLOEXEC | O_RDWR, 0)?;
let mut file = unsafe { File::from_raw_fd(fd as RawFd) };
for (num, irq_handle) in int_sources.iter_mut() {
+1
View File
@@ -9,6 +9,7 @@ license = "MIT"
[dependencies]
base64 = "0.11" # Only for debugging
libredox = "0.1.3"
plain = "0.2"
redox-daemon = "0.1"
redox_syscall = "0.4"
+3 -2
View File
@@ -3,6 +3,7 @@ use std::fs::File;
use std::io::prelude::*;
use std::os::unix::io::{FromRawFd, RawFd};
use libredox::flag;
use syscall::{Packet, SchemeMut};
use xhcid_interface::{ConfigureEndpointsReq, DeviceReqData, XhciClientHandle};
@@ -84,11 +85,11 @@ fn daemon(daemon: redox_daemon::Daemon, scheme: String, port: usize, protocol: u
// TODO: Let all of the USB drivers syscall clone(2), and xhcid won't have to keep track of all
// the drivers.
let socket_fd = syscall::open(disk_scheme_name, syscall::O_RDWR | syscall::O_CREAT)
let socket_fd = libredox::call::open(disk_scheme_name, flag::O_RDWR | flag::O_CREAT, 0)
.expect("usbscsid: failed to create disk scheme");
let mut socket_file = unsafe { File::from_raw_fd(socket_fd as RawFd) };
//syscall::setrens(0, 0).expect("scsid: failed to enter null namespace");
//libredox::call::setrens(0, 0).expect("scsid: failed to enter null namespace");
let mut scsi = Scsi::new(&mut *protocol).expect("usbscsid: failed to setup SCSI");
println!("SCSI initialized");
let mut buffer = [0u8; 512];
+2 -1
View File
@@ -14,10 +14,11 @@ spin = "*"
redox-daemon = "0.1"
redox-log = "0.1"
redox_syscall = "0.4"
redox_syscall = "0.5"
partitionlib = { git = "https://gitlab.redox-os.org/redox-os/partitionlib.git" }
common = { path = "../../common" }
driver-block = { path = "../driver-block" }
pcid = { path = "../../pcid" }
virtio-core = { path = "../../virtio-core" }
libredox = "0.1.3"
+5 -2
View File
@@ -8,6 +8,7 @@ use std::io::{Read, Write};
use std::os::fd::{FromRawFd, RawFd};
use std::sync::{Arc, Weak};
use libredox::flag;
use static_assertions::const_assert_eq;
use pcid_interface::*;
@@ -142,10 +143,12 @@ fn deamon(deamon: redox_daemon::Daemon) -> anyhow::Result<()> {
let scheme_name = format!("disk.{}", name);
let socket_fd = syscall::open(
let socket_fd = libredox::call::open(
&format!(":{}", scheme_name),
syscall::O_RDWR | syscall::O_CREAT | syscall::O_CLOEXEC,
flag::O_RDWR | flag::O_CREAT | flag::O_CLOEXEC,
0,
)
.map_err(syscall::Error::from)
.map_err(Error::SyscallError)?;
let mut socket_file = unsafe { File::from_raw_fd(socket_fd as RawFd) };
+2 -1
View File
@@ -6,8 +6,9 @@ edition = "2018"
[dependencies]
orbclient = "0.3.27"
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox_syscall = "0.4"
redox_syscall = "0.5"
redox-daemon = "0.1"
common = { path = "../common" }
pcid = { path = "../pcid" }
libredox = "0.1.3"
+4 -5
View File
@@ -11,7 +11,6 @@ use std::fs::File;
use std::io::{Result, Read, Write};
use pcid_interface::{PciBar, PcidServerHandle};
use syscall::call::iopl;
use syscall::flag::EventFlags;
use syscall::io::{Io, Mmio, Pio};
@@ -206,14 +205,14 @@ fn main() {
redox_daemon::Daemon::new(move |daemon| {
daemon.ready().expect("failed to signal readiness");
unsafe { iopl(3).expect("vboxd: failed to get I/O permission"); };
common::acquire_port_io_rights().expect("vboxd: failed to get I/O permission");
let mut width = 0;
let mut height = 0;
let mut display_opt = File::open("inputd:producer").ok();
if let Some(ref display) = display_opt {
let mut buf: [u8; 4096] = [0; 4096];
if let Ok(count) = syscall::fpath(display.as_raw_fd() as usize, &mut buf) {
if let Ok(count) = libredox::call::fpath(display.as_raw_fd() as usize, &mut buf) {
let path = unsafe { String::from_utf8_unchecked(Vec::from(&buf[..count])) };
let res = path.split(":").nth(1).unwrap_or("");
width = res.split("/").nth(1).unwrap_or("").parse::<u32>().unwrap_or(0);
@@ -245,7 +244,7 @@ fn main() {
let mut event_queue = EventQueue::<()>::new().expect("vboxd: failed to create event queue");
syscall::setrens(0, 0).expect("vboxd: failed to enter null namespace");
libredox::call::setrens(0, 0).expect("vboxd: failed to enter null namespace");
let mut bga = Bga::new();
let get_mouse = VboxGetMouse::new().expect("vboxd: failed to map GetMouse");
@@ -295,7 +294,7 @@ fn main() {
event_queue.trigger_all(event::Event {
fd: 0,
flags: EventFlags::empty()
flags: Default::default(),
}).expect("vboxd: failed to trigger events");
event_queue.run().expect("vboxd: failed to run event loop");
+2 -1
View File
@@ -7,7 +7,7 @@ authors = ["Anhad Singh <andypython@protonmail.com>"]
[dependencies]
static_assertions = "1.1.0"
bitflags = "2.3.2"
redox_syscall = "0.4"
redox_syscall = "0.5"
log = "0.4"
thiserror = "1.0.40"
futures = { version = "0.3.28", features = ["executor"] }
@@ -18,3 +18,4 @@ redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
common = { path = "../common" }
pcid = { path = "../pcid" }
libredox = "0.1.3"
+1 -1
View File
@@ -13,7 +13,7 @@ pub fn probe_legacy_port_transport(
) -> Result<Device, Error> {
let port = pci_config.func.bars[0].expect_port();
unsafe { syscall::iopl(3).expect("virtio: failed to set I/O privilege level") };
common::acquire_io_port_rights().expect("virtio: failed to set I/O privilege level");
log::warn!("virtio: using legacy transport");
let transport = LegacyTransport::new(port);
+1 -1
View File
@@ -54,7 +54,7 @@ pub fn probe_legacy_port_transport(
) -> Result<Device, Error> {
let port = pci_config.func.bars[0].expect_port();
unsafe { syscall::iopl(3).expect("virtio: failed to set I/O privilege level") };
common::acquire_port_io_rights().expect("virtio: failed to set I/O privilege level");
log::warn!("virtio: using legacy transport");
let transport = LegacyTransport::new(port);
+1 -7
View File
@@ -16,7 +16,7 @@ use std::task::{Poll, Waker};
#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("syscall failed")]
SyscallError(syscall::Error),
SyscallError(#[from] libredox::error::Error),
#[error("pcid client handle error")]
PcidClientHandle(pcid_interface::PcidClientHandleError),
#[error("the device is incapable of {0:?}")]
@@ -29,12 +29,6 @@ impl From<pcid_interface::PcidClientHandleError> for Error {
}
}
impl From<syscall::Error> for Error {
fn from(value: syscall::Error) -> Self {
Self::SyscallError(value)
}
}
/// Returns the queue part sizes in bytes.
///
/// ## Reference
+3 -2
View File
@@ -20,9 +20,9 @@ plain = "0.2"
lazy_static = "1.4"
log = "0.4"
redox-daemon = "0.1"
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox_event = "0.4.1"
redox-log = "0.1"
redox_syscall = "0.4"
redox_syscall = "0.5"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
smallvec = { version = "1", features = ["serde"] }
@@ -31,3 +31,4 @@ toml = "0.5"
common = { path = "../common" }
pcid = { path = "../pcid" }
libredox = "0.1.3"
+29 -36
View File
@@ -11,13 +11,14 @@ use std::ptr::NonNull;
use std::sync::{Arc, Mutex};
use std::env;
use libredox::flag;
use pcid_interface::{MsiSetFeatureInfo, PcidServerHandle, PciFeature, PciFeatureInfo, SetFeatureInfo};
#[cfg(target_arch = "x86_64")]
use pcid_interface::irq_helpers::allocate_single_interrupt_vector_for_msi;
use pcid_interface::irq_helpers::read_bsp_apic_id;
use pcid_interface::msi::MsixTableEntry;
use event::{Event, EventQueue};
use event::{Event, RawEventQueue};
use redox_log::{RedoxLogger, OutputBuilder};
use syscall::data::Packet;
use syscall::error::EWOULDBLOCK;
@@ -208,9 +209,10 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
println!(" + XHCI {}", pci_config.func.display());
let scheme_name = format!("usb.{}", name);
let socket_fd = syscall::open(
let socket_fd = libredox::call::open(
format!(":{}", scheme_name),
syscall::O_RDWR | syscall::O_CREAT,
flag::O_RDWR | flag::O_CREAT,
0,
)
.expect("xhcid: failed to create usb scheme");
let socket = Arc::new(Mutex::new(unsafe {
@@ -223,47 +225,38 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
xhci::start_irq_reactor(&hci, irq_file);
futures::executor::block_on(hci.probe()).expect("xhcid: failed to probe");
let mut event_queue =
EventQueue::<()>::new().expect("xhcid: failed to create event queue");
//let event_queue = RawEventQueue::new().expect("xhcid: failed to create event queue");
syscall::setrens(0, 0).expect("xhcid: failed to enter null namespace");
libredox::call::setrens(0, 0).expect("xhcid: failed to enter null namespace");
let todo = Arc::new(Mutex::new(Vec::<Packet>::new()));
let todo_futures = Arc::new(Mutex::new(Vec::<Pin<Box<dyn Future<Output = usize> + Send + Sync + 'static>>>::new()));
//let todo_futures = Arc::new(Mutex::new(Vec::<Pin<Box<dyn Future<Output = usize> + Send + Sync + 'static>>>::new()));
//let socket_fd = socket.lock().unwrap().as_raw_fd();
//event_queue.subscribe(socket_fd as usize, 0, event::EventFlags::READ).unwrap();
let socket_fd = socket.lock().unwrap().as_raw_fd();
let socket_packet = socket.clone();
event_queue
.add(socket_fd, move |_| -> io::Result<Option<()>> {
let mut socket = socket_packet.lock().unwrap();
let mut todo = todo.lock().unwrap();
loop {
let mut packet = Packet::default();
match socket.read(&mut packet) {
Ok(0) => break,
Ok(_) => (),
Err(err) => return Err(err),
}
loop {
let mut socket = socket_packet.lock().unwrap();
let mut todo = todo.lock().unwrap();
let a = packet.a;
hci.handle(&mut packet);
if packet.a == (-EWOULDBLOCK) as usize {
packet.a = a;
todo.push(packet);
} else {
socket.write(&packet)?;
}
}
Ok(None)
})
.expect("xhcid: failed to catch events on scheme file");
let mut packet = Packet::default();
match socket.read(&mut packet) {
Ok(0) => break,
Ok(_) => (),
Err(err) => panic!("xhcid failed to read from socket: {err}"),
}
event_queue
.trigger_all(Event { fd: 0, flags: EventFlags::empty() })
.expect("xhcid: failed to trigger events");
event_queue.run().expect("xhcid: failed to handle events");
let a = packet.a;
hci.handle(&mut packet);
if packet.a == (-EWOULDBLOCK) as usize {
packet.a = a;
todo.push(packet);
} else {
socket.write(&packet).expect("xhcid failed to write to socket");
}
}
std::process::exit(0);
}
+1 -1
View File
@@ -185,7 +185,7 @@ impl ScratchpadBufferArray {
pub fn new(ac64: bool, entries: u16) -> Result<Self> {
let mut entries = unsafe { Xhci::alloc_dma_zeroed_unsized_raw(ac64, entries as usize)? };
let pages = entries.iter_mut().map(|entry: &mut ScratchpadBufferEntry| {
let pages = entries.iter_mut().map(|entry: &mut ScratchpadBufferEntry| -> Result<_, syscall::Error> {
let dma = unsafe { Dma::<[u8; PAGE_SIZE]>::zeroed()?.assume_init() };
assert_eq!(dma.physical() % PAGE_SIZE, 0);
entry.set_addr(dma.physical() as u64);
+9 -9
View File
@@ -14,7 +14,7 @@ use log::{debug, error, info, warn, trace};
use futures::Stream;
use syscall::Io;
use event::{Event, EventQueue};
use event::{Event, EventQueue, RawEventQueue};
use super::Xhci;
use super::doorbell::Doorbell;
@@ -146,12 +146,13 @@ impl IrqReactor {
debug!("Running IRQ reactor with IRQ file and event queue");
let hci_clone = Arc::clone(&self.hci);
let mut event_queue = EventQueue::<()>::new().expect("xhcid irq_reactor: failed to create IRQ event queue");
let mut event_queue = RawEventQueue::new().expect("xhcid irq_reactor: failed to create IRQ event queue");
let irq_fd = self.irq_file.as_ref().unwrap().as_raw_fd();
event_queue.subscribe(irq_fd as usize, 0, event::EventFlags::READ).unwrap();
let mut event_trb_index = { hci_clone.primary_event_ring.lock().unwrap().ring.next_index() };
event_queue.add(irq_fd, move |_| -> io::Result<Option<()>> {
for _event in event_queue {
trace!("IRQ event queue notified");
let mut buffer = [0u8; 8];
@@ -160,7 +161,7 @@ impl IrqReactor {
if !self.hci.received_irq() {
// continue only when an IRQ to this device was received
trace!("no interrupt pending");
return Ok(None);
break;
}
trace!("IRQ reactor received an IRQ");
@@ -173,13 +174,13 @@ impl IrqReactor {
let mut count = 0;
'trb_loop: loop {
loop {
let event_trb = &mut event_ring.ring.trbs[event_trb_index];
if event_trb.completion_code() == TrbCompletionCode::Invalid as u8 {
if count == 0 { warn!("xhci: Received interrupt, but no event was found in the event ring. Ignoring interrupt.") }
// no more events were found, continue the loop
return Ok(None);
return;
} else { count += 1 }
trace!("Found event TRB type {}: {:?}", event_trb.trb_type(), event_trb);
@@ -187,7 +188,7 @@ impl IrqReactor {
if self.check_event_ring_full(event_trb.clone()) {
info!("Had to resize event TRB, retrying...");
hci_clone.event_handler_finished();
return Ok(None);
return;
}
self.handle_requests();
@@ -199,8 +200,7 @@ impl IrqReactor {
event_trb_index = event_ring.ring.next_index();
}
}).expect("xhcid: failed to catch irq events");
event_queue.run().expect("xhcid: failed to run IRQ event queue");
}
}
fn update_erdp(&self, event_ring: &EventRing) {
let dequeue_pointer_and_dcs = event_ring.erdp();
+1 -7
View File
@@ -11,7 +11,6 @@ use std::{mem, process, slice, sync::atomic, task, thread};
use syscall::PAGE_SIZE;
use syscall::error::{Error, Result, EBADF, EBADMSG, ENOENT, EIO};
use syscall::flag::{O_RDONLY, PhysallocFlags};
use syscall::io::Io;
use chashmap::CHashMap;
@@ -236,12 +235,7 @@ impl Xhci {
let cap = unsafe { &mut *(address as *mut CapabilityRegs) };
debug!("CAP REGS BASE {:X}", address);
/*let page_size = {
let memory_fd = syscall::open("memory:", O_RDONLY)?;
let mut stat = syscall::data::StatVfs::default();
syscall::fstatvfs(memory_fd, &mut stat)?;
stat.f_bsize as usize
};*/
//let page_size = ...
let op_base = address + cap.len.read() as usize;
let op = unsafe { &mut *(op_base as *mut OperationalRegs) };