Skip to content

[REFRACTOR] Transform OpenOS into Modular Research Kernel Architecture (OpenOS-RK)#7

Open
orgito1015 wants to merge 67 commits intoCybersecurity-Enthusiasts-from-42:mainfrom
orgito1015:main
Open

[REFRACTOR] Transform OpenOS into Modular Research Kernel Architecture (OpenOS-RK)#7
orgito1015 wants to merge 67 commits intoCybersecurity-Enthusiasts-from-42:mainfrom
orgito1015:main

Conversation

@orgito1015
Copy link
Member

Refactor: Transform OpenOS into Modular Research-Oriented Kernel Architecture (OpenOS-RK)

Summary

This pull request performs a full architectural refactor of OpenOS,
transitioning it from an educational monolithic kernel prototype into a
structured, research-oriented modular kernel architecture (OpenOS-RK).

The purpose of this refactor is not feature expansion but architectural
formalization. The changes introduce strict layering, a formal memory
stack, kernel object abstraction, scheduler skeleton integration,
slab-based allocation, and research instrumentation hooks. The kernel
remains monolithic, but now follows clear dependency boundaries and
modular separation principles.

This refactor establishes a clean foundation for future experimentation
in scheduling, memory management, isolation models, tracing, and
kernel-level research.


Motivation

The previous architecture of OpenOS had structural limitations including
mixed layers, lack of object abstraction, informal memory
initialization, and no instrumentation capability. This refactor
resolves these issues to establish a research-grade kernel foundation.


Architectural Goals

  1. Maintain monolithic kernel design.
  2. Enforce strict modular separation.
  3. Formalize memory layering.
  4. Introduce kernel object abstraction.
  5. Prepare scheduler abstraction layer.
  6. Add research instrumentation capability.
  7. Eliminate circular dependencies.
  8. Centralize memory layout management.
  9. Make the kernel experiment-ready.

New Directory Structure

/arch
    /x86
        cpu.c
        gdt.c
        idt.c
        isr.S
        pic.c
        cpuid.c

/core
    kernel.c
    panic.c
    logger.c
    trace.c
    config.h

/memory
    pmm.c
    vmm.c
    heap.c
    slab.c
    mem_layout.c

/process
    scheduler.c
    task.c
    context_switch.S

/object
    object.c
    object.h

/fs
    vfs.c
    ramfs.c
    file.c

/drivers
    keyboard.c
    timer.c
    console.c
    driver_manager.c

/ipc
    pipe.c
    message.c

/research
    instrumentation.c
    profiler.c

Dependency Rules

arch → memory → core → object → process → fs → drivers
  • arch must not depend on higher layers.
  • memory must not depend on drivers or process.
  • core must not manipulate hardware directly.
  • No circular includes are allowed.
  • Architecture-specific code is isolated under /arch/x86.

Memory Stack Formalization

pmm_init();
vmm_init();
heap_init();
slab_init();

No dynamic allocation occurs before heap initialization. Slab becomes
the primary object allocation layer.


Slab Allocator Integration

New files:

  • memory/slab.c
  • memory/slab.h

Purpose:

  • Reduce fragmentation
  • Enable object caching
  • Prepare for per-CPU allocation models
  • Replace direct kmalloc usage in higher-level subsystems

Kernel Object Model

struct kobject {
    uint32_t type;
    uint32_t flags;
    uint32_t refcount;
};

Benefits:

  • Reference counting
  • Structured resource lifetime management
  • Foundation for handle-based access
  • Clean resource ownership model

Scheduler Skeleton Integration

Timer IRQ routes through:

scheduler_tick();

Establishes deterministic execution control and preemption foundation.


Instrumentation and Research Hooks

void trace_event(uint32_t id);
void profile_enter(uint32_t id);
void profile_exit(uint32_t id);

Used for latency measurement, profiling, and research experiments.


Backward Compatibility

  • Boot process unchanged
  • Interrupts functional
  • Timer and keyboard operational
  • No external behavior changes

Future Research Roadmap

  • SMP support (APIC)
  • Per-CPU slab caches
  • Lock-free scheduling experiments
  • Capability-based security model
  • Isolation research
  • Page cache experimentation
  • IPC performance studies

Conclusion

This refactor establishes a clean architectural baseline and positions
OpenOS as a structured research kernel platform suitable for advanced
systems experimentation and long-term evolution.

Copilot AI and others added 30 commits February 14, 2026 21:20
- Create new directory structure (arch/x86, kernel, memory, drivers, include)
- Move architecture-specific code to arch/x86/
- Extract console driver from kernel.c
- Create common headers (types.h, multiboot.h, ports.h)
- Update all header guards to reflect new paths
- Create placeholder headers for future modules (heap, vfs, process)
- Update Makefile to build from new structure
- Kernel successfully builds and links

Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
- Add ARCHITECTURE.md with complete architecture documentation
- Add REFACTORING.md with migration guide
- Update README.md with architecture section and new stats
- Document module dependencies and design patterns
- Add naming conventions and build system docs
- Include benefits analysis and future extensions

Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
- Add KERNEL_REFACTORING_SUMMARY.md with executive summary
- Document key metrics and verification results
- Include benefits achieved and future extensions
- Provide comprehensive reference for the refactoring

Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
Refactor kernel to modular monolithic architecture
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
Refactor docs into structured hierarchy with learning materials
[WIP] Implement 5-stage pipelined CPU simulator
…us, performance counters)

Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
…cpu-again

Add CPU architecture simulator with 5-stage pipeline and performance analysis framework
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
Rebrand README from educational to research-oriented focus
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
Fix QEMU boot order and unused parameter warning
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
Copilot AI and others added 30 commits February 17, 2026 13:02
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
Add shell command system with 10 built-in commands
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
… quality

Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
Implement VFS layer with ramfs and filesystem commands
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
…arsing, MAC formatting

Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
…-networking-shell

Implement IPC, SMP, GUI, networking, and shell scripting subsystems
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
Suppress unused parameter warning in net_socket_recv stub
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
…ion-rust

Add Rust driver configuration system (no_std, bare-metal FFI)
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
Add QEMU/GDB debug workflow: `make debug`, `make gdb`, `make qemu-log`
Co-authored-by: orgito1015 <86354243+orgito1015@users.noreply.github.com>
…-binaries

Add enhanced ls, cat, and stat coreutils-style shell commands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants