Commit e6510c20 authored by Jeremy Soller's avatar Jeremy Soller

Merge branch 'update-syscall' into 'master'

vesad: Update redox_syscall

See merge request !74
parents 31bae743 c255a869
This diff is collapsed.
......@@ -23,3 +23,4 @@ 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" }
orbclient = { git = "https://gitlab.redox-os.org/redox-os/orbclient.git", version = "0.3.28" }
......@@ -7,7 +7,7 @@ edition = "2018"
orbclient = "0.3.27"
ransid = "0.4"
rusttype = { version = "0.2", optional = true }
redox_syscall = "0.1"
redox_syscall = "0.2.1"
[features]
default = []
......@@ -38,7 +38,7 @@ fn main() {
let physbaseptr;
{
let mode_info = unsafe { &*(physmap(0x5200, 4096, 0).expect("vesad: failed to map VBE info") as *const VBEModeInfo) };
let mode_info = unsafe { &*(physmap(0x5200, 4096, syscall::PhysmapFlags::empty()).expect("vesad: failed to map VBE info") as *const VBEModeInfo) };
width = mode_info.xresolution as usize;
height = mode_info.yresolution as usize;
......@@ -53,7 +53,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(syscall::CloneFlags::empty()).unwrap() };
if pid != 0 {
drop(write);
......@@ -113,7 +113,7 @@ fn main() {
}
for (handle_id, handle) in scheme.handles.iter_mut() {
if handle.events & EVENT_READ == 0 {
if !handle.events.contains(EVENT_READ) {
continue;
}
......@@ -135,7 +135,7 @@ fn main() {
gid: 0,
a: syscall::number::SYS_FEVENT,
b: *handle_id,
c: EVENT_READ,
c: EVENT_READ.bits(),
d: count
};
......
......@@ -2,7 +2,7 @@ use std::collections::BTreeMap;
use std::{mem, slice, str};
use orbclient::{Event, EventOption};
use syscall::{Result, Error, EACCES, EBADF, EINVAL, ENOENT, O_NONBLOCK, Map, SchemeMut};
use syscall::{Error, EventFlags, EACCES, EBADF, EINVAL, ENOENT, Map, OldMap, O_NONBLOCK, Result, SchemeMut};
use crate::display::Display;
use crate::screen::{Screen, GraphicScreen, TextScreen};
......@@ -17,7 +17,7 @@ pub enum HandleKind {
pub struct Handle {
pub kind: HandleKind,
pub flags: usize,
pub events: usize,
pub events: EventFlags,
pub notified_read: bool
}
......@@ -81,7 +81,7 @@ impl SchemeMut for DisplayScheme {
self.handles.insert(id, Handle {
kind: HandleKind::Input,
flags: flags,
events: 0,
events: EventFlags::empty(),
notified_read: false
});
......@@ -106,7 +106,7 @@ impl SchemeMut for DisplayScheme {
self.handles.insert(id, Handle {
kind: HandleKind::Screen(screen_i),
flags: flags,
events: 0,
events: EventFlags::empty(),
notified_read: false
});
......@@ -132,14 +132,14 @@ impl SchemeMut for DisplayScheme {
Ok(new_id)
}
fn fevent(&mut self, id: usize, flags: usize) -> Result<usize> {
fn fevent(&mut self, id: usize, flags: syscall::EventFlags) -> Result<syscall::EventFlags> {
let handle = self.handles.get_mut(&id).ok_or(Error::new(EBADF))?;
handle.notified_read = false;
if let HandleKind::Screen(_screen_i) = handle.kind {
handle.events = flags;
Ok(0)
Ok(syscall::EventFlags::empty())
} else {
Err(Error::new(EBADF))
}
......@@ -156,6 +156,14 @@ impl SchemeMut for DisplayScheme {
Err(Error::new(EBADF))
}
fn fmap_old(&mut self, id: usize, map: &syscall::OldMap) -> syscall::Result<usize> {
self.fmap(id, &Map {
offset: map.offset,
size: map.size,
flags: map.flags,
address: 0,
})
}
fn fpath(&mut self, id: usize, buf: &mut [u8]) -> Result<usize> {
let handle = self.handles.get(&id).ok_or(Error::new(EBADF))?;
......@@ -274,12 +282,12 @@ impl SchemeMut for DisplayScheme {
}
}
fn seek(&mut self, id: usize, pos: usize, whence: usize) -> Result<usize> {
fn seek(&mut self, id: usize, pos: isize, whence: usize) -> Result<isize> {
let handle = self.handles.get(&id).ok_or(Error::new(EBADF))?;
if let HandleKind::Screen(screen_i) = handle.kind {
if let Some(screen) = self.screens.get_mut(&screen_i) {
return screen.seek(pos, whence);
return screen.seek(pos, whence).map(|pos| pos as isize);
}
}
......
......@@ -91,13 +91,13 @@ impl Screen for GraphicScreen {
Ok(size * 4)
}
fn seek(&mut self, pos: usize, whence: usize) -> Result<usize> {
fn seek(&mut self, pos: isize, whence: usize) -> Result<usize> {
let size = self.display.offscreen.len();
self.seek = match whence {
SEEK_SET => cmp::min(size, pos/4),
SEEK_CUR => cmp::max(0, cmp::min(size as isize, self.seek as isize + (pos/4) as isize)) as usize,
SEEK_END => cmp::max(0, cmp::min(size as isize, size as isize + (pos/4) as isize)) as usize,
SEEK_SET => cmp::min(size, (pos/4) as usize),
SEEK_CUR => cmp::max(0, cmp::min(size as isize, self.seek as isize + (pos/4))) as usize,
SEEK_END => cmp::max(0, cmp::min(size as isize, size as isize + (pos/4))) as usize,
_ => return Err(Error::new(EINVAL))
};
......
......@@ -24,7 +24,7 @@ pub trait Screen {
fn write(&mut self, buf: &[u8], sync: bool) -> Result<usize>;
fn seek(&mut self, pos: usize, whence: usize) -> Result<usize>;
fn seek(&mut self, pos: isize, whence: usize) -> Result<usize>;
fn sync(&mut self);
......
......@@ -209,7 +209,7 @@ impl Screen for TextScreen {
Ok(buf.len())
}
fn seek(&mut self, _pos: usize, _whence: usize) -> Result<usize> {
fn seek(&mut self, _pos: isize, _whence: usize) -> Result<usize> {
Ok(0)
}
......
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