/** Publish and remove the iSCSI Boot Firmware Table according to the iSCSI session status. **/ VOID IScsiPublishIbft ( VOID ) { EFI_STATUS Status; EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol; EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Table; UINTN HandleCount; EFI_HANDLE *HandleBuffer; UINT8 *Heap; UINT8 Checksum; UINTN Index; EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp; EFI_ACPI_DESCRIPTION_HEADER *Rsdt; Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **)&AcpiTableProtocol); if (EFI_ERROR (Status)) { return ; } // // Find ACPI table RSD_PTR from system table // for (Index = 0, Rsdp = NULL; Index < gST->NumberOfTableEntries; Index++) { if (CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), &gEfiAcpi20TableGuid) || CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), &gEfiAcpi10TableGuid) || CompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), &gEfiAcpiTableGuid) ) { // // A match was found. // Rsdp = (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *) gST->ConfigurationTable[Index].VendorTable; break; } } if (Rsdp == NULL) { return ; } else { Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress; } if (mIbftInstalled) { Status = AcpiTableProtocol->UninstallAcpiTable ( AcpiTableProtocol, mTableKey ); if (EFI_ERROR (Status)) { return ; } mIbftInstalled = FALSE; } // // Get all iSCSI private protocols. // Status = gBS->LocateHandleBuffer ( ByProtocol, &gEfiCallerIdGuid, NULL, &HandleCount, &HandleBuffer ); if (EFI_ERROR (Status)) { return ; } // // Allocate 4k bytes to hold the ACPI table. // Table = AllocateZeroPool (IBFT_MAX_SIZE); if (Table == NULL) { return ; } Heap = (UINT8 *) Table + IBFT_HEAP_OFFSET; // // Fill in the various section of the iSCSI Boot Firmware Table. // IScsiInitIbfTableHeader (Table, Rsdt->OemId, &Rsdt->OemTableId); IScsiInitControlSection (Table, HandleCount); IScsiFillInitiatorSection (Table, &Heap, HandleBuffer[0]); IScsiFillNICAndTargetSections (Table, &Heap, HandleCount, HandleBuffer); Checksum = CalculateCheckSum8((UINT8 *)Table, Table->Length); Table->Checksum = Checksum; FreePool (HandleBuffer); // // Install or update the iBFT table. // Status = AcpiTableProtocol->InstallAcpiTable ( AcpiTableProtocol, Table, Table->Length, &mTableKey ); if (EFI_ERROR(Status)) { return; } mIbftInstalled = TRUE; FreePool (Table); }
VOID IScsiPublishIbft ( IN VOID ) /*++ Routine Description: Publish and remove the iSCSI Boot Firmware Table according to the iSCSI session status. Arguments: None. Returns: None. --*/ { EFI_STATUS Status; UINTN TableHandle; EFI_ACPI_SUPPORT_PROTOCOL *AcpiSupport; EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Table; EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp; EFI_ACPI_DESCRIPTION_HEADER *Rsdt; UINTN HandleCount; EFI_HANDLE *HandleBuffer; UINT8 *Heap; UINTN Index; INTN TableIndex; EFI_ACPI_TABLE_VERSION Version; UINT32 Signature; Status = gBS->LocateProtocol (&gEfiAcpiSupportGuid, NULL, &AcpiSupport); if (EFI_ERROR (Status)) { return ; } // // Find ACPI table RSD_PTR from system table // for (Index = 0, Rsdp = NULL; Index < gST->NumberOfTableEntries; Index++) { if (EfiCompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), &gEfiAcpi30TableGuid) || EfiCompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), &gEfiAcpi20TableGuid) || EfiCompareGuid (&(gST->ConfigurationTable[Index].VendorGuid), &gEfiAcpiTableGuid) ) { // // A match was found. // Rsdp = (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *) gST->ConfigurationTable[Index].VendorTable; break; } } if (Rsdp == NULL) { return ; } else { Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress; } // // Try to remove the old iSCSI Boot Firmware Table. // for (TableIndex = 0;; TableIndex++) { Status = AcpiSupport->GetAcpiTable ( AcpiSupport, TableIndex, &Table, &Version, &TableHandle ); if (EFI_ERROR (Status)) { break; } Signature = Table->Signature; NetFreePool (Table); if (Signature == EFI_ACPI_3_0_ISCSI_BOOT_FIRMWARE_TABLE_SIGNATURE) { // // Remove the table. // Status = AcpiSupport->SetAcpiTable ( AcpiSupport, NULL, FALSE, Version, &TableHandle ); if (EFI_ERROR (Status)) { return ; } break; } } // // Get all iSCSI private protocols. // Status = gBS->LocateHandleBuffer ( ByProtocol, &mIScsiPrivateGuid, NULL, &HandleCount, &HandleBuffer ); if (EFI_ERROR (Status)) { return ; } // // Allocate 4k bytes to hold the ACPI table. // Table = NetAllocatePool (IBFT_MAX_SIZE); if (Table == NULL) { return ; } Heap = (CHAR8 *) Table + IBFT_HEAP_OFFSET; // // Fill in the various section of the iSCSI Boot Firmware Table. // IScsiInitIbfTableHeader (Table, Rsdt->OemId, &Rsdt->OemTableId); IScsiInitControlSection (Table, HandleCount); IScsiFillInitiatorSection (Table, &Heap, HandleBuffer[0]); IScsiFillNICAndTargetSections (Table, &Heap, HandleCount, HandleBuffer); NetFreePool (HandleBuffer); TableHandle = 0; // // Install or update the iBFT table. // Status = AcpiSupport->SetAcpiTable ( AcpiSupport, Table, TRUE, EFI_ACPI_TABLE_VERSION_3_0, &TableHandle ); if (!EFI_ERROR (Status)) { AcpiSupport->PublishTables (AcpiSupport, EFI_ACPI_TABLE_VERSION_3_0); } NetFreePool (Table); }
/** Publish and remove the iSCSI Boot Firmware Table according to the iSCSI session status. **/ VOID IScsiPublishIbft ( VOID ) { EFI_STATUS Status; EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol; EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Table; UINTN HandleCount; EFI_HANDLE *HandleBuffer; UINT8 *Heap; UINT8 Checksum; EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp; EFI_ACPI_DESCRIPTION_HEADER *Rsdt; EFI_ACPI_DESCRIPTION_HEADER *Xsdt; Rsdt = NULL; Xsdt = NULL; Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **)&AcpiTableProtocol); if (EFI_ERROR (Status)) { return ; } // // Find ACPI table RSD_PTR from system table // Status = EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, (VOID **) &Rsdp); if (EFI_ERROR (Status)) { Status = EfiGetSystemConfigurationTable (&gEfiAcpi10TableGuid, (VOID **) &Rsdp); } if (EFI_ERROR (Status) || (Rsdp == NULL)) { return ; } else if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION && Rsdp->XsdtAddress != 0) { Xsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->XsdtAddress; } else if (Rsdp->RsdtAddress != 0) { Rsdt = (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress; } if ((Xsdt == NULL) && (Rsdt == NULL)) { return ; } if (mIbftInstalled) { Status = AcpiTableProtocol->UninstallAcpiTable ( AcpiTableProtocol, mTableKey ); if (EFI_ERROR (Status)) { return ; } mIbftInstalled = FALSE; } // // Get all iSCSI private protocols. // Status = gBS->LocateHandleBuffer ( ByProtocol, &gEfiCallerIdGuid, NULL, &HandleCount, &HandleBuffer ); if (EFI_ERROR (Status)) { return ; } // // Allocate 4k bytes to hold the ACPI table. // Table = AllocateZeroPool (IBFT_MAX_SIZE); if (Table == NULL) { return ; } Heap = (UINT8 *) Table + IBFT_HEAP_OFFSET; // // Fill in the various section of the iSCSI Boot Firmware Table. // if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION) { IScsiInitIbfTableHeader (Table, Xsdt->OemId, &Xsdt->OemTableId); } else { IScsiInitIbfTableHeader (Table, Rsdt->OemId, &Rsdt->OemTableId); } IScsiInitControlSection (Table, HandleCount); IScsiFillInitiatorSection (Table, &Heap, HandleBuffer[0]); IScsiFillNICAndTargetSections (Table, &Heap, HandleCount, HandleBuffer); Checksum = CalculateCheckSum8((UINT8 *)Table, Table->Length); Table->Checksum = Checksum; FreePool (HandleBuffer); // // Install or update the iBFT table. // Status = AcpiTableProtocol->InstallAcpiTable ( AcpiTableProtocol, Table, Table->Length, &mTableKey ); if (EFI_ERROR(Status)) { return; } mIbftInstalled = TRUE; FreePool (Table); }