Remove all usages of physunmap.
This commit is contained in:
+1
-1
@@ -126,7 +126,7 @@ impl Deref for PhysmapGuard {
|
||||
impl Drop for PhysmapGuard {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
let _ = syscall::physunmap(self.virt as usize);
|
||||
let _ = syscall::funmap(self.virt as usize, self.size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ impl DerefMut for DrhdPage {
|
||||
impl Drop for DrhdPage {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
let _ = syscall::physunmap(self.virt as usize);
|
||||
let _ = syscall::funmap(self.virt as usize, crate::acpi::PAGE_SIZE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ impl MappedPage {
|
||||
impl Drop for MappedPage {
|
||||
fn drop(&mut self) {
|
||||
log::trace!("Drop page {:#x}", self.phys_page);
|
||||
if let Err(e) = unsafe { syscall::physunmap(self.virt_page) } {
|
||||
log::error!("physunmap: {:?}", e);
|
||||
if let Err(e) = unsafe { syscall::funmap(self.virt_page, PAGE_SIZE) } {
|
||||
log::error!("funmap (phys): {:?}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,4 +1,5 @@
|
||||
#![cfg_attr(target_arch = "aarch64", feature(stdsimd))] // Required for yield instruction
|
||||
#![feature(int_roundings)]
|
||||
|
||||
extern crate syscall;
|
||||
extern crate byteorder;
|
||||
@@ -8,6 +9,7 @@ use std::fs::File;
|
||||
use std::io::{ErrorKind, Read, Write};
|
||||
use std::os::unix::io::{FromRawFd, RawFd};
|
||||
|
||||
use syscall::PAGE_SIZE;
|
||||
use syscall::error::{Error, ENODEV};
|
||||
use syscall::data::{Event, Packet};
|
||||
use syscall::flag::{EVENT_READ, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
|
||||
@@ -89,7 +91,7 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
|
||||
info!(" + AHCI {} on: {:X} size: {} IRQ: {}", name, bar, bar_size, irq);
|
||||
|
||||
let address = unsafe {
|
||||
syscall::physmap(bar, (bar_size+4095)/4096*4096, PHYSMAP_WRITE | PHYSMAP_NO_CACHE)
|
||||
syscall::physmap(bar, bar_size.next_multiple_of(PAGE_SIZE), PHYSMAP_WRITE | PHYSMAP_NO_CACHE)
|
||||
.expect("ahcid: failed to map address")
|
||||
};
|
||||
{
|
||||
@@ -200,7 +202,6 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
|
||||
}
|
||||
}
|
||||
}
|
||||
unsafe { let _ = syscall::physunmap(address); }
|
||||
|
||||
std::process::exit(0);
|
||||
}
|
||||
|
||||
@@ -141,7 +141,6 @@ fn main() {
|
||||
}).expect("alxd: failed to write event");
|
||||
}
|
||||
}
|
||||
unsafe { let _ = syscall::physunmap(address); }
|
||||
std::process::exit(0);
|
||||
}).expect("alxd: failed to daemonize");
|
||||
}
|
||||
|
||||
@@ -193,9 +193,6 @@ fn main() {
|
||||
send_events(event_count);
|
||||
}
|
||||
}
|
||||
unsafe {
|
||||
let _ = syscall::physunmap(address);
|
||||
}
|
||||
process::exit(0);
|
||||
}).expect("e1000d: failed to create daemon");
|
||||
}
|
||||
|
||||
+11
-6
@@ -1,4 +1,4 @@
|
||||
use syscall::{PHYSMAP_WRITE, PHYSMAP_NO_CACHE};
|
||||
use syscall::{PHYSMAP_WRITE, PHYSMAP_NO_CACHE, PAGE_SIZE};
|
||||
use syscall::error::{Error, EIO, Result};
|
||||
use syscall::io::{Mmio, Io};
|
||||
use std::result;
|
||||
@@ -289,8 +289,10 @@ pub struct StreamBuffer {
|
||||
|
||||
impl StreamBuffer {
|
||||
pub fn new(block_length: usize, block_count: usize) -> result::Result<StreamBuffer, &'static str> {
|
||||
let page_aligned_size = (block_length * block_count).next_multiple_of(PAGE_SIZE);
|
||||
|
||||
let phys = match unsafe {
|
||||
syscall::physalloc(block_length * block_count)
|
||||
syscall::physalloc(page_aligned_size)
|
||||
} {
|
||||
Ok(phys) => phys,
|
||||
Err(_err) => {
|
||||
@@ -299,17 +301,18 @@ impl StreamBuffer {
|
||||
};
|
||||
|
||||
let addr = match unsafe {
|
||||
syscall::physmap(phys, block_length * block_count, PHYSMAP_WRITE | PHYSMAP_NO_CACHE)
|
||||
syscall::physmap(phys, page_aligned_size, PHYSMAP_WRITE | PHYSMAP_NO_CACHE)
|
||||
} {
|
||||
Ok(addr) => addr,
|
||||
Err(_err) => {
|
||||
unsafe {
|
||||
syscall::physfree(phys, block_length * block_count);
|
||||
syscall::physfree(phys, page_aligned_size);
|
||||
}
|
||||
return Err("Could not map physical memory for buffer.");
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: Already zeroed by kernel?
|
||||
unsafe {
|
||||
ptr::write_bytes(addr as *mut u8, 0, block_length * block_count);
|
||||
}
|
||||
@@ -370,8 +373,10 @@ impl Drop for StreamBuffer {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
log::debug!("IHDA: Deallocating buffer.");
|
||||
if syscall::physunmap(self.addr).is_ok() {
|
||||
let _ = syscall::physfree(self.phys, self.block_len * self.block_cnt);
|
||||
let page_aligned_size = (self.block_len * self.block_cnt).next_multiple_of(PAGE_SIZE);
|
||||
|
||||
if syscall::funmap(self.addr, page_aligned_size).is_ok() {
|
||||
let _ = syscall::physfree(self.phys, page_aligned_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,5 @@
|
||||
//#![deny(warnings)]
|
||||
#![feature(int_roundings)]
|
||||
|
||||
extern crate bitflags;
|
||||
extern crate spin;
|
||||
@@ -300,7 +301,6 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe { let _ = syscall::physunmap(address); }
|
||||
std::process::exit(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -195,9 +195,6 @@ fn main() {
|
||||
send_events(event_count);
|
||||
}
|
||||
}
|
||||
unsafe {
|
||||
let _ = syscall::physunmap(address);
|
||||
}
|
||||
std::process::exit(0);
|
||||
}).expect("ixgbed: failed to daemonize");
|
||||
|
||||
|
||||
+3
-2
@@ -1,4 +1,5 @@
|
||||
#![cfg_attr(target_arch = "aarch64", feature(stdsimd))] // Required for yield instruction
|
||||
#![feature(int_roundings)]
|
||||
|
||||
use std::convert::TryInto;
|
||||
use std::fs::File;
|
||||
@@ -11,7 +12,7 @@ use std::{slice, usize};
|
||||
use pcid_interface::{PciBar, PciFeature, PciFeatureInfo, PciFunction, PcidServerHandle};
|
||||
use syscall::{
|
||||
Event, Mmio, Packet, Result, SchemeBlockMut, PHYSMAP_NO_CACHE,
|
||||
PHYSMAP_WRITE,
|
||||
PHYSMAP_WRITE, PAGE_SIZE,
|
||||
};
|
||||
use redox_log::{OutputBuilder, RedoxLogger};
|
||||
|
||||
@@ -42,7 +43,7 @@ impl Bar {
|
||||
|
||||
impl Drop for Bar {
|
||||
fn drop(&mut self) {
|
||||
let _ = unsafe { syscall::physunmap(self.physical) };
|
||||
let _ = unsafe { syscall::funmap(self.physical, self.bar_size.next_multiple_of(PAGE_SIZE)) };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ use std::{fmt, fs, io, mem, ptr, slice};
|
||||
use std::collections::BTreeMap;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use syscall::PAGE_SIZE;
|
||||
use syscall::flag::PhysmapFlags;
|
||||
|
||||
use smallvec::SmallVec;
|
||||
@@ -172,7 +173,7 @@ impl Pcie {
|
||||
};
|
||||
let mut maps_lock = self.maps.lock().unwrap();
|
||||
let virt_pointer = maps_lock.entry((bus, dev, func)).or_insert_with(|| {
|
||||
syscall::physmap(base_address_phys as usize + Self::addr_offset_in_bytes(starting_bus, bus, dev, func, 0), 4096, PhysmapFlags::PHYSMAP_NO_CACHE | PhysmapFlags::PHYSMAP_WRITE).unwrap_or_else(|error| panic!("failed to physmap pcie configuration space for {:2x}:{:2x}.{:2x}: {:?}", bus, dev, func, error)) as *mut u32
|
||||
syscall::physmap(base_address_phys as usize + Self::addr_offset_in_bytes(starting_bus, bus, dev, func, 0), PAGE_SIZE, PhysmapFlags::PHYSMAP_NO_CACHE | PhysmapFlags::PHYSMAP_WRITE).unwrap_or_else(|error| panic!("failed to physmap pcie configuration space for {:2x}:{:2x}.{:2x}: {:?}", bus, dev, func, error)) as *mut u32
|
||||
});
|
||||
f(Some(&mut *virt_pointer.offset((offset as usize / mem::size_of::<u32>()) as isize)))
|
||||
}
|
||||
@@ -207,7 +208,7 @@ impl CfgAccess for Pcie {
|
||||
impl Drop for Pcie {
|
||||
fn drop(&mut self) {
|
||||
for address in self.maps.lock().unwrap().values().copied() {
|
||||
let _ = unsafe { syscall::physunmap(address as usize) };
|
||||
let _ = unsafe { syscall::funmap(address as usize, PAGE_SIZE) };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,9 +459,6 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
|
||||
send_events(event_count);
|
||||
}
|
||||
}
|
||||
unsafe {
|
||||
let _ = syscall::physunmap(address);
|
||||
}
|
||||
process::exit(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -296,7 +296,6 @@ fn main() {
|
||||
|
||||
event_queue.run().expect("vboxd: failed to run event loop");
|
||||
}
|
||||
unsafe { let _ = syscall::physunmap(address); }
|
||||
|
||||
std::process::exit(0);
|
||||
}).expect("vboxd: failed to daemonize");
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#![feature(int_roundings)]
|
||||
extern crate orbclient;
|
||||
extern crate syscall;
|
||||
|
||||
|
||||
+3
-2
@@ -2,7 +2,7 @@ use std::collections::BTreeMap;
|
||||
use std::{mem, ptr, slice, str};
|
||||
|
||||
use orbclient::{Event, EventOption};
|
||||
use syscall::{Error, EventFlags, EACCES, EBADF, EINVAL, ENOENT, Map, O_NONBLOCK, physmap, physunmap, PHYSMAP_WRITE, PHYSMAP_WRITE_COMBINE, Result, SchemeMut};
|
||||
use syscall::{Error, EventFlags, EACCES, EBADF, EINVAL, ENOENT, Map, O_NONBLOCK, physmap, PHYSMAP_WRITE, PHYSMAP_WRITE_COMBINE, Result, SchemeMut, PAGE_SIZE};
|
||||
|
||||
use crate::{
|
||||
display::Display,
|
||||
@@ -102,7 +102,8 @@ impl DisplayScheme {
|
||||
|
||||
// Unmap old onscreen
|
||||
unsafe {
|
||||
physunmap(self.onscreens[fb_i].as_mut_ptr() as usize).expect("vesad: failed to unmap framebuffer");
|
||||
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");
|
||||
}
|
||||
|
||||
// Map new onscreen
|
||||
|
||||
@@ -333,8 +333,5 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! {
|
||||
|
||||
event_queue.run().expect("xhcid: failed to handle events");
|
||||
|
||||
unsafe {
|
||||
let _ = syscall::physunmap(address);
|
||||
}
|
||||
std::process::exit(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user