[coreboot] r983 - in coreboot-v3: device include/device
mylesgw at gmail.com
Thu Nov 6 17:46:27 CET 2008
> -----Original Message-----
> From: Stefan Reinauer [mailto:stepan at coresystems.de]
> Sent: Thursday, November 06, 2008 9:17 AM
> To: Vincent Legoll
> Cc: Myles Watson; ron minnich; Carl-Daniel Hailfinger;
> coreboot at coreboot.org
> Subject: Re: [coreboot] r983 - in coreboot-v3: device include/device
> Vincent Legoll wrote:
> > Isn't all that kind of things doable via function pointers and link-time
> > code elimination ? That would achieve the no ifdeffery goal, and may be
> > cleaner code...
> Link time optimization would suggest we look into compiling with LLVM
> instead of gcc.
> Has anyone tried this, yet?
As a start that wouldn't change the code much and would still work with gcc,
we could have an enum or defines in the device code and a table where the
device code that was compiled in could initialize a pointer to its default
ops. In practice it only affects dynamically detected bridges, but it would
be nice to support them.
#define DEVICE_PCI_DRIVER_NUM 1
#define DEVICE_HT_DRIVER_NUM 2
#define DEVICE_PCIE_DRIVER_NUM 1
#define DEVICE_PCIX_DRIVER_NUM 1
#define DEVICE_MAX_DRIVERS DEVICE_PCIX_DRIVER_NUM+1
static const device_operations * default_drivers[DEVICE_MAX_DRIVERS];
Then each device could set them:
default_drivers[DEVICE_HT_DRIVER_NUM] = &default_ht_ops_bus;
Or something similar. Note that this is just dry coding.
More information about the coreboot