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
|
|
@ -1,13 +1,13 @@
|
|||
#include "param.h"
|
||||
#include "types.h"
|
||||
#include "defs.h"
|
||||
#include "gfx.h"
|
||||
#include "x86.h"
|
||||
#include "memlayout.h"
|
||||
#include "mmu.h"
|
||||
#include "proc.h"
|
||||
#include "ioperm.h"
|
||||
#include "vmap.h"
|
||||
#include "core/param.h"
|
||||
#include "core/types.h"
|
||||
#include "core/defs.h"
|
||||
#include "gfx/gfx.h"
|
||||
#include "arch/x86.h"
|
||||
#include "arch/memlayout.h"
|
||||
#include "arch/mmu.h"
|
||||
#include "core/proc.h"
|
||||
#include "arch/ioperm.h"
|
||||
#include "arch/vmap.h"
|
||||
|
||||
int mappages(pml4e_t *pgdir, void *va, addr_t size, addr_t pa, int perm);
|
||||
static pte_t * walkpgdir(pml4e_t *pml4, const void *va, int alloc);
|
||||
|
|
@ -15,7 +15,7 @@ static pte_t * walkpgdir(pml4e_t *pml4, const void *va, int alloc);
|
|||
|
||||
// `cpu` and `proc` are no longer __thread variables; they live at fixed offsets
|
||||
// in the per-CPU block and are read through %gs at each use. See the long
|
||||
// comment in include/proc.h for why -- the short version is that __thread means
|
||||
// comment in include/core/proc.h for why -- the short version is that __thread means
|
||||
// per *thread*, the compiler caches the thread pointer across calls on that
|
||||
// basis, and a kernel thread changes CPU at every sched().
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ seginit(void)
|
|||
gdt = (struct segdesc*) local;
|
||||
|
||||
// The TSS moved out of this page. It now carries an I/O permission bitmap
|
||||
// (include/ioperm.h) which does not fit here, and it has to be one object
|
||||
// (include/arch/ioperm.h) which does not fit here, and it has to be one object
|
||||
// with it. ioperm_tss() returns it and the descriptor limit that reaches the
|
||||
// end of the bitmap.
|
||||
tss = (uint*) ioperm_tss(cpunum(), &tsslim);
|
||||
|
|
@ -136,7 +136,7 @@ seginit(void)
|
|||
*(uint64 *) kernel_fs_base = kernel_fs_base;
|
||||
|
||||
// Clear the per-CPU slots before anything can read them. Their offsets are
|
||||
// the PERCPU_* constants in include/proc.h and are shared with trapasm.S,
|
||||
// the PERCPU_* constants in include/core/proc.h and are shared with trapasm.S,
|
||||
// which reads %gs:24 for proc on the way out to user mode and parks three
|
||||
// registers at %gs:32..48 across the FS_BASE swap on the way in.
|
||||
((uint64 *) kernel_fs_base)[2] = 0; // struct cpu * (PERCPU_CPU)
|
||||
|
|
@ -339,7 +339,7 @@ ioremap(uint64 pa, uint64 size)
|
|||
|
||||
// --- write-combining, and big buffers -----------------------------------------
|
||||
//
|
||||
// See include/vmap.h. The console used to draw straight into the framebuffer
|
||||
// See include/arch/vmap.h. The console used to draw straight into the framebuffer
|
||||
// through the direct map, which is uncached across the whole PCI hole: every
|
||||
// store was its own bus transaction and every read -- a scroll is a memmove,
|
||||
// so a read for every byte on screen -- waited on the card. In QEMU that is
|
||||
|
|
|
|||
Loading…
Reference in a new issue