diff --git a/alxd/Cargo.toml b/alxd/Cargo.toml index 4d1a83dce0..a9865f295a 100644 --- a/alxd/Cargo.toml +++ b/alxd/Cargo.toml @@ -9,3 +9,5 @@ netutils = { git = "https://gitlab.redox-os.org/redox-os/netutils.git", branch = redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" } redox_syscall = "0.3" redox-daemon = "0.1" + +common = { path = "../common" } diff --git a/alxd/src/main.rs b/alxd/src/main.rs index 6f125a855f..4de3005c6e 100644 --- a/alxd/src/main.rs +++ b/alxd/src/main.rs @@ -15,7 +15,7 @@ use std::os::unix::io::{AsRawFd, FromRawFd, RawFd}; use std::sync::Arc; use event::EventQueue; -use syscall::{EventFlags, Packet, SchemeMut, PHYSMAP_NO_CACHE, PHYSMAP_WRITE}; +use syscall::{EventFlags, Packet, SchemeMut}; use syscall::error::EWOULDBLOCK; pub mod device; @@ -43,7 +43,7 @@ fn main() { let mut irq_file = File::open(format!("irq:{}", irq)).expect("alxd: failed to open IRQ file"); - let address = unsafe { syscall::physmap(bar, 128*1024, PHYSMAP_WRITE | PHYSMAP_NO_CACHE).expect("alxd: failed to map address") }; + let address = unsafe { common::physmap(bar, 128*1024, common::Prot::RW, common::MemoryType::Uncacheable).expect("alxd: failed to map address") as usize }; { let device = Arc::new(RefCell::new(unsafe { device::Alx::new(address).expect("alxd: failed to allocate device") })); diff --git a/e1000d/Cargo.toml b/e1000d/Cargo.toml index c7d5abaacd..2f2470cfbd 100644 --- a/e1000d/Cargo.toml +++ b/e1000d/Cargo.toml @@ -9,3 +9,5 @@ netutils = { git = "https://gitlab.redox-os.org/redox-os/netutils.git", branch = redox-daemon = "0.1" redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" } redox_syscall = "0.3" + +common = { path = "../common" } diff --git a/e1000d/src/main.rs b/e1000d/src/main.rs index e0353af679..2e2a617c8f 100644 --- a/e1000d/src/main.rs +++ b/e1000d/src/main.rs @@ -10,7 +10,7 @@ use std::os::unix::io::{AsRawFd, FromRawFd, RawFd}; use std::sync::Arc; use event::EventQueue; -use syscall::{EventFlags, Packet, SchemeBlockMut, PHYSMAP_NO_CACHE, PHYSMAP_WRITE}; +use syscall::{EventFlags, Packet, SchemeBlockMut}; pub mod device; @@ -91,9 +91,9 @@ fn main() { let mut irq_file = unsafe { File::from_raw_fd(irq_fd as RawFd) }; let address = unsafe { - syscall::physmap(bar, bar_size, PHYSMAP_WRITE | PHYSMAP_NO_CACHE) + common::physmap(bar, bar_size, common::Prot::RW, common::MemoryType::Uncacheable) .expect("e1000d: failed to map address") - }; + } as usize; { let device = Arc::new(RefCell::new(unsafe { device::Intel8254x::new(address).expect("e1000d: failed to allocate device") diff --git a/ihdad/Cargo.toml b/ihdad/Cargo.toml index 7ef0407d69..084efca393 100755 --- a/ihdad/Cargo.toml +++ b/ihdad/Cargo.toml @@ -12,4 +12,5 @@ redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" } redox_syscall = "0.3" spin = "0.9" +common = { path = "../common" } pcid = { path = "../pcid" } diff --git a/ihdad/src/hda/device.rs b/ihdad/src/hda/device.rs index 578299793e..9778ba1b09 100755 --- a/ihdad/src/hda/device.rs +++ b/ihdad/src/hda/device.rs @@ -7,7 +7,6 @@ use std::str; use std::collections::BTreeMap; use std::sync::atomic::{AtomicUsize, Ordering}; -use syscall::{PHYSMAP_NO_CACHE, PHYSMAP_WRITE}; use syscall::error::{Error, EACCES, EBADF, Result, EINVAL}; use syscall::flag::{SEEK_SET, SEEK_CUR, SEEK_END}; use syscall::io::{Mmio, Io}; @@ -159,8 +158,8 @@ impl IntelHDA { .expect("Could not allocate physical memory for buffer descriptor list."); let buff_desc_virt = - syscall::physmap(buff_desc_phys, 0x1000, PHYSMAP_WRITE | PHYSMAP_NO_CACHE) - .expect("ihdad: failed to map address for buffer descriptor list."); + common::physmap(buff_desc_phys, 0x1000, common::Prot::RW, common::MemoryType::Uncacheable) + .expect("ihdad: failed to map address for buffer descriptor list.") as usize; log::debug!("Virt: {:016X}, Phys: {:016X}", buff_desc_virt, buff_desc_phys); @@ -170,7 +169,7 @@ impl IntelHDA { syscall::physalloc(0x1000) .expect("Could not allocate physical memory for CORB and RIRB."); - let cmd_buff_virt = syscall::physmap(cmd_buff_address, 0x1000, PHYSMAP_WRITE | PHYSMAP_NO_CACHE).expect("ihdad: failed to map address for CORB/RIRB buff"); + let cmd_buff_virt = common::physmap(cmd_buff_address, 0x1000, common::Prot::RW, common::MemoryType::Uncacheable).expect("ihdad: failed to map address for CORB/RIRB buff") as usize; log::debug!("Virt: {:016X}, Phys: {:016X}", cmd_buff_virt, cmd_buff_address); let mut module = IntelHDA { diff --git a/ihdad/src/hda/stream.rs b/ihdad/src/hda/stream.rs index dbdc3ad79c..3f1e383419 100644 --- a/ihdad/src/hda/stream.rs +++ b/ihdad/src/hda/stream.rs @@ -1,4 +1,4 @@ -use syscall::{PHYSMAP_WRITE, PHYSMAP_NO_CACHE, PAGE_SIZE}; +use syscall::PAGE_SIZE; use syscall::error::{Error, EIO, Result}; use syscall::io::{Mmio, Io}; use std::result; @@ -301,9 +301,9 @@ impl StreamBuffer { }; let addr = match unsafe { - syscall::physmap(phys, page_aligned_size, PHYSMAP_WRITE | PHYSMAP_NO_CACHE) + common::physmap(phys, page_aligned_size, common::Prot::RW, common::MemoryType::Uncacheable) } { - Ok(addr) => addr, + Ok(ptr) => ptr as usize, Err(_err) => { unsafe { syscall::physfree(phys, page_aligned_size); diff --git a/ihdad/src/main.rs b/ihdad/src/main.rs index f77b2c278e..6362fcb4e7 100755 --- a/ihdad/src/main.rs +++ b/ihdad/src/main.rs @@ -11,7 +11,7 @@ use std::usize; use std::fs::File; use std::io::{ErrorKind, Read, Write, Result}; use std::os::unix::io::{AsRawFd, FromRawFd, RawFd}; -use syscall::{PHYSMAP_NO_CACHE, PHYSMAP_WRITE, Packet, SchemeBlockMut, EventFlags}; +use syscall::{Packet, SchemeBlockMut, EventFlags}; use std::cell::RefCell; use std::sync::Arc; @@ -177,8 +177,8 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! { log::info!(" + IHDA {} on: {:#X} size: {}", name, bar_ptr, bar_size); let address = unsafe { - syscall::physmap(bar_ptr as usize, bar_size as usize, PHYSMAP_WRITE | PHYSMAP_NO_CACHE) - .expect("ihdad: failed to map address") + common::physmap(bar_ptr as usize, bar_size as usize, common::Prot::RW, common::MemoryType::Uncacheable) + .expect("ihdad: failed to map address") as usize }; //TODO: MSI-X diff --git a/ixgbed/Cargo.toml b/ixgbed/Cargo.toml index 1884d76457..2df2b871b2 100644 --- a/ixgbed/Cargo.toml +++ b/ixgbed/Cargo.toml @@ -8,3 +8,5 @@ netutils = { git = "https://gitlab.redox-os.org/redox-os/netutils.git", branch = redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" } redox_syscall = "0.3" redox-daemon = "0.1" + +common = { path = "../common" } diff --git a/ixgbed/src/main.rs b/ixgbed/src/main.rs index 7bbd3a42fb..b1906fadc8 100644 --- a/ixgbed/src/main.rs +++ b/ixgbed/src/main.rs @@ -11,7 +11,7 @@ use std::{env, thread}; use event::EventQueue; use std::time::Duration; -use syscall::{EventFlags, Packet, SchemeBlockMut, PHYSMAP_NO_CACHE, PHYSMAP_WRITE}; +use syscall::{EventFlags, Packet, SchemeBlockMut}; pub mod device; #[rustfmt::skip] @@ -92,8 +92,8 @@ fn main() { File::open(format!("irq:{}", irq)).expect("ixgbed: failed to open IRQ file"); let address = unsafe { - syscall::physmap(bar, IXGBE_MMIO_SIZE, PHYSMAP_WRITE | PHYSMAP_NO_CACHE) - .expect("ixgbed: failed to map address") + common::physmap(bar, IXGBE_MMIO_SIZE, common::Prot::RW, common::MemoryType::Uncacheable) + .expect("ixgbed: failed to map address") as usize }; { let device = Arc::new(RefCell::new( diff --git a/rtl8139d/Cargo.toml b/rtl8139d/Cargo.toml index 48d15ec8ba..9dc4b9d24d 100644 --- a/rtl8139d/Cargo.toml +++ b/rtl8139d/Cargo.toml @@ -12,4 +12,5 @@ redox_syscall = "0.3" redox-daemon = "0.1" redox-log = "0.1" +common = { path = "../common" } pcid = { path = "../pcid" } diff --git a/rtl8139d/src/main.rs b/rtl8139d/src/main.rs index 49edbd9598..eac441a25f 100644 --- a/rtl8139d/src/main.rs +++ b/rtl8139d/src/main.rs @@ -18,7 +18,7 @@ use pcid_interface::{MsiSetFeatureInfo, PcidServerHandle, PciFeature, PciFeature use pcid_interface::irq_helpers::{read_bsp_apic_id, allocate_single_interrupt_vector}; use pcid_interface::msi::{MsixCapability, MsixTableEntry}; use redox_log::{RedoxLogger, OutputBuilder}; -use syscall::{EventFlags, Packet, SchemeBlockMut, PHYSMAP_NO_CACHE, PHYSMAP_WRITE}; +use syscall::{EventFlags, Packet, SchemeBlockMut}; use syscall::io::Io; pub mod device; @@ -187,8 +187,8 @@ fn get_int_method(pcid_handle: &mut PcidServerHandle) -> Option { }; let address = unsafe { - syscall::physmap(bar_ptr as usize, bar_size as usize, PHYSMAP_WRITE | PHYSMAP_NO_CACHE) - .expect("rtl8139d: failed to map address") + common::physmap(bar_ptr as usize, bar_size as usize, common::Prot::RW, common::MemoryType::Uncacheable) + .expect("rtl8139d: failed to map address") as usize }; if !(bar_ptr..bar_ptr + bar_size).contains(&(table_base as u64 + table_min_length as u64)) { @@ -345,8 +345,8 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! { log::info!(" + RTL8139 {} on: {:#X} size: {}", name, bar_ptr, bar_size); let address = unsafe { - syscall::physmap(bar_ptr, bar_size, PHYSMAP_WRITE | PHYSMAP_NO_CACHE) - .expect("rtl8139d: failed to map address") + common::physmap(bar_ptr, bar_size, common::Prot::RW, common::MemoryType::Uncacheable) + .expect("rtl8139d: failed to map address") as usize }; let socket_fd = syscall::open( diff --git a/rtl8168d/Cargo.toml b/rtl8168d/Cargo.toml index 16579d808b..9cd8099fe2 100644 --- a/rtl8168d/Cargo.toml +++ b/rtl8168d/Cargo.toml @@ -12,4 +12,5 @@ redox_syscall = "0.3" redox-daemon = "0.1" redox-log = "0.1" +common = { path = "../common" } pcid = { path = "../pcid" } diff --git a/rtl8168d/src/main.rs b/rtl8168d/src/main.rs index dae8c8a62e..2eea0c80f1 100644 --- a/rtl8168d/src/main.rs +++ b/rtl8168d/src/main.rs @@ -16,7 +16,7 @@ use pcid_interface::{MsiSetFeatureInfo, PcidServerHandle, PciFeature, PciFeature use pcid_interface::irq_helpers::{read_bsp_apic_id, allocate_single_interrupt_vector}; use pcid_interface::msi::{MsixCapability, MsixTableEntry}; use redox_log::{RedoxLogger, OutputBuilder}; -use syscall::{EventFlags, Packet, SchemeBlockMut, PHYSMAP_NO_CACHE, PHYSMAP_WRITE}; +use syscall::{EventFlags, Packet, SchemeBlockMut}; use syscall::io::Io; pub mod device; @@ -185,8 +185,8 @@ fn get_int_method(pcid_handle: &mut PcidServerHandle) -> Option { }; let address = unsafe { - syscall::physmap(bar_ptr as usize, bar_size as usize, PHYSMAP_WRITE | PHYSMAP_NO_CACHE) - .expect("rtl8168d: failed to map address") + common::physmap(bar_ptr as usize, bar_size as usize, common::Prot::RW, common::MemoryType::Uncacheable) + .expect("rtl8168d: failed to map address") as usize }; if !(bar_ptr..bar_ptr + bar_size).contains(&(table_base as u64 + table_min_length as u64)) { @@ -343,8 +343,8 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! { log::info!(" + RTL8168 {} on: {:#X} size: {}", name, bar_ptr, bar_size); let address = unsafe { - syscall::physmap(bar_ptr, bar_size, PHYSMAP_WRITE | PHYSMAP_NO_CACHE) - .expect("rtl8168d: failed to map address") + common::physmap(bar_ptr, bar_size, common::Prot::RW, common::MemoryType::Uncacheable) + .expect("rtl8168d: failed to map address") as usize }; let socket_fd = syscall::open( diff --git a/vboxd/Cargo.toml b/vboxd/Cargo.toml index 601f88ece6..bae4b35c82 100644 --- a/vboxd/Cargo.toml +++ b/vboxd/Cargo.toml @@ -8,3 +8,5 @@ orbclient = "0.3.27" redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" } redox_syscall = "0.3" redox-daemon = "0.1" + +common = { path = "../common" } diff --git a/vboxd/src/main.rs b/vboxd/src/main.rs index c42c8da424..de94f4ba9e 100644 --- a/vboxd/src/main.rs +++ b/vboxd/src/main.rs @@ -11,7 +11,7 @@ use std::fs::File; use std::io::{Result, Read, Write}; use syscall::call::iopl; -use syscall::flag::{EventFlags, PHYSMAP_NO_CACHE, PHYSMAP_WRITE}; +use syscall::flag::EventFlags; use syscall::io::{Dma, Io, Mmio, Pio}; use crate::bga::Bga; @@ -220,7 +220,7 @@ fn main() { let mut irq_file = File::open(format!("irq:{}", irq)).expect("vboxd: failed to open IRQ file"); let mut port = Pio::::new(bar0 as u16); - let address = unsafe { syscall::physmap(bar1, 4096, PHYSMAP_WRITE | PHYSMAP_NO_CACHE).expect("vboxd: failed to map address") }; + let address = unsafe { common::physmap(bar1, 4096, common::Prot::RW, common::MemoryType::Uncacheable).expect("vboxd: failed to map address") }; { let vmmdev = unsafe { &mut *(address as *mut VboxVmmDev) }; diff --git a/xhcid/Cargo.toml b/xhcid/Cargo.toml index a8d6a799f5..db53e8ed36 100644 --- a/xhcid/Cargo.toml +++ b/xhcid/Cargo.toml @@ -29,4 +29,5 @@ smallvec = { version = "1", features = ["serde"] } thiserror = "1" toml = "0.5" +common = { path = "../common" } pcid = { path = "../pcid" } diff --git a/xhcid/src/main.rs b/xhcid/src/main.rs index 8ccfd50653..decacdd666 100644 --- a/xhcid/src/main.rs +++ b/xhcid/src/main.rs @@ -19,7 +19,7 @@ use event::{Event, EventQueue}; use redox_log::{RedoxLogger, OutputBuilder}; use syscall::data::Packet; use syscall::error::EWOULDBLOCK; -use syscall::flag::{EventFlags, PHYSMAP_NO_CACHE, PHYSMAP_WRITE}; +use syscall::flag::EventFlags; use syscall::scheme::Scheme; use syscall::io::Io; @@ -264,8 +264,8 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! { }; let address = unsafe { - syscall::physmap(bar_ptr as usize, bar_size as usize, PHYSMAP_WRITE | PHYSMAP_NO_CACHE) - .expect("xhcid: failed to map address") + common::physmap(bar_ptr as usize, bar_size as usize, common::Prot::RW, common::MemoryType::Uncacheable) + .expect("xhcid: failed to map address") as usize }; let (mut irq_file, interrupt_method) = get_int_method(&mut pcid_handle, address);