Commit 7afaadab authored by Jeremy Soller's avatar Jeremy Soller

Ensure that MMIO memory is mapped without caching

parent e0902810
This diff is collapsed.
......@@ -7,7 +7,7 @@ use std::{env, usize};
use std::fs::File;
use std::io::{Read, Write};
use std::os::unix::io::FromRawFd;
use syscall::{EVENT_READ, PHYSMAP_WRITE, Event, Packet, SchemeBlockMut};
use syscall::{EVENT_READ, PHYSMAP_NO_CACHE, PHYSMAP_WRITE, Event, Packet, SchemeBlockMut};
use scheme::DiskScheme;
......@@ -30,7 +30,7 @@ fn main() {
// Daemonize
if unsafe { syscall::clone(0).unwrap() } == 0 {
let address = unsafe { syscall::physmap(bar, 4096, PHYSMAP_WRITE).expect("ahcid: failed to map address") };
let address = unsafe { syscall::physmap(bar, 4096, PHYSMAP_WRITE | PHYSMAP_NO_CACHE).expect("ahcid: failed to map address") };
{
let scheme_name = format!("disk/{}", name);
let socket_fd = syscall::open(
......
......@@ -16,7 +16,7 @@ use std::os::unix::io::{AsRawFd, FromRawFd};
use std::sync::Arc;
use event::EventQueue;
use syscall::{Packet, SchemeMut, PHYSMAP_WRITE};
use syscall::{Packet, SchemeMut, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
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).expect("alxd: failed to map address") };
let address = unsafe { syscall::physmap(bar, 128*1024, PHYSMAP_WRITE | PHYSMAP_NO_CACHE).expect("alxd: failed to map address") };
{
let device = Arc::new(RefCell::new(unsafe { device::Alx::new(address).expect("alxd: failed to allocate device") }));
......
......@@ -12,7 +12,7 @@ use std::os::unix::io::{AsRawFd, FromRawFd};
use std::sync::Arc;
use event::EventQueue;
use syscall::{Packet, SchemeBlockMut, PHYSMAP_WRITE};
use syscall::{Packet, SchemeBlockMut, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
use syscall::error::EWOULDBLOCK;
pub mod device;
......@@ -69,7 +69,7 @@ fn main() {
let mut irq_file = File::open(format!("irq:{}", irq)).expect("e1000d: failed to open IRQ file");
let address = unsafe { syscall::physmap(bar, 128*1024, PHYSMAP_WRITE).expect("e1000d: failed to map address") };
let address = unsafe { syscall::physmap(bar, 128*1024, PHYSMAP_WRITE | PHYSMAP_NO_CACHE).expect("e1000d: failed to map address") };
{
let device = Arc::new(RefCell::new(unsafe { device::Intel8254x::new(address).expect("e1000d: failed to allocate device") }));
......
......@@ -6,7 +6,7 @@ use std::str;
use std::collections::BTreeMap;
use std::sync::atomic::{AtomicUsize, Ordering};
use syscall::PHYSMAP_WRITE;
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,7 +159,7 @@ impl IntelHDA {
};
let buff_desc_virt = unsafe {
syscall::physmap(buff_desc_phys, 0x1000, PHYSMAP_WRITE)
syscall::physmap(buff_desc_phys, 0x1000, PHYSMAP_WRITE | PHYSMAP_NO_CACHE)
.expect("ihdad: failed to map address for buffer descriptor list.")
};
......@@ -172,7 +172,7 @@ impl IntelHDA {
.expect("Could not allocate physical memory for CORB and RIRB.")
};
let cmd_buff_virt = unsafe { syscall::physmap(cmd_buff_address, 0x1000, PHYSMAP_WRITE).expect("ihdad: failed to map address for CORB/RIRB buff") };
let cmd_buff_virt = unsafe { syscall::physmap(cmd_buff_address, 0x1000, PHYSMAP_WRITE | PHYSMAP_NO_CACHE).expect("ihdad: failed to map address for CORB/RIRB buff") };
print!("Virt: {:016X}, Phys: {:016X}\n", cmd_buff_virt, cmd_buff_address);
let mut module = IntelHDA {
......
use syscall::PHYSMAP_WRITE;
use syscall::{PHYSMAP_WRITE, PHYSMAP_NO_CACHE};
use syscall::error::{Error, EIO, Result};
use syscall::io::{Mmio, Io};
use std::result;
......@@ -301,7 +301,7 @@ impl StreamBuffer {
};
let addr = match unsafe {
syscall::physmap(phys, block_length * block_count, PHYSMAP_WRITE)
syscall::physmap(phys, block_length * block_count, PHYSMAP_WRITE | PHYSMAP_NO_CACHE)
} {
Ok(addr) => addr,
Err(err) => {
......
......@@ -10,7 +10,7 @@ use std::{env, usize};
use std::fs::File;
use std::io::{Read, Write, Result};
use std::os::unix::io::{AsRawFd, FromRawFd};
use syscall::{PHYSMAP_WRITE, Packet, SchemeBlockMut};
use syscall::{PHYSMAP_NO_CACHE, PHYSMAP_WRITE, Packet, SchemeBlockMut};
use std::cell::RefCell;
use std::sync::Arc;
......@@ -47,7 +47,7 @@ fn main() {
// Daemonize
if unsafe { syscall::clone(0).unwrap() } == 0 {
let address = unsafe { syscall::physmap(bar, 0x4000, PHYSMAP_WRITE).expect("ihdad: failed to map address") };
let address = unsafe { syscall::physmap(bar, 0x4000, PHYSMAP_WRITE | PHYSMAP_NO_CACHE).expect("ihdad: failed to map address") };
{
let mut irq_file = File::open(format!("irq:{}", irq)).expect("IHDA: failed to open IRQ file");
......
......@@ -9,7 +9,7 @@ use std::{env, usize};
use std::fs::File;
use std::io::{Read, Write};
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use syscall::{EVENT_READ, PHYSMAP_WRITE, Event, Packet, Result, Scheme};
use syscall::{EVENT_READ, PHYSMAP_NO_CACHE, PHYSMAP_WRITE, Event, Packet, Result, Scheme};
use self::nvme::Nvme;
......@@ -42,7 +42,7 @@ fn main() {
// Daemonize
if unsafe { syscall::clone(0).unwrap() } == 0 {
let address = unsafe { syscall::physmap(bar, 4096, PHYSMAP_WRITE).expect("nvmed: failed to map address") };
let address = unsafe { syscall::physmap(bar, 4096, PHYSMAP_WRITE | PHYSMAP_NO_CACHE).expect("nvmed: failed to map address") };
{
let mut nvme = Nvme::new(address);
nvme.init();
......
......@@ -12,7 +12,7 @@ use std::os::unix::io::{AsRawFd, FromRawFd};
use std::sync::Arc;
use event::EventQueue;
use syscall::{Packet, SchemeMut, PHYSMAP_WRITE};
use syscall::{Packet, SchemeMut, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
use syscall::error::EWOULDBLOCK;
pub mod device;
......@@ -38,7 +38,7 @@ fn main() {
let mut irq_file = File::open(format!("irq:{}", irq)).expect("rtl8168d: failed to open IRQ file");
let address = unsafe { syscall::physmap(bar, 256, PHYSMAP_WRITE).expect("rtl8168d: failed to map address") };
let address = unsafe { syscall::physmap(bar, 256, PHYSMAP_WRITE | PHYSMAP_NO_CACHE).expect("rtl8168d: failed to map address") };
{
let device = Arc::new(RefCell::new(unsafe { device::Rtl8168::new(address).expect("rtl8168d: failed to allocate device") }));
......
......@@ -9,7 +9,7 @@ use std::{env, mem};
use std::os::unix::io::AsRawFd;
use std::fs::File;
use std::io::{Result, Read, Write};
use syscall::flag::PHYSMAP_WRITE;
use syscall::flag::{PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
use syscall::io::{Dma, Io, Mmio, Pio};
use syscall::iopl;
......@@ -217,7 +217,7 @@ fn main() {
let mut irq_file = File::open(format!("irq:{}", irq)).expect("vboxd: failed to open IRQ file");
let mut port = Pio::<u32>::new(bar0 as u16);
let address = unsafe { syscall::physmap(bar1, 4096, PHYSMAP_WRITE).expect("vboxd: failed to map address") };
let address = unsafe { syscall::physmap(bar1, 4096, PHYSMAP_WRITE | PHYSMAP_NO_CACHE).expect("vboxd: failed to map address") };
{
let vmmdev = unsafe { &mut *(address as *mut VboxVmmDev) };
......
......@@ -12,6 +12,7 @@ use std::io::{Result, Read, Write};
use std::os::unix::io::{AsRawFd, FromRawFd};
use std::sync::Arc;
use syscall::data::Packet;
use syscall::flag::{PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
use syscall::error::EWOULDBLOCK;
use syscall::scheme::SchemeMut;
......@@ -41,7 +42,7 @@ fn main() {
let mut irq_file = File::open(format!("irq:{}", irq)).expect("xhcid: failed to open IRQ file");
let address = unsafe { syscall::physmap(bar, 65536, syscall::PHYSMAP_WRITE).expect("xhcid: failed to map address") };
let address = unsafe { syscall::physmap(bar, 65536, PHYSMAP_WRITE | PHYSMAP_NO_CACHE).expect("xhcid: failed to map address") };
{
let hci = Arc::new(RefCell::new(Xhci::new(address).expect("xhcid: failed to allocate device")));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment