DOCUMENTATION / V1.0.0 LTS
Console.rs Module Dependencies - Matrix
Module Dependencies by Target Module
help.rs (3 commands, 95 lines)
External Crates:
- core::sync::atomic (OrderIng)
Internal Modules:
✓ crate::serial_println!
✓ crate::shell_parse (for parsing utilities)
Shared State:
NONE
Helper Functions to Extract:
- print_help_general()
- print_help_tips()
- print_help_shell()
- print_help_system()
- print_help_commands()
- print_aliases()
Constants Needed:
- COMMANDS: [&[u8]; 48]
storage.rs (11 commands, 250 lines total)
External Crates:
- alloc::string::String
Internal Modules:
✓ crate::serial_println!
✓ crate::serial_print!
✓ crate::fs
✓ crate::pathing
✓ crate::shell_parse (split_command_and_args, parse_rm_args)
Shared State:
✓ WORKING_DIR: Mutex<WorkingDirectoryState> (MUST ACCESS)
Helper Functions to Extract:
- print_tree_recursive()
- current_working_dir() [wrapper]
- set_current_working_dir() [wrapper]
- resolve_shell_path() [wrapper]
- resolve_path_from_cwd() [wrapper]
Utility Functions Needed:
- ascii_bytes_to_str()
- eq_ignore_ascii_case()
- trim_spaces()
- split_command_and_args()
- parse_rm_args()
Constants Needed:
- CMD_BUF_SIZE: usize = 64
Structs Needed:
- WorkingDirectoryState (for working directory access)
system.rs (20+ commands, 1,700 lines total)
External Crates:
- core::sync::atomic (Ordering)
Internal Modules:
✓ crate::serial_println!
✓ crate::serial_print!
✓ crate::cpu
✓ crate::interrupts
✓ crate::server_tasks
✓ crate::boot
✓ crate::power
✓ crate::serial
✓ crate::pathing
Shared State:
✓ CONSOLE: Mutex<ConsoleState> (READ-ONLY for history access)
Helper Functions to Extract (40+):
Print Functions:
- print_cpu_summary()
- print_cpu_features()
- print_cpu_json()
- print_memory_summary()
- print_memory_json()
- print_selftest_text()
- print_selftest_json()
- print_about()
- print_banner()
- print_sysinfo_text()
- print_sysinfo_json()
- print_bootlog_text()
- print_bootlog_json()
- print_net_text()
- print_net_json()
- print_proc_text()
- print_proc_json()
- print_resources_text()
- print_resources_json()
- print_top_text()
- print_top_json()
- print_faults_text()
- print_faults_json()
- print_history()
- print_history_json()
- print_wai_tree_to_cwd()
- print_diagnose()
- print_diagnose_json()
- print_status_json()
- print_status_text()
- print_health_json()
- print_health_reasons_text()
- print_health_verbose_text()
- print_health_text()
- print_help_*() - SHOULD MOVE TO help.rs
- print_aliases() - SHOULD MOVE TO help.rs
Constants Needed:
- CMD_BUF_SIZE: usize = 64
- HISTORY_SIZE: usize = 8
- PAGING_POOL_HIGH_USAGE_PERCENT: u32 = 90
memory.rs (7 commands, 680 lines total) - LARGEST & MOST COMPLEX
External Crates:
- spin::Mutex
- core::sync::atomic (Ordering)
Internal Modules:
✓ crate::serial_println!
✓ crate::serial_print!
✓ crate::memory
✓ crate::paging
✓ crate::interrupts
✓ crate::boot
✓ crate::cpu
✓ crate::server_tasks
Shared State:
NONE (read-only queries to crate modules)
Helper Functions to Extract:
- print_memory_summary()
- print_memory_json()
- print_diagnose()
- print_diagnose_json()
- collect_health_state() [CRITICAL - uses all modules]
- parse_usize_arg()
Structs Needed:
struct HealthState {
soak: crate::paging::SoakStatus,
pool: crate::paging::FramePoolStats,
pool_usage_percent: u32,
pool_high_usage: bool,
paging_selftest_ok: bool,
paging_soak_errors: bool,
paging_alert: bool,
serial_backend_enabled: bool,
local_backend_enabled: bool,
local_backend_initialized: bool,
console_backend_alert: bool,
health: &'static str,
}
Constants Needed:
- CMD_BUF_SIZE: usize = 64
- HISTORY_SIZE: usize = 8
- PAGING_POOL_HIGH_USAGE_PERCENT: u32 = 90
⚠️ SPECIAL NOTE: paging command (378 lines) should potentially be extracted to separate paging_commands.rs due to:
- 30+ sub-commands
- Multiple output formats
- Stress/soak testing logic
- Complex branch handling
Shared Dependencies Summary
Functions Used by Multiple Modules
ascii_bytes_to_str() → ALL modules
eq_ignore_ascii_case() → system, storage (delegates to shell_parse)
starts_with_ignore_ascii_case() → system, memory, storage (delegates to shell_parse)
trim_spaces() → system (delegates to shell_parse)
split_command_and_args() → storage, system (delegates to shell_parse)
parse_rm_args() → storage (delegates to shell_parse)
normalize_alias() → system (delegates to shell_parse)
current_working_dir() → storage, system (cd/wai in system)
resolve_shell_path() → storage, system (wai uses it)
print_diagnose() → memory, system (health checking)
collect_health_state() → memory (used by status/health/diagnose)
Constants Used by Multiple Modules
CMD_BUF_SIZE (64) → system (history), memory (diagnose)
HISTORY_SIZE (8) → system (history), memory (diagnose)
PAGING_POOL_HIGH_USAGE_PERCENT (90) → memory, system (health)
COMMANDS array → help.rs
Shared Structs/State Needed
ConsoleState (CONSOLE mutex)
→ system.rs (for history reading)
WorkingDirectoryState (WORKING_DIR mutex)
→ storage.rs (for all filesystem commands)
→ system.rs (for wai command, cd tracking)
HealthState (internal to memory.rs)
→ Created by collect_health_state()
→ Used by status, health, diagnose commands
External Crate Dependency Map
crate::serial (used by ALL modules)
serial_println!() - output formatting
serial_print!() - output without newline
backend_status() - for outputs command & health checking
set_serial_backend_enabled() - for outputs command
set_local_backend_enabled() - for outputs command
crate::shell_parse (used by storage, system)
split_command_and_args()
normalize_alias()
eq_ignore_ascii_case()
starts_with_ignore_ascii_case()
trim_spaces()
parse_rm_args()
crate::paging (used by memory, system)
Heavy usage in paging command (30+ function calls)
Lighter usage in selftest, diagnose, health commands
crate::memory (used by memory, system)
stats() - for memory, info, diagnose commands
run_self_test() - for selftest command
reset_peak() - for memory command
run_alloc_test() - for memory command
self_test_status() - for status, health commands
crate::interrupts (used by memory, system)
timer_ticks() - for uptime, ticks, diagnose, status commands
page_fault_snapshot() - for faults, diagnose, resources commands
keyboard_snapshot() - for keyboard command
detailed_stats() - for various monitoring commands
crate::cpu (used by system)
get() - for cpu, info, sysinfo, diagnose commands
crate::fs (used by storage, system)
stat() - for stat, cd, tree commands
list_dir() - for ls, tree commands
read_file() - for cat command
write_file() - for write command
mkdir() - for mkdir command
touch() - for touch command
rm() - for rm command
rm_recursive() - for rm -r command
rmdir() - for rmdir command
mounts() - for mount command
crate::boot (used by system)
snapshot() - for bootlog command
crate::power (used by system)
mode_name() - for power command
set_mode() - for power command
request_reboot() - for reboot command
request_shutdown() - for shutdown command
should_halt_after_power_action() - for reboot/shutdown
halt_forever() - for reboot/shutdown
crate::server_tasks (used by system, memory)
stats() - for info, top, status commands
detailed_stats() - for net, proc, tasks, diagnose commands
crate::pathing (used by storage, system)
resolve_from_cwd() - for path resolution in cd, ls, tree, etc.
resolve_path_from_cwd() - wrapper for above
Extraction Order Recommendation
Order by dependency complexity (simplest first):
help.rs (95 lines)
- Minimal dependencies
- No external module calls except serial
storage.rs (250 lines)
- Isolated from other modules
- Depends on fs and pathing (stable)
- Needs WORKING_DIR access
system.rs (1,700 lines)
- Many print functions but all self-contained
- Read-only access to kernel state
- Includes monitoring, power, info commands
memory.rs (680 lines) - Consider splitting:
- memory_commands.rs (memory command only)
- paging_commands.rs (paging - 378 lines - LARGE)
- health_commands.rs (status, health, diagnose)
- Or keep as one module with sub-function organization
Implementation Checklist for Each Module
[ ] help.rs Implementation
[ ] storage.rs Implementation
[ ] system.rs Implementation
[ ] memory.rs Implementation
[ ] commands/mod.rs (dispatcher)
[ ] Update console.rs
This dependency matrix enables safe, parallel development of the four main modules.