Skip to content

Refactor and add more doc comments, improve code base with more global static in config file#46

Merged
LuernOutOfOrder merged 5 commits intodevelopfrom
22-refactor-some-doc-comment-on-struct-or-drivers-or-else
Dec 3, 2025
Merged

Refactor and add more doc comments, improve code base with more global static in config file#46
LuernOutOfOrder merged 5 commits intodevelopfrom
22-refactor-some-doc-comment-on-struct-or-drivers-or-else

Conversation

@LuernOutOfOrder
Copy link
Owner

This pull request refactors and improves the kernel's architecture and device initialization code, with a focus on modularity, clarity, and maintainability. The most significant changes include moving the RISC-V trap frame code into its own module, enhancing documentation and code comments throughout, and improving subsystem initialization and configuration. Additionally, several static initializers and constants have been standardized for consistency.

Architecture and Trap Frame Refactoring

  • Moved the TrapFrame struct and related initialization logic from src/arch/riscv32/mod.rs into a new dedicated module src/arch/riscv32/traps/trap_frame.rs, improving code organization and modularity. All references to TrapFrame and KERNEL_TRAP_FRAME have been updated accordingly. [1] [2] Fabd441dL6, Fabd441dL96)

Documentation and Code Comments

  • Added or improved documentation and comments across architecture modules, trap handlers, interrupt routines, and subsystem structs to clarify their purpose and usage. This includes detailed explanations for interrupt handling, trap routines, and subsystem pools. (src/arch/mod.rsR1-R9, Fd691b9dL1, Fd691b9dL46, Fd691b9dL58, F856cb23L22, Fdc3325fL6, F3db9d2fL1)

Subsystem Initialization and Static Constants

  • Standardized subsystem initialization methods by renaming constructors to init (e.g., SerialManager::init, KernelConsole::init), and updated static initializers for serial and console subsystems for consistency. (Fe6cb31aL28, Fe6cb31aL94, F51e092dL29, F51e092dL90)
  • Moved FDT pool size constants (FDT_MAX_STACK, FDT_MAX_PROPS) from local statics to global configuration in src/config.rs, improving configurability and visibility. (F1ffaf34L17, Fd872ac4L2)

Kernel Boot and Main Entry Point

  • Updated the kernel entry point to accept the hart/core ID and improved the boot sequence by initializing the trap frame and setting the kernel tick safety duration from configuration. (Fbeaa9ebL6, Fdced9c0L23, F1ffaf34L7)

Interrupt and Timer Handling Enhancements

  • Improved interrupt and timer handling routines with more descriptive comments, clarified CSR bit manipulations, and added helper functions for timer and ktime conversions. (Fabd441dL11, Fabd441dL20, Fabd441dL37, Fabd441dL96, Fd03e8edL3, Fd03e8edL27, F677d06eL167)

These changes collectively enhance the codebase's maintainability, readability, and modularity, making it easier to extend and support additional architectures and subsystems in the future.

…c to define max size of static pool for fdt node and props in config file
… static for safety tick duration and add doc comment in kprint
@LuernOutOfOrder LuernOutOfOrder self-assigned this Dec 3, 2025
@LuernOutOfOrder LuernOutOfOrder added documentation Improvements or additions to documentation enhancement New feature or request labels Dec 3, 2025
@LuernOutOfOrder LuernOutOfOrder linked an issue Dec 3, 2025 that may be closed by this pull request
@LuernOutOfOrder LuernOutOfOrder merged commit cf15094 into develop Dec 3, 2025
1 check passed
@LuernOutOfOrder LuernOutOfOrder deleted the 22-refactor-some-doc-comment-on-struct-or-drivers-or-else branch December 3, 2025 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor some doc comment on struct or drivers or else

1 participant