]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c
1. Add ISCSI iBFT CHAP types to IScsiBootFirmwareTable.h.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / IScsiDxe / IScsiIbft.c
index 6ca8a217f573251a39bac8ff44cd094f7383f3b0..372efdc15ef96ac3a56ee480241cfe9e6ec4501e 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Implementation for iSCSI Boot Firmware Table publication.\r
 \r
-Copyright (c) 2004 - 2009, Intel Corporation.<BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2004 - 2013, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
@@ -37,15 +37,9 @@ IScsiInitIbfTableHeader (
   Header->Length    = IBFT_HEAP_OFFSET;\r
   Header->Revision  = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_REVISION;\r
   Header->Checksum  = 0;\r
-\r
-  Header->OemId[0]  = 'I';\r
-  Header->OemId[1]  = 'N';\r
-  Header->OemId[2]  = 'T';\r
-  Header->OemId[3]  = 'E';\r
-  Header->OemId[4]  = 'L';\r
   \r
   CopyMem (Header->OemId, OemId, sizeof (Header->OemId));\r
-  Header->OemTableId = *OemTableId;\r
+  CopyMem (&Header->OemTableId, OemTableId, sizeof (UINT64));\r
 }\r
 \r
 /**\r
@@ -70,7 +64,7 @@ IScsiInitControlSection (
 \r
   Control->Header.StructureId = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE_ID;\r
   Control->Header.Version     = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE_VERSION;\r
-  Control->Header.Length      = sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE);\r
+  Control->Header.Length      = (UINT16) sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE);\r
 \r
   //\r
   // Each session occupies two offsets, one for the NIC section,\r
@@ -144,13 +138,13 @@ IScsiFillInitiatorSection (
 \r
   Initiator->Header.StructureId = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_ID;\r
   Initiator->Header.Version     = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_VERSION;\r
-  Initiator->Header.Length      = sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE);\r
+  Initiator->Header.Length      = (UINT16) sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE);\r
   Initiator->Header.Flags       = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_FLAG_BLOCK_VALID | EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_FLAG_BOOT_SELECTED;\r
 \r
   //\r
   // Get the identifier from the handle.\r
   //\r
-  Status = gBS->HandleProtocol (Handle, &gIScsiPrivateGuid, (VOID **) &IScsiIdentifier);\r
+  Status = gBS->HandleProtocol (Handle, &gEfiCallerIdGuid, (VOID **) &IScsiIdentifier);\r
   if (EFI_ERROR (Status)) {\r
     ASSERT (FALSE);\r
     return ;\r
@@ -288,7 +282,7 @@ IScsiFillNICAndTargetSections (
   SectionOffset = &Control->NIC0Offset;\r
 \r
   for (Index = 0; Index < HandleCount; Index++) {\r
-    Status = gBS->HandleProtocol (Handles[Index], &gIScsiPrivateGuid, (VOID **)&IScsiIdentifier);\r
+    Status = gBS->HandleProtocol (Handles[Index], &gEfiCallerIdGuid, (VOID **)&IScsiIdentifier);\r
     if (EFI_ERROR (Status)) {\r
       ASSERT (FALSE);\r
       return ;\r
@@ -305,7 +299,7 @@ IScsiFillNICAndTargetSections (
 \r
     Nic->Header.StructureId = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_ID;\r
     Nic->Header.Version     = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_VERSION;\r
-    Nic->Header.Length      = sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE);\r
+    Nic->Header.Length      = (UINT16) sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE);\r
     Nic->Header.Index       = (UINT8) Index;\r
     Nic->Header.Flags       = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_FLAG_BLOCK_VALID |\r
                             EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_FLAG_BOOT_SELECTED |\r
@@ -351,13 +345,20 @@ IScsiFillNICAndTargetSections (
 \r
     Target->Header.StructureId  = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_ID;\r
     Target->Header.Version      = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_VERSION;\r
-    Target->Header.Length       = sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE);\r
+    Target->Header.Length       = (UINT16) sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE);\r
     Target->Header.Index        = (UINT8) Index;\r
     Target->Header.Flags        = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_FLAG_BLOCK_VALID | EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_FLAG_BOOT_SELECTED;\r
     Target->Port                = SessionConfigData->NvData.TargetPort;\r
-    Target->CHAPType            = AuthConfig->CHAPType;\r
     Target->NicIndex            = (UINT8) Index;\r
 \r
+    if (AuthConfig->CHAPType == ISCSI_CHAP_NONE) {\r
+      Target->CHAPType = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_NO_CHAP;\r
+    } if (AuthConfig->CHAPType == ISCSI_CHAP_UNI) {\r
+      Target->CHAPType = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_CHAP;\r
+    } else if (AuthConfig->CHAPType == ISCSI_CHAP_MUTUAL) {\r
+      Target->CHAPType = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_MUTUAL_CHAP;\r
+    }\r
+\r
     IScsiMapV4ToV6Addr (&SessionConfigData->NvData.TargetIp, &Target->Ip);\r
     CopyMem (Target->BootLun, SessionConfigData->NvData.BootLun, sizeof (Target->BootLun));\r
 \r
@@ -370,7 +371,7 @@ IScsiFillNICAndTargetSections (
     Target->IScsiNameLength = Length;\r
     Target->IScsiNameOffset = (UINT16) ((UINTN) *Heap - (UINTN) Table);\r
 \r
-    if (Target->CHAPType != ISCSI_CHAP_NONE) {\r
+    if (Target->CHAPType != EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_NO_CHAP) {\r
       //\r
       // CHAP Name\r
       //\r
@@ -387,7 +388,7 @@ IScsiFillNICAndTargetSections (
       Target->CHAPSecretLength  = Length;\r
       Target->CHAPSecretOffset  = (UINT16) ((UINTN) *Heap - (UINTN) Table);\r
 \r
-      if (Target->CHAPType == ISCSI_CHAP_MUTUAL) {\r
+      if (Target->CHAPType == EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_CHAP_TYPE_MUTUAL_CHAP) {\r
         //\r
         // Reverse CHAP Name\r
         //\r
@@ -484,7 +485,7 @@ IScsiPublishIbft (
   //\r
   Status = gBS->LocateHandleBuffer (\r
                   ByProtocol,\r
-                  &gIScsiPrivateGuid,\r
+                  &gEfiCallerIdGuid,\r
                   NULL,\r
                   &HandleCount,\r
                   &HandleBuffer\r