include: one folder per subsystem, and includes that name it
Sixty-five headers sat side by side in include/, so `#include "irq.h"` said nothing about where irq.h was or what it belonged to, and errno.h, stat.h and fcntl.h at the top shadowed the system's for any host tool built with -I./include. They are in folders now -- arch/ core/ fs/ dev/ gfx/ net/ uapi/ (and ldls/ for the Linux driver layer) -- and every include names the folder, as Linux's do: "core/proc.h". Done mechanically and checked the hard way: the kernel built from this tree disassembles identically to the one built from the tree before it. The full image boots, and userland is the same set of programs. Paths in docs and comments follow; docs/guides/layout.md has a table of what is where, and tools/fix-includes.py rewrites old-style includes from the folders in the tree, for code written before this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S1giNvrHTrPMPw7V6x1kQ4
This commit is contained in:
parent
0e39e711f1
commit
a1c965da1e
267 changed files with 1560 additions and 1440 deletions
|
|
@ -15,7 +15,8 @@ schos/
|
|||
├─ boot/ uefi/ the PE/COFF loader (splash, F8 menu, kernel load),
|
||||
│ common/ the UI it shares. UEFI only -- there is no BIOS path.
|
||||
├─ kernel/ The kernel, by subsystem: arch/ core/ dev/ fs/ proc/ sys/
|
||||
├─ include/ Headers shared by kernel, userland, and tools/mkfs
|
||||
├─ include/ Headers shared by kernel, userland, and tools/mkfs, by
|
||||
│ subsystem -- see "include/" below
|
||||
├─ lib/ First-party userland runtime: _start glue, syscall stubs,
|
||||
│ the initcode blob embedded in the kernel, user.ld
|
||||
├─ cmd/ First-party programs — one directory per program:
|
||||
|
|
@ -57,6 +58,32 @@ schos/
|
|||
└─ build/ ALL generated output (see below)
|
||||
```
|
||||
|
||||
## include/
|
||||
|
||||
One folder per subsystem, and every include names it: `#include
|
||||
"core/proc.h"`, not `"proc.h"`. The compiler is given `-I./include` and
|
||||
nothing deeper, so the folder is the only way to reach a header and the
|
||||
include line says where to find it.
|
||||
|
||||
| folder | what is in it |
|
||||
|---------|---------------|
|
||||
| `arch/` | the x86-64 machine: `mmu.h`, `x86.h`, `traps.h`, `memlayout.h`, `mp.h`, `ioperm.h`, `vmap.h`, `asm.h`, and `schboot.h`, the loader's handoff block |
|
||||
| `core/` | the kernel proper: `types.h`, `param.h`, `defs.h`, `proc.h`, the locks, `kmem.h`, `dma.h`, `irq.h`, `klog.h`, `dbg.h`, `sbuf.h`, `syscall.h`, `uaccess.h`, `hwinfo.h`, `elf.h`, `date.h` |
|
||||
| `fs/` | the VFS and what is under it: `fs.h`, `file.h`, `buf.h`, `blkdev.h`, `schfs.h`, `fat.h`, `fsstat.h` |
|
||||
| `dev/` | devices and buses: `device.h`, `pci.h`, `pciuser.h`, `usb.h`, `virtio.h`, `acpi.h`, `input.h`, `kbd.h`, `keymap.h`, `vt.h`, `audio.h`, `netdev.h` |
|
||||
| `gfx/` | pixels: `display.h`, `fb.h`, `gfx.h`, `font.h`, `text.h`, `ttf.h`, `theme.h`, `logo.h` (generated), `qr.h` |
|
||||
| `net/` | `socket.h`, `netuser.h` |
|
||||
| `uapi/` | what userland is built against: `user.h`, `posix.h`, `errno.h`, `stat.h`, `fcntl.h`, `schinit.h` |
|
||||
| `ldls/` | the Linux driver layer's headers |
|
||||
|
||||
A side effect worth having: `errno.h`, `stat.h` and `fcntl.h` are no longer
|
||||
at the top of `include/`, so a host tool built with `-I./include` gets the
|
||||
system's versions of them rather than ours.
|
||||
|
||||
`tools/fix-includes.py` rewrites a bare `#include "proc.h"` to the folder the
|
||||
header is in, reading the folders from the tree. Run it with `--modified` on
|
||||
code written before the split, or after moving a header.
|
||||
|
||||
## build/
|
||||
|
||||
```
|
||||
|
|
|
|||
Loading…
Reference in a new issue