-----Original Message----- From: Stefan Reinauer [mailto:stepan@coresystems.de] Sent: Thursday, November 06, 2008 9:17 AM To: Vincent Legoll Cc: Myles Watson; ron minnich; Carl-Daniel Hailfinger; coreboot@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
dead
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.
Something like
#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.
Thanks, Myles
Thanks, Myles