HarvTTP Operation

Structure and request flow

HarvTTP combines a small cooperative scheduler, a preloaded asset bundle, a minimal packet stack, a PHP request queue and an HNET MMIO driver. The current runtime is deliberately compact so the processor and boot behavior remain visible.

Boot-ROM handoff

The boot ROM validates harvttp.elf, loads executable segments into IMEM, data segments into DMEM, creates start parameters and optionally places a content bundle in DMEM. At application entry:

a0 = address of harvos_app_start_params_t
sp = 0x00178000
pc = ELF entry point
IMEM loader = locked

Start parameters

FieldUse in HarvTTP
app_idMixed into the local MAC address: 02:48:54:54:50:app_id.
service_maskReserved for later service policy.
debug_flagsReserved for diagnostics and telemetry.
preloaded_content_vaddrAddress of the HTTP bundle prepared by the boot ROM.
preloaded_content_sizeBundle size, checked against the bundle header.
config_pathDocuments the YAML configuration source.
data_pathDocuments the persistent data path used by the service.
content_root_pathDocuments the program-image web root path.

Internal structures

TypePurpose
harvttp_context_tMain runtime state: start parameters, workers, network state, TCP peers, bundle pointers, PHP jobs, SQL loopback sockets, buffers and counters.
harvttp_thread_tCooperative worker with active/running flags, wake tick, fault counters and a run function.
harvttp_net_tMAC address, IP, mask, gateway, DNS, DHCP server, DHCP XID and DHCP state.
harvttp_tcp_peer_tClient MAC/IP/port, sequence numbers, last tick and TCP state for up to 64 peers.
harvttp_tx_queue_t64 slots for outgoing Ethernet frames, which prevents short response bursts from being dropped immediately.
harvttp_http_job_tQueued PHP request with URI, query string, POST body, peer index and response buffers.
harvos_http_bundle_entry_tOne entry per preloaded file: path, offset, size and MIME type.

Cooperative workers

IDNameTaskWake behavior
0ContentValidates the bundle, finds /index.html and prepares fallback output.Runs rarely after initialization.
1DHCPSends DHCP Discover/Request and manages the bound state.Short sleeps until a lease is acquired.
2TXFlushes the outgoing frame queue to HNET.One tick while work exists, otherwise two ticks.
3RX/HTTPReceives bursts, dispatches ARP/DHCP/TCP and routes HTTP requests.One to two ticks in normal operation.
4WatchdogPublishes telemetry through the HarvOS syscall path and restarts faulted workers.4096 ticks.
5SQL loopbackMaintains the HarvSQL loopback client path used by PHP database calls.Fast while connecting, slow while idle.
6-9HTTP workersConsume queued PHP jobs, stream heartbeats for long requests and send completed responses.One tick while busy, longer sleeps while idle.

HTTP request flow

  1. HNET reports RX_VALID.
  2. HarvTTP copies the Ethernet frame out of the DMA window into the RX buffer.
  3. ARP requests for the assigned IP are answered.
  4. DHCP replies are processed until the network is bound.
  5. A TCP SYN to port 80 creates a peer and returns SYN/ACK.
  6. The HTTP parser accepts GET and selected POST data up to the configured request buffer.
  7. Static paths are resolved against the preloaded bundle or data web root.
  8. .php paths are queued as harvttp_http_job_t entries when PHP support is enabled.
  9. The response uses HTTP/1.0 and Connection: close.

PHP execution path

HarvTTP has two PHP paths. The small template renderer remains useful for smoke tests and diagnostics. The PHP 8.5 path builds a harvos_php85_request_t and calls the HarvOS SAPI so Zend executes the script from a memory-backed stream. Four HTTP workers can keep independent request jobs in flight; the Zend lane still depends on the linked PHP build and the available HarvOS runtime layer.

FeatureCurrent behavior
OutputBuffered into HarvTTP-owned memory, with heartbeat streaming for long-running PHP requests.
HeadersCaptured by the SAPI and translated back into the HTTP response.
Request dataURI, script name, query string, server fields, cookies and POST bytes are passed through the ABI.
DatabasePHP database calls target HarvSQL through the loopback socket path on the MySQL-compatible port.

Path and MIME rules

RuleDescription
/Resolves to /index.html or to the configured PHP entry point in a WordPress data web root.
Trailing slash/docs/ resolves to /docs/index.html when the path buffer allows it.
Query/fragmentThe path resolver ignores everything after ? or #.
Traversal. and .. are normalized; paths escaping above / are rejected.
MIMEHTML, CSS, JS, images, text, PHP and binary data are classified before response generation.