DOCUMENTATION / V1.0.0 LTS

Console.rs Command Handler Extraction Analysis

File: /home/ldjiba/Sources/repos/OrbitOne/src/console.rs Total File Lines: ~3700+ execute_command() function: Lines 586-2204


PART 1: COMPLETE COMMAND DISPATCH SECTIONS WITH EXACT LINE RANGES

MODULE 1: HELP HANDLERS (95 lines total)

Command Start Line End Line Approx Lines Dispatch Block Contains
help 595 631 37 6 if-else branches for help topics
commands 633 642 10 List all commands
logs 643 677 35 on/off/status control

Help Section Details:


MODULE 2: OUTPUT/SYSTEM HANDLERS (1200+ lines total)

2A: OUTPUTS & PROMPT (154 lines)

Command Start Line End Line Approx Lines
outputs 678 749 72
prompt 750 785 36

2B: CPU & SELFTEST (57 lines)

Command Start Line End Line Approx Lines
cpu 786 811 26
selftest 869 889 21

2C: SYSTEM INFO COMMANDS (196 lines)

Command Start Line End Line Approx Lines
about 890 899 10
sysinfo 900 914 15
banner 915 924 10
version 925 934 10
info 935 1005 71
bootlog 1006 1026 21

2D: SHELL DISPLAY COMMANDS (40 lines)

Command Start Line End Line Approx Lines
uname 1724 1742 19
history 1743 1763 21
aliases 1764 1773 10
clear 1774 1783 10
echo 1784 1793 10

2E: SYSTEM MONITORING (188 lines)

Command Start Line End Line Approx Lines
net 1515 1535 21
proc 1536 1556 21
resources 1557 1577 21
top 1578 1598 21
tasks/ps 1599 1647 49
faults 1648 1668 21
keyboard 1669 1723 55

2F: POWER COMMANDS (63 lines)

Command Start Line End Line Approx Lines
power 2126 2160 35
reboot 2161 2182 22
shutdown 2183 2203 21

MODULE 3: STORAGE/FILESYSTEM HANDLERS (332 lines total)

Command Start Line End Line Approx Lines
cd 1794 1825 32
wai 1826 1841 16
ls 1842 1872 31
cat 1873 1895 23
mount 1896 1913 18
stat 1914 1949 36
tree 1950 1976 27
mkdir 1977 1999 23
touch 2000 2022 23
write 2023 2052 30
rm 2053 2102 50
rmdir 2103 2125 23

Storage Module Details:


MODULE 4: MEMORY/PAGING HANDLERS (583 lines total)

Command Start Line End Line Approx Lines
memory 812 868 57
paging 1027 1404 378
diagnose 1405 1425 21
ticks 1426 1435 10
uptime 1436 1448 13
status 1449 1473 25
health 1474 1514 41

Memory/Paging Module Details:


PART 2: HELPER FUNCTIONS ANALYSIS

Helper Functions Used by Command Handlers

CPU/System:

Diagnostics:

Status/Health:

System Monitoring:

Faults/Keyboard:

Boot/History:

Help:

Aliases:

Filesystem:

Utility Functions (25+ total)

Command Parsing:

Path/Directory:

Parsing:

Health Monitoring:


PART 3: DEPENDENCIES BY MODULE

MODULE 1: HELP (help.rs)

External Crate Imports Needed:

use core::sync::atomic::Ordering;
use spin::Mutex;

Internal Module Dependencies:

crate::serial_println!
crate::shell_parse (for command parsing)

Helper Functions to Move:

Total Lines to Extract: ~165 lines

Self-contained Functions Used:


MODULE 2: SYSTEM (system.rs)

External Crate Imports Needed:

use core::sync::atomic::Ordering;

Internal Module Dependencies:

crate::serial_println!
crate::serial_print!
crate::cpu
crate::interrupts
crate::paging
crate::memory
crate::boot
crate::power
crate::serial
crate::pathing

Constants Needed:

const CMD_BUF_SIZE: usize = 64;
const HISTORY_SIZE: usize = 8;

Helper Functions to Move:

Total Lines to Extract: ~850 lines

Dependencies Flow:


MODULE 3: STORAGE (storage.rs)

External Crate Imports Needed:

use alloc::string::String;

Internal Module Dependencies:

crate::serial_println!
crate::serial_print!
crate::fs
crate::pathing

Helper Functions to Move:

Helper Functions Already Available:

Total Lines to Extract: ~200 lines (command bodies) + ~50 lines (helpers) = ~250 lines

Working Directory State Required:

Dependencies Flow:


MODULE 4: MEMORY (memory.rs) - COMPLEX

External Crate Imports Needed:

use spin::Mutex;

Internal Module Dependencies:

crate::serial_println!
crate::serial_print!
crate::memory
crate::paging
crate::interrupts
crate::boot
crate::cpu
crate::server_tasks

Helper Functions to Move:

Constants Needed:

const CMD_BUF_SIZE: usize = 64;
const HISTORY_SIZE: usize = 8;
const PAGING_POOL_HIGH_USAGE_PERCENT: u32 = 90;

Struct Needed:

struct HealthState {
    // ... 12 fields
}

Total Lines to Extract: ~400 lines (command bodies) + ~280 lines (helpers) = ~680 lines

PAGING COMMAND COMPLEXITY: The paging command (lines 1027-1404) is extremely complex:

Memory Command Dependencies:

crate::memory::stats()
crate::memory::run_self_test()
crate::memory::reset_peak()
crate::memory::run_alloc_test()

Paging Command Dependencies:

crate::paging::get()
crate::paging::hw_vm_status()
crate::paging::set_hw_vm_enabled()
crate::paging::run_hw_vm_self_test()
crate::paging::frame_pool_stats()
crate::paging::vm_map_stats()
crate::paging::run_vm_self_test()
crate::paging::map_page()
crate::paging::unmap_page()
crate::paging::query_mapping()
crate::paging::soak_status()
crate::paging::stop_soak()
crate::paging::start_soak()
crate::paging::run_self_test()
crate::paging::run_stress()
crate::paging::alloc_frame()
crate::paging::free_frame()

PART 4: SUMMARY TABLE - EXTRACTION EFFORT ESTIMATE

Module Lines Commands Complexity Helpers Dependencies Effort
help.rs 95 3 Low 6 Medium 1 hour
system.rs 1,700 20+ Medium 40+ High 3 hours
storage.rs 250 11 Low 8 Medium 1.5 hours
memory.rs 680 7 HIGH 8 HIGH 3 hours
TOTAL 2,725 41 Medium 62+ Complex ~8.5 hrs

Phase 1: Foundation (Quick Wins)

  1. Extract help.rs (low complexity, few dependencies)
  2. Extract storage.rs (low complexity, isolated from others)

Phase 2: System Commands

  1. Extract system.rs (medium complexity, many print functions but isolated)
    • All helper functions are self-contained
    • Dependencies are read-only (querying state)

Phase 3: Complex Core

  1. Extract memory.rs
    • Potentially split into:
      • memory_commands.rs (~90 lines)
      • paging_commands.rs (~380 lines - LARGE)
      • health_commands.rs (~100 lines)
      • diagnostics.rs (~200 lines)

Phase 4: Integration

  1. Create commands/mod.rs dispatcher
  2. Update console.rs to call new dispatcher
  3. Test and validate

PART 6: CRITICAL OBSERVATIONS

1. Shared State Requirements

2. Helper Function Sharing Opportunities

Several helpers used by multiple modules:

3. Paging Command is Exceptionally Complex

4. Dependencies Hierarchy

help.rs (bottom - no dependencies on other command modules)
storage.rs (isolated)
system.rs (queries multiple crates, no command module deps)
memory.rs (top - uses collect_health_state(), paging module heavily)

5. No Circular Dependencies


PART 7: EXACT COMMAND DISPATCH BLOCKS - QUICK REFERENCE

In execute_command() function (lines 586-2204):

595-631     help command (37 lines)
633-642     commands (10 lines)
643-677     logs (35 lines)
678-749     outputs (72 lines)
750-785     prompt (36 lines)
786-811     cpu (26 lines)
812-868     memory (57 lines)
869-889     selftest (21 lines)
890-899     about (10 lines)
900-914     sysinfo (15 lines)
915-924     banner (10 lines)
925-934     version (10 lines)
935-1005    info (71 lines)
1006-1026   bootlog (21 lines)
1027-1404   paging (378 lines) ⚠️ LARGEST
1405-1425   diagnose (21 lines)
1426-1435   ticks (10 lines)
1436-1448   uptime (13 lines)
1449-1473   status (25 lines)
1474-1514   health (41 lines)
1515-1535   net (21 lines)
1536-1556   proc (21 lines)
1557-1577   resources (21 lines)
1578-1598   top (21 lines)
1599-1647   tasks/ps (49 lines)
1648-1668   faults (21 lines)
1669-1723   keyboard (55 lines)
1724-1742   uname (19 lines)
1743-1763   history (21 lines)
1764-1773   aliases (10 lines)
1774-1783   clear (10 lines)
1784-1793   echo (10 lines)
1794-1825   cd (32 lines)
1826-1841   wai (16 lines)
1842-1872   ls (31 lines)
1873-1895   cat (23 lines)
1896-1913   mount (18 lines)
1914-1949   stat (36 lines)
1950-1976   tree (27 lines)
1977-1999   mkdir (23 lines)
2000-2022   touch (23 lines)
2023-2052   write (30 lines)
2053-2102   rm (50 lines)
2103-2125   rmdir (23 lines)
2126-2160   power (35 lines)
2161-2182   reboot (22 lines)
2183-2203   shutdown (21 lines)

PART 8: HELPER FUNCTIONS - COMPLETE INVENTORY

Total: 62+ helper functions

Location Coordinates in File:

Note: Line numbers are approximate ±5 lines due to file structure


ANALYSIS COMPLETE

This structured analysis provides everything needed for targeted extraction. All command dispatch blocks are identified with exact line numbers, dependencies are catalogued, and effort estimates are provided.