minix/userspace_contamination.txt
google-labs-jules[bot] c3119ae881 I've refactored the MINIX kernel for architectural soundness.
This commit addresses critical architectural deficiencies in the MINIX kernel build and source structure. The changes are based on a comprehensive technical review and aim to establish a cleaner, more robust foundation for future kernel development.

Key changes include:

1.  **Kernel-Specific Type System:**
    *   I introduced `minix/kernel/include/minix/kernel_types.h`.
    *   I defined kernel-specific types (e.g., `k_size_t`, `k_pid_t`) and fixed-width integer types (e.g., `k_uint32_t`) to replace userspace types.

2.  **Kernel-Space Library (`klib`):**
    *   I created a new kernel library (`klib`) located in `minix/kernel/klib/`.
    *   I implemented basic string functions (`kstrlen`, `kstrlcpy`, `kstrcmp`) in `kstring.c`.
    *   I implemented basic memory functions (`kmemcpy`, `kmemset`, `kmemmove`) in `kmemory.c`.
    *   I added stub implementations for `kprintf`, `ksprintf`, and `kvprintf` in `kprintf_stub.c`, along with a `KASSERT_PLACEHOLDER` macro.

3.  **Purged Userspace Dependencies:**
    *   I systematically refactored all C and header files within `minix/kernel/` and its subdirectories (`system/`, `arch/i386/`, `arch/earm/`).
    *   I removed userspace includes (e.g., `<string.h>`, `<stdlib.h>`, `<stdio.h>`, `<assert.h>`, `<sys/types.h>`, `<signal.h>`, `<unistd.h>`).
    *   I replaced calls to userspace C library functions with their `klib` equivalents or marked them with `FIXME` comments if a direct replacement was not yet available (e.g., `atoi`, `strncmp`).
    *   I replaced userspace types with their `k_` prefixed kernel versions.

4.  **Build System Reconstruction (Meson):**
    *   I replaced `minix/kernel/meson.build` with a new script designed for a proper kernel build.
    *   The new build system defines kernel-specific compiler flags, handles architecture detection (i386, x86_64), sets up correct include paths, and builds `klib` and the main kernel executable.
    *   Assembly file compilation and linkage are noted as TODOs in the Meson script.

**Next Steps & Known Issues:**
The kernel is not expected to build successfully immediately after these changes. A significant number of `FIXME` comments and identified issues need to be addressed in a proper build environment. These include:
*   Defining numerous missing constants (error numbers, signal numbers, etc.).
*   Providing kernel-safe implementations for macros like `offsetof`.
*   Implementing missing `klib` functions (e.g., a real `kprintf`, `kstrncmp`, `kmemcmp`, `katoi`).
*   Developing kernel-space signal handling and ELF loading mechanisms.
*   Adding rules for compiling and linking assembly source files.

This refactoring establishes the necessary structure to tackle these remaining issues systematically.
2025-06-06 20:12:01 +00:00

112 lines
3.7 KiB
Plaintext

minix/kernel/arch/earm/arch_clock.c
minix/kernel/arch/earm/arch_do_vmctl.c
minix/kernel/arch/earm/arch_reset.c
minix/kernel/arch/earm/arch_system.c
minix/kernel/arch/earm/bsp/include/bsp_init.h
minix/kernel/arch/earm/bsp/include/bsp_intr.h
minix/kernel/arch/earm/bsp/include/bsp_padconf.h
minix/kernel/arch/earm/bsp/include/bsp_reset.h
minix/kernel/arch/earm/bsp/include/bsp_serial.h
minix/kernel/arch/earm/bsp/include/bsp_timer.h
minix/kernel/arch/earm/bsp/ti/omap_intr_registers.h
minix/kernel/arch/earm/bsp/ti/omap_rtc.h
minix/kernel/arch/earm/bsp/ti/omap_serial.c
minix/kernel/arch/earm/bsp/ti/omap_serial.h
minix/kernel/arch/earm/bsp/ti/omap_timer_registers.h
minix/kernel/arch/earm/exception.c
minix/kernel/arch/earm/include/arch_clock.h
minix/kernel/arch/earm/include/arch_proto.h
minix/kernel/arch/earm/include/arch_watchdog.h
minix/kernel/arch/earm/include/archconst.h
minix/kernel/arch/earm/include/ccnt.h
minix/kernel/arch/earm/include/cpufunc.h
minix/kernel/arch/earm/include/direct_utils.h
minix/kernel/arch/earm/include/hw_intr.h
minix/kernel/arch/earm/include/io.h
minix/kernel/arch/earm/memory.c
minix/kernel/arch/earm/pg_utils.c
minix/kernel/arch/earm/pre_init.c
minix/kernel/arch/earm/protect.c
minix/kernel/arch/i386/acpi.c
minix/kernel/arch/i386/acpi.h
minix/kernel/arch/i386/apic.c
minix/kernel/arch/i386/apic.h
minix/kernel/arch/i386/arch_clock.c
minix/kernel/arch/i386/arch_do_vmctl.c
minix/kernel/arch/i386/arch_reset.c
minix/kernel/arch/i386/arch_smp.c
minix/kernel/arch/i386/arch_system.c
minix/kernel/arch/i386/debugreg.h
minix/kernel/arch/i386/do_iopenable.c
minix/kernel/arch/i386/exception.c
minix/kernel/arch/i386/include/arch_clock.h
minix/kernel/arch/i386/include/arch_proto.h
minix/kernel/arch/i386/include/arch_smp.h
minix/kernel/arch/i386/include/arch_watchdog.h
minix/kernel/arch/i386/include/archconst.h
minix/kernel/arch/i386/include/direct_utils.h
minix/kernel/arch/i386/include/hw_intr.h
minix/kernel/arch/i386/memory.c
minix/kernel/arch/i386/oxpcie.c
minix/kernel/arch/i386/oxpcie.h
minix/kernel/arch/i386/pg_utils.c
minix/kernel/arch/i386/pre_init.c
minix/kernel/arch/i386/protect.c
minix/kernel/arch/i386/serial.h
minix/kernel/clock.c
minix/kernel/const.h
minix/kernel/debug.c
minix/kernel/debug.h
minix/kernel/ipc.h
minix/kernel/ipc_filter.h
minix/kernel/kernel.h
minix/kernel/main.c
minix/kernel/priv.h
minix/kernel/proc.h
minix/kernel/profile.c
minix/kernel/profile.h
minix/kernel/proto.h
minix/kernel/smp.c
minix/kernel/smp.h
minix/kernel/system/do_abort.c
minix/kernel/system/do_clear.c
minix/kernel/system/do_copy.c
minix/kernel/system/do_devio.c
minix/kernel/system/do_diagctl.c
minix/kernel/system/do_exec.c
minix/kernel/system/do_exit.c
minix/kernel/system/do_fork.c
minix/kernel/system/do_getinfo.c
minix/kernel/system/do_getksig.c
minix/kernel/system/do_irqctl.c
minix/kernel/system/do_kill.c
minix/kernel/system/do_mcontext.c
minix/kernel/system/do_privctl.c
minix/kernel/system/do_runctl.c
minix/kernel/system/do_safecopy.c
minix/kernel/system/do_safememset.c
minix/kernel/system/do_schedctl.c
minix/kernel/system/do_schedule.c
minix/kernel/system/do_setalarm.c
minix/kernel/system/do_setgrant.c
minix/kernel/system/do_settime.c
minix/kernel/system/do_sigreturn.c
minix/kernel/system/do_sigsend.c
minix/kernel/system/do_sprofile.c
minix/kernel/system/do_statectl.c
minix/kernel/system/do_stime.c
minix/kernel/system/do_times.c
minix/kernel/system/do_trace.c
minix/kernel/system/do_umap.c
minix/kernel/system/do_umap_remote.c
minix/kernel/system/do_update.c
minix/kernel/system/do_vdevio.c
minix/kernel/system/do_vmctl.c
minix/kernel/system/do_vtimer.c
minix/kernel/system/do_vumap.c
minix/kernel/system.c
minix/kernel/table.c
minix/kernel/type.h
minix/kernel/utility.c
minix/kernel/watchdog.c