config/drivers.conf: which drivers are compiled in
y or n per optional driver (virtio-gpu, stdvga, e1000, rtl8139, native r8169, AC'97, AHCI, NVMe), all y except the native r8169, overridable with make DRV_X=n. Only drivers nothing else calls can be optional; the registry #ifdefs them and the Makefile leaves their objects out. Built with every one off (links, none of their symbols present), with r8169 on, and by default. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EVRhxi9zpdW2uDUN4FVcao
This commit is contained in:
parent
f94d19ae47
commit
1334f446cc
6 changed files with 139 additions and 16 deletions
|
|
@ -9,6 +9,17 @@ Drivers that live in a process rather than in the kernel are described below
|
|||
|
||||
---
|
||||
|
||||
## Which drivers are compiled in
|
||||
|
||||
`config/drivers.conf` lists the drivers that can be left out of a kernel, `y` (compiled in and offered every device it can
|
||||
drive) or `n` (not linked at all), all `y` unless a line says otherwise — the one exception is the native `r8169`, `n`
|
||||
because Linux's runs in its place under LDLS. Override one for a build with `make DRV_E1000=n DRV_NVME=n`. A changed
|
||||
choice rebuilds only `registry.o` and the link. The list is short on purpose: a driver is optional only if nothing else in
|
||||
the kernel calls it (display: `vga_pci`, `virtio_gpu`; network: `e1000`, `rtl8139`, `r8169`; storage: `ahci`, `nvme`;
|
||||
audio: `ac97`). `vga_fb`, the USB stack and the legacy PS/2, IDE and UART devices are always there, because the console, the
|
||||
keyboard and the root disk can depend on them. A kernel with every optional driver off builds and links; whether such a
|
||||
kernel is useful on any particular machine is the person who turned them off to say.
|
||||
|
||||
## What stays in the kernel, and what may leave
|
||||
|
||||
"Hybrid" is used to mean everything from "a monolith with a nice device model" to
|
||||
|
|
|
|||
|
|
@ -61,6 +61,10 @@ ours.
|
|||
|
||||
2. Declare it in `kernel/drivers/registry.c` and add it to the array.
|
||||
3. Add the object to `KERN_DRIVERS` in the `Makefile`.
|
||||
3½. If nothing else in the kernel calls it, make it optional: a `DRV_<NAME>` line in
|
||||
`config/drivers.conf`, the name in `DRV_LIST` in the Makefile, the object behind
|
||||
`$(filter y,$(DRV_<NAME>))`, and an `#ifdef CONFIG_DRV_<NAME>` around its line in `registry.c`.
|
||||
A driver other code calls (`vga_fb`, the USB stack) cannot be optional.
|
||||
4. Fill in the **class vtable** for what it is, and point `.ops` at it. That is
|
||||
the whole of what the rest of the kernel sees:
|
||||
|
||||
|
|
@ -113,7 +117,7 @@ That is data; the logic stays ours.
|
|||
- [ ] One directory under `kernel/drivers/<class>/<name>/`
|
||||
- [ ] Exports a `struct pci_driver` or `struct usb_driver`
|
||||
- [ ] Declared in `kernel/drivers/registry.c` **and** added to its array
|
||||
- [ ] Object added to `KERN_DRIVERS` in the `Makefile`
|
||||
- [ ] Object added to `KERN_DRIVERS` in the `Makefile`, and an option in `config/drivers.conf` if it can be left out
|
||||
- [ ] Class vtable filled in and `.ops` pointed at it
|
||||
- [ ] `.attached` implemented if it can drive more than one card
|
||||
- [ ] `devclass` set, if it is a USB driver
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ hundred megabytes, kept in `dist/`) and compiles Xorg's dependencies not at all:
|
|||
packages are Alpine's binaries, pinned in `ports/alpine/world.lock`. See
|
||||
[packages](../architecture/packages.md).
|
||||
|
||||
Which drivers go into the kernel is `config/drivers.conf` (all of the optional ones by default);
|
||||
`make DRV_E1000=n` leaves one out for a build. See [devices](../architecture/devices.md).
|
||||
|
||||
## Prerequisites
|
||||
|
||||
| Need | Why | Windows | Linux | macOS | BSD |
|
||||
|
|
|
|||
Loading…
Reference in a new issue