Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions kernel/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ fn main() {
println!("cargo:rerun-if-changed={}/job_control_test.rs", userspace_tests);
println!("cargo:rerun-if-changed={}/session_test.rs", userspace_tests);
println!("cargo:rerun-if-changed={}/job_table_test.rs", userspace_tests);
println!("cargo:rerun-if-changed={}/http_test.rs", userspace_tests);
println!("cargo:rerun-if-changed={}/pipeline_test.rs", userspace_tests);
println!("cargo:rerun-if-changed={}/sigchld_job_test.rs", userspace_tests);
println!("cargo:rerun-if-changed={}/lib.rs", libbreenix_dir.to_str().unwrap());
Expand Down
5 changes: 5 additions & 0 deletions kernel/src/arch_impl/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
//!
//! These traits define the interface between architecture-specific code and
//! the rest of the kernel. Each architecture must implement these traits.
//!
//! Note: This is part of the complete HAL API. Not all traits and their
//! methods are actively used yet, but they define the complete abstraction.

#![allow(dead_code)] // HAL traits - complete API for architecture abstraction

use core::ops::BitOr;

Expand Down
6 changes: 6 additions & 0 deletions kernel/src/arch_impl/x86_64/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
//!
//! This module centralizes all x86_64-specific magic numbers and constants
//! that were previously scattered throughout the kernel.
//!
//! Note: This is a complete HAL constants module. Many constants are
//! intentionally defined for API completeness and documentation even
//! if not currently used by the kernel.

#![allow(dead_code)] // HAL constants - complete API for x86_64 architecture

// ============================================================================
// Memory Layout Constants
Expand Down
5 changes: 5 additions & 0 deletions kernel/src/arch_impl/x86_64/cpu.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
//! x86_64 CPU operations.
//!
//! Implements basic CPU control operations like interrupt management and halt.
//!
//! Note: This is part of the complete HAL API. The X86Cpu struct
//! implements the CpuOps trait.

#![allow(dead_code)] // HAL type - part of complete API

use crate::arch_impl::traits::CpuOps;

Expand Down
7 changes: 7 additions & 0 deletions kernel/src/arch_impl/x86_64/interrupt_frame.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
//! x86_64 interrupt frame abstraction.
//!
//! Note: This is part of the complete HAL API. The struct may not be
//! directly constructed in all code paths but implements the InterruptFrame trait.

#![allow(dead_code)] // HAL type - part of complete API

use x86_64::structures::idt::InterruptStackFrame;
use x86_64::VirtAddr;

Expand Down
15 changes: 15 additions & 0 deletions kernel/src/arch_impl/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
//! - Per-CPU data access via GS segment
//! - TSC timer operations
//! - PIC interrupt controller
//!
//! Note: This is a complete Hardware Abstraction Layer (HAL) API.
//! Many items are intentionally defined for API completeness even
//! if not currently used by the kernel.

// HAL modules define complete APIs - not all items are used yet
#[allow(unused_imports)]
pub mod constants;
pub mod cpu;
pub mod interrupt_frame;
Expand All @@ -18,11 +24,20 @@ pub mod privilege;
pub mod timer;

// Re-export commonly used items
// These re-exports are part of the complete HAL API
#[allow(unused_imports)]
pub use constants::*;
#[allow(unused_imports)]
pub use cpu::X86Cpu;
#[allow(unused_imports)]
pub use interrupt_frame::X86InterruptFrame;
#[allow(unused_imports)]
pub use paging::{X86PageFlags, X86PageTableOps};
#[allow(unused_imports)]
pub use percpu::X86PerCpu;
#[allow(unused_imports)]
pub use pic::X86Pic;
#[allow(unused_imports)]
pub use privilege::X86PrivilegeLevel;
#[allow(unused_imports)]
pub use timer::X86Timer;
5 changes: 5 additions & 0 deletions kernel/src/arch_impl/x86_64/paging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
//!
//! Implements the PageTableOps and PageFlags traits for x86_64's 4-level
//! page table hierarchy.
//!
//! Note: This is part of the complete HAL API. Helper functions like
//! index extractors are defined for API completeness.

#![allow(dead_code)] // HAL module - complete API for x86_64 paging

use crate::arch_impl::traits::{PageFlags, PageTableOps};
use core::ops::BitOr;
Expand Down
5 changes: 5 additions & 0 deletions kernel/src/arch_impl/x86_64/percpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
//! This module provides all x86_64-specific per-CPU operations. The kernel's
//! per_cpu.rs module delegates to these functions for architecture-specific
//! operations.
//!
//! Note: This is part of the complete HAL API. Many operations are defined
//! for API completeness (e.g., NMI context, softirq operations).

#![allow(dead_code)] // HAL module - complete API for x86_64 per-CPU operations

use crate::arch_impl::traits::PerCpuOps;
use crate::arch_impl::x86_64::constants::*;
Expand Down
7 changes: 7 additions & 0 deletions kernel/src/arch_impl/x86_64/pic.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
//! x86_64 PIC (8259A) interrupt controller.
//!
//! Note: This is part of the complete HAL API. The X86Pic struct
//! implements the InterruptController trait.

#![allow(dead_code)] // HAL type - part of complete API

use crate::arch_impl::traits::InterruptController;
use crate::interrupts::{PICS, PIC_1_OFFSET};

Expand Down
7 changes: 7 additions & 0 deletions kernel/src/arch_impl/x86_64/privilege.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
//! x86_64 privilege level abstraction.
//!
//! Note: This is part of the complete HAL API. The enum variants
//! represent x86_64 protection rings.

#![allow(dead_code)] // HAL type - part of complete API

use crate::arch_impl::traits::PrivilegeLevel;

#[derive(Copy, Clone, Debug, PartialEq, Eq)]
Expand Down
5 changes: 5 additions & 0 deletions kernel/src/arch_impl/x86_64/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
//! Implements the TimerOps trait using the Time Stamp Counter (TSC).
//! This module provides all x86_64-specific timer functionality including
//! TSC reading and PIT-based calibration.
//!
//! Note: This is part of the complete HAL API. Helper functions for TSC
//! operations are defined for API completeness.

#![allow(dead_code)] // HAL module - complete API for x86_64 timer operations

use crate::arch_impl::traits::TimerOps;
use core::arch::asm;
Expand Down
14 changes: 14 additions & 0 deletions kernel/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,20 @@ fn kernel_main_continue() -> ! {
}
}
}

// Launch HTTP test to verify HTTP client over TCP+DNS
{
serial_println!("RING3_SMOKE: creating http_test userspace process");
let http_test_buf = crate::userspace_test::get_test_binary("http_test");
match process::creation::create_user_process(String::from("http_test"), &http_test_buf) {
Ok(pid) => {
log::info!("Created http_test process with PID {}", pid.as_u64());
}
Err(e) => {
log::error!("Failed to create http_test process: {}", e);
}
}
}
});
}

Expand Down
3 changes: 2 additions & 1 deletion kernel/src/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ use crate::drivers::e1000;
pub struct NetConfig {
/// Our IPv4 address
pub ip_addr: [u8; 4],
/// Subnet mask
/// Subnet mask (for routing decisions - not yet used but required for complete config)
#[allow(dead_code)] // Part of complete network config API
pub subnet_mask: [u8; 4],
/// Default gateway
pub gateway: [u8; 4],
Expand Down
30 changes: 18 additions & 12 deletions kernel/src/net/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ impl TcpFlags {
}

/// Parsed TCP header
///
/// All fields are parsed from the TCP header for completeness and protocol conformance.
#[derive(Debug)]
#[allow(dead_code)] // All TCP header fields are part of RFC 793 protocol structure
pub struct TcpHeader {
/// Source port
pub src_port: u16,
Expand Down Expand Up @@ -232,7 +235,11 @@ pub fn build_tcp_packet_with_checksum(
}

/// TCP connection state (RFC 793)
///
/// All variants are part of the complete TCP state machine as defined in RFC 793.
/// Some states may not be actively used yet as the implementation matures.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[allow(dead_code)] // RFC 793 state machine - all states are part of the complete protocol
pub enum TcpState {
Closed,
Listen,
Expand Down Expand Up @@ -262,7 +269,8 @@ pub struct TcpConnection {
pub state: TcpState,
/// Our sequence number (next byte to send)
pub send_next: u32,
/// Initial send sequence number
/// Initial send sequence number (RFC 793 - needed for retransmission and RST validation)
#[allow(dead_code)] // Part of RFC 793 state machine, needed for future retransmission logic
pub send_initial: u32,
/// Send unacknowledged (oldest unacked seq)
pub send_unack: u32,
Expand All @@ -276,11 +284,13 @@ pub struct TcpConnection {
pub send_window: u16,
/// Pending data to receive
pub rx_buffer: VecDeque<u8>,
/// Pending data to send
/// Pending data to send (for future send buffering/retransmission)
#[allow(dead_code)] // Part of TCP API, needed for send buffering when window is full
pub tx_buffer: VecDeque<u8>,
/// Maximum segment size
pub mss: u16,
/// Process ID that owns this connection
/// Process ID that owns this connection (for cleanup on process exit)
#[allow(dead_code)] // Needed for connection ownership tracking
pub owner_pid: crate::process::process::ProcessId,
/// True if SHUT_WR was called (no more sending)
pub send_shutdown: bool,
Expand Down Expand Up @@ -315,6 +325,7 @@ impl TcpConnection {
}

/// Create a new connection in LISTEN state (for accept)
#[allow(dead_code)] // Part of TCP server API, used when implementing server-side accept
pub fn new_listening(
local_ip: [u8; 4],
local_port: u16,
Expand Down Expand Up @@ -361,6 +372,8 @@ pub struct PendingConnection {

/// Listening socket info
pub struct ListenSocket {
/// Local IP address for this listening socket (for binding to specific interfaces)
#[allow(dead_code)] // Part of socket bind API, needed for interface-specific listening
pub local_ip: [u8; 4],
pub local_port: u16,
pub backlog: usize,
Expand Down Expand Up @@ -1074,14 +1087,6 @@ pub fn tcp_close(conn_id: &ConnectionId) -> Result<(), &'static str> {
Ok(())
}

/// Check if a connection is established
pub fn tcp_is_connected(conn_id: &ConnectionId) -> bool {
let connections = TCP_CONNECTIONS.lock();
connections.get(conn_id)
.map(|c| c.state == TcpState::Established)
.unwrap_or(false)
}

/// Check if there's a pending connection to accept
pub fn tcp_has_pending(local_port: u16) -> bool {
let listeners = TCP_LISTENERS.lock();
Expand All @@ -1090,7 +1095,8 @@ pub fn tcp_has_pending(local_port: u16) -> bool {
.unwrap_or(false)
}

/// Get connection state for debugging
/// Get connection state for debugging and introspection
#[allow(dead_code)] // Part of TCP debugging API
pub fn tcp_get_state(conn_id: &ConnectionId) -> Option<TcpState> {
let connections = TCP_CONNECTIONS.lock();
connections.get(conn_id).map(|c| c.state)
Expand Down
5 changes: 0 additions & 5 deletions kernel/src/syscall/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@ impl SyscallFrame {
pub fn set_return_value(&mut self, value: u64) {
self.rax = value;
}

/// Get return value
pub fn return_value(&self) -> u64 {
self.rax
}
}

// Implement the HAL SyscallFrame trait
Expand Down
2 changes: 2 additions & 0 deletions kernel/src/time/tsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::arch_impl::current::timer as hal_timer;
/// Returns a 64-bit cycle count. On modern CPUs with invariant TSC,
/// this increments at a constant rate regardless of CPU frequency scaling.
#[inline(always)]
#[allow(dead_code)] // Low-level timing primitive, part of TSC API
pub fn read_tsc() -> u64 {
hal_timer::rdtsc()
}
Expand All @@ -21,6 +22,7 @@ pub fn read_tsc() -> u64 {
/// providing more accurate timing for benchmarking. This is more portable
/// than RDTSCP which isn't available on all CPU models.
#[inline(always)]
#[allow(dead_code)] // Low-level timing primitive, part of TSC API
pub fn read_tsc_serialized() -> u64 {
hal_timer::rdtsc_serialized()
}
Expand Down
Loading
Loading