summaryrefslogtreecommitdiffstats
path: root/vendor/redox_syscall/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:06:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:06:31 +0000
commit2ff14448863ac1a1dd9533461708e29aae170c2d (patch)
tree85b9fea2bbfe3f06473cfa381eed11f273b57c5c /vendor/redox_syscall/src
parentAdding debian version 1.64.0+dfsg1-1. (diff)
downloadrustc-2ff14448863ac1a1dd9533461708e29aae170c2d.tar.xz
rustc-2ff14448863ac1a1dd9533461708e29aae170c2d.zip
Adding debian version 1.65.0+dfsg1-2.debian/1.65.0+dfsg1-2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/redox_syscall/src')
-rw-r--r--vendor/redox_syscall/src/arch/x86.rs105
-rw-r--r--vendor/redox_syscall/src/io/mod.rs4
-rw-r--r--vendor/redox_syscall/src/lib.rs2
3 files changed, 108 insertions, 3 deletions
diff --git a/vendor/redox_syscall/src/arch/x86.rs b/vendor/redox_syscall/src/arch/x86.rs
new file mode 100644
index 000000000..2f9301e0e
--- /dev/null
+++ b/vendor/redox_syscall/src/arch/x86.rs
@@ -0,0 +1,105 @@
+use core::{mem, slice};
+use core::arch::asm;
+use core::ops::{Deref, DerefMut};
+
+use super::error::{Error, Result};
+
+macro_rules! syscall {
+ ($($name:ident($a:ident, $($b:ident, $($c:ident, $($d:ident, $($e:ident, $($f:ident, )?)?)?)?)?);)+) => {
+ $(
+ pub unsafe fn $name(mut $a: usize, $($b: usize, $($c: usize, $($d: usize, $($e: usize, $($f: usize)?)?)?)?)?) -> Result<usize> {
+ asm!(
+ "int 0x80",
+ inout("eax") $a,
+ $(
+ in("ebx") $b,
+ $(
+ in("ecx") $c,
+ $(
+ in("edx") $d,
+ $(
+ in("esi") $e,
+ $(
+ in("edi") $f,
+ )?
+ )?
+ )?
+ )?
+ )?
+ options(nostack),
+ );
+
+ Error::demux($a)
+ }
+ )+
+ };
+}
+
+syscall! {
+ syscall0(a,);
+ syscall1(a, b,);
+ syscall2(a, b, c,);
+ syscall3(a, b, c, d,);
+ // Must be done custom because LLVM reserves ESI
+ //syscall4(a, b, c, d, e,);
+ //syscall5(a, b, c, d, e, f,);
+}
+
+pub unsafe fn syscall4(mut a: usize, b: usize, c: usize, d: usize, e: usize)
+ -> Result<usize> {
+ asm!(
+ "xchg esi, {e}
+ int 0x80
+ xchg esi, {e}",
+ e = in(reg) e,
+ inout("eax") a,
+ in("ebx") b,
+ in("ecx") c,
+ in("edx") d,
+ options(nostack),
+ );
+
+ Error::demux(a)
+}
+
+pub unsafe fn syscall5(mut a: usize, b: usize, c: usize, d: usize, e: usize, f: usize)
+ -> Result<usize> {
+ asm!(
+ "xchg esi, {e}
+ int 0x80
+ xchg esi, {e}",
+ e = in(reg) e,
+ inout("eax") a,
+ in("ebx") b,
+ in("ecx") c,
+ in("edx") d,
+ in("edi") f,
+ options(nostack),
+ );
+
+ Error::demux(a)
+}
+
+#[derive(Clone, Copy, Debug, Default)]
+#[repr(packed)]
+pub struct EnvRegisters {
+ pub fsbase: u32,
+ pub gsbase: u32,
+}
+
+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/io/mod.rs b/vendor/redox_syscall/src/io/mod.rs
index a9cd4c86d..a225f0650 100644
--- a/vendor/redox_syscall/src/io/mod.rs
+++ b/vendor/redox_syscall/src/io/mod.rs
@@ -4,12 +4,12 @@ pub use self::dma::*;
pub use self::io::*;
pub use self::mmio::*;
-#[cfg(target_arch = "x86_64")]
+#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
pub use self::pio::*;
mod dma;
mod io;
mod mmio;
-#[cfg(target_arch = "x86_64")]
+#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
mod pio;
diff --git a/vendor/redox_syscall/src/lib.rs b/vendor/redox_syscall/src/lib.rs
index 050ee8160..9c5939830 100644
--- a/vendor/redox_syscall/src/lib.rs
+++ b/vendor/redox_syscall/src/lib.rs
@@ -26,7 +26,7 @@ mod arch;
mod arch;
#[cfg(all(any(target_os = "none", target_os = "redox"), target_arch = "x86"))]
-#[path="arch/nonredox.rs"]
+#[path="arch/x86.rs"]
mod arch;
#[cfg(all(any(target_os = "none", target_os = "redox"), target_arch = "x86_64"))]