Merge branch 'update_dependencies' into 'master'

Update dependencies.

See merge request redox-os/drivers!78
This commit is contained in:
4lDO2
2021-06-18 15:24:25 +00:00
46 changed files with 1059 additions and 999 deletions
Generated
+768 -719
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -23,5 +23,5 @@ members = [
[patch.crates-io]
mio = { git = "https://gitlab.redox-os.org/redox-os/mio.git", branch = "redox-unix" }
net2 = { git = "https://gitlab.redox-os.org/redox-os/net2-rs.git", branch = "redox-unix" }
net2 = { git = "https://gitlab.redox-os.org/redox-os/net2-rs.git", branch = "master" }
orbclient = { git = "https://gitlab.redox-os.org/redox-os/orbclient.git", version = "0.3.28" }
+1 -1
View File
@@ -13,5 +13,5 @@ num-traits = "0.2"
parking_lot = "0.11.1"
plain = "0.2.3"
redox-log = "0.1.1"
redox_syscall = "0.2.5"
redox_syscall = "0.2.9"
thiserror = "1"
-2
View File
@@ -1,5 +1,3 @@
#![feature(renamed_spin_loop, seek_convenience)]
use std::convert::TryFrom;
use std::io::{self, prelude::*};
use std::fs::{File, OpenOptions};
+2 -2
View File
@@ -8,6 +8,6 @@ bitflags = "1.2"
byteorder = "1.2"
log = "0.4"
partitionlib = { git = "https://gitlab.redox-os.org/redox-os/partitionlib.git" }
redox-log = { git = "https://gitlab.redox-os.org/redox-os/redox-log.git", tag = "v0.1.0" }
redox_syscall = "0.1"
redox-log = "0.1"
redox_syscall = "0.2.9"
block-io-wrapper = { path = "../block-io-wrapper" }
+12 -14
View File
@@ -1,3 +1,4 @@
use std::convert::TryInto;
use std::ptr;
use syscall::io::Dma;
@@ -31,19 +32,16 @@ pub struct DiskATA {
impl DiskATA {
pub fn new(id: usize, port: &'static mut HbaPort) -> Result<Self> {
let mut clb = Dma::zeroed()?;
let mut ctbas = [
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
];
let mut fb = Dma::zeroed()?;
let buf = Dma::zeroed()?;
let mut clb = unsafe { Dma::zeroed()?.assume_init() };
let mut ctbas: [_; 32] = (0..32)
.map(|_| Dma::zeroed().map(|dma| unsafe { dma.assume_init() }))
.collect::<Result<Vec<_>>>()?
.try_into()
.unwrap_or_else(|_| unreachable!());
let mut fb = unsafe { Dma::zeroed()?.assume_init() };
let buf = unsafe { Dma::zeroed()?.assume_init() };
port.init(&mut clb, &mut ctbas, &mut fb);
@@ -55,7 +53,7 @@ impl DiskATA {
size: size,
request_opt: None,
clb: clb,
ctbas: ctbas,
ctbas,
_fb: fb,
buf: buf
})
+17 -19
View File
@@ -1,5 +1,6 @@
#![allow(dead_code)]
use std::convert::TryInto;
use std::ptr;
use byteorder::{ByteOrder, BigEndian};
@@ -27,32 +28,29 @@ pub struct DiskATAPI {
impl DiskATAPI {
pub fn new(id: usize, port: &'static mut HbaPort) -> Result<Self> {
let mut clb = Dma::zeroed()?;
let mut ctbas = [
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
];
let mut fb = Dma::zeroed()?;
let buf = Dma::zeroed()?;
let mut clb = unsafe { Dma::zeroed()?.assume_init() };
let mut ctbas: [_; 32] = (0..32)
.map(|_| Dma::zeroed().map(|dma| unsafe { dma.assume_init() }))
.collect::<Result<Vec<_>>>()?
.try_into()
.unwrap_or_else(|_| unreachable!());
let mut fb = unsafe { Dma::zeroed()?.assume_init() };
let buf = unsafe { Dma::zeroed()?.assume_init() };
port.init(&mut clb, &mut ctbas, &mut fb);
let size = unsafe { port.identify_packet(&mut clb, &mut ctbas).unwrap_or(0) };
Ok(DiskATAPI {
id: id,
port: port,
size: size,
clb: clb,
ctbas: ctbas,
id,
port,
size,
clb,
ctbas,
_fb: fb,
buf: buf
buf,
})
}
+9 -4
View File
@@ -3,13 +3,18 @@
extern crate syscall;
extern crate byteorder;
use log::{error, info};
use redox_log::{OutputBuilder, RedoxLogger};
use std::{env, usize};
use std::fs::File;
use std::io::{ErrorKind, Read, Write};
use std::os::unix::io::{FromRawFd, RawFd};
use syscall::{ENODEV, EVENT_READ, PHYSMAP_NO_CACHE, PHYSMAP_WRITE, Error, Event, Packet, SchemeBlockMut};
use syscall::error::{Error, ENODEV};
use syscall::data::{Event, Packet};
use syscall::flag::{CloneFlags, EVENT_READ, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
use syscall::scheme::SchemeBlockMut;
use log::{error, info};
use redox_log::{OutputBuilder, RedoxLogger};
use crate::scheme::DiskScheme;
@@ -76,7 +81,7 @@ fn main() {
let irq = irq_str.parse::<u8>().expect("ahcid: failed to parse irq");
// Daemonize
if unsafe { syscall::clone(0).unwrap() } != 0 {
if unsafe { syscall::clone(CloneFlags::empty()).unwrap() } != 0 {
return;
}
+8 -6
View File
@@ -148,9 +148,9 @@ impl DiskScheme {
}
impl SchemeBlockMut for DiskScheme {
fn open(&mut self, path: &[u8], flags: usize, uid: u32, _gid: u32) -> Result<Option<usize>> {
fn open(&mut self, path: &str, flags: usize, uid: u32, _gid: u32) -> Result<Option<usize>> {
if uid == 0 {
let path_str = str::from_utf8(path).or(Err(Error::new(ENOENT)))?.trim_matches('/');
let path_str = path.trim_matches('/');
if path_str.is_empty() {
if flags & O_DIRECTORY == O_DIRECTORY || flags & O_STAT == O_STAT {
let mut list = String::new();
@@ -390,7 +390,9 @@ impl SchemeBlockMut for DiskScheme {
}
}
fn seek(&mut self, id: usize, pos: usize, whence: usize) -> Result<Option<usize>> {
fn seek(&mut self, id: usize, pos: isize, whence: usize) -> Result<Option<isize>> {
let pos = pos as usize;
match *self.handles.get_mut(&id).ok_or(Error::new(EBADF))? {
Handle::List(ref mut handle, ref mut size) => {
let len = handle.len() as usize;
@@ -401,7 +403,7 @@ impl SchemeBlockMut for DiskScheme {
_ => return Err(Error::new(EINVAL))
};
Ok(Some(*size))
Ok(Some(*size as isize))
},
Handle::Disk(number, ref mut size) => {
let disk = self.disks.get_mut(number).ok_or(Error::new(EBADF))?;
@@ -413,7 +415,7 @@ impl SchemeBlockMut for DiskScheme {
_ => return Err(Error::new(EINVAL))
};
Ok(Some(*size))
Ok(Some(*size as isize))
}
Handle::Partition(disk_num, part_num, ref mut position) => {
let disk = self.disks.get_mut(disk_num).ok_or(Error::new(EBADF))?;
@@ -426,7 +428,7 @@ impl SchemeBlockMut for DiskScheme {
SEEK_END => cmp::max(0, cmp::min(len as isize, len as isize + pos as isize)) as usize,
_ => return Err(Error::new(EINVAL)),
};
Ok(Some(*position as usize))
Ok(Some(*position as isize))
}
}
}
+2 -2
View File
@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2018"
[dependencies]
bitflags = "0.7"
bitflags = "1"
netutils = { git = "https://gitlab.redox-os.org/redox-os/netutils.git", branch = "redox-unix" }
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox_syscall = "0.1"
redox_syscall = "0.2.9"
+18 -19
View File
@@ -1,8 +1,9 @@
use std::{ptr, thread, time};
use std::convert::TryInto;
use netutils::setcfg;
use syscall::error::{Error, EACCES, EINVAL, EIO, EWOULDBLOCK, Result};
use syscall::flag::O_NONBLOCK;
use syscall::flag::{EventFlags, O_NONBLOCK};
use syscall::io::{Dma, Io, Mmio};
use syscall::scheme;
@@ -275,6 +276,14 @@ pub struct Alx {
tpd_ring: [Dma<[Tpd; 16]>; 4],
}
fn dma_array<T, const N: usize>() -> Result<[Dma<T>; N]> {
Ok((0..N)
.map(|_| Dma::zeroed().map(|dma| unsafe { dma.assume_init() }))
.collect::<Result<Vec<_>>>()?
.try_into()
.unwrap_or_else(|_| unreachable!()))
}
impl Alx {
pub unsafe fn new(base: usize) -> Result<Self> {
let mut module = Alx {
@@ -325,21 +334,11 @@ impl Alx {
hib_patch: false,
is_fpga: false,
rfd_buffer: [
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?
],
rfd_ring: Dma::zeroed()?,
rrd_ring: Dma::zeroed()?,
tpd_buffer: [
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?
],
tpd_ring: [Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?]
rfd_buffer: dma_array()?,
rfd_ring: Dma::zeroed()?.assume_init(),
rrd_ring: Dma::zeroed()?.assume_init(),
tpd_buffer: dma_array()?,
tpd_ring: dma_array()?,
};
module.init()?;
@@ -1789,7 +1788,7 @@ impl Alx {
}
impl scheme::SchemeMut for Alx {
fn open(&mut self, _path: &[u8], flags: usize, uid: u32, _gid: u32) -> Result<usize> {
fn open(&mut self, _path: &str, flags: usize, uid: u32, _gid: u32) -> Result<usize> {
if uid == 0 {
Ok(flags)
} else {
@@ -1886,8 +1885,8 @@ impl scheme::SchemeMut for Alx {
Ok(0)
}
fn fevent(&mut self, _id: usize, _flags: usize) -> Result<usize> {
Ok(0)
fn fevent(&mut self, _id: usize, _flags: EventFlags) -> Result<EventFlags> {
Ok(EventFlags::empty())
}
fn fsync(&mut self, _id: usize) -> Result<usize> {
+5 -5
View File
@@ -16,7 +16,7 @@ use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::sync::Arc;
use event::EventQueue;
use syscall::{Packet, SchemeMut, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
use syscall::{CloneFlags, EventFlags, Packet, SchemeMut, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
use syscall::error::EWOULDBLOCK;
pub mod device;
@@ -36,7 +36,7 @@ fn main() {
print!("{}", format!(" + ALX {} on: {:X}, IRQ: {}\n", name, bar, irq));
// Daemonize
if unsafe { syscall::clone(0).unwrap() } == 0
if unsafe { syscall::clone(CloneFlags::empty()).unwrap() } == 0
{
let socket_fd = syscall::open(":network", syscall::O_RDWR | syscall::O_CREAT | syscall::O_NONBLOCK).expect("alxd: failed to create network scheme");
let socket = Arc::new(RefCell::new(unsafe { File::from_raw_fd(socket_fd as RawFd) }));
@@ -112,7 +112,7 @@ fn main() {
for event_count in event_queue.trigger_all(event::Event {
fd: 0,
flags: 0,
flags: EventFlags::empty(),
}).expect("alxd: failed to trigger events") {
socket.borrow_mut().write(&Packet {
id: 0,
@@ -121,7 +121,7 @@ fn main() {
gid: 0,
a: syscall::number::SYS_FEVENT,
b: 0,
c: syscall::flag::EVENT_READ,
c: syscall::flag::EVENT_READ.bits(),
d: event_count
}).expect("alxd: failed to write event");
}
@@ -136,7 +136,7 @@ fn main() {
gid: 0,
a: syscall::number::SYS_FEVENT,
b: 0,
c: syscall::flag::EVENT_READ,
c: syscall::flag::EVENT_READ.bits(),
d: event_count
}).expect("alxd: failed to write event");
}
+1 -1
View File
@@ -5,4 +5,4 @@ edition = "2018"
[dependencies]
orbclient = "0.3.27"
redox_syscall = "0.1"
redox_syscall = "0.2.9"
+4 -2
View File
@@ -6,8 +6,10 @@ extern crate syscall;
use std::env;
use std::fs::File;
use std::io::{Read, Write};
use syscall::iopl;
use syscall::call::iopl;
use syscall::data::Packet;
use syscall::flag::CloneFlags;
use syscall::scheme::SchemeMut;
use crate::bga::Bga;
@@ -28,7 +30,7 @@ fn main() {
print!("{}", format!(" + BGA {} on: {:X}\n", name, bar));
// Daemonize
if unsafe { syscall::clone(0).unwrap() } == 0 {
if unsafe { syscall::clone(CloneFlags::empty()).unwrap() } == 0 {
unsafe { iopl(3).unwrap() };
let mut socket = File::create(":bga").expect("bgad: failed to create bga scheme");
+1 -1
View File
@@ -12,7 +12,7 @@ pub struct BgaScheme {
}
impl SchemeMut for BgaScheme {
fn open(&mut self, _path: &[u8], _flags: usize, uid: u32, _gid: u32) -> Result<usize> {
fn open(&mut self, _path: &str, _flags: usize, uid: u32, _gid: u32) -> Result<usize> {
if uid == 0 {
Ok(0)
} else {
+2 -2
View File
@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2018"
[dependencies]
bitflags = "0.7"
bitflags = "1"
netutils = { git = "https://gitlab.redox-os.org/redox-os/netutils.git", branch = "redox-unix" }
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox_syscall = "0.1"
redox_syscall = "0.2.9"
+17 -18
View File
@@ -1,9 +1,11 @@
use std::collections::BTreeMap;
use std::convert::TryInto;
use std::{cmp, mem, ptr, slice};
use netutils::setcfg;
use syscall::error::{Error, Result, EACCES, EBADF, EINVAL, EWOULDBLOCK};
use syscall::flag::O_NONBLOCK;
use syscall::flag::{EventFlags, O_NONBLOCK};
use syscall::io::Dma;
use syscall::scheme::SchemeBlockMut;
@@ -113,7 +115,7 @@ fn wrap_ring(index: usize, ring_size: usize) -> usize {
}
impl SchemeBlockMut for Intel8254x {
fn open(&mut self, _path: &[u8], flags: usize, uid: u32, _gid: u32) -> Result<Option<usize>> {
fn open(&mut self, _path: &str, flags: usize, uid: u32, _gid: u32) -> Result<Option<usize>> {
if uid == 0 {
self.next_id += 1;
self.handles.insert(self.next_id, flags);
@@ -218,9 +220,9 @@ impl SchemeBlockMut for Intel8254x {
Ok(Some(i))
}
fn fevent(&mut self, id: usize, _flags: usize) -> Result<Option<usize>> {
fn fevent(&mut self, id: usize, _flags: EventFlags) -> Result<Option<EventFlags>> {
let _flags = self.handles.get(&id).ok_or(Error::new(EBADF))?;
Ok(Some(0))
Ok(Some(EventFlags::empty()))
}
fn fpath(&mut self, id: usize, buf: &mut [u8]) -> Result<Option<usize>> {
@@ -246,26 +248,23 @@ impl SchemeBlockMut 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() }))
.collect::<Result<Vec<_>>>()?
.try_into()
.unwrap_or_else(|_| unreachable!()))
}
impl Intel8254x {
pub unsafe fn new(base: usize) -> Result<Self> {
#[rustfmt::skip]
let mut module = Intel8254x {
base: base,
receive_buffer: [
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
],
receive_ring: Dma::zeroed()?,
transmit_buffer: [
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
],
receive_buffer: dma_array()?,
receive_ring: Dma::zeroed()?.assume_init(),
transmit_buffer: dma_array()?,
receive_index: 0,
transmit_ring: Dma::zeroed()?,
transmit_ring: Dma::zeroed()?.assume_init(),
transmit_ring_free: 16,
transmit_index: 0,
transmit_clean_index: 0,
+4 -4
View File
@@ -12,7 +12,7 @@ use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::sync::Arc;
use event::EventQueue;
use syscall::{Packet, SchemeBlockMut, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
use syscall::{CloneFlags, EventFlags, Packet, SchemeBlockMut, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
pub mod device;
@@ -81,7 +81,7 @@ fn main() {
syscall::pipe2(&mut pipes, 0).unwrap();
let mut read = unsafe { File::from_raw_fd(pipes[0] as RawFd) };
let mut write = unsafe { File::from_raw_fd(pipes[1] as RawFd) };
let pid = unsafe { syscall::clone(0).unwrap() };
let pid = unsafe { syscall::clone(CloneFlags::empty()).unwrap() };
if pid != 0 {
drop(write);
@@ -191,7 +191,7 @@ fn main() {
gid: 0,
a: syscall::number::SYS_FEVENT,
b: *handle_id,
c: syscall::flag::EVENT_READ,
c: syscall::flag::EVENT_READ.bits(),
d: event_count,
})
.expect("e1000d: failed to write event");
@@ -199,7 +199,7 @@ fn main() {
};
for event_count in event_queue
.trigger_all(event::Event { fd: 0, flags: 0 })
.trigger_all(event::Event { fd: 0, flags: EventFlags::empty() })
.expect("e1000d: failed to trigger events")
{
send_events(event_count);
+3 -4
View File
@@ -4,8 +4,7 @@ version = "0.1.0"
edition = "2018"
[dependencies]
bitflags = "0.7"
spin = "0.4"
bitflags = "1"
spin = "0.9"
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox_syscall = "0.1"
redox_syscall = "0.2.9"
+4 -3
View File
@@ -866,7 +866,7 @@ impl Drop for IntelHDA {
}
impl SchemeBlockMut for IntelHDA {
fn open(&mut self, _path: &[u8], _flags: usize, uid: u32, _gid: u32) -> Result<Option<usize>> {
fn open(&mut self, _path: &str, _flags: usize, uid: u32, _gid: u32) -> Result<Option<usize>> {
//let path: Vec<&str>;
/*
match str::from_utf8(_path) {
@@ -901,7 +901,8 @@ impl SchemeBlockMut for IntelHDA {
self.write_to_output(index, buf)
}
fn seek(&mut self, id: usize, pos: usize, whence: usize) -> Result<Option<usize>> {
fn seek(&mut self, id: usize, pos: isize, whence: usize) -> Result<Option<isize>> {
let pos = pos as usize;
let mut handles = self.handles.lock();
match *handles.get_mut(&id).ok_or(Error::new(EBADF))? {
Handle::StrBuf(ref mut strbuf, ref mut size) => {
@@ -912,7 +913,7 @@ impl SchemeBlockMut for IntelHDA {
SEEK_END => cmp::max(0, cmp::min(len as isize, len as isize + pos as isize)) as usize,
_ => return Err(Error::new(EINVAL))
};
Ok(Some(*size))
Ok(Some(*size as isize))
},
_ => Err(Error::new(EINVAL)),
+5 -5
View File
@@ -10,7 +10,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 syscall::{PHYSMAP_NO_CACHE, PHYSMAP_WRITE, Packet, SchemeBlockMut};
use syscall::{CloneFlags, PHYSMAP_NO_CACHE, PHYSMAP_WRITE, Packet, SchemeBlockMut, EventFlags};
use std::cell::RefCell;
use std::sync::Arc;
@@ -49,7 +49,7 @@ fn main() {
print!("{}", format!(" + ihda {} on: {:X} size: {} IRQ: {}\n", name, bar, bar_size, irq));
// Daemonize
if unsafe { syscall::clone(0).unwrap() } == 0 {
if unsafe { syscall::clone(CloneFlags::empty()).unwrap() } == 0 {
let address = unsafe {
syscall::physmap(bar, bar_size, PHYSMAP_WRITE | PHYSMAP_NO_CACHE)
.expect("ihdad: failed to map address")
@@ -136,7 +136,7 @@ fn main() {
for event_count in event_queue.trigger_all(event::Event {
fd: 0,
flags: 0,
flags: EventFlags::empty(),
}).expect("IHDA: failed to trigger events") {
socket.borrow_mut().write(&Packet {
id: 0,
@@ -145,7 +145,7 @@ fn main() {
gid: 0,
a: syscall::number::SYS_FEVENT,
b: 0,
c: syscall::flag::EVENT_READ,
c: syscall::flag::EVENT_READ.bits(),
d: event_count
}).expect("IHDA: failed to write event");
}
@@ -167,7 +167,7 @@ fn main() {
gid: 0,
a: syscall::number::SYS_FEVENT,
b: 0,
c: syscall::flag::EVENT_READ,
c: syscall::flag::EVENT_READ.bits(),
d: event_count
}).expect("IHDA: failed to write event");
}
+1 -1
View File
@@ -6,4 +6,4 @@ version = "1.0.0"
bitflags = "1.0"
netutils = { git = "https://gitlab.redox-os.org/redox-os/netutils.git", branch = "redox-unix" }
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox_syscall = "0.1.54"
redox_syscall = "0.2.9"
+17 -26
View File
@@ -1,10 +1,11 @@
use std::collections::BTreeMap;
use std::convert::TryInto;
use std::time::{Duration, Instant};
use std::{cmp, mem, ptr, slice, thread};
use netutils::setcfg;
use syscall::error::{Error, Result, EACCES, EBADF, EINVAL, EWOULDBLOCK};
use syscall::flag::O_NONBLOCK;
use syscall::flag::{EventFlags, O_NONBLOCK};
use syscall::io::Dma;
use syscall::scheme::SchemeBlockMut;
@@ -30,7 +31,7 @@ fn wrap_ring(index: usize, ring_size: usize) -> usize {
}
impl SchemeBlockMut for Intel8259x {
fn open(&mut self, _path: &[u8], flags: usize, uid: u32, _gid: u32) -> Result<Option<usize>> {
fn open(&mut self, _path: &str, flags: usize, uid: u32, _gid: u32) -> Result<Option<usize>> {
if uid == 0 {
self.next_id += 1;
self.handles.insert(self.next_id, flags);
@@ -146,9 +147,9 @@ impl SchemeBlockMut for Intel8259x {
Ok(Some(i))
}
fn fevent(&mut self, id: usize, _flags: usize) -> Result<Option<usize>> {
fn fevent(&mut self, id: usize, _flags: EventFlags) -> Result<Option<EventFlags>> {
let _flags = self.handles.get(&id).ok_or_else(|| Error::new(EBADF))?;
Ok(Some(0))
Ok(Some(EventFlags::empty()))
}
fn fpath(&mut self, id: usize, buf: &mut [u8]) -> Result<Option<usize>> {
@@ -178,29 +179,19 @@ impl Intel8259x {
let mut module = Intel8259x {
base,
size,
receive_buffer: [
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
],
receive_ring: Dma::zeroed()?,
transmit_buffer: [
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
],
receive_buffer: (0..32)
.map(|_| Dma::zeroed().map(|dma| unsafe { dma.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() }))
.collect::<Result<Vec<_>>>()?
.try_into()
.unwrap_or_else(|_| unreachable!()),
receive_index: 0,
transmit_ring: Dma::zeroed()?,
transmit_ring: unsafe { Dma::zeroed()?.assume_init() },
transmit_ring_free: 32,
transmit_index: 0,
transmit_clean_index: 0,
+4 -4
View File
@@ -11,7 +11,7 @@ use std::{env, thread};
use event::EventQueue;
use std::time::Duration;
use syscall::{Packet, SchemeBlockMut, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
use syscall::{CloneFlags, EventFlags, Packet, SchemeBlockMut, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
pub mod device;
#[rustfmt::skip]
@@ -77,7 +77,7 @@ fn main() {
println!(" + IXGBE {} on: {:X} IRQ: {}", name, bar, irq);
// Daemonize
if unsafe { syscall::clone(0).unwrap() } == 0 {
if unsafe { syscall::clone(CloneFlags::empty()).unwrap() } == 0 {
let socket_fd = syscall::open(
":network",
syscall::O_RDWR | syscall::O_CREAT | syscall::O_NONBLOCK,
@@ -170,7 +170,7 @@ fn main() {
gid: 0,
a: syscall::number::SYS_FEVENT,
b: *handle_id,
c: syscall::flag::EVENT_READ,
c: syscall::flag::EVENT_READ.bits(),
d: event_count,
})
.expect("ixgbed: failed to write event");
@@ -178,7 +178,7 @@ fn main() {
};
for event_count in event_queue
.trigger_all(event::Event { fd: 0, flags: 0 })
.trigger_all(event::Event { fd: 0, flags: EventFlags::empty() })
.expect("ixgbed: failed to trigger events")
{
send_events(event_count);
+3 -3
View File
@@ -5,12 +5,12 @@ edition = "2018"
[dependencies]
arrayvec = "0.5"
bitflags = "0.7"
bitflags = "1"
crossbeam-channel = "0.4"
futures = "0.3"
log = "0.4"
redox-log = { git = "https://gitlab.redox-os.org/redox-os/redox-log.git", tag = "v0.1.0" }
redox_syscall = { git = "https://gitlab.redox-os.org/redox-os/syscall.git" }
redox-log = "0.1"
redox_syscall = "0.2.9"
partitionlib = { git = "https://gitlab.redox-os.org/redox-os/partitionlib.git" }
smallvec = "1"
block-io-wrapper = { path = "../block-io-wrapper" }
+2 -3
View File
@@ -160,10 +160,9 @@ impl DiskScheme {
}
impl SchemeBlockMut for DiskScheme {
fn open(&mut self, path: &[u8], flags: usize, uid: u32, _gid: u32) -> Result<Option<usize>> {
fn open(&mut self, path_str: &str, flags: usize, uid: u32, _gid: u32) -> Result<Option<usize>> {
if uid == 0 {
let path_str = str::from_utf8(path)
.or(Err(Error::new(ENOENT)))?
let path_str = path_str
.trim_matches('/');
if path_str.is_empty() {
if flags & O_DIRECTORY == O_DIRECTORY || flags & O_STAT == O_STAT {
+2 -2
View File
@@ -19,8 +19,8 @@ libc = "0.2"
log = "0.4"
paw = "1.0"
plain = "0.2"
redox-log = { git = "https://gitlab.redox-os.org/redox-os/redox-log.git", tag = "v0.1.0" }
redox_syscall = { git = "https://gitlab.redox-os.org/redox-os/syscall.git" }
redox-log = "0.1"
redox_syscall = "0.2.9"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
smallvec = "1"
+1 -1
View File
@@ -5,4 +5,4 @@ authors = ["Tibor Nagy <xnagytibor@gmail.com>"]
edition = "2018"
[dependencies]
redox_syscall = "0.1"
redox_syscall = "0.2.9"
+4 -2
View File
@@ -3,8 +3,10 @@ mod scheme;
use std::fs::File;
use std::io::{Read, Write};
use syscall::call::iopl;
use syscall::data::Packet;
use syscall::iopl;
use syscall::flag::CloneFlags;
use syscall::scheme::SchemeMut;
use self::pcspkr::Pcspkr;
@@ -12,7 +14,7 @@ use self::scheme::PcspkrScheme;
fn main() {
// Daemonize
if unsafe { syscall::clone(0).unwrap() } == 0 {
if unsafe { syscall::clone(CloneFlags::empty()).unwrap() } == 0 {
unsafe { iopl(3).unwrap() };
let mut socket = File::create(":pcspkr").expect("pcspkrd: failed to create pcspkr scheme");
+1 -1
View File
@@ -12,7 +12,7 @@ pub struct PcspkrScheme {
}
impl SchemeMut for PcspkrScheme {
fn open(&mut self, _path: &[u8], flags: usize, _uid: u32, _gid: u32) -> Result<usize> {
fn open(&mut self, _path: &str, flags: usize, _uid: u32, _gid: u32) -> Result<usize> {
if (flags & O_ACCMODE == 0) && (flags & O_STAT == O_STAT) {
Ok(0)
} else if flags & O_ACCMODE == O_WRONLY {
+2 -2
View File
@@ -4,6 +4,6 @@ version = "0.1.0"
edition = "2018"
[dependencies]
bitflags = "0.7"
bitflags = "1"
orbclient = "0.3.27"
redox_syscall = "0.1"
redox_syscall = "0.2.9"
+33 -33
View File
@@ -1,32 +1,32 @@
use syscall::io::{Io, Pio, ReadOnly, WriteOnly};
bitflags! {
flags StatusFlags: u8 {
const OUTPUT_FULL = 1,
const INPUT_FULL = 1 << 1,
const SYSTEM = 1 << 2,
const COMMAND = 1 << 3,
pub struct StatusFlags: u8 {
const OUTPUT_FULL = 1;
const INPUT_FULL = 1 << 1;
const SYSTEM = 1 << 2;
const COMMAND = 1 << 3;
// Chipset specific
const KEYBOARD_LOCK = 1 << 4,
const KEYBOARD_LOCK = 1 << 4;
// Chipset specific
const SECOND_OUTPUT_FULL = 1 << 5,
const TIME_OUT = 1 << 6,
const PARITY = 1 << 7
const SECOND_OUTPUT_FULL = 1 << 5;
const TIME_OUT = 1 << 6;
const PARITY = 1 << 7;
}
}
bitflags! {
flags ConfigFlags: u8 {
const FIRST_INTERRUPT = 1,
const SECOND_INTERRUPT = 1 << 1,
const POST_PASSED = 1 << 2,
pub struct ConfigFlags: u8 {
const FIRST_INTERRUPT = 1;
const SECOND_INTERRUPT = 1 << 1;
const POST_PASSED = 1 << 2;
// 1 << 3 should be zero
const CONFIG_RESERVED_3 = 1 << 3,
const FIRST_DISABLED = 1 << 4,
const SECOND_DISABLED = 1 << 5,
const FIRST_TRANSLATE = 1 << 6,
const CONFIG_RESERVED_3 = 1 << 3;
const FIRST_DISABLED = 1 << 4;
const SECOND_DISABLED = 1 << 5;
const FIRST_TRANSLATE = 1 << 6;
// 1 << 7 should be zero
const CONFIG_RESERVED_7 = 1 << 7,
const CONFIG_RESERVED_7 = 1 << 7;
}
}
@@ -95,15 +95,15 @@ impl Ps2 {
}
fn wait_write(&mut self) {
while self.status().contains(INPUT_FULL) {}
while self.status().contains(StatusFlags::INPUT_FULL) {}
}
fn wait_read(&mut self) {
while ! self.status().contains(OUTPUT_FULL) {}
while ! self.status().contains(StatusFlags::OUTPUT_FULL) {}
}
fn flush_read(&mut self, message: &str) {
while self.status().contains(OUTPUT_FULL) {
while self.status().contains(StatusFlags::OUTPUT_FULL) {
print!("ps2d: flush {}: {:X}\n", message, self.data.read());
}
}
@@ -191,9 +191,9 @@ impl Ps2 {
pub fn next(&mut self) -> Option<(bool, u8)> {
let status = self.status();
if status.contains(OUTPUT_FULL) {
if status.contains(StatusFlags::OUTPUT_FULL) {
let data = self.data.read();
Some((! status.contains(SECOND_OUTPUT_FULL), data))
Some((! status.contains(StatusFlags::SECOND_OUTPUT_FULL), data))
} else {
None
}
@@ -215,11 +215,11 @@ impl Ps2 {
// Disable clocks, disable interrupts, and disable translate
{
let mut config = self.config();
config.insert(FIRST_DISABLED);
config.insert(SECOND_DISABLED);
config.remove(FIRST_TRANSLATE);
config.remove(FIRST_INTERRUPT);
config.remove(SECOND_INTERRUPT);
config.insert(ConfigFlags::FIRST_DISABLED);
config.insert(ConfigFlags::SECOND_DISABLED);
config.remove(ConfigFlags::FIRST_TRANSLATE);
config.remove(ConfigFlags::FIRST_INTERRUPT);
config.remove(ConfigFlags::SECOND_INTERRUPT);
self.set_config(config);
}
@@ -312,11 +312,11 @@ impl Ps2 {
// Enable clocks and interrupts
{
let mut config = self.config();
config.remove(FIRST_DISABLED);
config.remove(SECOND_DISABLED);
config.insert(FIRST_TRANSLATE);
config.insert(FIRST_INTERRUPT);
config.insert(SECOND_INTERRUPT);
config.remove(ConfigFlags::FIRST_DISABLED);
config.remove(ConfigFlags::SECOND_DISABLED);
config.insert(ConfigFlags::FIRST_TRANSLATE);
config.insert(ConfigFlags::FIRST_INTERRUPT);
config.insert(ConfigFlags::SECOND_INTERRUPT);
self.set_config(config);
}
+3 -2
View File
@@ -11,7 +11,8 @@ use std::io::{Read, Write};
use std::os::unix::fs::OpenOptionsExt;
use std::os::unix::io::AsRawFd;
use syscall::iopl;
use syscall::call::iopl;
use syscall::flag::CloneFlags;
use crate::state::Ps2d;
@@ -113,7 +114,7 @@ fn main() {
match OpenOptions::new().write(true).open("display:input") {
Ok(input) => {
// Daemonize
if unsafe { syscall::clone(0).unwrap() } == 0 {
if unsafe { syscall::clone(CloneFlags::empty()).unwrap() } == 0 {
daemon(input);
}
},
+18 -18
View File
@@ -1,23 +1,23 @@
use orbclient::{KeyEvent, MouseEvent, MouseRelativeEvent, ButtonEvent, ScrollEvent};
use std::fs::File;
use std::io::Write;
use std::os::unix::io::AsRawFd;
use std::str;
use syscall;
use orbclient::{KeyEvent, MouseEvent, MouseRelativeEvent, ButtonEvent, ScrollEvent};
use crate::controller::Ps2;
use crate::vm;
bitflags! {
flags MousePacketFlags: u8 {
const LEFT_BUTTON = 1,
const RIGHT_BUTTON = 1 << 1,
const MIDDLE_BUTTON = 1 << 2,
const ALWAYS_ON = 1 << 3,
const X_SIGN = 1 << 4,
const Y_SIGN = 1 << 5,
const X_OVERFLOW = 1 << 6,
const Y_OVERFLOW = 1 << 7
pub struct MousePacketFlags: u8 {
const LEFT_BUTTON = 1;
const RIGHT_BUTTON = 1 << 1;
const MIDDLE_BUTTON = 1 << 2;
const ALWAYS_ON = 1 << 3;
const X_SIGN = 1 << 4;
const Y_SIGN = 1 << 5;
const X_OVERFLOW = 1 << 6;
const Y_OVERFLOW = 1 << 7;
}
}
@@ -176,20 +176,20 @@ impl<F: Fn(u8,bool) -> char> Ps2d<F> {
self.packet_i += 1;
let flags = MousePacketFlags::from_bits_truncate(self.packets[0]);
if ! flags.contains(ALWAYS_ON) {
if ! flags.contains(MousePacketFlags::ALWAYS_ON) {
println!("ps2d: mouse misalign {:X}", self.packets[0]);
self.packets = [0; 4];
self.packet_i = 0;
} else if self.packet_i >= self.packets.len() || (!self.extra_packet && self.packet_i >= 3) {
if ! flags.contains(X_OVERFLOW) && ! flags.contains(Y_OVERFLOW) {
if ! flags.contains(MousePacketFlags::X_OVERFLOW) && ! flags.contains(MousePacketFlags::Y_OVERFLOW) {
let mut dx = self.packets[1] as i32;
if flags.contains(X_SIGN) {
if flags.contains(MousePacketFlags::X_SIGN) {
dx -= 0x100;
}
let mut dy = -(self.packets[2] as i32);
if flags.contains(Y_SIGN) {
if flags.contains(MousePacketFlags::Y_SIGN) {
dy += 0x100;
}
@@ -216,9 +216,9 @@ impl<F: Fn(u8,bool) -> char> Ps2d<F> {
}.to_event()).expect("ps2d: failed to write scroll event");
}
let left = flags.contains(LEFT_BUTTON);
let middle = flags.contains(MIDDLE_BUTTON);
let right = flags.contains(RIGHT_BUTTON);
let left = flags.contains(MousePacketFlags::LEFT_BUTTON);
let middle = flags.contains(MousePacketFlags::MIDDLE_BUTTON);
let right = flags.contains(MousePacketFlags::RIGHT_BUTTON);
if left != self.mouse_left || middle != self.mouse_middle || right != self.mouse_right {
self.mouse_left = left;
self.mouse_middle = middle;
+2 -2
View File
@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2018"
[dependencies]
bitflags = "0.7"
bitflags = "1"
netutils = { git = "https://gitlab.redox-os.org/redox-os/netutils.git", branch = "redox-unix" }
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox_syscall = "0.1"
redox_syscall = "0.2.9"
+23 -31
View File
@@ -2,11 +2,12 @@
// See https://people.freebsd.org/~wpaul/RealTek/rtl8169spec-121.pdf
use std::mem;
use std::convert::TryInto;
use std::collections::BTreeMap;
use netutils::setcfg;
use syscall::error::{Error, EACCES, EBADF, EINVAL, EWOULDBLOCK, Result};
use syscall::flag::O_NONBLOCK;
use syscall::flag::{EventFlags, O_NONBLOCK};
use syscall::io::{Dma, Mmio, Io, ReadOnly};
use syscall::scheme::SchemeBlockMut;
@@ -83,7 +84,7 @@ pub struct Rtl8168 {
}
impl SchemeBlockMut for Rtl8168 {
fn open(&mut self, _path: &[u8], flags: usize, uid: u32, _gid: u32) -> Result<Option<usize>> {
fn open(&mut self, _path: &str, flags: usize, uid: u32, _gid: u32) -> Result<Option<usize>> {
if uid == 0 {
self.next_id += 1;
self.handles.insert(self.next_id, flags);
@@ -163,7 +164,7 @@ impl SchemeBlockMut for Rtl8168 {
self.regs.tppoll.writef(1 << 6, true); //Notify of normal priority packet
while self.regs.tppoll.readf(1 << 6) {
unsafe { llvm_asm!("pause"); }
std::hint::spin_loop();
}
self.transmit_i += 1;
@@ -171,13 +172,13 @@ impl SchemeBlockMut for Rtl8168 {
return Ok(Some(i));
}
unsafe { llvm_asm!("pause"); }
std::hint::spin_loop();
}
}
fn fevent(&mut self, id: usize, _flags: usize) -> Result<Option<usize>> {
fn fevent(&mut self, id: usize, _flags: EventFlags) -> Result<Option<EventFlags>> {
let _flags = self.handles.get(&id).ok_or(Error::new(EBADF))?;
Ok(Some(0))
Ok(Some(EventFlags::empty()))
}
fn fpath(&mut self, id: usize, buf: &mut [u8]) -> Result<Option<usize>> {
@@ -220,34 +221,25 @@ impl Rtl8168 {
let mut module = Rtl8168 {
regs: regs,
receive_buffer: [Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?],
receive_ring: Dma::zeroed()?,
receive_buffer: (0..64)
.map(|_| Dma::zeroed().map(|dma| dma.assume_init()))
.collect::<Result<Vec<_>>>()?
.try_into()
.unwrap_or_else(|_| unreachable!()),
receive_ring: Dma::zeroed()?.assume_init(),
receive_i: 0,
transmit_buffer: [Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?,
Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?, Dma::zeroed()?],
transmit_ring: Dma::zeroed()?,
transmit_buffer: (0..16)
.map(|_| Dma::zeroed().map(|dma| dma.assume_init()))
.collect::<Result<Vec<_>>>()?
.try_into()
.unwrap_or_else(|_| unreachable!()),
transmit_ring: Dma::zeroed()?.assume_init(),
transmit_i: 0,
transmit_buffer_h: [Dma::zeroed()?],
transmit_ring_h: Dma::zeroed()?,
transmit_buffer_h: [Dma::zeroed()?.assume_init()],
transmit_ring_h: Dma::zeroed()?.assume_init(),
next_id: 0,
handles: BTreeMap::new()
handles: BTreeMap::new(),
};
module.init();
+4 -4
View File
@@ -12,7 +12,7 @@ use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::sync::Arc;
use event::EventQueue;
use syscall::{Packet, SchemeBlockMut, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
use syscall::{CloneFlags, EventFlags, Packet, SchemeBlockMut, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
pub mod device;
@@ -81,7 +81,7 @@ fn main() {
syscall::pipe2(&mut pipes, 0).unwrap();
let mut read = unsafe { File::from_raw_fd(pipes[0] as RawFd) };
let mut write = unsafe { File::from_raw_fd(pipes[1] as RawFd) };
let pid = unsafe { syscall::clone(0).unwrap() };
let pid = unsafe { syscall::clone(CloneFlags::empty()).unwrap() };
if pid != 0 {
drop(write);
@@ -192,7 +192,7 @@ fn main() {
gid: 0,
a: syscall::number::SYS_FEVENT,
b: *handle_id,
c: syscall::flag::EVENT_READ,
c: syscall::flag::EVENT_READ.bits(),
d: event_count,
})
.expect("rtl8168d: failed to write event");
@@ -200,7 +200,7 @@ fn main() {
};
for event_count in event_queue
.trigger_all(event::Event { fd: 0, flags: 0 })
.trigger_all(event::Event { fd: 0, flags: EventFlags::empty() })
.expect("rtl8168d: failed to trigger events")
{
send_events(event_count);
+1 -1
View File
@@ -10,6 +10,6 @@ license = "MIT"
[dependencies]
base64 = "0.11" # Only for debugging
plain = "0.2"
redox_syscall = { git = "https://gitlab.redox-os.org/redox-os/syscall.git" }
redox_syscall = "0.2.9"
thiserror = "1"
xhcid = { path = "../xhcid" }
+2 -3
View File
@@ -39,15 +39,14 @@ impl<'a> ScsiScheme<'a> {
}
impl<'a> SchemeMut for ScsiScheme<'a> {
fn open(&mut self, path: &[u8], flags: usize, uid: u32, _gid: u32) -> Result<usize> {
fn open(&mut self, path_str: &str, flags: usize, uid: u32, _gid: u32) -> Result<usize> {
if uid != 0 {
return Err(Error::new(EACCES));
}
if flags & O_DIRECTORY != 0 && flags & O_STAT == 0 {
return Err(Error::new(EACCES));
}
let path_str = str::from_utf8(path)
.or(Err(Error::new(ENOENT)))?
let path_str = path_str
.trim_start_matches('/');
let handle = if path_str.is_empty() {
// List
+1 -1
View File
@@ -6,4 +6,4 @@ edition = "2018"
[dependencies]
orbclient = "0.3.27"
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox_syscall = "0.1"
redox_syscall = "0.2.9"
+11 -10
View File
@@ -9,9 +9,10 @@ use std::{env, mem};
use std::os::unix::io::AsRawFd;
use std::fs::File;
use std::io::{Result, Read, Write};
use syscall::flag::{PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
use syscall::call::iopl;
use syscall::flag::{CloneFlags, EventFlags, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
use syscall::io::{Dma, Io, Mmio, Pio};
use syscall::iopl;
use crate::bga::Bga;
@@ -60,7 +61,7 @@ impl VboxGetMouse {
fn request() -> u32 { 1 }
fn new() -> syscall::Result<Dma<Self>> {
let mut packet = Dma::<Self>::zeroed()?;
let mut packet = unsafe { Dma::<Self>::zeroed()?.assume_init() };
packet.header.size.write(mem::size_of::<Self>() as u32);
packet.header.version.write(VBOX_REQUEST_HEADER_VERSION);
@@ -83,7 +84,7 @@ impl VboxSetMouse {
fn request() -> u32 { 2 }
fn new() -> syscall::Result<Dma<Self>> {
let mut packet = Dma::<Self>::zeroed()?;
let mut packet = unsafe { Dma::<Self>::zeroed()?.assume_init() };
packet.header.size.write(mem::size_of::<Self>() as u32);
packet.header.version.write(VBOX_REQUEST_HEADER_VERSION);
@@ -104,7 +105,7 @@ impl VboxAckEvents {
fn request() -> u32 { 41 }
fn new() -> syscall::Result<Dma<Self>> {
let mut packet = Dma::<Self>::zeroed()?;
let mut packet = unsafe { Dma::<Self>::zeroed()?.assume_init() };
packet.header.size.write(mem::size_of::<Self>() as u32);
packet.header.version.write(VBOX_REQUEST_HEADER_VERSION);
@@ -125,7 +126,7 @@ impl VboxGuestCaps {
fn request() -> u32 { 55 }
fn new() -> syscall::Result<Dma<Self>> {
let mut packet = Dma::<Self>::zeroed()?;
let mut packet = unsafe { Dma::<Self>::zeroed()?.assume_init() };
packet.header.size.write(mem::size_of::<Self>() as u32);
packet.header.version.write(VBOX_REQUEST_HEADER_VERSION);
@@ -148,7 +149,7 @@ impl VboxDisplayChange {
fn request() -> u32 { 51 }
fn new() -> syscall::Result<Dma<Self>> {
let mut packet = Dma::<Self>::zeroed()?;
let mut packet = unsafe { Dma::<Self>::zeroed()?.assume_init() };
packet.header.size.write(mem::size_of::<Self>() as u32);
packet.header.version.write(VBOX_REQUEST_HEADER_VERSION);
@@ -170,7 +171,7 @@ impl VboxGuestInfo {
fn request() -> u32 { 50 }
fn new() -> syscall::Result<Dma<Self>> {
let mut packet = Dma::<Self>::zeroed()?;
let mut packet = unsafe { Dma::<Self>::zeroed()?.assume_init() };
packet.header.size.write(mem::size_of::<Self>() as u32);
packet.header.version.write(VBOX_REQUEST_HEADER_VERSION);
@@ -198,7 +199,7 @@ fn main() {
print!("{}", format!(" + VirtualBox {} on: {:X}, {:X}, IRQ {}\n", name, bar0, bar1, irq));
// Daemonize
if unsafe { syscall::clone(0).unwrap() } == 0 {
if unsafe { syscall::clone(CloneFlags::empty()).unwrap() } == 0 {
unsafe { iopl(3).expect("vboxd: failed to get I/O permission"); };
let mut width = 0;
@@ -288,7 +289,7 @@ fn main() {
event_queue.trigger_all(event::Event {
fd: 0,
flags: 0
flags: EventFlags::empty()
}).expect("vboxd: failed to trigger events");
event_queue.run().expect("vboxd: failed to run event loop");
+1 -1
View File
@@ -7,7 +7,7 @@ edition = "2018"
orbclient = "0.3.27"
ransid = "0.4"
rusttype = { version = "0.2", optional = true }
redox_syscall = "0.2.1"
redox_syscall = "0.2.9"
[features]
default = []
+32 -6
View File
@@ -1,7 +1,7 @@
#[cfg(feature="rusttype")]
extern crate rusttype;
use std::alloc::{AllocInit, AllocRef, Global, Layout};
use std::alloc::{Allocator, Global, Layout};
use std::{cmp, slice};
use std::ptr::NonNull;
@@ -42,7 +42,13 @@ impl Display {
#[cfg(not(feature="rusttype"))]
pub fn new(width: usize, height: usize, onscreen: usize) -> Display {
let size = width * height;
let offscreen = unsafe { Global.alloc(Layout::from_size_align_unchecked(size * 4, 4096), AllocInit::Zeroed).unwrap().ptr.as_ptr() };
let offscreen = unsafe {
Global
.allocate_zeroed(Layout::from_size_align_unchecked(size * 4, 4096))
.expect("failed to allocate offscreen memory")
.as_ptr()
};
Display {
width: width,
height: height,
@@ -54,7 +60,12 @@ impl Display {
#[cfg(feature="rusttype")]
pub fn new(width: usize, height: usize, onscreen: usize) -> Display {
let size = width * height;
let offscreen = unsafe { Global.alloc(Layout::from_size_align_unchecked(size * 4, 4096), AllocInit::Zeroed).unwrap().ptr.as_ptr() };
let offscreen = unsafe {
Global
.allocate_zeroed(Layout::from_size_align_unchecked(size * 4, 4096))
.expect("failed to allocate offscreen memory")
.as_ptr()
};
Display {
width: width,
height: height,
@@ -72,7 +83,12 @@ impl Display {
println!("Resize display to {}, {}", width, height);
let size = width * height;
let offscreen = unsafe { Global.alloc(Layout::from_size_align_unchecked(size * 4, 4096), AllocInit::Zeroed).unwrap().ptr.as_ptr() };
let offscreen = unsafe {
Global
.allocate_zeroed(Layout::from_size_align_unchecked(size * 4, 4096))
.expect("failed to allocate offscreen memory when resizing")
.as_ptr()
};
{
let mut old_ptr = self.offscreen.as_ptr();
@@ -105,7 +121,7 @@ impl Display {
let onscreen = self.onscreen.as_mut_ptr();
self.onscreen = unsafe { slice::from_raw_parts_mut(onscreen, size) };
unsafe { Global.dealloc(NonNull::new_unchecked(self.offscreen.as_mut_ptr() as *mut u8), Layout::from_size_align_unchecked(self.offscreen.len() * 4, 4096)) };
unsafe { Global.deallocate(NonNull::new_unchecked(self.offscreen.as_mut_ptr() as *mut u8), Layout::from_size_align_unchecked(self.offscreen.len() * 4, 4096)) };
self.offscreen = unsafe { slice::from_raw_parts_mut(offscreen as *mut u32, size) };
} else {
println!("Display is already {}, {}", width, height);
@@ -273,7 +289,17 @@ impl Display {
}
impl Drop for Display {
#[cold]
fn drop(&mut self) {
unsafe { Global.dealloc(NonNull::new_unchecked(self.offscreen.as_mut_ptr() as *mut u8), Layout::from_size_align_unchecked(self.offscreen.len() * 4, 4096)) };
unsafe {
let offscreen = std::mem::replace(&mut self.offscreen, &mut []);
let layout = Layout::from_size_align(offscreen.len() * 4, 4096).unwrap();
Global.deallocate(
NonNull::from(offscreen).cast::<u8>(),
layout,
);
}
}
}
+3 -3
View File
@@ -13,15 +13,15 @@ path = "src/lib.rs"
[dependencies]
bitflags = "1"
chashmap = { git = "https://gitlab.redox-os.org/redox-os/chashmap.git" }
chashmap = "2.2.2"
crossbeam-channel = "0.4"
futures = "0.3"
plain = "0.2"
lazy_static = "1.4"
log = "0.4"
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox-log = { git = "https://gitlab.redox-os.org/redox-os/redox-log.git", tag = "v0.1.0" }
redox_syscall = { git = "https://gitlab.redox-os.org/redox-os/syscall.git" }
redox-log = "0.1"
redox_syscall = "0.2.9"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
smallvec = { version = "1", features = ["serde"] }
+2 -2
View File
@@ -20,7 +20,7 @@ use log::info;
use redox_log::{RedoxLogger, OutputBuilder};
use syscall::data::Packet;
use syscall::error::EWOULDBLOCK;
use syscall::flag::{CloneFlags, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
use syscall::flag::{CloneFlags, EventFlags, PHYSMAP_NO_CACHE, PHYSMAP_WRITE};
use syscall::scheme::Scheme;
use syscall::io::Io;
@@ -278,7 +278,7 @@ fn main() {
.expect("xhcid: failed to catch events on scheme file");
event_queue
.trigger_all(Event { fd: 0, flags: 0 })
.trigger_all(Event { fd: 0, flags: EventFlags::empty() })
.expect("xhcid: failed to trigger events");
event_queue.run().expect("xhcid: failed to handle events");
+2 -3
View File
@@ -1252,13 +1252,12 @@ impl Xhci {
}
impl Scheme for Xhci {
fn open(&self, path: &[u8], flags: usize, uid: u32, _gid: u32) -> Result<usize> {
fn open(&self, path_str: &str, flags: usize, uid: u32, _gid: u32) -> Result<usize> {
if uid != 0 {
return Err(Error::new(EACCES));
}
let path_str = str::from_utf8(path)
.or(Err(Error::new(ENOENT)))?
let path_str = path_str
.trim_start_matches('/');
let components = path::Path::new(path_str)