Expand description
Bare-metal main loop for post-ExitBootServices execution.
This module provides the complete end-to-end runner that:
- Initializes the VirtIO-net driver using ASM layer
- Creates the smoltcp interface and sockets
- Runs the 5-phase main loop
- Orchestrates ISO download and disk write
- Writes manifest to disk for boot entry discovery
§Reference
NETWORK_IMPL_GUIDE.md §6, §7
Structs§
- Configuration for the bare-metal runner.
- RX token for smoltcp - uses a fixed-size buffer (no heap allocation). Maximum Ethernet frame size is 1514 bytes.
- Adapter bridging NetworkDriver to smoltcp Device trait.
- TX token for smoltcp - uses a fixed-size stack buffer (no heap allocation).
Enums§
- Run result.
Constants§
- Size of write buffer: 64KB = 128 sectors (optimal for VirtIO-blk)
- Number of sectors per write operation
- Serial port base address (COM1).
Statics§
- Actual start sector (after finding free space)
- Next request ID for block driver
- Next sector to write to
- Total bytes written to disk
- Static buffer for accumulating data before disk write
- Current fill level of write buffer
- Static buffer for manifest serialization (1 sector = 512 bytes, but manifest can be up to ~1KB, so use 2 sectors).
- Static flag to detect reentrancy in polling loop. If this is > 1 during a poll, we have a bug.
Functions§
- Main bare-metal entry point.
- Add data to the disk write buffer. Automatically flushes when buffer is full. Returns the number of bytes consumed from the input.
- Case-insensitive contains for ASCII strings (no heap allocation).
- Create a GPT partition for ISO data storage.
- Increment poll depth, panic if already polling.
- Decrement poll depth.
- Create and write a completed ISO manifest to disk.
- Write manifest to FAT32 ESP filesystem.
- Write manifest to raw disk sector (legacy method).
- Find the end of HTTP headers (\r\n\r\n). Returns the position of the first \r in \r\n\r\n.
- Flush the disk write buffer to the block device.
- Flush any remaining data in the buffer (for end of download).
- Format an HTTP GET request into a static buffer. Returns the number of bytes written, or None if buffer too small.
- Parse IPv4 address from string without allocation. Format: “a.b.c.d” where a,b,c,d are 0-255.
- parse_
u8 🔒Parse a u8 from a string without allocation. - Parse a u16 from a string without allocation.
- Parse usize from string without allocation.
- Print an IPv4 address (e.g., “10.0.2.15”).
- Full integrated main loop with real state machines.
- Write string to serial port.
- Print a decimal number.
- Print hex number.
- Write string with newline.
- Write a byte to serial port.
- Case-insensitive starts_with for ASCII strings (no heap allocation).
- Convert TSC ticks to smoltcp Instant.
- Write an ISO manifest to disk at the specified sector.