# SmbiosDataUpdateDxeLightningRidgeEXECB2

## Function Table

| Address | Name | Description |
|---------|------|-------------|
|  | **GetPlatformLang** |  |
|  | **InternalAsciiStrLen** |  |
|  | **InternalAsciiStrSize** |  |
|  | **InternalStrLen** |  |
|  | **InternalStrSize** |  |
|  | **InternalSmbiosStringPackFindByType** |  |
|  | **MmPciRead32** |  |
|  | **LocateProtocol** |  |
|  | **UpdateSmbiosType9Slots** |  |
|  | **UpdateSmbiosType10Devices** |  |
|  | **UpdateSmbiosType41Devices** |  |
|  | **SmbiosDataUpdate** |  |
|  | **DriverInitInternal** |  |
|  | **SmbiosDataUpdateEntry** |  |
| Global | **UEFI protocol pointers** |  |
| EFI_SYSTEM_TABLE | ***gSystemTable    = NULL;** |  |
| Global | **SMBIOS string pack handle from UBA** |  |
| EFI_HII_HANDLE | **gSmbiosStringPackHandle = NULL;** |  |
| HOB | **list pointer** |  |
| VOID | ***gHobList        = NULL;** |  |
| DXE | **Services Table pointer** |  |
| EFI_DXE_SERVICES | ***gDxeServices    = NULL;** |  |
| UBA | **SMBIOS data update protocol** |  |
| VOID | ***gUbaSmbiosUpdateProtocol = NULL;** |  |
| HII | **Config Routing Protocol (for SMBIOS string updates)** |  |
| EFI_HII_CONFIG_ROUTING_PROTOCOL | ***gHiiConfigRouting = NULL;** |  |
| HII | **Config Access Protocol (driver handle)** |  |
| EFI_HII_CONFIG_ACCESS_PROTOCOL | ***gHiiConfigAccess  = NULL;** |  |
| HII | **Package List handle** |  |
| EFI_HII_HANDLE | **gHiiPackageList   = NULL;** |  |
| SMBIOS | **string pack configuration port handle** |  |
| VOID | ***gSmbiosStringPackConfigPort = NULL;** |  |
| SMBIOS | **string pack data port (used in string enumeration)** |  |
| VOID | ***gSmbiosStringPackDataPort = NULL;** |  |
| Forward | **declarations of internal helper functions** |  |
| STATIC | **EFI_STATUS** |  |
| SMBIOS | **Type 9 slot configuration table for Lightning Ridge EXECB2.** |  |
| Each | **entry is a 10-byte record: { Type, BusWidth, Characteristics1, Characteristics2** |  |
| Organized | **as an array of 30 (0x1E) entries.** |  |
| STATIC | **CONST UINT8  mType9SlotConfig[] = {** |  |
| Slot | **0:  PCH PCIe x16, width x16 (0x0B), x1 link (0x08)** |  |
| Slot | **1:  PCH PCIe x8** |  |
| Build | **PCI CF8 address from bus/dev/func/reg** |  |
| CF8 | **= (EN | Bus << 16 | Device << 11 | Function << 8 | Register)** |  |
| Address | **= (UINT32)((Function & 0x7) |** |  |
| If | **MM PCI protocol is not available, return error** |  |
| if | **(gMmPciBase == NULL) {** |  |
| Read | **via MM PCI base protocol function 24 (Read32)** |  |
| return | **gMmPciBase->Read32 (Address);** |  |
| Use | **forward copy if source and destination don't overlap** |  |
| or | **source is before destination (non-an overlapping case)** |  |
| if | **(Src8 > Dst8 || Src8 + Count <= Dst8) {** |  |
| Backward | **copy for overlapping regions where src < dst** |  |
| Dst8 | **+= Count;** |  |
| Convert | **in-place: each CHAR16 narrows to one CHAR8** |  |
| Dst | **= (CHAR8 *)Source;** |  |
| First | **call to get the required buffer size** |  |
| BufferSize | **= 0;** |  |
| Allocate | **the buffer** |  |
| Lang | **= AllocatePool (BufferSize);** |  |
| Second | **call to get the actual data** |  |
| Status | **= gRuntimeServices->GetVariable (** |  |
| Determine | **the length of the primary language subtag** |  |
| PrimaryLen | **= InternalAsciiStrLen (TargetLanguage);** |  |
| Walk | **through the comma/semicolon-separated language list** |  |
| Lang | **= SupportedLanguages;** |  |
| Skip | **separators** |  |
| while | **(*Lang == ';' || *Lang == ',') {** |  |
| Find | **the end of this language entry** |  |
| Compare | **the primary subtag** |  |
| if | **(LangLen >= PrimaryLen) {** |  |
| Check | **if the secondary subtag (after '-') matches** |  |
| if | **(InternalAsciiStrnCmp (Lang, TargetLanguage, PrimaryLen) == 0) {** |  |
| Found | **a match - allocate and copy** |  |
| Match | **= AllocatePool (LangLen + 1);** |  |
| If | **we didn't find a match via primary language and there are no** |  |
| additional | **arguments, try the other language list from the va_list** |  |
| if | **(Match == NULL) {** |  |
| Recurse | **through additional language lists** |  |
| Match | **= GetSupportedLanguage (Lang, TargetLanguage);** |  |
| First | **call to get the string size** |  |
| Language | **not needed for size query** |  |
| Allocate | **the string buffer** |  |
| String | **= AllocatePool (StringSize);** |  |
| Second | **call to get the actual string** |  |
| Status | **= gHiiString->GetString (** |  |
| Get | **the HII string for this slot** |  |
| HiiString | **= HiiGetString ((EFI_HII_HANDLE)SlotHandle, StringId);** |  |
| Convert | **to ASCII (narrow each CHAR16)** |  |
| AsciiString | **= AllocatePool (InternalStrSize (HiiString));** |  |
| SMBIOS | **type 9 structure:** |  |
| The | **first field [0] must be the SMBIOS type (set by caller)** |  |
| Field | **[1] is the structure length (set by caller = -2 for variable)** |  |
| Field | **[2-3] handle (initialized by SMBIOS stack)** |  |
| Validate | **slot index (0 to 29)** |  |
| if | **(SlotIndex >= SMBIOS_TYPE9_SLOT_COUNT) {** |  |
| Set | **SMBIOS type 9 header fields** |  |
| WRITE_UINT8 | **(Buffer, 9);                                // Type** |  |
| Length | **(variable)** |  |
| Handle | **set by caller** |  |
| Slot | **0: PCIe x16 (PCH root port)** |  |
| SlotType | **= SLOT_TYPE_PCIE_X16;** |  |
| x1 | **link (x16 physical)** |  |
| Slot | **1: PCIe x8 (PCH root port)** |  |
| SlotType | **= SLOT_TYPE_PCIE_X8;** |  |
| Slot | **2: PCIe x8 (PCH root port)** |  |
| Slot | **3: PCIe x16 (PCH root port, x8 electrically)** |  |
| Slot | **4: PCIe x8 (PCH)** |  |
| Slot | **5: PCIe x8 (PCH)** |  |
| Slots | **on CPU1 (PCIe root ports)** |  |
| Slots | **on CPU2 (PCIe root port)** |  |
| All | **other slots use PCIe x8 width** |  |
| Write | **slot descriptor fields** |  |
| WRITE_UINT8 | **(Buffer + 4, SlotType);** |  |
| CurrentUsage | **= SLOT_USAGE_AVAILABLE;** |  |
| SlotLength | **= SLOT_LENGTH_LONG;** |  |
| Slot | **ID / String number: 1-based offset into string table** |  |
| StringNumber | **= (UINT16)(SlotIndex + 1);** |  |
| SlotCharacteristics1 | **= SLOT_CHAR1_3_3V | SLOT_CHAR1_PME;** |  |
| Characteristics2 | **//** |  |
| Segment | **group number (default 0)** |  |
| Bus | **number, Device/Function number, Data bus width** |  |
| These | **are populated from the slot configuration table** |  |
| BusNum | **= mSlotConfig[SlotIndex].BusNum;** |  |
| SMBIOS | **type 10 structure:** |  |
| Each | **pair: [0] = Device Type, [1] = String Number (for description)** |  |
| WRITE_UINT8 | **(Buffer, 10);               // Type** |  |
| Handle | **placeholder** |  |
| BMC | **/ AST2500 video controller** |  |
| DeviceType | **= TYPE10_DEVICE_TYPE_VIDEO;** |  |
| DeviceType | **= TYPE10_DEVICE_TYPE_ETHERNET;** |  |
| SATA | **controller** |  |
| DeviceType | **= TYPE10_DEVICE_TYPE_SATA;** |  |
| DeviceType | **= TYPE10_DEVICE_TYPE_UNKNOWN;** |  |
| No | **string** |  |
| SAS | **/ SATA controller (PCH)** |  |
| DeviceType | **= TYPE10_DEVICE_TYPE_SAS;** |  |
| Check | **if the device is actually present via MM PCI register read** |  |
| if | **(DeviceIndex <= 5) {** |  |
| Read | **PCI vendor/device ID at the device's bus/dev/func** |  |
| if | **(DeviceIndex == 0) {** |  |
| Device | **not present - mark as not present** |  |
| DeviceStatus | **= TYPE10_DEVICE_NOT_PRESENT;** |  |
| Write | **device descriptor: DeviceType | (DeviceStatus << 5)** |  |
| SMBIOS | **Type 10 encodes: bits[4:0] = device type, bits[7:5] = status** |  |
| WRITE_UINT8 | **(Buffer + 5 + DeviceIndex * 2, DeviceType | (DeviceStatus << 5));** |  |
| SMBIOS | **Type 41:** |  |
| WRITE_UINT8 | **(Buffer, 41);    // Type** |  |
| Length | **(fixed)** |  |
| Set | **default status = enabled** |  |
| DeviceStatus | **= TYPE41_DEVICE_ENABLED;** |  |
| Embedded | **NIC 1 (I350 port 0):** |  |
| Bus | **0, Dev 0x01, Func 0 - via MM PCI read at bus=0, dev=1, func=2** |  |
| ReferencedType | **= TYPE41_DEVICE_TYPE_NIC_1;** |  |
| Check | **if the I350 exists** |  |
| if | **(DeviceStatus == TYPE41_DEVICE_ENABLED) {** |  |
| I350 | **found - encode status as "enabled" with bit 7 set for** |  |
| the | **reference designation type instance encoding used by this SMBIOS** |  |
| DeviceStringNum | **= 0;  // No string, use instance encoding** |  |
| Embedded | **NIC 2 (I350 port 1)** |  |
| ReferencedType | **= TYPE41_DEVICE_TYPE_NIC_2;** |  |
| SATA | **controller (PCH)** |  |
| ReferencedType | **= TYPE41_DEVICE_TYPE_SATA_C;** |  |
| Additional | **on-board storage controller** |  |
| ReferencedType | **= TYPE41_DEVICE_TYPE_UNKNOWN;** |  |
| Write | **the Type 41 entry fields** |  |
| WRITE_UINT8 | **(Buffer + 4, 0);  // Reference designation string (0 = no string)** |  |
| Device | **type encoding** |  |
| Device | **Type Instance (offset 7):** |  |
| If | **device is present, encodes as: Type | 0x80** |  |
| If | **not present, encodes as: Type** |  |
| WRITE_UINT8 | **(Buffer + 8, (UINT8)SegmentNum);** |  |
| Allocate | **a temporary buffer (768 bytes) for constructing SMBIOS structures** |  |
| Buffer | **= AllocatePool (768);** |  |
| There | **are 30 (0x1E) system slots on this platform.** |  |
| for | **(Index = 0; Index < SMBIOS_TYPE9_SLOT_COUNT; Index++) {** |  |
| Clear | **the temporary buffer** |  |
| InternalZeroMem | **(Buffer, 768);** |  |
| Build | **the Type 9 SMBIOS structure for this slot** |  |
| Status | **= UpdateSmbiosType9Slots (Buffer, Index);** |  |
| Submit | **the updated SMBIOS structure to the system SMBIOS table** |  |
| Status | **= SubmitSmbiosStructure (Buffer);** |  |
| This | **ensures stale Type 9 entries are cleared before we add the new ones.** |  |
| RemoveSmbiosStructuresByType | **(9);** |  |
| There | **are up to 8 on-board devices.** |  |
| for | **(Index = 0; Index < SMBIOS_TYPE10_DEVICE_COUNT; Index++) {** |  |
| Remove | **old Type 10 structures** |  |
| RemoveSmbiosStructuresByType | **(10);** |  |
| There | **are up to 4 Type 41 device entries.** |  |
| for | **(Index = 0; Index < SMBIOS_TYPE41_DEVICE_COUNT; Index++) {** |  |
| FreePool | **(Buffer);** |  |
| Save | **the ImageHandle and SystemTable globally** |  |
| gImageHandle | **= ImageHandle;** |  |
| Validate | **global pointers** |  |
| ASSERT | **(gImageHandle != NULL);** |  |
| Locate | **the HII Database protocol** |  |
| Status | **= gBootServices->LocateProtocol (** |  |
| Locate | **the HII String protocol** |  |
| Locate | **the HII Package List protocol** |  |
| Locate | **the DXE Services Table** |  |
| Locate | **the MM PCI Base protocol (for register reads)** |  |
| Log | **entry point** |  |
| DEBUG | **((EFI_D_INFO, "UBA:SmbiosDataUpdateEntry Image GUID=%g\n", &gUbaPlatformDataGuid));** |  |
| DriverInitInternal | **(ImageHandle, SystemTable);** |  |
| Initialize | **HOB list** |  |
| HobLibInitialize | **();** |  |
| Locate | **the UBA SMBIOS string pack protocol** |  |
| Register | **the SMBIOS string pack** |  |
| Status | **= RegisterSmbiosStringPack (** |  |
| Register | **the actual SMBIOS update callback via UBA protocol** |  |
| Revision | **ProtocolData[2] = 11;      // Callback Function Type (Type 9/10/41 update)** |  |
| Look | **up the UBA SMBIOS update protocol** |  |
| if | **(gUbaSmbiosUpdateProtocol == NULL) {** |  |
| Register | **our update callback via the protocol's RegisterNotify function** |  |
| Status | **= ((EFI_STATUS (EFIAPI *)(VOID *, VOID *, UINT32 *, UINTN))** |  |

---
*Generated by HR650X BIOS Decompilation Project*