On Fri, Jul 20, 2012 at 3:14 PM, Laszlo Ersek <ler...@redhat.com> wrote: > Tested with the "bootorder" fw_cfg file. Example contents (leading space > added and line terminators transcribed for readability): > > /pci@i0cf8/ide@1,1/drive@0/disk@0<LF> > /pci@i0cf8/ide@1,1/drive@1/disk@0<LF> > /pci@i0cf8/ethernet@3/ethernet-phy@0<NUL> > > Contributed-under: TianoCore Contribution Agreement 1.0 > > Signed-off-by: Laszlo Ersek <ler...@redhat.com> > --- > OvmfPkg/Include/Library/QemuFwCfgLib.h | 21 +++++++++++ > OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c | 53 > +++++++++++++++++++++++++++ > 2 files changed, 74 insertions(+), 0 deletions(-) > > diff --git a/OvmfPkg/Include/Library/QemuFwCfgLib.h > b/OvmfPkg/Include/Library/QemuFwCfgLib.h > index 5a3db7e..7e02f39 100644 > --- a/OvmfPkg/Include/Library/QemuFwCfgLib.h > +++ b/OvmfPkg/Include/Library/QemuFwCfgLib.h > @@ -41,6 +41,7 @@ typedef enum { > QemuFwCfgItemKernelSetupAddress = 0x0016, > QemuFwCfgItemKernelSetupSize = 0x0017, > QemuFwCfgItemKernelSetupData = 0x0018, > + QemuFwCfgItemFileDir = 0x0019, > > QemuFwCfgItemX86AcpiTables = 0x8000, > QemuFwCfgItemX86SmbiosTables = 0x8001, > @@ -153,5 +154,25 @@ QemuFwCfgRead64 ( > ); > > > +/** > + Find the configuration item corresponding to the firmware configuration > file. > + > + @param[in] Name - Name of file to look up. > + @param[out] Item - Configuration item corresponding to the file, to be > passed > + to QemuFwCfgSelectItem (). > + @param[out] Size - Number of bytes in the file. > + > + @return RETURN_SUCCESS if file is found, > + RETURN_NOT_FOUND if file is not found, > + RETURN_UNSUPPORTED if firmware configuration is unavailable.
Minor: if => If > + > +**/ > +RETURN_STATUS > +EFIAPI > +QemuFwCfgFindFile ( > + IN CONST CHAR8 Name[56], IN CONST CHAR8 *Name, > + OUT FIRMWARE_CONFIG_ITEM *Item, > + OUT UINT32 *Size Minor: I think I'd use UINTN > + ); > #endif > > diff --git a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c > b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c > index b94dc67..95dd2ea 100644 > --- a/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c > +++ b/OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c > @@ -244,3 +244,56 @@ QemuFwCfgInitialize ( > DEBUG ((EFI_D_INFO, "QemuFwCfg interface is supported.\n")); > return RETURN_SUCCESS; > } > + > + > +/** > + Find the configuration item corresponding to the firmware configuration > file. > + > + @param[in] Name - Name of file to look up. > + @param[out] Item - Configuration item corresponding to the file, to be > passed > + to QemuFwCfgSelectItem (). > + @param[out] Size - Number of bytes in the file. > + > + @return RETURN_SUCCESS if file is found, > + RETURN_NOT_FOUND if file is not found, > + RETURN_UNSUPPORTED if firmware configuration is unavailable. > + > +**/ > +RETURN_STATUS > +EFIAPI > +QemuFwCfgFindFile ( > + IN CONST CHAR8 Name[56], > + OUT FIRMWARE_CONFIG_ITEM *Item, > + OUT UINT32 *Size > + ) > +{ > + UINT32 Count; > + UINT32 Idx; > + > + if (!mQemuFwCfgSupported) { > + return RETURN_UNSUPPORTED; > + } > + > + QemuFwCfgSelectItem (QemuFwCfgItemFileDir); > + Count = SwapBytes32 (QemuFwCfgRead32 ()); > + > + for (Idx = 0; Idx < Count; ++Idx) { > + UINT32 FSizeBE; > + UINT16 FSelectBE; > + UINT16 FReservedBE; > + CHAR8 FName[56]; Minor: Names don't seem to follow code style. > + > + FSizeBE = QemuFwCfgRead32 (); > + FSelectBE = QemuFwCfgRead16 (); > + FReservedBE = QemuFwCfgRead16 (); > + InternalQemuFwCfgReadBytes (sizeof (FName), FName); > + > + if (AsciiStrCmp (Name, FName) == 0) { > + *Item = SwapBytes16 (FSelectBE); > + *Size = SwapBytes32 (FSizeBE); > + return RETURN_SUCCESS; > + } > + } > + > + return RETURN_NOT_FOUND; > +} > -- > 1.7.1 > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/edk2-devel ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel