diff --git a/etc/i686-unknown-none.json b/etc/i686-unknown-none.json deleted file mode 100644 index 99b3ed3f..00000000 --- a/etc/i686-unknown-none.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "arch": "x86", - "cpu": "pentium4", - "os": "none", - "abi": "softfloat", - "llvm-target": "i686-unknown-linux-gnu", - "data-layout": "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-f64:32:64-f80:32-n8:16:32-S128", - "max-atomic-width": 64, - "target-pointer-width": "32", - "features": "-avx,-sse,+soft-float", - - "executables": true, - "stack-probes": { - "kind": "inline" - }, - "dynamic-linking": true, - "panic-strategy": "abort", - "relocation-model": "pic", - - "has-thread-local": false, - - "supported-split-debuginfo": [ - "packed", - "unpacked", - "off" - ], - "linker": "rust-lld", - "linker-flavor": "ld.lld" -} diff --git a/lib/abi/src/arch/i686.rs b/lib/abi/src/arch/i686.rs deleted file mode 100644 index b6208994..00000000 --- a/lib/abi/src/arch/i686.rs +++ /dev/null @@ -1,46 +0,0 @@ -#![allow(missing_docs)] - -use abi_serde::impl_struct_serde; - -use super::FrameOps; - -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -#[derive(Clone, Debug, Default)] -#[repr(C)] -pub struct SavedFrame { - pub eax: u32, - pub ecx: u32, - pub edx: u32, - pub ebx: u32, - pub ebp: u32, - pub esi: u32, - pub edi: u32, - - pub user_ip: u32, - pub user_sp: u32, - pub eflags: u32, -} - -impl FrameOps for SavedFrame { - fn set_user_ip(&mut self, value: usize) { - self.user_ip = value as _; - } - - fn user_ip(&self) -> usize { - self.user_ip as _ - } -} - -impl_struct_serde!(SavedFrame: [ - eax, - ecx, - edx, - ebx, - ebp, - esi, - edi, - - user_ip, - user_sp, - eflags, -]); diff --git a/lib/abi/src/arch/mod.rs b/lib/abi/src/arch/mod.rs index ae094814..9c144e20 100644 --- a/lib/abi/src/arch/mod.rs +++ b/lib/abi/src/arch/mod.rs @@ -12,11 +12,6 @@ pub(crate) mod x86_64; #[cfg(any(target_arch = "x86_64", rust_analyzer))] use x86_64 as arch_impl; -#[cfg(any(target_arch = "x86", rust_analyzer))] -pub(crate) mod i686; -#[cfg(any(target_arch = "x86", rust_analyzer))] -use i686 as arch_impl; - #[cfg(any(target_arch = "riscv64", rust_analyzer))] pub(crate) mod riscv64; #[cfg(any(target_arch = "riscv64", rust_analyzer))] diff --git a/lib/runtime/src/process/signal.rs b/lib/runtime/src/process/signal.rs index 442d5931..a69b017d 100644 --- a/lib/runtime/src/process/signal.rs +++ b/lib/runtime/src/process/signal.rs @@ -31,8 +31,6 @@ const MAX_SIGNALS: usize = 16; static TABLE: RwLock<[SignalHandler; MAX_SIGNALS]> = RwLock::new([const { SignalHandler::Terminate }; MAX_SIGNALS]); -// TODO remove unused for i686 -#[allow(unused)] unsafe extern "C" fn common_signal_entry(data: &SignalEntryData) -> ! { let index = data.signal.into_raw() as usize; @@ -162,31 +160,6 @@ pub fn setup_signal_full(size: usize) -> Result<(), Error> { // implementation details -// TODO -#[cfg(any(target_arch = "x86", rust_analyzer))] -mod imp { - use super::common_signal_entry; - - // i686 is a bit tricky: cdecl ABI requires the arguments to be passed on the stack, while - // the kernel does the easy thing and just puts it into %eax, so a fixup needs to be done - // before entering a proper handler. The wrapper also aligns the stack nicely. - #[naked] - pub(super) unsafe extern "C" fn signal_entry() -> ! { - // %eax - SignalEntryData pointer - core::arch::naked_asm!( - r#" - // Align the stack - and $~0xF, %esp - push %eax - call {entry} - "#, - options(att_syntax), - entry = sym common_signal_entry - ); - } -} - -#[cfg(any(not(target_arch = "x86"), rust_analyzer))] mod imp { pub(super) use super::common_signal_entry as signal_entry; } diff --git a/lib/runtime/src/process/thread_local/i686.rs b/lib/runtime/src/process/thread_local/i686.rs deleted file mode 100644 index efd1c47b..00000000 --- a/lib/runtime/src/process/thread_local/i686.rs +++ /dev/null @@ -1,42 +0,0 @@ -#![allow(missing_docs)] - -use abi::error::Error; - -use crate::process::{self, thread}; - -pub fn get_thread_pointer() -> usize { - let tp: usize; - unsafe { - core::arch::asm!("mov %gs:0, {0}", out(reg) tp, options(att_syntax)); - } - tp -} - -/// Sets the %gs register base to `value` for this thread. -/// -/// # Safety -/// -/// `value` must hold an address to a structure, first element of which is a pointer to itself. -/// Usual pointer safety requirements apply. -pub unsafe fn set_thread_pointer(value: usize) -> Result<(), Error> { - process::set_thread_option::(&value) -} - -// ___tls_get_addr, TLS_index structure address gets passed in the %eax register -#[cfg(any(feature = "__tls_get_addr", rust_analyzer))] -core::arch::global_asm!( - r#" -.pushsection .text -.global ___tls_get_addr -.type ___tls_get_addr, %function -___tls_get_addr: - sub $8, %esp - push %eax - call __tls_get_addr@plt - add $12, %esp - ret -.size ___tls_get_addr, . - ___tls_get_addr -.popsection -"#, - options(att_syntax) -); diff --git a/lib/runtime/src/process/thread_local/mod.rs b/lib/runtime/src/process/thread_local/mod.rs index 2851a0bc..32e01864 100644 --- a/lib/runtime/src/process/thread_local/mod.rs +++ b/lib/runtime/src/process/thread_local/mod.rs @@ -21,11 +21,6 @@ mod x86_64; #[cfg(any(target_arch = "x86_64", rust_analyzer))] use x86_64 as imp; -#[cfg(any(target_arch = "x86", rust_analyzer))] -mod i686; -#[cfg(any(target_arch = "x86", rust_analyzer))] -use i686 as imp; - #[cfg(any(target_arch = "riscv64", rust_analyzer))] mod riscv64; #[cfg(any(target_arch = "riscv64", rust_analyzer))] diff --git a/lib/runtime/src/sys/i686.rs b/lib/runtime/src/sys/i686.rs deleted file mode 100644 index 1a9ffb19..00000000 --- a/lib/runtime/src/sys/i686.rs +++ /dev/null @@ -1,94 +0,0 @@ -/// i686 implementation of a system call macro -#[macro_export] -macro_rules! syscall { - ($num:expr $(,)?) => {{ - let mut res = usize::from($num); - core::arch::asm!("int $0x80", inlateout("eax") res); - res - }}; - - ($num:expr, $a0:expr $(,)?) => {{ - let mut res = usize::from($num); - core::arch::asm!( - "int $0x80", - inlateout("eax") res, - in("ebx") $a0, - ); - res - }}; - - ($num:expr, $a0:expr, $a1:expr $(,)?) => {{ - let mut res = usize::from($num); - core::arch::asm!( - "int $0x80", - inlateout("eax") res, - in("ebx") $a0, - in("ecx") $a1 - ); - res - }}; - - ($num:expr, $a0:expr, $a1:expr, $a2:expr $(,)?) => {{ - let mut res = usize::from($num); - core::arch::asm!( - "int $0x80", - inlateout("eax") res, - in("ebx") $a0, - in("ecx") $a1, - in("edx") $a2 - ); - res - }}; - - ($num:expr, $a0:expr, $a1:expr, $a2:expr, $a3:expr $(,)?) => {{ - let mut res = usize::from($num); - core::arch::asm!( - r#" - xchg %esi, {a3} - int $0x80 - xchg %esi, {a3} - "#, - a3 = in(reg) $a3, - inlateout("eax") res, - in("ebx") $a0, - in("ecx") $a1, - in("edx") $a2, - options(nostack, att_syntax) - ); - res - }}; - - ($num:expr, $a0:expr, $a1:expr, $a2:expr, $a3:expr, $a4:expr $(,)?) => {{ - let mut res = usize::from($num); - core::arch::asm!( - r#" - xchg %esi, {a3} - int $0x80 - xchg %esi, {a3} - "#, - a3 = in(reg) $a3, - inlateout("eax") res, - in("ebx") $a0, - in("ecx") $a1, - in("edx") $a2, - in("edi") $a4, - options(nostack, att_syntax) - ); - res - }}; - - ($num:expr, $a0:expr, $a1:expr, $a2:expr, $a3:expr, $a4:expr, $a5:expr $(,)?) => {{ - let mut res = usize::from($num); - core::arch::asm!( - r#" - int $0x81 - "#, - inlateout("eax") res, - in("ebx") $a0, - in("ecx") $a1, - in("edx") $a2, - options(nostack, att_syntax) - ); - res - }}; -} diff --git a/lib/runtime/src/sys/mod.rs b/lib/runtime/src/sys/mod.rs index 201357f5..92157d18 100644 --- a/lib/runtime/src/sys/mod.rs +++ b/lib/runtime/src/sys/mod.rs @@ -6,9 +6,6 @@ mod aarch64; #[cfg(any(target_arch = "x86_64", rust_analyzer))] #[macro_use] mod x86_64; -#[cfg(any(target_arch = "x86", rust_analyzer))] -#[macro_use] -mod i686; #[cfg(any(target_arch = "riscv64", rust_analyzer))] #[macro_use] mod riscv64; diff --git a/userspace/dyn-loader/src/relocation/i686.rs b/userspace/dyn-loader/src/relocation/i686.rs deleted file mode 100644 index 26b1763c..00000000 --- a/userspace/dyn-loader/src/relocation/i686.rs +++ /dev/null @@ -1,80 +0,0 @@ -use elf::relocation::{Rel, Rela}; - -use crate::{error::Error, object::ResolvedSymbol, state::State}; - -use super::{RelValue, RelaValue, Relocation}; - -impl Relocation for Rela { - type Value = RelaValue; - - fn resolve( - &self, - _state: &State, - _name: &str, - _symbol: &ResolvedSymbol, - _load_base: usize, - ) -> Result, Error> { - unimplemented!("rela-type relocations are not implemented for i686") - } -} - -impl Relocation for Rel { - type Value = RelValue; - - fn resolve( - &self, - state: &State, - name: &str, - symbol: &ResolvedSymbol, - load_base: usize, - ) -> Result, Error> { - match symbol { - ResolvedSymbol::Tls(tls) => match self.r_type { - // R_386_DTPMOD32: TLS module ID - 35 => Ok(Some(RelValue::DWordNoAddend(tls.module_id as _))), - // R_386_DTPOFF32: TLS offset within a module - 36 => Ok(Some(RelValue::DWordNoAddend(tls.offset as _))), - // R_386_TPOFF: tp-relative offset - 14 => { - // Need to extract fixed global offset - let tls_layout = state.tls_layout.as_ref().unwrap(); - // Offset from TLS start - let offset = tls_layout.offset(tls.module_id, tls.offset).unwrap(); - let offset_from_tp = -((tls_layout.tp_offset - offset) as i32); - log::debug!("{}@tpoff -> {}", name, offset_from_tp); - - Ok(Some(RelValue::DWordNoAddend(offset_from_tp))) - } - // 14 => Ok(Some(RelValue::DWordNoAddend())) - _ => todo!("Unsupported relocation against TLS symbol: {}", self.r_type), - }, - &ResolvedSymbol::Null(object_id) => match self.r_type { - // R_386_RELATIVE: B + A - 8 => Ok(Some(RelValue::DWord(load_base as _))), - - // R_386_DTPMOD32: TLS module ID - 35 => Ok(Some(RelValue::DWordNoAddend(object_id as _))), - - _ => todo!( - "Unsupported relocation against NULL symbol: {}", - self.r_type - ), - }, - _ => { - let s: i32 = symbol.value().try_into().unwrap(); - if s == 0 { - todo!("Relocation: r_type={}, name={name} is NULL", self.r_type) - } - match self.r_type { - // R_386_32: S + A - 1 => Ok(Some(RelValue::DWord(s))), - // R_386_GLOB_DAT: S - // R_386_JMP_SLOT: S - 6 | 7 => Ok(Some(RelValue::DWordNoAddend(s))), - - _ => todo!("Unsupported relocation type: {}", self.r_type), - } - } - } - } -} diff --git a/userspace/dyn-loader/src/relocation/mod.rs b/userspace/dyn-loader/src/relocation/mod.rs index 80bff615..6a8e8d20 100644 --- a/userspace/dyn-loader/src/relocation/mod.rs +++ b/userspace/dyn-loader/src/relocation/mod.rs @@ -7,8 +7,6 @@ use crate::{error::Error, mapping::Mapping, object::ResolvedSymbol, state::State #[cfg(any(target_arch = "aarch64", rust_analyzer))] mod aarch64; -#[cfg(any(target_arch = "x86", rust_analyzer))] -mod i686; #[cfg(any(target_arch = "riscv64", rust_analyzer))] mod riscv64; #[cfg(any(target_arch = "x86_64", rust_analyzer))] diff --git a/userspace/lib/ygglibc/build.rs b/userspace/lib/ygglibc/build.rs index 85860d18..101f63b3 100644 --- a/userspace/lib/ygglibc/build.rs +++ b/userspace/lib/ygglibc/build.rs @@ -81,7 +81,6 @@ fn generate_header(config_path: impl AsRef, header_output: impl AsRef) { let output_dir = output_dir.as_ref(); let mut command = Command::new("clang"); - let arch = if arch == "x86" { "i686" } else { arch }; let input_dir = PathBuf::from("crt").join(arch); let crt0_c = input_dir.join("crt0.c"); let crt0_s = input_dir.join("crt0.S"); @@ -100,10 +99,8 @@ fn compile_crt0(arch: &str, output_dir: impl AsRef) { .arg("-fPIC") .arg("-c"); + #[allow(clippy::single_match)] match arch { - "i686" => { - command.arg("-m32"); - } "riscv64" => { command.arg("-march=rv64gc"); } diff --git a/userspace/lib/ygglibc/crt/i686/crt0.c b/userspace/lib/ygglibc/crt/i686/crt0.c deleted file mode 100644 index 13c56673..00000000 --- a/userspace/lib/ygglibc/crt/i686/crt0.c +++ /dev/null @@ -1,6 +0,0 @@ -extern void __ygglibc_entry(const void *, const void *); -extern int main(int, const char **, const char **); - -void _start(const void *arg) { - __ygglibc_entry(main, arg); -} diff --git a/userspace/lib/ygglibc/etc/i686-unknown-none.json b/userspace/lib/ygglibc/etc/i686-unknown-none.json deleted file mode 100644 index b19edb69..00000000 --- a/userspace/lib/ygglibc/etc/i686-unknown-none.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "arch": "x86", - "cpu": "pentium4", - "os": "none", - "llvm-target": "i686-unknown-linux-gnu", - "data-layout": "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i128:128-f64:32:64-f80:32-n8:16:32-S128", - "max-atomic-width": 64, - "target-pointer-width": "32", - "features": "+sse", - - "executables": true, - "dynamic-linking": true, - "panic-strategy": "abort", - "relocation-model": "pic", - "position-independent-executables": true, - "crt-static-allows-dylibs": true, - "crt-static-respected": true, - - "has-thread-local": true, - - "supported-split-debuginfo": [ - "packed", - "unpacked", - "off" - ], - - "linker": "rust-lld", - "linker-flavor": "ld.lld", - "pre-link-args": { - "ld.lld": [ - "--dynamic-linker=/libexec/dyn-loader" - ] - } -} diff --git a/xtask/src/build/mod.rs b/xtask/src/build/mod.rs index 8a57d9ee..f052c6a7 100644 --- a/xtask/src/build/mod.rs +++ b/xtask/src/build/mod.rs @@ -73,20 +73,8 @@ pub fn build_all(env: &BuildEnv) -> Result { // Kernel stuff let kernel = build_kernel(env, check)?; - - // let modules = match env.arch { - // Arch::i686 => Vec::new(), - // _ => build_modules(&env, env.workspace_root.join("kernel/modules"))?, - // }; - - // let mut install_extra = vec![]; - let install_extra = vec![]; - // for module in modules { - // install_extra.push((module.clone(), module.file_name().unwrap().into())); - // } - // Userspace stuff - let initrd = userspace::build_initrd(env, install_extra, check)?; + let initrd = userspace::build_initrd(env, check)?; // Build target-specific image let image = match env.arch { diff --git a/xtask/src/build/userspace.rs b/xtask/src/build/userspace.rs index f7dc36a3..e64a62d3 100644 --- a/xtask/src/build/userspace.rs +++ b/xtask/src/build/userspace.rs @@ -1,7 +1,7 @@ use std::{ fs::{self, File}, io::BufWriter, - path::{Path, PathBuf}, + path::Path, }; use walkdir::WalkDir; @@ -105,7 +105,6 @@ fn build_ports(env: &BuildEnv) -> Result<(), Error> { fn build_rootfs, D: AsRef>( env: &BuildEnv, - install_extra: Vec<(PathBuf, PathBuf)>, build_dir: S, rootfs_dir: D, _: AllOk, @@ -162,11 +161,6 @@ fn build_rootfs, D: AsRef>( rootfs_dir.join("dynload-program"), )?; - log::info!("Installing extras"); - for (src, dst) in install_extra { - util::copy_file(src, rootfs_dir.join(dst))?; - } - // Copy /etc util::copy_dir_recursive(user_dir.join("etc"), rootfs_dir.join("etc"))?; @@ -222,22 +216,12 @@ fn pack_initrd>(env: &BuildEnv, rootfs_dir: P) -> Result, - check: AllOk, -) -> Result { +pub fn build_initrd(env: &BuildEnv, check: AllOk) -> Result { let rootfs_dir = env.userspace_output_dir.join("rootfs"); build_userspace(env, check)?; build_ports(env)?; - build_rootfs( - env, - install_extra, - &env.userspace_output_dir, - &rootfs_dir, - check, - )?; + build_rootfs(env, &env.userspace_output_dir, &rootfs_dir, check)?; pack_initrd(env, rootfs_dir) } diff --git a/xtask/src/env.rs b/xtask/src/env.rs index 6d13cf22..01657975 100644 --- a/xtask/src/env.rs +++ b/xtask/src/env.rs @@ -34,19 +34,12 @@ pub struct X86_64TargetConfig { pub components: BuildComponents, } -#[derive(Debug, Default, serde::Deserialize, serde::Serialize)] -#[serde(default)] -pub struct I686TargetConfig { - pub components: BuildComponents, -} - #[derive(Debug, Default, serde::Deserialize, serde::Serialize)] #[serde(default)] pub struct TargetConfig { pub aarch64: AArch64TargetConfig, pub riscv64: Riscv64TargetConfig, pub x86_64: X86_64TargetConfig, - pub i686: I686TargetConfig, } #[derive(Debug, Default, serde::Deserialize, serde::Serialize)] diff --git a/xtask/src/qemu.rs b/xtask/src/qemu.rs index 6d518dc6..1056d0c8 100644 --- a/xtask/src/qemu.rs +++ b/xtask/src/qemu.rs @@ -63,19 +63,11 @@ struct QemuAArch64MachineConfig { memory: usize, } -#[derive(Debug, serde::Deserialize, serde::Serialize)] -#[serde(rename_all = "kebab-case", default)] -struct QemuI686MachineConfig { - enable_kvm: bool, - memory: usize, -} - #[derive(Debug, serde::Deserialize, serde::Serialize)] #[serde(default)] struct QemuMachineConfig { x86_64: QemuX86_64MachineConfig, aarch64: QemuAArch64MachineConfig, - i686: QemuI686MachineConfig, smp: usize, } @@ -92,21 +84,11 @@ impl Default for QemuMachineConfig { Self { x86_64: Default::default(), aarch64: Default::default(), - i686: Default::default(), smp: 4, } } } -impl Default for QemuI686MachineConfig { - fn default() -> Self { - Self { - enable_kvm: true, - memory: 512, - } - } -} - impl Default for QemuAArch64MachineConfig { fn default() -> Self { Self { memory: 512 }