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
|
|
@ -12,9 +12,10 @@
|
|||
// a driver silently dropped by the linker looks exactly like one that was
|
||||
// never written. At this size, being able to read the list wins.
|
||||
//
|
||||
// To add a driver: write kernel/drivers/<name>.c exporting a struct
|
||||
// pci_driver, declare it here, and add it to the array and to the Makefile's
|
||||
// KERN_DRIVERS.
|
||||
// To add a driver: write kernel/drivers/<class>/<name>/<name>.c exporting a
|
||||
// struct pci_driver, declare it here, add it to the array and to the Makefile's
|
||||
// KERN_DRIVERS -- and, if nothing else in the kernel calls it, give it a
|
||||
// DRV_<NAME> option in config/drivers.conf so it can be left out.
|
||||
|
||||
#include "core/types.h"
|
||||
#include "core/defs.h"
|
||||
|
|
@ -28,14 +29,34 @@
|
|||
#include "dev/usb.h"
|
||||
#include "dev/device.h"
|
||||
|
||||
// Which of these exist in this kernel is config/drivers.conf: the Makefile
|
||||
// leaves a disabled driver's object out and defines CONFIG_DRV_<NAME> for the
|
||||
// ones it keeps. The ones with no option (xHCI) are always here.
|
||||
#ifdef CONFIG_DRV_VGA_PCI
|
||||
extern const struct pci_driver vga_pci_driver;
|
||||
#endif
|
||||
extern const struct pci_driver xhci_driver;
|
||||
#ifdef CONFIG_DRV_VIRTIO_GPU
|
||||
extern const struct pci_driver virtio_gpu_driver;
|
||||
#endif
|
||||
#ifdef CONFIG_DRV_E1000
|
||||
extern const struct pci_driver e1000_driver;
|
||||
#endif
|
||||
#ifdef CONFIG_DRV_AC97
|
||||
extern const struct pci_driver ac97_driver;
|
||||
#endif
|
||||
#ifdef CONFIG_DRV_RTL8139
|
||||
extern const struct pci_driver rtl8139_driver;
|
||||
#endif
|
||||
#ifdef CONFIG_DRV_R8169
|
||||
extern const struct pci_driver r8169_driver;
|
||||
#endif
|
||||
#ifdef CONFIG_DRV_AHCI
|
||||
extern const struct pci_driver ahci_driver;
|
||||
#endif
|
||||
#ifdef CONFIG_DRV_NVME
|
||||
extern const struct pci_driver nvme_driver;
|
||||
#endif
|
||||
|
||||
// Order matters here in one respect: virtio-gpu is offered the bus before the
|
||||
// VBE framebuffer driver, so that on a machine with both, the device with real
|
||||
|
|
@ -43,23 +64,42 @@ extern const struct pci_driver nvme_driver;
|
|||
// claims the stdvga card underneath, which is what the boot splash and the
|
||||
// text console are drawn on.
|
||||
static const struct pci_driver *drivers[] = {
|
||||
#ifdef CONFIG_DRV_VIRTIO_GPU
|
||||
&virtio_gpu_driver,
|
||||
#endif
|
||||
#ifdef CONFIG_DRV_VGA_PCI
|
||||
&vga_pci_driver,
|
||||
#endif
|
||||
#ifdef CONFIG_DRV_E1000
|
||||
&e1000_driver,
|
||||
// &r8169_driver -- the RTL8168 is driven by Linux's own r8169 through
|
||||
// LDLS (etc/schinit/ldls-r8169.job), which a kernel driver here would
|
||||
// claim first. The native driver stays in the tree as the fallback.
|
||||
#endif
|
||||
// The RTL8168 is driven by Linux's own r8169 through LDLS
|
||||
// (etc/schinit/ldls-r8169.job), which a kernel driver here would claim
|
||||
// first -- so DRV_R8169 is off by default. The native driver stays in the
|
||||
// tree as the fallback for a machine without that job.
|
||||
#ifdef CONFIG_DRV_R8169
|
||||
&r8169_driver,
|
||||
#endif
|
||||
#ifdef CONFIG_DRV_RTL8139
|
||||
&rtl8139_driver,
|
||||
#endif
|
||||
&xhci_driver,
|
||||
#ifdef CONFIG_DRV_AHCI
|
||||
&ahci_driver,
|
||||
#endif
|
||||
#ifdef CONFIG_DRV_NVME
|
||||
&nvme_driver,
|
||||
#endif
|
||||
#ifdef CONFIG_DRV_AC97
|
||||
&ac97_driver,
|
||||
#endif
|
||||
0, // keeps the array non-empty when everything optional is off
|
||||
};
|
||||
|
||||
void
|
||||
pci_bind_all(void)
|
||||
{
|
||||
for (unsigned i = 0; i < sizeof(drivers) / sizeof(drivers[0]); i++)
|
||||
for (unsigned i = 0; drivers[i]; i++)
|
||||
pci_bind(drivers[i]);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue