Skip to content
cllm

// architecture

From Multiboot entry to HTTP response.

The whole kernel is eight files of substance. There is no dynamic linking, no module loader, no plugin surface, and no host OS. Every layer has a single owner and you can read the entire control flow top to bottom.

cllm :: layers
+-----------------------------------------------------------+
|  QEMU / Bare Metal  (x86, Multiboot)                     |
+-----------------------------------------------------------+
|  boot.S             Multiboot entry, stack, serial init   |
|  kernel.c           Kernel main, VGA terminal, serial I/O |
|  memory.c           Heap allocator (malloc/free)          |
|  string.c           libc subset (snprintf, memcpy, ...)   |
|  network.c          PCI enumeration + e1000 NIC driver    |
|  http.c / api.c     HTTP server, request routing          |
|  api_v1.c           llama.cpp-compatible REST API         |
|  llm.c              Model loading and inference interface |
+-----------------------------------------------------------+

The path a request takes

  1. 01 A frame arrives on the Intel e1000 NIC. network.c pulls it off the receive ring.
  2. 02 The minimal IPv4 + TCP layer reassembles the byte stream for port 80.
  3. 03 http.c parses the HTTP/1.1 request line and headers.
  4. 04 api.c matches the method and path to a v1 handler.
  5. 05 api_v1.c validates the request body and calls into llm.c.
  6. 06 llm.c returns the result (a stub today) and the response is serialized back down the same path.

Every file, what it owns

boot.S Multiboot entry

Declares the Multiboot header, sets up the stack, initializes serial output, and jumps to kernel_main. This is the first code the loader runs.

kernel.c Kernel main

Brings up the VGA terminal and serial I/O, then enters the main loop. There is no scheduler — this loop owns the CPU.

memory.c Heap allocator

Manages a statically-allocated 4 MB arena with malloc and free. Flat 32-bit addressing, no paging, no virtual memory manager.

string.c libc subset

snprintf, memcpy, memset, strncmp and the handful of string routines the rest of the kernel needs. No external C library.

network.c PCI + e1000

Walks the PCI bus, claims the Intel e1000 NIC, brings up the descriptor rings, and moves raw Ethernet frames in and out.

http.c / api.c HTTP server + router

Parses HTTP/1.1 requests off the wire and routes them to handlers. The server is the packet-processing loop, not a daemon on an OS.

api_v1.c v1 REST API

Implements the llama.cpp-shaped v1 endpoints: completions, chat, embeddings, models, tokenize, detokenize.

llm.c Inference seam

The interface where model loading and the inference engine plug in. Handlers dispatch here; responses are stubs until the llama.cpp path is integrated.

// memory & concurrency model

  • Flat 32-bit addressing. No paging, no virtual memory manager, no page faults.
  • Single-threaded request handling — one request processed at a time in the main loop.
  • 4 MB heap arena. Enough for the kernel and structures; the model loader will grow it before real weights land.
  • The architecture notes call out SSE/AVX/AVX-512 for math kernels, but optimized kernels are not shipped because the engine is not integrated yet.