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
|
|
@ -20,21 +20,21 @@
|
|||
// not a matter of starting it and walking away; it is a matter of keeping LVI
|
||||
// ahead of CIV, which is what queue() does.
|
||||
|
||||
#include "types.h"
|
||||
#include "defs.h"
|
||||
#include "param.h"
|
||||
#include "x86.h"
|
||||
#include "spinlock.h"
|
||||
#include "sleeplock.h"
|
||||
#include "fs.h"
|
||||
#include "file.h"
|
||||
#include "memlayout.h"
|
||||
#include "mmu.h"
|
||||
#include "pci.h"
|
||||
#include "device.h"
|
||||
#include "audio.h"
|
||||
#include "dma.h"
|
||||
#include "irq.h"
|
||||
#include "core/types.h"
|
||||
#include "core/defs.h"
|
||||
#include "core/param.h"
|
||||
#include "arch/x86.h"
|
||||
#include "core/spinlock.h"
|
||||
#include "core/sleeplock.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/file.h"
|
||||
#include "arch/memlayout.h"
|
||||
#include "arch/mmu.h"
|
||||
#include "dev/pci.h"
|
||||
#include "dev/device.h"
|
||||
#include "dev/audio.h"
|
||||
#include "core/dma.h"
|
||||
#include "core/irq.h"
|
||||
|
||||
// --- NAM, the mixer ---------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -19,19 +19,19 @@
|
|||
// scheduler, so a driver that waited for an interrupt during probe would wait
|
||||
// forever. Interrupts are for later, when a device is delivering data.
|
||||
|
||||
#include "types.h"
|
||||
#include "defs.h"
|
||||
#include "irq.h"
|
||||
#include "dma.h"
|
||||
#include "param.h"
|
||||
#include "memlayout.h"
|
||||
#include "mmu.h"
|
||||
#include "spinlock.h"
|
||||
#include "sleeplock.h"
|
||||
#include "fs.h"
|
||||
#include "file.h"
|
||||
#include "pci.h"
|
||||
#include "usb.h"
|
||||
#include "core/types.h"
|
||||
#include "core/defs.h"
|
||||
#include "core/irq.h"
|
||||
#include "core/dma.h"
|
||||
#include "core/param.h"
|
||||
#include "arch/memlayout.h"
|
||||
#include "arch/mmu.h"
|
||||
#include "core/spinlock.h"
|
||||
#include "core/sleeplock.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/file.h"
|
||||
#include "dev/pci.h"
|
||||
#include "dev/usb.h"
|
||||
#include "xhci.h"
|
||||
|
||||
#define RING_TRBS 64 // TRBs per ring, including the link
|
||||
|
|
|
|||
|
|
@ -5,22 +5,22 @@
|
|||
// library, and the text console -- and only the first is a driver. The other
|
||||
// two are now kernel/dev/gfx.c and do not name any driver at all, so the crash
|
||||
// screen and the console draw on whatever hardware is bound rather than on
|
||||
// this one by name. See include/gfx.h.
|
||||
// this one by name. See include/gfx/gfx.h.
|
||||
//
|
||||
// What stays here is everything that knows *where the pixels are*: the mode the
|
||||
// loader programmed and handed over in the boot block, the aperture it lives
|
||||
// in, and the display class vtable that presents all of it as one of possibly
|
||||
// several displays.
|
||||
|
||||
#include "types.h"
|
||||
#include "x86.h"
|
||||
#include "memlayout.h"
|
||||
#include "defs.h"
|
||||
#include "device.h"
|
||||
#include "display.h"
|
||||
#include "gfx.h"
|
||||
#include "dma.h"
|
||||
#include "schboot.h" /* the hand-off block */
|
||||
#include "core/types.h"
|
||||
#include "arch/x86.h"
|
||||
#include "arch/memlayout.h"
|
||||
#include "core/defs.h"
|
||||
#include "dev/device.h"
|
||||
#include "gfx/display.h"
|
||||
#include "gfx/gfx.h"
|
||||
#include "core/dma.h"
|
||||
#include "arch/schboot.h" /* the hand-off block */
|
||||
|
||||
static volatile uchar *fb;
|
||||
// Physical base of the linear framebuffer, as reported by VBE. Everything that
|
||||
|
|
@ -115,7 +115,7 @@ vga_fb_init(uint64 phys_addr)
|
|||
|
||||
// --- display class implementation ------------------------------------------
|
||||
//
|
||||
// See include/display.h. The VBE framebuffer presenting itself as a generic
|
||||
// See include/gfx/display.h. The VBE framebuffer presenting itself as a generic
|
||||
// display, so a compositor is written against the class rather than against
|
||||
// this file.
|
||||
|
||||
|
|
|
|||
|
|
@ -17,16 +17,16 @@
|
|||
// shown up first on hardware where the guess was wrong, and until now there
|
||||
// was nothing in the kernel capable of noticing it.
|
||||
|
||||
#include "types.h"
|
||||
#include "defs.h"
|
||||
#include "param.h"
|
||||
#include "x86.h"
|
||||
#include "spinlock.h"
|
||||
#include "sleeplock.h"
|
||||
#include "fs.h"
|
||||
#include "file.h"
|
||||
#include "pci.h"
|
||||
#include "display.h"
|
||||
#include "core/types.h"
|
||||
#include "core/defs.h"
|
||||
#include "core/param.h"
|
||||
#include "arch/x86.h"
|
||||
#include "core/spinlock.h"
|
||||
#include "core/sleeplock.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/file.h"
|
||||
#include "dev/pci.h"
|
||||
#include "gfx/display.h"
|
||||
|
||||
// The framebuffer lives in the first memory BAR big enough to hold a screen.
|
||||
// Display controllers commonly expose two apertures -- the framebuffer and a
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// virtio-gpu, 2D. Written from the OASIS virtio 1.1 specification.
|
||||
//
|
||||
// This is the second implementation of the display class (include/display.h),
|
||||
// This is the second implementation of the display class (include/gfx/display.h),
|
||||
// and the first one that is a real GPU driver rather than a flat framebuffer.
|
||||
// The difference that matters for a compositor: presenting is an explicit
|
||||
// operation. With VBE you write pixels and hope the scanout is not looking;
|
||||
|
|
@ -12,23 +12,23 @@
|
|||
// FEATURES_OK stuck, set up queues, DRIVER_OK. A device that finds the sequence
|
||||
// wrong is entitled to simply refuse, and it will not say why.
|
||||
|
||||
#include "types.h"
|
||||
#include "defs.h"
|
||||
#include "irq.h"
|
||||
#include "param.h"
|
||||
#include "x86.h"
|
||||
#include "spinlock.h"
|
||||
#include "sleeplock.h"
|
||||
#include "fs.h"
|
||||
#include "file.h"
|
||||
#include "mmu.h"
|
||||
#include "memlayout.h"
|
||||
#include "pci.h"
|
||||
#include "device.h"
|
||||
#include "display.h"
|
||||
#include "dma.h"
|
||||
#include "virtio.h"
|
||||
#include "gfx.h"
|
||||
#include "core/types.h"
|
||||
#include "core/defs.h"
|
||||
#include "core/irq.h"
|
||||
#include "core/param.h"
|
||||
#include "arch/x86.h"
|
||||
#include "core/spinlock.h"
|
||||
#include "core/sleeplock.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/file.h"
|
||||
#include "arch/mmu.h"
|
||||
#include "arch/memlayout.h"
|
||||
#include "dev/pci.h"
|
||||
#include "dev/device.h"
|
||||
#include "gfx/display.h"
|
||||
#include "core/dma.h"
|
||||
#include "dev/virtio.h"
|
||||
#include "gfx/gfx.h"
|
||||
|
||||
// One control queue is enough for 2D: there is also a cursor queue, which is
|
||||
// only worth having once there is a hardware cursor to move.
|
||||
|
|
@ -79,7 +79,7 @@ static struct vgpu gpus[VGPU_MAX];
|
|||
|
||||
// The instance behind a device, or 0. Every op goes through this rather than a
|
||||
// file-static, which is what makes the second adapter possible at all. See
|
||||
// include/netdev.h and the e1000 for the same arrangement on the network side.
|
||||
// include/dev/netdev.h and the e1000 for the same arrangement on the network side.
|
||||
static struct vgpu *
|
||||
vgpu_of(struct device *d)
|
||||
{
|
||||
|
|
@ -782,7 +782,7 @@ static const struct pci_match virtio_gpu_match[] = {
|
|||
|
||||
// Hang the instance on the device the bus has just published. probe() runs
|
||||
// before device_add(), so there is nothing to attach it to in there -- see the
|
||||
// comment on `attached` in include/pci.h.
|
||||
// comment on `attached` in include/dev/pci.h.
|
||||
static void
|
||||
vgpu_attached(struct pci_dev *d, struct device *dev)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// What it provides the rest of the system is a struct netdev_ops and nothing
|
||||
// else: a station address, a transmit path and a receive ring. It does not
|
||||
// know that lwIP exists, and lwIP does not know that it does -- see
|
||||
// include/netdev.h for why that boundary is where it is. Adding a second NIC
|
||||
// include/dev/netdev.h for why that boundary is where it is. Adding a second NIC
|
||||
// means writing another driver that fills in the same four function pointers,
|
||||
// and touching no file outside its own directory.
|
||||
//
|
||||
|
|
@ -13,21 +13,21 @@
|
|||
// receiver whose ring base is still zero makes the device DMA into physical
|
||||
// address 0, which on this kernel is the boot page table.
|
||||
|
||||
#include "types.h"
|
||||
#include "defs.h"
|
||||
#include "param.h"
|
||||
#include "x86.h"
|
||||
#include "spinlock.h"
|
||||
#include "sleeplock.h"
|
||||
#include "fs.h"
|
||||
#include "file.h"
|
||||
#include "mmu.h"
|
||||
#include "memlayout.h"
|
||||
#include "pci.h"
|
||||
#include "device.h"
|
||||
#include "netdev.h"
|
||||
#include "dma.h"
|
||||
#include "irq.h"
|
||||
#include "core/types.h"
|
||||
#include "core/defs.h"
|
||||
#include "core/param.h"
|
||||
#include "arch/x86.h"
|
||||
#include "core/spinlock.h"
|
||||
#include "core/sleeplock.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/file.h"
|
||||
#include "arch/mmu.h"
|
||||
#include "arch/memlayout.h"
|
||||
#include "dev/pci.h"
|
||||
#include "dev/device.h"
|
||||
#include "dev/netdev.h"
|
||||
#include "core/dma.h"
|
||||
#include "core/irq.h"
|
||||
#include "e1000.h"
|
||||
|
||||
struct e1000 {
|
||||
|
|
@ -477,7 +477,7 @@ e1000_release(struct pci_dev *d)
|
|||
}
|
||||
|
||||
// Hang the instance on the device the bus has just published. See the comment
|
||||
// on `attached` in include/pci.h for why this cannot happen inside probe().
|
||||
// on `attached` in include/dev/pci.h for why this cannot happen inside probe().
|
||||
static void
|
||||
e1000_attached(struct pci_dev *d, struct device *dev)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,21 +20,21 @@
|
|||
// is Linux's: this is a descriptor-ring driver in the same shape as the e1000
|
||||
// beside it, because that is the shape this kernel's netdev class wants.
|
||||
|
||||
#include "types.h"
|
||||
#include "defs.h"
|
||||
#include "param.h"
|
||||
#include "x86.h"
|
||||
#include "spinlock.h"
|
||||
#include "sleeplock.h"
|
||||
#include "fs.h"
|
||||
#include "file.h"
|
||||
#include "memlayout.h"
|
||||
#include "mmu.h"
|
||||
#include "pci.h"
|
||||
#include "device.h"
|
||||
#include "netdev.h"
|
||||
#include "dma.h"
|
||||
#include "irq.h"
|
||||
#include "core/types.h"
|
||||
#include "core/defs.h"
|
||||
#include "core/param.h"
|
||||
#include "arch/x86.h"
|
||||
#include "core/spinlock.h"
|
||||
#include "core/sleeplock.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/file.h"
|
||||
#include "arch/memlayout.h"
|
||||
#include "arch/mmu.h"
|
||||
#include "dev/pci.h"
|
||||
#include "dev/device.h"
|
||||
#include "dev/netdev.h"
|
||||
#include "core/dma.h"
|
||||
#include "core/irq.h"
|
||||
|
||||
// --- registers --------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -12,21 +12,21 @@
|
|||
// and it is the one Realtek part QEMU emulates, so unlike the 8169 beside it
|
||||
// every line of this has been run.
|
||||
|
||||
#include "types.h"
|
||||
#include "defs.h"
|
||||
#include "param.h"
|
||||
#include "x86.h"
|
||||
#include "spinlock.h"
|
||||
#include "sleeplock.h"
|
||||
#include "fs.h"
|
||||
#include "file.h"
|
||||
#include "memlayout.h"
|
||||
#include "mmu.h"
|
||||
#include "pci.h"
|
||||
#include "device.h"
|
||||
#include "netdev.h"
|
||||
#include "dma.h"
|
||||
#include "irq.h"
|
||||
#include "core/types.h"
|
||||
#include "core/defs.h"
|
||||
#include "core/param.h"
|
||||
#include "arch/x86.h"
|
||||
#include "core/spinlock.h"
|
||||
#include "core/sleeplock.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/file.h"
|
||||
#include "arch/memlayout.h"
|
||||
#include "arch/mmu.h"
|
||||
#include "dev/pci.h"
|
||||
#include "dev/device.h"
|
||||
#include "dev/netdev.h"
|
||||
#include "core/dma.h"
|
||||
#include "core/irq.h"
|
||||
|
||||
// --- registers --------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -16,17 +16,17 @@
|
|||
// pci_driver, declare it here, and add it to the array and to the Makefile's
|
||||
// KERN_DRIVERS.
|
||||
|
||||
#include "types.h"
|
||||
#include "defs.h"
|
||||
#include "param.h"
|
||||
#include "spinlock.h"
|
||||
#include "sleeplock.h"
|
||||
#include "fs.h"
|
||||
#include "file.h"
|
||||
#include "pci.h"
|
||||
#include "core/types.h"
|
||||
#include "core/defs.h"
|
||||
#include "core/param.h"
|
||||
#include "core/spinlock.h"
|
||||
#include "core/sleeplock.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/file.h"
|
||||
#include "dev/pci.h"
|
||||
|
||||
#include "usb.h"
|
||||
#include "device.h"
|
||||
#include "dev/usb.h"
|
||||
#include "dev/device.h"
|
||||
|
||||
extern const struct pci_driver vga_pci_driver;
|
||||
extern const struct pci_driver xhci_driver;
|
||||
|
|
|
|||
|
|
@ -21,18 +21,18 @@
|
|||
// few milliseconds, so the cost is that, spent spinning, and it is yielded
|
||||
// once a wait goes long.
|
||||
|
||||
#include "types.h"
|
||||
#include "defs.h"
|
||||
#include "param.h"
|
||||
#include "x86.h"
|
||||
#include "spinlock.h"
|
||||
#include "sleeplock.h"
|
||||
#include "fs.h"
|
||||
#include "file.h"
|
||||
#include "proc.h"
|
||||
#include "pci.h"
|
||||
#include "dma.h"
|
||||
#include "blkdev.h"
|
||||
#include "core/types.h"
|
||||
#include "core/defs.h"
|
||||
#include "core/param.h"
|
||||
#include "arch/x86.h"
|
||||
#include "core/spinlock.h"
|
||||
#include "core/sleeplock.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/file.h"
|
||||
#include "core/proc.h"
|
||||
#include "dev/pci.h"
|
||||
#include "core/dma.h"
|
||||
#include "fs/blkdev.h"
|
||||
|
||||
// --- HBA registers (section 3.1) ---------------------------------------------
|
||||
|
||||
|
|
@ -345,7 +345,7 @@ port_init(volatile uint8 *hba, int port, uint32 cap)
|
|||
return;
|
||||
}
|
||||
// Without S64A the HBA cannot see above 4 GB. The DMA arena is below it
|
||||
// (see include/dma.h), so this holds, and says so if that ever changes.
|
||||
// (see include/core/dma.h), so this holds, and says so if that ever changes.
|
||||
if (!(cap & CAP_S64A) && dma_phys(p->xfer) + BSIZE > 0xFFFFFFFFULL) {
|
||||
cprintf("ahci: DMA memory above 4 GB and the HBA is 32-bit\n");
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -19,18 +19,18 @@
|
|||
// A flash read completes in tens of microseconds, so the spin is short, and
|
||||
// it is yielded once a wait goes long.
|
||||
|
||||
#include "types.h"
|
||||
#include "defs.h"
|
||||
#include "param.h"
|
||||
#include "x86.h"
|
||||
#include "spinlock.h"
|
||||
#include "sleeplock.h"
|
||||
#include "fs.h"
|
||||
#include "file.h"
|
||||
#include "proc.h"
|
||||
#include "pci.h"
|
||||
#include "dma.h"
|
||||
#include "blkdev.h"
|
||||
#include "core/types.h"
|
||||
#include "core/defs.h"
|
||||
#include "core/param.h"
|
||||
#include "arch/x86.h"
|
||||
#include "core/spinlock.h"
|
||||
#include "core/sleeplock.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/file.h"
|
||||
#include "core/proc.h"
|
||||
#include "dev/pci.h"
|
||||
#include "core/dma.h"
|
||||
#include "fs/blkdev.h"
|
||||
|
||||
// --- controller registers (section 3.1) --------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -7,15 +7,15 @@
|
|||
// part of USB that is the same for every device ever made: read the
|
||||
// configuration, choose one, look at the interface, find someone who wants it.
|
||||
|
||||
#include "types.h"
|
||||
#include "defs.h"
|
||||
#include "param.h"
|
||||
#include "memlayout.h"
|
||||
#include "mmu.h"
|
||||
#include "spinlock.h"
|
||||
#include "dma.h"
|
||||
#include "usb.h"
|
||||
#include "hwinfo.h"
|
||||
#include "core/types.h"
|
||||
#include "core/defs.h"
|
||||
#include "core/param.h"
|
||||
#include "arch/memlayout.h"
|
||||
#include "arch/mmu.h"
|
||||
#include "core/spinlock.h"
|
||||
#include "core/dma.h"
|
||||
#include "dev/usb.h"
|
||||
#include "core/hwinfo.h"
|
||||
|
||||
// A staging buffer for control transfers.
|
||||
//
|
||||
|
|
@ -130,7 +130,7 @@ parse_config(struct usb_dev *dev, int nth)
|
|||
}
|
||||
|
||||
// One usb_dev for every interface after the first. See `base` in
|
||||
// include/usb.h. A fixed pool, like everything else here. It was sixteen,
|
||||
// include/dev/usb.h. A fixed pool, like everything else here. It was sixteen,
|
||||
// which a dock -- hub, Ethernet, audio, card reader, each two or three
|
||||
// interfaces -- and a couple of receivers already reach. 672 bytes each.
|
||||
#define NIFDEV 64
|
||||
|
|
|
|||
|
|
@ -17,14 +17,14 @@
|
|||
// in the descriptor is stepped over. A boot mouse whose descriptor makes no
|
||||
// sense is still driven, in boot protocol, as before.
|
||||
|
||||
#include "types.h"
|
||||
#include "defs.h"
|
||||
#include "gfx.h"
|
||||
#include "param.h"
|
||||
#include "spinlock.h"
|
||||
#include "dma.h"
|
||||
#include "usb.h"
|
||||
#include "input.h"
|
||||
#include "core/types.h"
|
||||
#include "core/defs.h"
|
||||
#include "gfx/gfx.h"
|
||||
#include "core/param.h"
|
||||
#include "core/spinlock.h"
|
||||
#include "core/dma.h"
|
||||
#include "dev/usb.h"
|
||||
#include "dev/input.h"
|
||||
|
||||
#define NHID 8
|
||||
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@
|
|||
// translator rather than against the device. So this driver's real job is
|
||||
// less "operate the hub" than "tell the controller what shape the tree is".
|
||||
|
||||
#include "types.h"
|
||||
#include "defs.h"
|
||||
#include "param.h"
|
||||
#include "spinlock.h"
|
||||
#include "dma.h"
|
||||
#include "usb.h"
|
||||
#include "core/types.h"
|
||||
#include "core/defs.h"
|
||||
#include "core/param.h"
|
||||
#include "core/spinlock.h"
|
||||
#include "core/dma.h"
|
||||
#include "dev/usb.h"
|
||||
|
||||
#define MAX_PORTS 15 // per hub; more than any real bus hub has
|
||||
#define NHUB 8
|
||||
|
|
|
|||
|
|
@ -14,18 +14,18 @@
|
|||
// below (INQUIRY, READ CAPACITY, READ(10), WRITE(10)) are the same ones a
|
||||
// SCSI drive answered in 1990.
|
||||
|
||||
#include "types.h"
|
||||
#include "defs.h"
|
||||
#include "param.h"
|
||||
#include "memlayout.h"
|
||||
#include "mmu.h"
|
||||
#include "spinlock.h"
|
||||
#include "sleeplock.h"
|
||||
#include "fs.h"
|
||||
#include "buf.h"
|
||||
#include "dma.h"
|
||||
#include "usb.h"
|
||||
#include "blkdev.h"
|
||||
#include "core/types.h"
|
||||
#include "core/defs.h"
|
||||
#include "core/param.h"
|
||||
#include "arch/memlayout.h"
|
||||
#include "arch/mmu.h"
|
||||
#include "core/spinlock.h"
|
||||
#include "core/sleeplock.h"
|
||||
#include "fs/fs.h"
|
||||
#include "fs/buf.h"
|
||||
#include "core/dma.h"
|
||||
#include "dev/usb.h"
|
||||
#include "fs/blkdev.h"
|
||||
|
||||
#define CBW_SIGNATURE 0x43425355 // "USBC"
|
||||
#define CSW_SIGNATURE 0x53425355 // "USBS"
|
||||
|
|
|
|||
Loading…
Reference in a new issue