morpheus_core/net/mod.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
//! Network Initialization Orchestrator
//!
//! Complete network stack initialization for the bootloader. This module
//! coordinates `dma-pool` and `morpheus_network` to bring up networking
//! and return success/failure to the bootstrap phase.
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────┐
//! │ Bootstrap (bootloader) │
//! │ Calls NetworkInit::initialize(), displays result │
//! └─────────────────────────────────────────────────────────────┘
//! │
//! ▼
//! ┌─────────────────────────────────────────────────────────────┐
//! │ core::net (this module) │
//! │ Orchestrates init, manages error ring buffer │
//! └─────────────────────────────────────────────────────────────┘
//! │
//! ┌────────────────────┼────────────────────┐
//! ▼ ▼ ▼
//! dma-pool morpheus_network ping (later)
//! ```
//!
//! # Error Handling
//!
//! All errors are logged to a ring buffer that the bootstrap UI can
//! dump if initialization fails. This includes:
//! - Core orchestration errors
//! - Network crate debug logs (forwarded from its ring buffer)
//!
//! # Usage
//!
//! ```ignore
//! use morpheus_core::net::{NetworkInit, InitConfig, NetworkStatus};
//!
//! // Bootstrap phase
//! let config = InitConfig::default();
//! match NetworkInit::initialize(config, get_time_ms) {
//! Ok(status) => {
//! // Network ready! status.ip_address has our IP
//! // Later: call ping to verify connectivity
//! }
//! Err(e) => {
//! // Dump error ring buffer to UI
//! while let Some(entry) = net::error_log_pop() {
//! display_error(&entry);
//! }
//! }
//! }
//! ```
mod config;
mod error;
mod init;
mod ring_buffer;
mod status;
pub use config::{InitConfig, ECAM_BASE_QEMU_I440FX, ECAM_BASE_QEMU_Q35};
pub use error::{NetInitError, NetInitResult};
pub use ring_buffer::{
debug_log, drain_network_logs, error_log, error_log_available, error_log_clear,
error_log_count, error_log_pop, ErrorLogEntry, InitStage,
};
pub use status::NetworkStatus;