summaryrefslogtreecommitdiffstats
path: root/vendor/redox_syscall
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /vendor/redox_syscall
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/redox_syscall')
-rw-r--r--vendor/redox_syscall/.cargo-checksum.json2
-rw-r--r--vendor/redox_syscall/Cargo.toml14
-rw-r--r--vendor/redox_syscall/src/arch/aarch64.rs32
-rw-r--r--vendor/redox_syscall/src/arch/nonredox.rs3
-rw-r--r--vendor/redox_syscall/src/arch/x86.rs79
-rw-r--r--vendor/redox_syscall/src/arch/x86_64.rs2
-rw-r--r--vendor/redox_syscall/src/call.rs41
-rw-r--r--vendor/redox_syscall/src/daemon.rs62
-rw-r--r--vendor/redox_syscall/src/flag.rs28
-rw-r--r--vendor/redox_syscall/src/io/dma.rs61
-rw-r--r--vendor/redox_syscall/src/lib.rs4
-rw-r--r--vendor/redox_syscall/src/number.rs5
-rw-r--r--vendor/redox_syscall/src/scheme/scheme.rs5
-rw-r--r--vendor/redox_syscall/src/scheme/scheme_block.rs5
-rw-r--r--vendor/redox_syscall/src/scheme/scheme_block_mut.rs5
-rw-r--r--vendor/redox_syscall/src/scheme/scheme_mut.rs5
-rw-r--r--vendor/redox_syscall/src/tests.rs28
17 files changed, 171 insertions, 210 deletions
diff --git a/vendor/redox_syscall/.cargo-checksum.json b/vendor/redox_syscall/.cargo-checksum.json
index 9c62b6521..72e27feeb 100644
--- a/vendor/redox_syscall/.cargo-checksum.json
+++ b/vendor/redox_syscall/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"0e92420005ca47c7854d02e9b637262cc13f800d48614aeef69be2f1119fc19b","LICENSE":"efcfee7981ff72431fffb06925cad00a23dce079ed4354f61030ad5abdb78829","README.md":"9161f18ba7f69b4ca51e844aee8ffb8237513a468c5c3b1f3a5f989044f895ac","src/arch/aarch64.rs":"61b5811b47a29257c3b5e15e7d9d15e7143bad99fbe29f0cb17ead9cbc17186f","src/arch/nonredox.rs":"9eac0fa2cf9eae07f0cafa2dd63c4a820791897a3de9ad1a933ab4f53458dbd8","src/arch/riscv64.rs":"20bf9a8db779059773b113643d0cb3737fbb5d57f45ee39b8ae9d3396b6ef636","src/arch/x86.rs":"7802186155c06638235e49e11f4c046b68f1d8145b2c849adec84497eb3cb70f","src/arch/x86_64.rs":"f40bad2680fd5e7f100ee1afaa805f33dd0e12ec8786b956d47204f66771801d","src/call.rs":"0d3e32e33ecdf75963e5d244f9e86e94047d155c5de5fa3c0085faf18ed97b33","src/daemon.rs":"11cd633298fe2eb89906a4d8c12ab34e4ee355f759e1216cee536f24c7c679b2","src/data.rs":"bd4545d4c2fcc59ff26ae52ad7f773a697d5ccf639a2ffc253cece6b31e94d51","src/error.rs":"ef20f3817f997a1aeb7114628407f19cb8bc13c555d4e093918f38a5d098f798","src/flag.rs":"f07d6a7aa6766d30d0a303c7b3bda5bb4c473dd9dd51687cf8e0631b1bf3ec9d","src/io/dma.rs":"fbc46e924d5913f5a3fb723751d7a9dd1b079ccf058500fde4957aaf9fa7dd1c","src/io/io.rs":"e1d454ff47efac70fdaa709251a5a9c1c5637f931994ba3bf6a38c6db9145822","src/io/mmio.rs":"12d0fb4d4f45097bf2c14f73cb1ce21325eae193b537e9f18af73ed5281b5e63","src/io/mod.rs":"79c2fce4fd6d75f3b9169df64b7a605feff31fab2e5ed81984ae085a1d07c0c4","src/io/pio.rs":"9ee6f2229b700d1c45b4c8c6242bd99fe69634e16dcd5843d9e8d1c958047406","src/lib.rs":"0bc9c8ca513dc6f0d9ef587bc53587114c31c1217d6b620399fc0fcbc54bf658","src/number.rs":"fe7b47b06566aa1f8a75f50b685801259df03a1a5c85b91817b4552583cd7862","src/scheme/generate.sh":"dde4e30f4e0223fb1a24ed486a6c36e624c854dbf890862cb6866f4fa3c7a6eb","src/scheme/mod.rs":"cb622405deb0aef4ab04499ea1adfd338c9c5dd9c31a1fe9989786dbf69b49d8","src/scheme/scheme.rs":"30263996f0b4930edd76dace5f5750e48229066bc888bc13365846688d0a870b","src/scheme/scheme_block.rs":"b7a761e4349eb87d106c8af14894e8c4272769b9eb235cd500b075ac1f823683","src/scheme/scheme_block_mut.rs":"4a4fc03bce14757b64006b9bc3fa2779e95382b2d99579870146ee0c3be3f46c","src/scheme/scheme_mut.rs":"e6f0671b77f1bf5263e497c69dec553352249b75d52af62ac19477ba5127f803","src/scheme/seek.rs":"94e044de47b0f00eb0c2aea3fb21001ac2b9aa1e4b20d73fd54163fe92fa63f7","src/tests.rs":"416a428ba6a9c5f0d8f4c3dbe91d9aa940a04472ec9a2d17bc5a66c455b4416f"},"package":"fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"} \ No newline at end of file
+{"files":{"Cargo.toml":"80db3d7e545f9b8a04804e634948c6e80c712f051680b2e7a39ddb848c200151","LICENSE":"efcfee7981ff72431fffb06925cad00a23dce079ed4354f61030ad5abdb78829","README.md":"9161f18ba7f69b4ca51e844aee8ffb8237513a468c5c3b1f3a5f989044f895ac","src/arch/aarch64.rs":"9b4cf7da1f001ce54bfd01b7a001dbc8043c1ef89823781a2a1070e2c096a9ce","src/arch/nonredox.rs":"1055cd441f4b95c9ec428222a7796c7fac953a8a500ca08173743ea95220aab3","src/arch/riscv64.rs":"20bf9a8db779059773b113643d0cb3737fbb5d57f45ee39b8ae9d3396b6ef636","src/arch/x86.rs":"cf01f4d798e8861ad5b9429714c947e2d7c53a3cb9a13d53dc7a38e4bdad4101","src/arch/x86_64.rs":"fd80c9a412d07c85f2b942f36de364edfff7cd49f6c00c043e69becb7c76119f","src/call.rs":"141bdb2cb64dc118beadf40fc8180cd32e41841c8d7db71aed646a5a8ab9fac3","src/data.rs":"bd4545d4c2fcc59ff26ae52ad7f773a697d5ccf639a2ffc253cece6b31e94d51","src/error.rs":"ef20f3817f997a1aeb7114628407f19cb8bc13c555d4e093918f38a5d098f798","src/flag.rs":"aad91126a0bb3413cd103fc38b457aa4d1f6b949605e3ae249aea0dfec8504ff","src/io/dma.rs":"85577342547afaac0dc46740dfeb9d2e4239d8809b86748c3fcaa12f922b1c9d","src/io/io.rs":"e1d454ff47efac70fdaa709251a5a9c1c5637f931994ba3bf6a38c6db9145822","src/io/mmio.rs":"12d0fb4d4f45097bf2c14f73cb1ce21325eae193b537e9f18af73ed5281b5e63","src/io/mod.rs":"79c2fce4fd6d75f3b9169df64b7a605feff31fab2e5ed81984ae085a1d07c0c4","src/io/pio.rs":"9ee6f2229b700d1c45b4c8c6242bd99fe69634e16dcd5843d9e8d1c958047406","src/lib.rs":"25c9f35cf709e7e50336ae12f0390f968cc11515f93b6d757825a7b7725eeadb","src/number.rs":"773d9f55a98c6ae5b4cb08b396568f05f8d9b187a7609b7a1c5dd940f6ee674a","src/scheme/generate.sh":"dde4e30f4e0223fb1a24ed486a6c36e624c854dbf890862cb6866f4fa3c7a6eb","src/scheme/mod.rs":"cb622405deb0aef4ab04499ea1adfd338c9c5dd9c31a1fe9989786dbf69b49d8","src/scheme/scheme.rs":"2e27e08e3b9005a5705fadd10a6160a570322c873d1b6477f269e0beae35f046","src/scheme/scheme_block.rs":"a8d0137e106dcb605367bfc6a22b83317142996b7e410c832de0f63a423d5305","src/scheme/scheme_block_mut.rs":"b6cea44a3e79dd6c30b4280b6913a215628918978451efe11f31b0d7eddd44a5","src/scheme/scheme_mut.rs":"e77da9d5208de101c126eca9fa685f2b78a5ddc4890ad5f5f4d79ded3bbd8fbd","src/scheme/seek.rs":"94e044de47b0f00eb0c2aea3fb21001ac2b9aa1e4b20d73fd54163fe92fa63f7","src/tests.rs":"b44de69251d6bcc1cb796147a1212fffd3ac7d5796d9a0d2265db0aac8a909df"},"package":"567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29"} \ No newline at end of file
diff --git a/vendor/redox_syscall/Cargo.toml b/vendor/redox_syscall/Cargo.toml
index 74e23e8c9..ab14e3fe8 100644
--- a/vendor/redox_syscall/Cargo.toml
+++ b/vendor/redox_syscall/Cargo.toml
@@ -12,10 +12,11 @@
[package]
edition = "2018"
name = "redox_syscall"
-version = "0.2.16"
+version = "0.3.5"
authors = ["Jeremy Soller <jackpot51@gmail.com>"]
description = "A Rust library to access raw Redox system calls"
documentation = "https://docs.rs/redox_syscall"
+readme = "README.md"
license = "MIT"
repository = "https://gitlab.redox-os.org/redox-os/syscall"
@@ -24,3 +25,14 @@ name = "syscall"
[dependencies.bitflags]
version = "1.1.0"
+
+[dependencies.core]
+version = "1.0.0"
+optional = true
+package = "rustc-std-workspace-core"
+
+[features]
+rustc-dep-of-std = [
+ "core",
+ "bitflags/rustc-dep-of-std",
+]
diff --git a/vendor/redox_syscall/src/arch/aarch64.rs b/vendor/redox_syscall/src/arch/aarch64.rs
index e771396e3..e792427cf 100644
--- a/vendor/redox_syscall/src/arch/aarch64.rs
+++ b/vendor/redox_syscall/src/arch/aarch64.rs
@@ -3,6 +3,8 @@ use core::ops::{Deref, DerefMut};
use super::error::{Error, Result};
+pub const PAGE_SIZE: usize = 4096;
+
macro_rules! syscall {
($($name:ident($a:ident, $($b:ident, $($c:ident, $($d:ident, $($e:ident, $($f:ident, )?)?)?)?)?);)+) => {
$(
@@ -49,13 +51,6 @@ syscall! {
#[derive(Copy, Clone, Debug, Default)]
#[repr(C)]
pub struct IntRegisters {
- pub elr_el1: usize,
- pub tpidr_el0: usize,
- pub tpidrro_el0: usize,
- pub spsr_el1: usize,
- pub esr_el1: usize,
- pub sp_el0: usize, // Shouldn't be used if interrupt occurred at EL1
- pub padding: usize, // To keep the struct even number aligned
pub x30: usize,
pub x29: usize,
pub x28: usize,
@@ -130,3 +125,26 @@ impl DerefMut for FloatRegisters {
}
}
}
+
+#[derive(Clone, Copy, Debug, Default)]
+#[repr(packed)]
+pub struct EnvRegisters {
+ pub tpidr_el0: usize,
+ pub tpidrro_el0: usize,
+}
+impl Deref for EnvRegisters {
+ type Target = [u8];
+ fn deref(&self) -> &[u8] {
+ unsafe {
+ slice::from_raw_parts(self as *const EnvRegisters as *const u8, mem::size_of::<EnvRegisters>())
+ }
+ }
+}
+
+impl DerefMut for EnvRegisters {
+ fn deref_mut(&mut self) -> &mut [u8] {
+ unsafe {
+ slice::from_raw_parts_mut(self as *mut EnvRegisters as *mut u8, mem::size_of::<EnvRegisters>())
+ }
+ }
+}
diff --git a/vendor/redox_syscall/src/arch/nonredox.rs b/vendor/redox_syscall/src/arch/nonredox.rs
index f99a7148c..65c44fcd8 100644
--- a/vendor/redox_syscall/src/arch/nonredox.rs
+++ b/vendor/redox_syscall/src/arch/nonredox.rs
@@ -1,5 +1,8 @@
use super::error::{Error, Result, ENOSYS};
+// Doesn't really matter, but since we will most likely run on an x86_64 host, why not 4096?
+pub const PAGE_SIZE: usize = 4096;
+
pub unsafe fn syscall0(_a: usize) -> Result<usize> {
Err(Error::new(ENOSYS))
}
diff --git a/vendor/redox_syscall/src/arch/x86.rs b/vendor/redox_syscall/src/arch/x86.rs
index 2f9301e0e..54d8c0a93 100644
--- a/vendor/redox_syscall/src/arch/x86.rs
+++ b/vendor/redox_syscall/src/arch/x86.rs
@@ -4,6 +4,8 @@ use core::ops::{Deref, DerefMut};
use super::error::{Error, Result};
+pub const PAGE_SIZE: usize = 4096;
+
macro_rules! syscall {
($($name:ident($a:ident, $($b:ident, $($c:ident, $($d:ident, $($e:ident, $($f:ident, )?)?)?)?)?);)+) => {
$(
@@ -80,6 +82,83 @@ pub unsafe fn syscall5(mut a: usize, b: usize, c: usize, d: usize, e: usize, f:
Error::demux(a)
}
+#[derive(Copy, Clone, Debug, Default)]
+#[repr(C)]
+pub struct IntRegisters {
+ // TODO: Some of these don't get set by Redox yet. Should they?
+
+ pub ebp: usize,
+ pub esi: usize,
+ pub edi: usize,
+ pub ebx: usize,
+ pub eax: usize,
+ pub ecx: usize,
+ pub edx: usize,
+ // pub orig_rax: usize,
+ pub eip: usize,
+ pub cs: usize,
+ pub eflags: usize,
+ pub esp: usize,
+ pub ss: usize,
+ // pub fs_base: usize,
+ // pub gs_base: usize,
+ // pub ds: usize,
+ // pub es: usize,
+ pub fs: usize,
+ // pub gs: usize
+}
+
+impl Deref for IntRegisters {
+ type Target = [u8];
+ fn deref(&self) -> &[u8] {
+ unsafe {
+ slice::from_raw_parts(self as *const IntRegisters as *const u8, mem::size_of::<IntRegisters>())
+ }
+ }
+}
+
+impl DerefMut for IntRegisters {
+ fn deref_mut(&mut self) -> &mut [u8] {
+ unsafe {
+ slice::from_raw_parts_mut(self as *mut IntRegisters as *mut u8, mem::size_of::<IntRegisters>())
+ }
+ }
+}
+
+#[derive(Clone, Copy, Debug, Default)]
+#[repr(packed)]
+pub struct FloatRegisters {
+ pub fcw: u16,
+ pub fsw: u16,
+ pub ftw: u8,
+ pub _reserved: u8,
+ pub fop: u16,
+ pub fip: u64,
+ pub fdp: u64,
+ pub mxcsr: u32,
+ pub mxcsr_mask: u32,
+ pub st_space: [u128; 8],
+ pub xmm_space: [u128; 16],
+ // TODO: YMM/ZMM
+}
+
+impl Deref for FloatRegisters {
+ type Target = [u8];
+ fn deref(&self) -> &[u8] {
+ unsafe {
+ slice::from_raw_parts(self as *const FloatRegisters as *const u8, mem::size_of::<FloatRegisters>())
+ }
+ }
+}
+
+impl DerefMut for FloatRegisters {
+ fn deref_mut(&mut self) -> &mut [u8] {
+ unsafe {
+ slice::from_raw_parts_mut(self as *mut FloatRegisters as *mut u8, mem::size_of::<FloatRegisters>())
+ }
+ }
+}
+
#[derive(Clone, Copy, Debug, Default)]
#[repr(packed)]
pub struct EnvRegisters {
diff --git a/vendor/redox_syscall/src/arch/x86_64.rs b/vendor/redox_syscall/src/arch/x86_64.rs
index f71898e90..2ff57bb2d 100644
--- a/vendor/redox_syscall/src/arch/x86_64.rs
+++ b/vendor/redox_syscall/src/arch/x86_64.rs
@@ -4,6 +4,8 @@ use core::ops::{Deref, DerefMut};
use super::error::{Error, Result};
+pub const PAGE_SIZE: usize = 4096;
+
macro_rules! syscall {
($($name:ident($a:ident, $($b:ident, $($c:ident, $($d:ident, $($e:ident, $($f:ident, )?)?)?)?)?);)+) => {
$(
diff --git a/vendor/redox_syscall/src/call.rs b/vendor/redox_syscall/src/call.rs
index f6eb89c8c..bc1af0dc2 100644
--- a/vendor/redox_syscall/src/call.rs
+++ b/vendor/redox_syscall/src/call.rs
@@ -12,37 +12,6 @@ extern "C" fn restorer() -> ! {
unreachable!();
}
-/// Change the process's working directory
-///
-/// This function will attempt to set the process's working directory to `path`, which can be
-/// either a relative, scheme relative, or absolute path.
-///
-/// On success, `Ok(0)` will be returned. On error, one of the following errors will be returned.
-///
-/// # Errors
-///
-/// * `EACCES` - permission is denied for one of the components of `path`, or `path`
-/// * `EFAULT` - `path` does not point to the process's addressible memory
-/// * `EIO` - an I/O error occurred
-/// * `ENOENT` - `path` does not exit
-/// * `ENOTDIR` - `path` is not a directory
-pub fn chdir<T: AsRef<str>>(path: T) -> Result<usize> {
- unsafe { syscall2(SYS_CHDIR, path.as_ref().as_ptr() as usize, path.as_ref().len()) }
-}
-
-#[deprecated(
- since = "0.1.55",
- note = "use fchmod instead"
-)]
-pub fn chmod<T: AsRef<str>>(path: T, mode: usize) -> Result<usize> {
- unsafe { syscall3(SYS_CHMOD, path.as_ref().as_ptr() as usize, path.as_ref().len(), mode) }
-}
-
-/// Produce a fork of the current process, or a new process thread
-pub unsafe fn clone(flags: CloneFlags) -> Result<usize> {
- syscall1(SYS_CLONE, flags.bits())
-}
-
/// Close a file
pub fn close(fd: usize) -> Result<usize> {
unsafe { syscall1(SYS_CLOSE, fd) }
@@ -85,11 +54,6 @@ pub fn fcntl(fd: usize, cmd: usize, arg: usize) -> Result<usize> {
unsafe { syscall3(SYS_FCNTL, fd, cmd, arg) }
}
-/// Replace the current process with a new executable
-pub fn fexec(fd: usize, args: &[[usize; 2]], vars: &[[usize; 2]]) -> Result<usize> {
- unsafe { syscall5(SYS_FEXEC, fd, args.as_ptr() as usize, args.len(), vars.as_ptr() as usize, vars.len()) }
-}
-
/// Map a file into memory, but with the ability to set the address to map into, either as a hint
/// or as a requirement of the map.
///
@@ -150,11 +114,6 @@ pub unsafe fn futex(addr: *mut i32, op: usize, val: i32, val2: usize, addr2: *mu
syscall5(SYS_FUTEX, addr as usize, op, (val as isize) as usize, val2, addr2 as usize)
}
-/// Get the current working directory
-pub fn getcwd(buf: &mut [u8]) -> Result<usize> {
- unsafe { syscall2(SYS_GETCWD, buf.as_mut_ptr() as usize, buf.len()) }
-}
-
/// Get the effective group ID
pub fn getegid() -> Result<usize> {
unsafe { syscall0(SYS_GETEGID) }
diff --git a/vendor/redox_syscall/src/daemon.rs b/vendor/redox_syscall/src/daemon.rs
deleted file mode 100644
index 6433bcd7d..000000000
--- a/vendor/redox_syscall/src/daemon.rs
+++ /dev/null
@@ -1,62 +0,0 @@
-use core::convert::Infallible;
-
-use super::{
- clone,
- CloneFlags,
- close,
- EIO,
- Error,
- exit,
- pipe2,
- read,
- Result,
- write,
-};
-
-#[must_use = "Daemon::ready must be called"]
-pub struct Daemon {
- write_pipe: usize,
-}
-
-impl Daemon {
- pub fn new<F: FnOnce(Daemon) -> Infallible>(f: F) -> Result<Infallible> {
- let mut pipes = [0; 2];
- pipe2(&mut pipes, 0)?;
-
- let [read_pipe, write_pipe] = pipes;
-
- if unsafe { clone(CloneFlags::empty())? } == 0 {
- let _ = close(read_pipe);
-
- f(Daemon {
- write_pipe,
- });
- // TODO: Replace Infallible with the never type once it is stabilized.
- unreachable!();
- } else {
- let _ = close(write_pipe);
-
- let mut data = [0];
- let res = read(read_pipe, &mut data);
- let _ = close(read_pipe);
-
- if res? == 1 {
- exit(data[0] as usize)?;
- unreachable!();
- } else {
- Err(Error::new(EIO))
- }
- }
- }
-
- pub fn ready(self) -> Result<()> {
- let res = write(self.write_pipe, &[0]);
- let _ = close(self.write_pipe);
-
- if res? == 1 {
- Ok(())
- } else {
- Err(Error::new(EIO))
- }
- }
-}
diff --git a/vendor/redox_syscall/src/flag.rs b/vendor/redox_syscall/src/flag.rs
index 9788884af..341104856 100644
--- a/vendor/redox_syscall/src/flag.rs
+++ b/vendor/redox_syscall/src/flag.rs
@@ -32,18 +32,6 @@ macro_rules! bitflags {
}
}
-bitflags! {
- pub struct CloneFlags: usize {
- const CLONE_VM = 0x100;
- const CLONE_FS = 0x200;
- const CLONE_FILES = 0x400;
- const CLONE_SIGHAND = 0x800;
- const CLONE_VFORK = 0x4000;
- const CLONE_THREAD = 0x10000;
- const CLONE_STACK = 0x1000_0000;
- }
-}
-
pub const CLOCK_REALTIME: usize = 1;
pub const CLOCK_MONOTONIC: usize = 4;
@@ -213,8 +201,10 @@ bitflags! {
/// If you don't catch this, the child is started as normal.
const PTRACE_EVENT_CLONE = 0x0000_0000_0000_0100;
- const PTRACE_EVENT_MASK = 0x0000_0000_0000_0F00;
+ /// Sent when current-addrspace is changed, allowing the tracer to reopen the memory file.
+ const PTRACE_EVENT_ADDRSPACE_SWITCH = 0x0000_0000_0000_0200;
+ const PTRACE_EVENT_MASK = 0x0000_0000_0000_0F00;
/// Special meaning, depending on the event. Usually, when fired before
/// an action, it will skip performing that action.
@@ -292,13 +282,6 @@ bitflags! {
}
}
-// Auxiliery vector types
-pub const AT_NULL: usize = 0;
-pub const AT_PHDR: usize = 3;
-pub const AT_PHENT: usize = 4;
-pub const AT_PHNUM: usize = 5;
-pub const AT_ENTRY: usize = 9;
-
bitflags! {
pub struct WaitFlags: usize {
const WNOHANG = 0x01;
@@ -307,6 +290,11 @@ bitflags! {
}
}
+pub const ADDRSPACE_OP_MMAP: usize = 0;
+pub const ADDRSPACE_OP_MUNMAP: usize = 1;
+pub const ADDRSPACE_OP_MPROTECT: usize = 2;
+pub const ADDRSPACE_OP_TRANSFER: usize = 3;
+
/// True if status indicates the child is stopped.
pub fn wifstopped(status: usize) -> bool {
(status & 0xff) == 0x7f
diff --git a/vendor/redox_syscall/src/io/dma.rs b/vendor/redox_syscall/src/io/dma.rs
index b356c8abe..0613fc9fc 100644
--- a/vendor/redox_syscall/src/io/dma.rs
+++ b/vendor/redox_syscall/src/io/dma.rs
@@ -3,7 +3,8 @@ use core::ops::{Deref, DerefMut};
use core::{ptr, slice};
use crate::Result;
-use crate::{PartialAllocStrategy, PhysallocFlags};
+use crate::{PartialAllocStrategy, PhysallocFlags, PhysmapFlags};
+use crate::arch::PAGE_SIZE;
/// An RAII guard of a physical memory allocation. Currently all physically allocated memory are
/// page-aligned and take up at least 4k of space (on x86_64).
@@ -13,12 +14,35 @@ pub struct PhysBox {
size: usize
}
+const fn round_up(x: usize) -> usize {
+ (x + PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE
+}
+fn assert_aligned(x: usize) {
+ assert_eq!(x % PAGE_SIZE, 0);
+}
+
+#[cfg(target_arch = "aarch64")]
+fn physmap_flags() -> PhysmapFlags {
+ // aarch64 currently must map DMA memory without caching to ensure coherence
+ crate::PHYSMAP_NO_CACHE | crate::PHYSMAP_WRITE
+}
+
+#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
+fn physmap_flags() -> PhysmapFlags {
+ // x86 ensures cache coherence with DMA memory
+ crate::PHYSMAP_WRITE
+}
+
impl PhysBox {
- /// Construct a PhysBox from an address and a size.
+ /// Construct a PhysBox from an address and a size. The address must be page-aligned, and the
+ /// size must similarly be a multiple of the page size.
///
/// # Safety
/// This function is unsafe because when dropping, Self has to a valid allocation.
pub unsafe fn from_raw_parts(address: usize, size: usize) -> Self {
+ assert_aligned(address);
+ assert_aligned(size);
+
Self {
address,
size,
@@ -42,12 +66,10 @@ impl PhysBox {
pub fn new_with_flags(size: usize, flags: PhysallocFlags) -> Result<Self> {
assert!(!flags.contains(PhysallocFlags::PARTIAL_ALLOC));
+ assert_aligned(size);
let address = unsafe { crate::physalloc2(size, flags.bits())? };
- Ok(Self {
- address,
- size,
- })
+ Ok(unsafe { Self::from_raw_parts(address, size) })
}
/// "Partially" allocate physical memory, in the sense that the allocation may be smaller than
@@ -57,21 +79,18 @@ impl PhysBox {
/// that first allocation only returns half the size, the driver can do another allocation
/// and then let the device use both buffers.
pub fn new_partial_allocation(size: usize, flags: PhysallocFlags, strategy: Option<PartialAllocStrategy>, mut min: usize) -> Result<Self> {
+ assert_aligned(size);
debug_assert!(!(flags.contains(PhysallocFlags::PARTIAL_ALLOC) && strategy.is_none()));
- let address = unsafe { crate::physalloc3(size, flags.bits() | strategy.map(|s| s as usize).unwrap_or(0), &mut min)? };
- Ok(Self {
- address,
- size: min,
- })
+ let address = unsafe { crate::physalloc3(size, flags.bits() | strategy.map_or(0, |s| s as usize), &mut min)? };
+ Ok(unsafe { Self::from_raw_parts(address, size) })
}
pub fn new(size: usize) -> Result<Self> {
+ assert_aligned(size);
+
let address = unsafe { crate::physalloc(size)? };
- Ok(Self {
- address,
- size,
- })
+ Ok(unsafe { Self::from_raw_parts(address, size) })
}
}
@@ -88,7 +107,7 @@ pub struct Dma<T: ?Sized> {
impl<T> Dma<T> {
pub fn from_physbox_uninit(phys: PhysBox) -> Result<Dma<MaybeUninit<T>>> {
- let virt = unsafe { crate::physmap(phys.address, phys.size, crate::PHYSMAP_WRITE)? } as *mut MaybeUninit<T>;
+ let virt = unsafe { crate::physmap(phys.address, phys.size, physmap_flags())? } as *mut MaybeUninit<T>;
Ok(Dma {
phys,
@@ -111,11 +130,11 @@ impl<T> Dma<T> {
}
pub fn new(value: T) -> Result<Self> {
- let phys = PhysBox::new(mem::size_of::<T>())?;
+ let phys = PhysBox::new(round_up(mem::size_of::<T>()))?;
Self::from_physbox(phys, value)
}
pub fn zeroed() -> Result<Dma<MaybeUninit<T>>> {
- let phys = PhysBox::new(mem::size_of::<T>())?;
+ let phys = PhysBox::new(round_up(mem::size_of::<T>()))?;
Self::from_physbox_zeroed(phys)
}
}
@@ -149,7 +168,7 @@ impl<T> Dma<[T]> {
assert!(len <= max_len);
Ok(Dma {
- virt: unsafe { slice::from_raw_parts_mut(crate::physmap(phys.address, phys.size, crate::PHYSMAP_WRITE)? as *mut MaybeUninit<T>, len) } as *mut [MaybeUninit<T>],
+ virt: unsafe { slice::from_raw_parts_mut(crate::physmap(phys.address, phys.size, physmap_flags())? as *mut MaybeUninit<T>, len) } as *mut [MaybeUninit<T>],
phys,
})
}
@@ -163,7 +182,7 @@ impl<T> Dma<[T]> {
/// * `T` must be properly aligned.
/// * `T` must be valid as zeroed (i.e. no NonNull pointers).
pub unsafe fn zeroed_unsized(count: usize) -> Result<Self> {
- let phys = PhysBox::new(mem::size_of::<T>() * count)?;
+ let phys = PhysBox::new(round_up(mem::size_of::<T>() * count))?;
Ok(Self::from_physbox_zeroed_unsized(phys, count)?.assume_init())
}
}
@@ -195,6 +214,6 @@ impl<T: ?Sized> DerefMut for Dma<T> {
impl<T: ?Sized> Drop for Dma<T> {
fn drop(&mut self) {
unsafe { ptr::drop_in_place(self.virt) }
- let _ = unsafe { crate::physunmap(self.virt as *mut u8 as usize) };
+ let _ = unsafe { crate::funmap(self.virt as *mut u8 as usize, self.phys.size) };
}
}
diff --git a/vendor/redox_syscall/src/lib.rs b/vendor/redox_syscall/src/lib.rs
index 9c5939830..3f6d88479 100644
--- a/vendor/redox_syscall/src/lib.rs
+++ b/vendor/redox_syscall/src/lib.rs
@@ -5,7 +5,6 @@ extern crate core;
pub use self::arch::*;
pub use self::call::*;
-pub use self::daemon::*;
pub use self::data::*;
pub use self::error::*;
pub use self::flag::*;
@@ -43,9 +42,6 @@ pub mod call;
/// Complex structures that are used for some system calls
pub mod data;
-/// Wrapper to make daemons easier to write
-pub mod daemon;
-
/// All errors that can be generated by a system call
pub mod error;
diff --git a/vendor/redox_syscall/src/number.rs b/vendor/redox_syscall/src/number.rs
index 1f037eb19..2b9205a26 100644
--- a/vendor/redox_syscall/src/number.rs
+++ b/vendor/redox_syscall/src/number.rs
@@ -12,7 +12,6 @@ pub const SYS_RET_FILE: usize = 0x0010_0000;
pub const SYS_LINK: usize = SYS_CLASS_PATH | SYS_ARG_PATH | 9;
pub const SYS_OPEN: usize = SYS_CLASS_PATH | SYS_RET_FILE | 5;
-pub const SYS_CHMOD: usize = SYS_CLASS_PATH | 15;
pub const SYS_RMDIR: usize = SYS_CLASS_PATH | 84;
pub const SYS_UNLINK: usize = SYS_CLASS_PATH | 10;
@@ -26,7 +25,6 @@ pub const SYS_FCHMOD: usize = SYS_CLASS_FILE | 94;
pub const SYS_FCHOWN: usize = SYS_CLASS_FILE | 207;
pub const SYS_FCNTL: usize = SYS_CLASS_FILE | 55;
pub const SYS_FEVENT: usize = SYS_CLASS_FILE | 927;
-pub const SYS_FEXEC: usize = SYS_CLASS_FILE | 11;
pub const SYS_FMAP_OLD: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 90;
pub const SYS_FMAP: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 900;
pub const SYS_FUNMAP_OLD: usize = SYS_CLASS_FILE | 91;
@@ -39,12 +37,9 @@ pub const SYS_FSYNC: usize = SYS_CLASS_FILE | 118;
pub const SYS_FTRUNCATE: usize = SYS_CLASS_FILE | 93;
pub const SYS_FUTIMENS: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 320;
-pub const SYS_CHDIR: usize = 12;
pub const SYS_CLOCK_GETTIME: usize = 265;
-pub const SYS_CLONE: usize = 120;
pub const SYS_EXIT: usize = 1;
pub const SYS_FUTEX: usize = 240;
-pub const SYS_GETCWD: usize = 183;
pub const SYS_GETEGID: usize = 202;
pub const SYS_GETENS: usize = 951;
pub const SYS_GETEUID: usize = 201;
diff --git a/vendor/redox_syscall/src/scheme/scheme.rs b/vendor/redox_syscall/src/scheme/scheme.rs
index 249d28c6e..6bf36172c 100644
--- a/vendor/redox_syscall/src/scheme/scheme.rs
+++ b/vendor/redox_syscall/src/scheme/scheme.rs
@@ -14,11 +14,6 @@ pub trait Scheme {
} else {
Err(Error::new(EINVAL))
},
- SYS_CHMOD => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } {
- self.chmod(path, packet.d as u16, packet.uid, packet.gid)
- } else {
- Err(Error::new(EINVAL))
- },
SYS_RMDIR => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } {
self.rmdir(path, packet.uid, packet.gid)
} else {
diff --git a/vendor/redox_syscall/src/scheme/scheme_block.rs b/vendor/redox_syscall/src/scheme/scheme_block.rs
index e22535e0f..3b3de4bc9 100644
--- a/vendor/redox_syscall/src/scheme/scheme_block.rs
+++ b/vendor/redox_syscall/src/scheme/scheme_block.rs
@@ -14,11 +14,6 @@ pub trait SchemeBlock {
} else {
Err(Error::new(EINVAL))
},
- SYS_CHMOD => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } {
- self.chmod(path, packet.d as u16, packet.uid, packet.gid)
- } else {
- Err(Error::new(EINVAL))
- },
SYS_RMDIR => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } {
self.rmdir(path, packet.uid, packet.gid)
} else {
diff --git a/vendor/redox_syscall/src/scheme/scheme_block_mut.rs b/vendor/redox_syscall/src/scheme/scheme_block_mut.rs
index c1e54351a..1fae3a0e5 100644
--- a/vendor/redox_syscall/src/scheme/scheme_block_mut.rs
+++ b/vendor/redox_syscall/src/scheme/scheme_block_mut.rs
@@ -14,11 +14,6 @@ pub trait SchemeBlockMut {
} else {
Err(Error::new(EINVAL))
},
- SYS_CHMOD => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } {
- self.chmod(path, packet.d as u16, packet.uid, packet.gid)
- } else {
- Err(Error::new(EINVAL))
- },
SYS_RMDIR => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } {
self.rmdir(path, packet.uid, packet.gid)
} else {
diff --git a/vendor/redox_syscall/src/scheme/scheme_mut.rs b/vendor/redox_syscall/src/scheme/scheme_mut.rs
index deb148366..b364b62aa 100644
--- a/vendor/redox_syscall/src/scheme/scheme_mut.rs
+++ b/vendor/redox_syscall/src/scheme/scheme_mut.rs
@@ -14,11 +14,6 @@ pub trait SchemeMut {
} else {
Err(Error::new(EINVAL))
},
- SYS_CHMOD => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } {
- self.chmod(path, packet.d as u16, packet.uid, packet.gid)
- } else {
- Err(Error::new(EINVAL))
- },
SYS_RMDIR => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } {
self.rmdir(path, packet.uid, packet.gid)
} else {
diff --git a/vendor/redox_syscall/src/tests.rs b/vendor/redox_syscall/src/tests.rs
index c5e1f8df0..fdff89b4b 100644
--- a/vendor/redox_syscall/src/tests.rs
+++ b/vendor/redox_syscall/src/tests.rs
@@ -1,30 +1,4 @@
#[test]
-fn chdir() {
- use std::str;
-
- let mut current_buf = [0; 4096];
- let current_count = dbg!(crate::getcwd(&mut current_buf)).unwrap();
- let current = dbg!(str::from_utf8(&current_buf[..current_count])).unwrap();
-
- let new = "file:";
- assert_eq!(dbg!(crate::chdir(dbg!(new))), Ok(0));
- {
- let mut buf = [0; 4096];
- let count = dbg!(crate::getcwd(&mut buf)).unwrap();
- assert_eq!(dbg!(str::from_utf8(&buf[..count])), Ok(new));
- }
-
- assert_eq!(dbg!(crate::chdir(current)), Ok(0));
- {
- let mut buf = [0; 4096];
- let count = dbg!(crate::getcwd(&mut buf)).unwrap();
- assert_eq!(dbg!(str::from_utf8(&buf[..count])), Ok(current));
- }
-}
-
-//TODO: chmod
-
-#[test]
fn clone() {
let expected_status = 42;
let pid_res = unsafe { crate::clone(crate::CloneFlags::empty()) };
@@ -207,8 +181,6 @@ fn fstatvfs() {
//TODO: futex
-// getcwd tested by chdir
-
#[test]
fn getegid() {
assert_eq!(crate::getegid(), Ok(0));