Official MINIX sources - Automatically replicated from gerrit.minix3.org
This commit culminates a significant refactoring effort to address foundational architectural issues in the MINIX kernel, based on your initial technical review and subsequent detailed architectural roadmap feedback. It aims to establish a cleaner separation between kernel and userspace, introduce kernel-specific types and libraries, and prepare the build system for more robust kernel development.
**Key Achievements:**
1. **Critical Fixes (Phase 0):**
* Corrected `kmemmove` implementation in `klib/kmemory.c` to prevent data corruption.
* Integrated i386 assembly files (`.S`) into the `meson.build` process, enabling kernel linkage.
2. **Foundational Infrastructure (Phase 1 - Partial):**
* **Assertion Framework:**
* Introduced `include/sys/kassert.h` with `KASSERT` (conditional on `DEBUG_KERNEL`) and `KSTATIC_ASSERT` macros.
* Added `klib/kpanic.c` with a `kpanic` function (using `kprintf_stub` for now, relies on `extern arch_halt` and `arch_disable_interrupts`).
* **Memory Barriers:** Created `include/sys/barrier.h` with `kcompiler_barrier`, x86 memory barriers (`kmb`, `krmb`, `kwmb`), and SMP atomic operation barriers.
* **Enhanced Type System (`include/minix/kernel_types.h`):**
* Added `k_atomic_t`, `k_atomic_long_t`.
* Added opaque handle forward declarations (e.g., `k_proc_handle_t`).
* Added `K_CACHE_LINE_SIZE` and `__k_cacheline_aligned` macros.
* Added a kernel-safe `K_OFFSETOF` macro.
* Verified presence of previously added kernel-specific fixed-width integer types (e.g., `k_uint32_t`).
* **`offsetof` Replacement:** Replaced `offsetof` macro usage with `K_OFFSETOF` in files under `minix/kernel/` and `minix/kernel/system/`.
3. **Initial Codebase Refactoring (Base for current work):**
* Established initial `kernel_types.h` with basic `k_` prefixed types.
* Created `klib` with `kstring.c`, `kmemory.c` (initial versions), and `kprintf_stub.c`.
* Systematically refactored all `.c` and `.h` files across `minix/kernel/` and its subdirectories (`system/`, `arch/i386/`, `arch/earm/`) to remove userspace headers, types, and function calls, replacing them with kernel-specific versions or `FIXME` placeholders.
* Overhauled `minix/kernel/meson.build` with kernel-specific flags, architecture handling, and definitions for `klib` and the kernel executable.
**Deferred Tasks & Known Next Steps:**
Due to environment limitations and the scale of changes, the following tasks are deferred for handling in a suitable build environment, ideally with scripting:
* **`KASSERT_PLACEHOLDER` Migration:** Codebase-wide replacement of `KASSERT_PLACEHOLDER` with the new `KASSERT` macro and inclusion of `<sys/kassert.h>`.
* **`offsetof` Migration (arch dirs):** Completion of `offsetof` to `K_OFFSETOF` replacement for `arch/i386/` and `arch/earm/` directories.
**Critical Outstanding Work (requiring a build environment):**
* **Resolve FIXMEs:** Address all `FIXME` comments generated during refactoring. This includes defining numerous missing constants (error numbers, signal numbers, hardware constants), types (fixed-width if not covered, `struct exec_info`, `struct sigcontext`), and macros.
* **Implement Missing `klib` Functions:** Provide full implementations for `kprintf`/`ksprintf` (currently stubs), `kstrncmp`, `kmemcmp`, `katoi`, `kstrlcat`, etc.
* **Kernel Services:** Develop kernel-space signal handling, ELF loading mechanisms.
* **Build System Enhancements:** Add full assembly language file support (specific flags, rules), manage linker scripts, and incorporate advanced linker options.
* **HAL Implementation:** Define and implement Hardware Abstraction Layer interfaces as per the detailed roadmap.
* **Thorough Build & Testing:** Iteratively build, resolve errors, and test on target hardware/emulators.
This commit represents a significant step towards a more robust MINIX kernel architecture. The subsequent phases outlined in your "Structured Implementation Roadmap" should be followed to achieve a production-ready state.
|
||
|---|---|---|
| .github/workflows | ||
| minix | ||
| releasetools | ||
| .DS_Store | ||
| .gitignore | ||
| .gitreview | ||
| arch_dependencies.txt | ||
| bsd_tree.txt | ||
| include_analysis.txt | ||
| LICENSE | ||
| meson_options.txt | ||
| meson.build | ||
| userspace_contamination.txt | ||