Vendor dependencies for 0.3.0 release

This commit is contained in:
2025-09-27 10:29:08 -05:00
parent 0c8d39d483
commit 82ab7f317b
26803 changed files with 16134934 additions and 0 deletions

201
vendor/redox_syscall/src/arch/aarch64.rs vendored Normal file
View File

@@ -0,0 +1,201 @@
use core::{
mem,
ops::{Deref, DerefMut},
slice,
};
use super::error::{Error, Result};
pub const PAGE_SIZE: usize = 4096;
#[cfg(feature = "userspace")]
macro_rules! syscall {
($($name:ident($a:ident, $($b:ident, $($c:ident, $($d:ident, $($e:ident, $($f:ident, )?)?)?)?)?);)+) => {
$(
pub unsafe fn $name($a: usize, $($b: usize, $($c: usize, $($d: usize, $($e: usize, $($f: usize)?)?)?)?)?) -> Result<usize> {
let ret: usize;
core::arch::asm!(
"svc 0",
in("x8") $a,
$(
in("x0") $b,
$(
in("x1") $c,
$(
in("x2") $d,
$(
in("x3") $e,
$(
in("x4") $f,
)?
)?
)?
)?
)?
lateout("x0") ret,
options(nostack),
);
Error::demux(ret)
}
)+
};
}
#[cfg(feature = "userspace")]
syscall! {
syscall0(a,);
syscall1(a, b,);
syscall2(a, b, c,);
syscall3(a, b, c, d,);
syscall4(a, b, c, d, e,);
syscall5(a, b, c, d, e, f,);
}
#[derive(Copy, Clone, Debug, Default)]
#[repr(C)]
pub struct IntRegisters {
pub x30: usize,
pub x29: usize,
pub x28: usize,
pub x27: usize,
pub x26: usize,
pub x25: usize,
pub x24: usize,
pub x23: usize,
pub x22: usize,
pub x21: usize,
pub x20: usize,
pub x19: usize,
pub x18: usize,
pub x17: usize,
pub x16: usize,
pub x15: usize,
pub x14: usize,
pub x13: usize,
pub x12: usize,
pub x11: usize,
pub x10: usize,
pub x9: usize,
pub x8: usize,
pub x7: usize,
pub x6: usize,
pub x5: usize,
pub x4: usize,
pub x3: usize,
pub x2: usize,
pub x1: usize,
pub x0: 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(C, packed)]
pub struct FloatRegisters {
pub fp_simd_regs: [u128; 32],
pub fpsr: u32,
pub fpcr: u32,
}
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(C, 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>(),
)
}
}
}
#[derive(Clone, Copy, Debug, Default)]
#[repr(C, packed)]
pub struct Exception {
pub kind: usize,
// TODO
}
impl Deref for Exception {
type Target = [u8];
fn deref(&self) -> &[u8] {
unsafe {
slice::from_raw_parts(
self as *const Exception as *const u8,
mem::size_of::<Exception>(),
)
}
}
}
impl DerefMut for Exception {
fn deref_mut(&mut self) -> &mut [u8] {
unsafe {
slice::from_raw_parts_mut(
self as *mut Exception as *mut u8,
mem::size_of::<Exception>(),
)
}
}
}

200
vendor/redox_syscall/src/arch/riscv64.rs vendored Normal file
View File

@@ -0,0 +1,200 @@
use super::error::{Error, Result};
use core::arch::asm;
use core::{
mem,
ops::{Deref, DerefMut},
slice,
};
pub const PAGE_SIZE: usize = 4096;
#[cfg(feature = "userspace")]
macro_rules! syscall {
($($name:ident($a:ident, $($b:ident, $($c:ident, $($d:ident, $($e:ident, $($f:ident, )?)?)?)?)?);)+) => {
$(
pub unsafe fn $name($a: usize, $($b: usize, $($c: usize, $($d: usize, $($e: usize, $($f: usize)?)?)?)?)?) -> Result<usize> {
let ret: usize;
asm!(
"ecall",
in("a7") $a,
$(
in("a0") $b,
$(
in("a1") $c,
$(
in("a2") $d,
$(
in("a3") $e,
$(
in("a4") $f,
)?
)?
)?
)?
)?
lateout("a0") ret,
options(nostack),
);
Error::demux(ret)
}
)+
};
}
#[cfg(feature = "userspace")]
syscall! {
syscall0(a,);
syscall1(a, b,);
syscall2(a, b, c,);
syscall3(a, b, c, d,);
syscall4(a, b, c, d, e,);
syscall5(a, b, c, d, e, f,);
}
#[derive(Copy, Clone, Debug, Default)]
#[repr(C)]
pub struct IntRegisters {
pub pc: usize,
pub x31: usize,
pub x30: usize,
pub x29: usize,
pub x28: usize,
pub x27: usize,
pub x26: usize,
pub x25: usize,
pub x24: usize,
pub x23: usize,
pub x22: usize,
pub x21: usize,
pub x20: usize,
pub x19: usize,
pub x18: usize,
pub x17: usize,
pub x16: usize,
pub x15: usize,
pub x14: usize,
pub x13: usize,
pub x12: usize,
pub x11: usize,
pub x10: usize,
pub x9: usize,
pub x8: usize,
pub x7: usize,
pub x6: usize,
pub x5: usize,
// x4(tp) is in env
// x3(gp) is a platform scratch register
pub x2: usize,
pub x1: 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(C, packed)]
pub struct FloatRegisters {
pub fregs: [u64; 32],
pub fcsr: u32,
}
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 {
pub tp: 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>(),
)
}
}
}
#[derive(Clone, Copy, Debug, Default)]
#[repr(C, packed)]
pub struct Exception {
pub kind: usize,
// TODO
}
impl Deref for Exception {
type Target = [u8];
fn deref(&self) -> &[u8] {
unsafe {
slice::from_raw_parts(
self as *const Exception as *const u8,
mem::size_of::<Exception>(),
)
}
}
}
impl DerefMut for Exception {
fn deref_mut(&mut self) -> &mut [u8] {
unsafe {
slice::from_raw_parts_mut(
self as *mut Exception as *mut u8,
mem::size_of::<Exception>(),
)
}
}
}

243
vendor/redox_syscall/src/arch/x86.rs vendored Normal file
View File

@@ -0,0 +1,243 @@
use core::{
arch::asm,
mem,
ops::{Deref, DerefMut},
slice,
};
use super::error::{Error, Result};
pub const PAGE_SIZE: usize = 4096;
#[cfg(feature = "userspace")]
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)
}
)+
};
}
#[cfg(feature = "userspace")]
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,);
}
#[cfg(feature = "userspace")]
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)
}
#[cfg(feature = "userspace")]
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(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(C, 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(C, 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>(),
)
}
}
}
#[derive(Clone, Copy, Debug, Default)]
#[repr(C, packed)]
pub struct Exception {
pub kind: usize,
pub code: usize,
pub address: usize,
}
impl Deref for Exception {
type Target = [u8];
fn deref(&self) -> &[u8] {
unsafe {
slice::from_raw_parts(
self as *const Exception as *const u8,
mem::size_of::<Exception>(),
)
}
}
}
impl DerefMut for Exception {
fn deref_mut(&mut self) -> &mut [u8] {
unsafe {
slice::from_raw_parts_mut(
self as *mut Exception as *mut u8,
mem::size_of::<Exception>(),
)
}
}
}

188
vendor/redox_syscall/src/arch/x86_64.rs vendored Normal file
View File

@@ -0,0 +1,188 @@
use core::{
mem,
ops::{Deref, DerefMut},
slice,
};
pub const PAGE_SIZE: usize = 4096;
#[cfg(feature = "userspace")]
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)?)?)?)?)?) -> crate::error::Result<usize> {
core::arch::asm!(
"syscall",
inout("rax") $a,
$(
in("rdi") $b,
$(
in("rsi") $c,
$(
in("rdx") $d,
$(
in("r10") $e,
$(
in("r8") $f,
)?
)?
)?
)?
)?
out("rcx") _,
out("r11") _,
options(nostack),
);
crate::error::Error::demux($a)
}
)+
};
}
#[cfg(feature = "userspace")]
syscall! {
syscall0(a,);
syscall1(a, b,);
syscall2(a, b, c,);
syscall3(a, b, c, d,);
syscall4(a, b, c, d, e,);
syscall5(a, b, c, d, e, f,);
}
#[derive(Copy, Clone, Debug, Default)]
#[repr(C)]
pub struct IntRegisters {
pub r15: usize,
pub r14: usize,
pub r13: usize,
pub r12: usize,
pub rbp: usize,
pub rbx: usize,
pub r11: usize,
pub r10: usize,
pub r9: usize,
pub r8: usize,
pub rax: usize,
pub rcx: usize,
pub rdx: usize,
pub rsi: usize,
pub rdi: usize,
pub rip: usize,
pub cs: usize,
pub rflags: usize,
pub rsp: usize,
pub ss: usize,
}
impl Deref for IntRegisters {
type Target = [u8];
fn deref(&self) -> &[u8] {
unsafe { slice::from_raw_parts(self as *const Self as *const u8, mem::size_of::<Self>()) }
}
}
impl DerefMut for IntRegisters {
fn deref_mut(&mut self) -> &mut [u8] {
unsafe { slice::from_raw_parts_mut(self as *mut Self as *mut u8, mem::size_of::<Self>()) }
}
}
#[derive(Clone, Copy, Debug, Default)]
#[repr(C, 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(C, packed)]
pub struct EnvRegisters {
pub fsbase: u64,
pub gsbase: u64,
// TODO: PKRU?
}
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>(),
)
}
}
}
#[derive(Clone, Copy, Debug, Default)]
#[repr(C, packed)]
pub struct Exception {
pub kind: usize,
pub code: usize,
pub address: usize,
}
impl Deref for Exception {
type Target = [u8];
fn deref(&self) -> &[u8] {
unsafe {
slice::from_raw_parts(
self as *const Exception as *const u8,
mem::size_of::<Exception>(),
)
}
}
}
impl DerefMut for Exception {
fn deref_mut(&mut self) -> &mut [u8] {
unsafe {
slice::from_raw_parts_mut(
self as *mut Exception as *mut u8,
mem::size_of::<Exception>(),
)
}
}
}