Table of Contents

gPXE Network Driver Initialization

What happens when gPXE starts up?
How does a network driver get initialized?

Let's follow the call stack at key points from instantiation.

Reaching probe

At this point netdev_init() associates netdev with driver functions.
register_netdev() adds to the device list.
We return up the call stack to main().

Reaching close

All network devices are closed before attempting to boot each network device.
We return up the call stack to autoboot().

Reaching open

At this point transmit and receive are enabled.

root_device and pci_device structs

Both struct root_device and struct pci_device have a special function in gPXE. Bus drivers are root_devices, thus there is one for PCI, ISA, etc. PCI devices are self-explanatory. Both root_device and pci_device structs are defined within their respective driver code. These structs hold function pointers to essential interface routines, such as probe() and remove(). The __pci_driver and __root_driver tags cause the drivers to be added to a list of modules, resulting in their probe() routines being called during initialization.