How cseslowpoke/nycu-osc works
Main Components
• Bootloader – This is the first-stage component responsible for initializing hardware and loading the kernel. It contains assembly code (boot.s), a linker script (linker.ld), and a C entry point (main.c), plus UART support (uart.c and uart.h) for early debugging/output.
• Kernel – This is the core operating system and is modularly organized into:
• Architecture-specific layer (kernel/arch/arm64): Contains ARM64-specific boot code (boot.s) and exception handling (exception.s), showing platform-dependent initializations.
• Core functionalities (kernel/core): Implements the command system, exception handling, basic shell, simple memory allocation (simple_alloc.c), and user execution, indicating an interactive and possibly multi-user system.
• Drivers (kernel/drivers): Contains code managing interrupts (irq.c), mailbox communication, timers, UART communication, and watchdog timers, thus abstracting hardware interfaces.
• Filesystem (kernel/fs): Implements filesystem-related functionalities such as handling CPIO archives, Flattened Device Trees (FDT), and abstract file operations.
• Common Utilities (kernel/common): Includes shared utility functions (e.g., string operations in string.c and utils in utils.c) used across different kernel components.
• Shared headers in kernel/include: Organizes all the interface definitions by module including types and helper functions.
• Tools – Contains supporting scripts such as send_kernel.py, which is likely used to deploy the kernel image to target hardware.
Relationships and Interactions
• Bootloader initiates the system and loads the kernel image into memory.
• The kernel initialization begins in main.c (in the kernel directory) and then diverges into the architecture-specific startup routines (kernel/arch/arm64).
• The core module sets up essential services such as the shell interface, exception handling, and user process execution.
• Drivers provide a hardware abstraction layer essential for system services—IRQ, UART, timer, and others are invoked by both the core and filesystem modules.
• The filesystem module interacts with hardware drivers to read files (e.g., the initial ramdisk in CPIO format) and possibly to parse device trees with FDT.
• The tools, particularly the Python script, support deployment or debugging by interfacing with the bootloader/kernel binaries.
Architectural Patterns and Design Principles
• Modularity: The system is clearly divided into well-defined modules (bootloader, core, drivers, filesystem, architecture-specific code) that simplify maintenance and testing.
• Hardware Abstraction: Drivers isolate hardware-specific code from core components.
• Layered Initialization: The bootloader’s responsibility for low-level initialization and the kernel’s structured initialization (architecture layer → core services → drivers/filesystem) follows an organized hierarchy.
• Use of Makefiles: Each module has its own Makefile, indicating that the build process is modular and component-specific.
Relevant Technologies, Frameworks, and Libraries
• Assembly language for initial boot (boot.s and exception.s)
• C language for implementing both low-level hardware interfacing and higher-level OS functionalities.
• Makefile-driven builds, which are prevalent across all modules.
• Likely use of linked scripts (linker.ld) to manage memory layout, particularly critical in OS development.
Specific Elements
• Component Labels: Bootloader, Kernel (with sub-components Architecture [ARM64], Core, Drivers, Filesystem, and Common Utilities), and Tools.
• Build and Deployment Process: Optionally include a flow to represent the role of the Makefiles and the deployment script (send_kernel.py) in flashing or running the OS.