Date
1 - 1 of 1
Create HII Formset for every supported device in the OptionROM code
Konstantin Aladyshev
Hello!
Currently I develop OptionROM code for the custom PCIe device.
In my OptionROM code I publish HII formset with some diagnostic information
and configuration options for the device.
The code is successfully working if there is one such PCIe device in the
system.
Now I want to understand what I should do if multiple PCIe devices are
present in the system.
How to install a HII formset for each PCIe device in this case?
Currently in the OptionROM code I do something like this:
```
HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath = {
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
(UINT8) (sizeof (VENDOR_DEVICE_PATH)),
(UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
DATAPATH_GUID
},
{
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
(UINT8) (END_DEVICE_PATH_LENGTH),
(UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
}
}
};
EFI_HII_HANDLE mHiiHandle = NULL;
EFI_HANDLE mDriverHandle = NULL;
EFI_HII_CONFIG_ACCESS_PROTOCOL mConfigAccess;
...
STATIC
EFI_STATUS
EFIAPI
MyDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE DeviceHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
...
Status = gBS->InstallMultipleProtocolInterfaces(
&mDriverHandle,
&gEfiDevicePathProtocolGuid,
&mHiiVendorDevicePath,
&gEfiHiiConfigAccessProtocolGuid,
&mConfigAccess,
NULL
);
if (EFI_ERROR (Status)) {
Print(L"Can't install protocol\n");
goto ClosePciIo;
}
...
mHiiHandle = HiiAddPackages(
&gEfiCallerIdGuid,
mDriverHandle,
AngaraOptionRomStrings,
FormBin,
NULL
);
}
```
When several PCIe devices are present in the system the
`InstallMultipleProtocolInterfaces` and `HiiAddPackages` calls fail.
In the idea, formsets from different devices should have different titles
based on the PCI bus/dev/fn. I.e. something like this:
```
UINTN SegmentNumber;
UINTN BusNumber;
UINTN DeviceNumber;
UINTN FunctionNumber;
Status = AngaraPciIo->GetLocation(
AngaraPciIo,
&SegmentNumber,
&BusNumber,
&DeviceNumber,
&FunctionNumber
);
Print(L"%02x:%02x.%x\n", BusNumber, DeviceNumber, FunctionNumber);
if (!EFI_ERROR(Status)) {
CHAR16 FormTitle[32] = {0};
EFI_STRING DefaultFormTitle;
DefaultFormTitle = HiiGetString(mHiiHandle, STRING_TOKEN(FORMSET_TITLE),
NULL);
if (DefaultFormTitle != NULL) {
UnicodeSPrint(FormTitle, sizeof(FormTitle), L"%s (%02x:%02x.%x)",
DefaultFormTitle, BusNumber, DeviceNumber, FunctionNumber);
HiiSetString(mHiiHandle, STRING_TOKEN(FORMSET_TITLE), FormTitle, NULL);
FreePool(DefaultFormTitle);
}
}
```
Can someone advice, how the driver is needed to be restructured to support
several devices simultaneously?
Do I need to dynamically allocate new mHiiHandle and mDriverHandle? Or do
I need to use some other handles in the InstallMultipleProtocolInterfaces
and HiiAddPackages calls?
Best regards,
Konstantin Aladyshev
Currently I develop OptionROM code for the custom PCIe device.
In my OptionROM code I publish HII formset with some diagnostic information
and configuration options for the device.
The code is successfully working if there is one such PCIe device in the
system.
Now I want to understand what I should do if multiple PCIe devices are
present in the system.
How to install a HII formset for each PCIe device in this case?
Currently in the OptionROM code I do something like this:
```
HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath = {
{
{
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
(UINT8) (sizeof (VENDOR_DEVICE_PATH)),
(UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
DATAPATH_GUID
},
{
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
(UINT8) (END_DEVICE_PATH_LENGTH),
(UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
}
}
};
EFI_HII_HANDLE mHiiHandle = NULL;
EFI_HANDLE mDriverHandle = NULL;
EFI_HII_CONFIG_ACCESS_PROTOCOL mConfigAccess;
...
STATIC
EFI_STATUS
EFIAPI
MyDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE DeviceHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
{
...
Status = gBS->InstallMultipleProtocolInterfaces(
&mDriverHandle,
&gEfiDevicePathProtocolGuid,
&mHiiVendorDevicePath,
&gEfiHiiConfigAccessProtocolGuid,
&mConfigAccess,
NULL
);
if (EFI_ERROR (Status)) {
Print(L"Can't install protocol\n");
goto ClosePciIo;
}
...
mHiiHandle = HiiAddPackages(
&gEfiCallerIdGuid,
mDriverHandle,
AngaraOptionRomStrings,
FormBin,
NULL
);
}
```
When several PCIe devices are present in the system the
`InstallMultipleProtocolInterfaces` and `HiiAddPackages` calls fail.
In the idea, formsets from different devices should have different titles
based on the PCI bus/dev/fn. I.e. something like this:
```
UINTN SegmentNumber;
UINTN BusNumber;
UINTN DeviceNumber;
UINTN FunctionNumber;
Status = AngaraPciIo->GetLocation(
AngaraPciIo,
&SegmentNumber,
&BusNumber,
&DeviceNumber,
&FunctionNumber
);
Print(L"%02x:%02x.%x\n", BusNumber, DeviceNumber, FunctionNumber);
if (!EFI_ERROR(Status)) {
CHAR16 FormTitle[32] = {0};
EFI_STRING DefaultFormTitle;
DefaultFormTitle = HiiGetString(mHiiHandle, STRING_TOKEN(FORMSET_TITLE),
NULL);
if (DefaultFormTitle != NULL) {
UnicodeSPrint(FormTitle, sizeof(FormTitle), L"%s (%02x:%02x.%x)",
DefaultFormTitle, BusNumber, DeviceNumber, FunctionNumber);
HiiSetString(mHiiHandle, STRING_TOKEN(FORMSET_TITLE), FormTitle, NULL);
FreePool(DefaultFormTitle);
}
}
```
Can someone advice, how the driver is needed to be restructured to support
several devices simultaneously?
Do I need to dynamically allocate new mHiiHandle and mDriverHandle? Or do
I need to use some other handles in the InstallMultipleProtocolInterfaces
and HiiAddPackages calls?
Best regards,
Konstantin Aladyshev