From e50576b28c4c6643f2134cc72ead62590af36468 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 9 Jan 2017 20:37:34 -0700 Subject: [PATCH] Updates to use absolute URLs --- crates/dma/Cargo.toml | 6 -- crates/dma/src/lib.rs | 78 ----------------------- crates/event | 1 + crates/event/Cargo.toml | 6 -- crates/event/src/lib.rs | 83 ------------------------- crates/hole_list_allocator/Cargo.toml | 8 --- crates/hole_list_allocator/src/lib.rs | 62 ------------------- crates/io/Cargo.toml | 3 - crates/io/src/io.rs | 67 -------------------- crates/io/src/lib.rs | 14 ----- crates/io/src/mmio.rs | 31 ---------- crates/io/src/pio.rs | 89 --------------------------- schemes/ethernetd/Cargo.toml | 5 +- schemes/example/Cargo.toml | 2 +- schemes/ipd/Cargo.toml | 5 +- schemes/ptyd/Cargo.toml | 2 +- schemes/randd/Cargo.toml | 2 +- schemes/tcpd/Cargo.toml | 7 +-- schemes/udpd/Cargo.toml | 7 +-- 19 files changed, 14 insertions(+), 464 deletions(-) delete mode 100644 crates/dma/Cargo.toml delete mode 100644 crates/dma/src/lib.rs create mode 160000 crates/event delete mode 100644 crates/event/Cargo.toml delete mode 100644 crates/event/src/lib.rs delete mode 100644 crates/hole_list_allocator/Cargo.toml delete mode 100644 crates/hole_list_allocator/src/lib.rs delete mode 100644 crates/io/Cargo.toml delete mode 100644 crates/io/src/io.rs delete mode 100644 crates/io/src/lib.rs delete mode 100644 crates/io/src/mmio.rs delete mode 100644 crates/io/src/pio.rs diff --git a/crates/dma/Cargo.toml b/crates/dma/Cargo.toml deleted file mode 100644 index 24c1b8e..0000000 --- a/crates/dma/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "dma" -version = "0.1.0" - -[dependencies] -redox_syscall = { path = "../../syscall/" } diff --git a/crates/dma/src/lib.rs b/crates/dma/src/lib.rs deleted file mode 100644 index 557b60a..0000000 --- a/crates/dma/src/lib.rs +++ /dev/null @@ -1,78 +0,0 @@ -extern crate syscall; - -use std::{mem, ptr}; -use std::ops::{Deref, DerefMut}; - -use syscall::Result; - -struct PhysBox { - address: usize, - size: usize -} - -impl PhysBox { - fn new(size: usize) -> Result { - let address = unsafe { syscall::physalloc(size)? }; - Ok(PhysBox { - address: address, - size: size - }) - } -} - -impl Drop for PhysBox { - fn drop(&mut self) { - let _ = unsafe { syscall::physfree(self.address, self.size) }; - } -} - -pub struct Dma { - phys: PhysBox, - virt: *mut T -} - -impl Dma { - pub fn new(value: T) -> Result> { - let phys = PhysBox::new(mem::size_of::())?; - let virt = unsafe { syscall::physmap(phys.address, phys.size, syscall::MAP_WRITE)? } as *mut T; - unsafe { ptr::write(virt, value); } - Ok(Dma { - phys: phys, - virt: virt - }) - } - - pub fn zeroed() -> Result> { - let phys = PhysBox::new(mem::size_of::())?; - let virt = unsafe { syscall::physmap(phys.address, phys.size, syscall::MAP_WRITE)? } as *mut T; - unsafe { ptr::write_bytes(virt as *mut u8, 0, phys.size); } - Ok(Dma { - phys: phys, - virt: virt - }) - } - - pub fn physical(&self) -> usize { - self.phys.address - } -} - -impl Deref for Dma { - type Target = T; - fn deref(&self) -> &T { - unsafe { &*self.virt } - } -} - -impl DerefMut for Dma { - fn deref_mut(&mut self) -> &mut T { - unsafe { &mut *self.virt } - } -} - -impl Drop for Dma { - fn drop(&mut self) { - unsafe { drop(ptr::read(self.virt)); } - let _ = unsafe { syscall::physunmap(self.virt as usize) }; - } -} diff --git a/crates/event b/crates/event new file mode 160000 index 0000000..d8d4724 --- /dev/null +++ b/crates/event @@ -0,0 +1 @@ +Subproject commit d8d472487f5e666b8c61a54326d3f89e4a816fec diff --git a/crates/event/Cargo.toml b/crates/event/Cargo.toml deleted file mode 100644 index d382ece..0000000 --- a/crates/event/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "event" -version = "0.1.0" - -[dependencies] -redox_syscall = { path = "../../syscall/" } diff --git a/crates/event/src/lib.rs b/crates/event/src/lib.rs deleted file mode 100644 index a3662a0..0000000 --- a/crates/event/src/lib.rs +++ /dev/null @@ -1,83 +0,0 @@ -extern crate syscall; - -use std::collections::BTreeMap; -use std::fs::File; -use std::io::{Read, Error, Result}; -use std::os::unix::io::RawFd; - -pub struct EventQueue { - /// The file to read events from - file: File, - /// A map of registered file descriptors to their handler callbacks - callbacks: BTreeMap Result>>> -} - -impl EventQueue { - /// Create a new event queue - pub fn new() -> Result> { - Ok(EventQueue { - file: File::open("event:")?, - callbacks: BTreeMap::new() - }) - } - - /// Add a file to the event queue, calling a callback when an event occurs - /// - /// The callback is given a mutable reference to the file and the event data - /// (typically the length of data available for read) - /// - /// The callback returns Ok(None) if it wishes to continue the event loop, - /// or Ok(Some(R)) to break the event loop and return the value. - /// Err can be used to allow the callback to return an I/O error, and break the - /// event loop - pub fn add Result> + 'static>(&mut self, fd: RawFd, callback: F) -> Result<()> { - syscall::fevent(fd, syscall::EVENT_READ).map_err(|x| Error::from_raw_os_error(x.errno))?; - - self.callbacks.insert(fd, Box::new(callback)); - - Ok(()) - } - - /// Remove a file from the event queue, returning its callback if found - pub fn remove(&mut self, fd: RawFd) -> Result Result>>>> { - if let Some(callback) = self.callbacks.remove(&fd) { - syscall::fevent(fd, 0).map_err(|x| Error::from_raw_os_error(x.errno))?; - - Ok(Some(callback)) - } else { - Ok(None) - } - } - - /// Send an event to a descriptor callback - pub fn trigger(&mut self, fd: RawFd, count: usize) -> Result> { - if let Some(callback) = self.callbacks.get_mut(&fd) { - callback(count) - } else { - Ok(None) - } - } - - /// Send an event to all descriptor callbacks, useful for cleaning out buffers after init - pub fn trigger_all(&mut self, count: usize) -> Result> { - let mut rets = Vec::new(); - for (_fd, callback) in self.callbacks.iter_mut() { - if let Some(ret) = callback(count)? { - rets.push(ret); - } - } - Ok(rets) - } - - /// Process the event queue until a callback returns Some(R) - pub fn run(&mut self) -> Result { - loop { - let mut event = syscall::Event::default(); - if self.file.read(&mut event)? > 0 { - if let Some(ret) = self.trigger(event.id, event.data)? { - return Ok(ret); - } - } - } - } -} diff --git a/crates/hole_list_allocator/Cargo.toml b/crates/hole_list_allocator/Cargo.toml deleted file mode 100644 index 5ef3a50..0000000 --- a/crates/hole_list_allocator/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -authors = ["Philipp Oppermann "] -name = "hole_list_allocator" -version = "0.1.0" - -[dependencies] -linked_list_allocator = { git = "https://github.com/phil-opp/linked-list-allocator.git" } -spin = "*" diff --git a/crates/hole_list_allocator/src/lib.rs b/crates/hole_list_allocator/src/lib.rs deleted file mode 100644 index df90843..0000000 --- a/crates/hole_list_allocator/src/lib.rs +++ /dev/null @@ -1,62 +0,0 @@ -#![feature(allocator)] -#![feature(const_fn)] - -#![allocator] -#![no_std] - -use spin::Mutex; -use linked_list_allocator::Heap; - -extern crate spin; -extern crate linked_list_allocator; - -static HEAP: Mutex> = Mutex::new(None); - -pub unsafe fn init(offset: usize, size: usize) { - *HEAP.lock() = Some(Heap::new(offset, size)); -} - -#[no_mangle] -pub extern fn __rust_allocate(size: usize, align: usize) -> *mut u8 { - if let Some(ref mut heap) = *HEAP.lock() { - heap.allocate_first_fit(size, align).expect("out of memory") - } else { - panic!("__rust_allocate: heap not initialized"); - } -} - -#[no_mangle] -pub extern fn __rust_deallocate(ptr: *mut u8, size: usize, align: usize) { - if let Some(ref mut heap) = *HEAP.lock() { - unsafe { heap.deallocate(ptr, size, align) }; - } else { - panic!("__rust_deallocate: heap not initialized"); - } -} - -#[no_mangle] -pub extern fn __rust_usable_size(size: usize, _align: usize) -> usize { - size -} - -#[no_mangle] -pub extern fn __rust_reallocate_inplace(_ptr: *mut u8, size: usize, - _new_size: usize, _align: usize) -> usize -{ - size -} - -#[no_mangle] -pub extern fn __rust_reallocate(ptr: *mut u8, size: usize, new_size: usize, - align: usize) -> *mut u8 { - use core::{ptr, cmp}; - - // from: https://github.com/rust-lang/rust/blob/ - // c66d2380a810c9a2b3dbb4f93a830b101ee49cc2/ - // src/liballoc_system/lib.rs#L98-L101 - - let new_ptr = __rust_allocate(new_size, align); - unsafe { ptr::copy(ptr, new_ptr, cmp::min(size, new_size)) }; - __rust_deallocate(ptr, size, align); - new_ptr -} diff --git a/crates/io/Cargo.toml b/crates/io/Cargo.toml deleted file mode 100644 index b0ee40b..0000000 --- a/crates/io/Cargo.toml +++ /dev/null @@ -1,3 +0,0 @@ -[package] -name = "io" -version = "0.1.0" diff --git a/crates/io/src/io.rs b/crates/io/src/io.rs deleted file mode 100644 index fb866b5..0000000 --- a/crates/io/src/io.rs +++ /dev/null @@ -1,67 +0,0 @@ -use core::cmp::PartialEq; -use core::ops::{BitAnd, BitOr, Not}; - -pub trait Io { - type Value: Copy + PartialEq + BitAnd + BitOr + Not; - - fn read(&self) -> Self::Value; - fn write(&mut self, value: Self::Value); - - #[inline(always)] - fn readf(&self, flags: Self::Value) -> bool { - (self.read() & flags) as Self::Value == flags - } - - #[inline(always)] - fn writef(&mut self, flags: Self::Value, value: bool) { - let tmp: Self::Value = match value { - true => self.read() | flags, - false => self.read() & !flags, - }; - self.write(tmp); - } -} - -pub struct ReadOnly { - inner: I -} - -impl ReadOnly { - pub const fn new(inner: I) -> ReadOnly { - ReadOnly { - inner: inner - } - } - - #[inline(always)] - pub fn read(&self) -> I::Value { - self.inner.read() - } - - #[inline(always)] - pub fn readf(&self, flags: I::Value) -> bool { - self.inner.readf(flags) - } -} - -pub struct WriteOnly { - inner: I -} - -impl WriteOnly { - pub const fn new(inner: I) -> WriteOnly { - WriteOnly { - inner: inner - } - } - - #[inline(always)] - pub fn write(&mut self, value: I::Value) { - self.inner.write(value) - } - - #[inline(always)] - pub fn writef(&mut self, flags: I::Value, value: bool) { - self.inner.writef(flags, value) - } -} diff --git a/crates/io/src/lib.rs b/crates/io/src/lib.rs deleted file mode 100644 index 22f8eb7..0000000 --- a/crates/io/src/lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -//! I/O functions - -#![feature(asm)] -#![feature(const_fn)] -#![feature(core_intrinsics)] -#![no_std] - -pub use self::io::*; -pub use self::mmio::*; -pub use self::pio::*; - -mod io; -mod mmio; -mod pio; diff --git a/crates/io/src/mmio.rs b/crates/io/src/mmio.rs deleted file mode 100644 index 1a1d199..0000000 --- a/crates/io/src/mmio.rs +++ /dev/null @@ -1,31 +0,0 @@ -use core::intrinsics::{volatile_load, volatile_store}; -use core::mem::uninitialized; -use core::ops::{BitAnd, BitOr, Not}; - -use super::io::Io; - -#[repr(packed)] -pub struct Mmio { - value: T, -} - -impl Mmio { - /// Create a new Mmio without initializing - pub fn new() -> Self { - Mmio { - value: unsafe { uninitialized() } - } - } -} - -impl Io for Mmio where T: Copy + PartialEq + BitAnd + BitOr + Not { - type Value = T; - - fn read(&self) -> T { - unsafe { volatile_load(&self.value) } - } - - fn write(&mut self, value: T) { - unsafe { volatile_store(&mut self.value, value) }; - } -} diff --git a/crates/io/src/pio.rs b/crates/io/src/pio.rs deleted file mode 100644 index 91ae310..0000000 --- a/crates/io/src/pio.rs +++ /dev/null @@ -1,89 +0,0 @@ -use core::marker::PhantomData; - -use super::io::Io; - -/// Generic PIO -#[derive(Copy, Clone)] -pub struct Pio { - port: u16, - value: PhantomData, -} - -impl Pio { - /// Create a PIO from a given port - pub const fn new(port: u16) -> Self { - Pio:: { - port: port, - value: PhantomData, - } - } -} - -/// Read/Write for byte PIO -impl Io for Pio { - type Value = u8; - - /// Read - #[inline(always)] - fn read(&self) -> u8 { - let value: u8; - unsafe { - asm!("in $0, $1" : "={al}"(value) : "{dx}"(self.port) : "memory" : "intel", "volatile"); - } - value - } - - /// Write - #[inline(always)] - fn write(&mut self, value: u8) { - unsafe { - asm!("out $1, $0" : : "{al}"(value), "{dx}"(self.port) : "memory" : "intel", "volatile"); - } - } -} - -/// Read/Write for word PIO -impl Io for Pio { - type Value = u16; - - /// Read - #[inline(always)] - fn read(&self) -> u16 { - let value: u16; - unsafe { - asm!("in $0, $1" : "={ax}"(value) : "{dx}"(self.port) : "memory" : "intel", "volatile"); - } - value - } - - /// Write - #[inline(always)] - fn write(&mut self, value: u16) { - unsafe { - asm!("out $1, $0" : : "{ax}"(value), "{dx}"(self.port) : "memory" : "intel", "volatile"); - } - } -} - -/// Read/Write for doubleword PIO -impl Io for Pio { - type Value = u32; - - /// Read - #[inline(always)] - fn read(&self) -> u32 { - let value: u32; - unsafe { - asm!("in $0, $1" : "={eax}"(value) : "{dx}"(self.port) : "memory" : "intel", "volatile"); - } - value - } - - /// Write - #[inline(always)] - fn write(&mut self, value: u32) { - unsafe { - asm!("out $1, $0" : : "{eax}"(value), "{dx}"(self.port) : "memory" : "intel", "volatile"); - } - } -} diff --git a/schemes/ethernetd/Cargo.toml b/schemes/ethernetd/Cargo.toml index 6e10ca0..eb68975 100644 --- a/schemes/ethernetd/Cargo.toml +++ b/schemes/ethernetd/Cargo.toml @@ -3,6 +3,5 @@ name = "ethernetd" version = "0.1.0" [dependencies] -event = { path = "../../crates/event/" } -netutils = { path = "../../programs/netutils/" } -redox_syscall = { path = "../../syscall/" } +netutils = { git = "https://github.com/redox-os/netutils.git" } +redox_syscall = { git = "https://github.com/redox-os/syscall.git" } diff --git a/schemes/example/Cargo.toml b/schemes/example/Cargo.toml index dcd504b..9ddf8dd 100644 --- a/schemes/example/Cargo.toml +++ b/schemes/example/Cargo.toml @@ -3,4 +3,4 @@ name = "example" version = "0.1.0" [dependencies] -redox_syscall = { path = "../../syscall/" } +redox_syscall = { git = "https://github.com/redox-os/syscall.git" } diff --git a/schemes/ipd/Cargo.toml b/schemes/ipd/Cargo.toml index 23d2f3d..63e9e70 100644 --- a/schemes/ipd/Cargo.toml +++ b/schemes/ipd/Cargo.toml @@ -3,6 +3,5 @@ name = "ipd" version = "0.1.0" [dependencies] -event = { path = "../../crates/event/" } -netutils = { path = "../../programs/netutils/" } -redox_syscall = { path = "../../syscall/" } +netutils = { git = "https://github.com/redox-os/netutils.git" } +redox_syscall = { git = "https://github.com/redox-os/syscall.git" } diff --git a/schemes/ptyd/Cargo.toml b/schemes/ptyd/Cargo.toml index c8001df..69b4365 100644 --- a/schemes/ptyd/Cargo.toml +++ b/schemes/ptyd/Cargo.toml @@ -3,4 +3,4 @@ name = "ptyd" version = "0.1.0" [dependencies] -redox_syscall = { path = "../../syscall/" } +redox_syscall = { git = "https://github.com/redox-os/syscall.git" } diff --git a/schemes/randd/Cargo.toml b/schemes/randd/Cargo.toml index 5ecdeff..2222cf5 100644 --- a/schemes/randd/Cargo.toml +++ b/schemes/randd/Cargo.toml @@ -4,4 +4,4 @@ version = "0.1.0" [dependencies] raw-cpuid = "2.*" -redox_syscall = { path = "../../syscall/" } +redox_syscall = { git = "https://github.com/redox-os/syscall.git" } diff --git a/schemes/tcpd/Cargo.toml b/schemes/tcpd/Cargo.toml index a9c4202..b575718 100644 --- a/schemes/tcpd/Cargo.toml +++ b/schemes/tcpd/Cargo.toml @@ -3,7 +3,6 @@ name = "tcpd" version = "0.1.0" [dependencies] -event = { path = "../../crates/event/" } -netutils = { path = "../../programs/netutils/" } -rand = { git = "https://github.com/rust-lang-nursery/rand.git" } -redox_syscall = { path = "../../syscall/" } +netutils = { git = "https://github.com/redox-os/netutils.git" } +rand = "0.3" +redox_syscall = { git = "https://github.com/redox-os/syscall.git" } diff --git a/schemes/udpd/Cargo.toml b/schemes/udpd/Cargo.toml index a62ffb0..c609ec9 100644 --- a/schemes/udpd/Cargo.toml +++ b/schemes/udpd/Cargo.toml @@ -3,7 +3,6 @@ name = "udpd" version = "0.1.0" [dependencies] -event = { path = "../../crates/event/" } -netutils = { path = "../../programs/netutils/" } -rand = { git = "https://github.com/rust-lang-nursery/rand.git" } -redox_syscall = { path = "../../syscall/" } +netutils = { git = "https://github.com/redox-os/netutils.git" } +rand = "0.3" +redox_syscall = { git = "https://github.com/redox-os/syscall.git" }