
On Thu, Dec 31, 2020 at 07:08:25PM -0800, Bin Gao wrote:
On physical hardware, some PCI devices are not detectable when UEFI invokes our InitializeYourself() function. But they are guaranteed to be available before UEFI invokes our PreparToBoot() function.
Signed-off-by: Bin Gao <gaobin@amazon.com> --- src/fw/csm.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/fw/csm.c b/src/fw/csm.c index f64bc73..1bd821e 100644 --- a/src/fw/csm.c +++ b/src/fw/csm.c @@ -64,7 +64,9 @@ static void csm_maininit(struct bregs *regs) { interface_init(); - pci_probe_devices(); + + if (CONFIG_CSM && CONFIG_QEMU_HARDWARE) + pci_probe_devices();
csm_compat_table.PnPInstallationCheckSegment = SEG_BIOS; csm_compat_table.PnPInstallationCheckOffset = get_pnp_offset(); @@ -144,6 +146,13 @@ handle_csm_0002(struct bregs *regs) return; }
+ // On physical hardware, some PCI devices are not detectable when + // UEFI invokes our InitializeYourself() function. But they + // are guaranteed to be available before UEFI invokes our + // PreparToBoot() function. + if (CONFIG_CSM && !CONFIG_QEMU_HARDWARE) + pci_probe_devices();
This looks like a hack. I'm not sure what's being attempted, but a more scalable solution will be needed.
As the commit message described, the goal is to make sure all the pci devices can be found in pci_probe_devices(). Due to the BIOS internal logic, some PCI devices may not be visible yet when InitializeYourself() is called. Thus we wanted to run pci_probe_devices() later, i.e. in PrepareToBoot() instead of in InitializeYourself(). As Paul and Gerd suggested, I will remove CONFIG_QEMU_HARDWARE and let the code be common for both qemu and bare metal.
-Kevin