charlotte-os / charlotte-core

The Kernel of CharlotteOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Eliminate the dependency on the lazy_static crate

mdpatelcsecon opened this issue · comments

Given the current state of the Rust language lazy_static is not necessary and its use also makes the codebase somewhat harder to read and maintain compared to the alternatives that only require the use of the spin crate which is already in use in the project and thus does not grow its dependencies.

  • Immutable lazily initialized statics should use spin::once::Once<T> instead.
  • Mutable lazily initialized statics should use spin::lazy::Lazy<T> instead.

The code to actually do the lazy initialization will need to go where it reasonably makes sense. Structures used for BSP initialization can be initialized in crate::arch::x86_64::init_bsp. Values that are kernel globals and not tied to any particular LP will probably need an entirely new function exposed in arch::Api for that explicit purpose to be called in main.