11BOOLEAN mIbftInstalled =
FALSE;
30 Header->Length = IBFT_HEAP_OFFSET;
31 Header->Revision = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_REVISION;
34 CopyMem (Header->OemId, OemId, sizeof (Header->OemId));
35 CopyMem (&Header->OemTableId, OemTableId, sizeof (UINT64));
54 Control->Header.StructureId = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE_ID;
55 Control->Header.Version = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE_VERSION;
65 if (mPrivate->EnableMpio) {
66 Control->Header.Flags = 0;
67 NumOffset = 2 * (mPrivate->MpioCount - mPrivate->Krb5MpioCount);
69 NumOffset = 2 * mPrivate->ValidSinglePathCount;
81 Control->Header.Length = (UINT16)(Control->Header.Length + (NumOffset - 4) *
sizeof (UINT16));
132 ((UINT8 *)Control + IBFT_ROUNDUP (Control->Header.Length));
134 Control->InitiatorOffset = (UINT16)((
UINTN)Initiator - (
UINTN)Table);
136 Initiator->Header.StructureId = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_ID;
137 Initiator->Header.Version = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_VERSION;
139 Initiator->Header.Flags = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_FLAG_BLOCK_VALID |
140 EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_FLAG_BOOT_SELECTED;
145 IScsiAddHeapItem (Heap, mPrivate->InitiatorName, mPrivate->InitiatorNameLength - 1);
147 Initiator->IScsiNameLength = (UINT16)(mPrivate->InitiatorNameLength - 1);
148 Initiator->IScsiNameOffset = (UINT16)((
UINTN)*Heap - (
UINTN)Table);
171 for (Index = 0; Index < 4; Index++) {
172 V6->Addr[12 + Index] = V4->Addr[Index];
195 UINT16 *SectionOffset;
212 SectionOffset = &Control->NIC0Offset;
217 NET_LIST_FOR_EACH (Entry, &mPrivate->AttemptConfigs) {
223 if (Attempt ==
NULL) {
230 ASSERT (Attempt->SessionConfigData.Enabled != ISCSI_DISABLED);
232 if ((Index == 1) && Flag) {
233 Entry = mPrivate->AttemptConfigs.ForwardLink;
238 if (Attempt->AttemptConfigIndex == mPrivate->BootSelectedIndex) {
243 if (Attempt->SessionConfigData.Enabled == ISCSI_DISABLED) {
250 if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_KRB) {
257 if (mPrivate->EnableMpio && (Attempt->SessionConfigData.Enabled != ISCSI_ENABLED_FOR_MPIO)) {
264 if (!Attempt->ValidiBFTPath) {
268 NvData = &Attempt->SessionConfigData;
269 AuthConfig = &Attempt->AuthConfigData.CHAP;
275 Nic->Header.StructureId = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_ID;
276 Nic->Header.Version = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_VERSION;
278 Nic->Header.Index = (UINT8)Index;
279 Nic->Header.Flags = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_FLAG_BLOCK_VALID |
280 EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_FLAG_GLOBAL;
283 Nic->Header.Flags |= EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_FLAG_BOOT_SELECTED;
286 if (NvData->InitiatorInfoFromDhcp) {
287 Nic->Origin = IpPrefixOriginDhcp;
289 Nic->Origin = IpPrefixOriginManual;
292 if ((NvData->IpMode == IP_MODE_IP4) || (NvData->IpMode == IP_MODE_AUTOCONFIG)) {
306 }
else if ((NvData->IpMode == IP_MODE_IP6) || (NvData->IpMode == IP_MODE_AUTOCONFIG)) {
307 Nic->SubnetMaskPrefixLength = NvData->PrefixLength;
321 ASSERT (NicInfo !=
NULL);
323 Nic->VLanTag = NicInfo->VlanId;
324 CopyMem (Nic->Mac, &NicInfo->PermanentAddress, sizeof (Nic->Mac));
325 Nic->PciLocation = (UINT16)((NicInfo->BusNumber << 8) |
326 (NicInfo->DeviceNumber << 3) | NicInfo->FunctionNumber);
327 *SectionOffset = (UINT16)((
UINTN)Nic - (
UINTN)Table);
334 Target->Header.StructureId = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_ID;
335 Target->Header.Version = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_VERSION;
337 Target->Header.Index = (UINT8)Index;
338 Target->Header.Flags = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_FLAG_BLOCK_VALID;
341 Target->Header.Flags |= EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_FLAG_BOOT_SELECTED;
344 Target->Port = NvData->TargetPort;
346 if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) {
347 if (AuthConfig->CHAPType == ISCSI_CHAP_UNI) {
348 Target->CHAPType = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_CHAP;
349 }
else if (AuthConfig->CHAPType == ISCSI_CHAP_MUTUAL) {
350 Target->CHAPType = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_MUTUAL_CHAP;
352 }
else if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_NONE) {
353 Target->CHAPType = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_NO_CHAP;
356 Target->NicIndex = (UINT8)Index;
358 if ((NvData->IpMode == IP_MODE_IP4) || (NvData->IpMode == IP_MODE_AUTOCONFIG)) {
360 }
else if ((NvData->IpMode == IP_MODE_IP6) || (NvData->IpMode == IP_MODE_AUTOCONFIG)) {
366 CopyMem (Target->BootLun, NvData->BootLun, sizeof (Target->BootLun));
374 Target->IScsiNameLength = Length;
375 Target->IScsiNameOffset = (UINT16)((
UINTN)*Heap - (
UINTN)Table);
377 if (Attempt->AuthenticationType == ISCSI_AUTH_TYPE_CHAP) {
381 Length = (UINT16)
AsciiStrLen (AuthConfig->CHAPName);
383 Target->CHAPNameLength = Length;
384 Target->CHAPNameOffset = (UINT16)((
UINTN)*Heap - (
UINTN)Table);
389 Length = (UINT16)
AsciiStrLen (AuthConfig->CHAPSecret);
391 Target->CHAPSecretLength = Length;
392 Target->CHAPSecretOffset = (UINT16)((
UINTN)*Heap - (
UINTN)Table);
394 if (Target->CHAPType == EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_MUTUAL_CHAP) {
398 Length = (UINT16)
AsciiStrLen (AuthConfig->ReverseCHAPName);
400 Target->ReverseCHAPNameLength = Length;
401 Target->ReverseCHAPNameOffset = (UINT16)((
UINTN)*Heap - (
UINTN)Table);
406 Length = (UINT16)
AsciiStrLen (AuthConfig->ReverseCHAPSecret);
408 Target->ReverseCHAPSecretLength = Length;
409 Target->ReverseCHAPSecretOffset = (UINT16)((
UINTN)*Heap - (
UINTN)Table);
413 *SectionOffset = (UINT16)((
UINTN)Target - (
UINTN)Table);
450 Status =
gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid,
NULL, (VOID **)&AcpiTableProtocol);
451 if (EFI_ERROR (Status)) {
459 if (EFI_ERROR (Status)) {
463 if (EFI_ERROR (Status) || (Rsdp ==
NULL)) {
467 }
else if (Rsdp->RsdtAddress != 0) {
471 if ((Xsdt ==
NULL) && (Rsdt ==
NULL)) {
475 if (mIbftInstalled) {
476 Status = AcpiTableProtocol->UninstallAcpiTable (
480 if (EFI_ERROR (Status)) {
484 mIbftInstalled =
FALSE;
490 if ((!mPrivate->EnableMpio && (mPrivate->ValidSinglePathCount == 0)) ||
491 (mPrivate->EnableMpio && (mPrivate->MpioCount <= mPrivate->Krb5MpioCount)))
504 Heap = (UINT8 *)Table + IBFT_HEAP_OFFSET;
520 Table->Checksum = Checksum;
525 Status = AcpiTableProtocol->InstallAcpiTable (
531 if (EFI_ERROR (Status)) {
535 mIbftInstalled =
TRUE;
#define EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION
#define EFI_ACPI_3_0_ISCSI_BOOT_FIRMWARE_TABLE_SIGNATURE
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
UINT8 EFIAPI CalculateCheckSum8(IN CONST UINT8 *Buffer, IN UINTN Length)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
ISCSI_ATTEMPT_CONFIG_NVDATA * IScsiConfigGetAttemptByConfigIndex(IN UINT8 AttemptConfigIndex)
VOID IScsiFillNICAndTargetSections(IN EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Table, IN OUT UINT8 **Heap)
VOID IScsiFillInitiatorSection(IN EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Table, IN OUT UINT8 **Heap)
VOID IScsiInitIbfTableHeader(OUT EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Header, IN UINT8 *OemId, IN UINT64 *OemTableId)
VOID IScsiInitControlSection(IN EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Table)
VOID IScsiPublishIbft(IN VOID)
VOID IScsiAddHeapItem(IN OUT UINT8 **Heap, IN VOID *Data, IN UINTN Len)
VOID IScsiMapV4ToV6Addr(IN EFI_IPv4_ADDRESS *V4, OUT EFI_IPv6_ADDRESS *V6)
UINT8 IScsiGetSubnetMaskPrefixLength(IN EFI_IPv4_ADDRESS *SubnetMask)
ISCSI_NIC_INFO * IScsiGetNicInfoByIndex(IN UINT8 NicIndex)
EFI_STATUS EFIAPI EfiGetSystemConfigurationTable(IN EFI_GUID *TableGuid, OUT VOID **Table)