X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FIScsiDxe%2FIScsiIbft.c;h=83824331ba9697277d850b6358ad2a3dc15e3685;hb=c5de0d5599d8833c511d8668583ee2d4fe5643fc;hp=0c06437de19ba5a21be5a54ab073a98add6bc877;hpb=7a444476b4ffb405006ee36d0f2cec80c2d4b348;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c index 0c06437de1..83824331ba 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c @@ -1,6 +1,7 @@ -/*++ +/** @file + Implementation for iSCSI Boot Firmware Table publication. -Copyright (c) 2004 - 2007, Intel Corporation +Copyright (c) 2004 - 2008, Intel Corporation.
All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -9,40 +10,21 @@ http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. -Module Name: - - IScsiIbft.c - -Abstract: - - Implementation for iSCSI Boot Firmware Table publication. - ---*/ +**/ #include "IScsiImpl.h" -STATIC +/** + Initialize the header of the iSCSI Boot Firmware Table. + + @param[out] Header The header of the iSCSI Boot Firmware Table. +**/ VOID IScsiInitIbfTableHeader ( - IN EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Header + OUT EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Header ) -/*++ - -Routine Description: - - Initialize the header of the iSCSI Boot Firmware Table. - -Arguments: - - Header - The header of the iSCSI Boot Firmware Table. - -Returns: - - None. - ---*/ { - NetZeroMem (Header, sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER)); + ZeroMem (Header, sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER)); Header->Signature = EFI_ACPI_3_0_ISCSI_BOOT_FIRMWARE_TABLE_SIGNATURE; Header->Length = IBFT_HEAP_OFFSET; @@ -56,36 +38,25 @@ Returns: Header->OemId[4] = 'L'; } -STATIC +/** + Initialize the control section of the iSCSI Boot Firmware Table. + + @param[in] Table The ACPI table. + @param[in] HandleCount The number of the handles associated with iSCSI sessions, it's + equal to the number of iSCSI sessions. +**/ VOID IScsiInitControlSection ( IN EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Table, IN UINTN HandleCount ) -/*++ - -Routine Description: - - Initialize the control section of the iSCSI Boot Firmware Table. - -Arguments: - - Table - The ACPI table. - HandleCount - The number of the handles associated with iSCSI sessions, it's - equal to the number of iSCSI sessions. - -Returns: - - None. - ---*/ { EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *Control; UINTN NumOffset; Control = (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *) (Table + 1); - NetZeroMem (Control, sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE)); + ZeroMem (Control, sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE)); Control->Header.StructureId = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE_ID; Control->Header.Version = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE_VERSION; @@ -105,65 +76,43 @@ Returns: } } -STATIC +/** + Add one item into the heap. + + @param[in, out] Heap On input, the current address of the heap; On output, the address of + the heap after the item is added. + @param[in] Data The data to add into the heap. + @param[in] Len Length of the Data in byte. +**/ VOID IScsiAddHeapItem ( IN OUT UINT8 **Heap, IN VOID *Data, IN UINTN Len ) -/*++ - -Routine Description: - - Add one item into the heap. - -Arguments: - - Heap - On input, the current address of the heap; On output, the address of - the heap after the item is added. - Data - The data to add into the heap. - Len - Length of the Data in byte. - -Returns: - - None. - ---*/ { // // Add one byte for the NULL delimiter. // *Heap -= Len + 1; - NetCopyMem (*Heap, Data, Len); + CopyMem (*Heap, Data, Len); *(*Heap + Len) = 0; } -STATIC +/** + Fill the Initiator section of the iSCSI Boot Firmware Table. + + @param[in] Table The ACPI table. + @param[in, out] Heap The heap. + @param[in] Handle The handle associated with the iSCSI session. +**/ VOID IScsiFillInitiatorSection ( IN EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Table, IN OUT UINT8 **Heap, IN EFI_HANDLE Handle ) -/*++ - -Routine Description: - - Fill the Initiator section of the iSCSI Boot Firmware Table. - -Arguments: - - Table - The ACPI table. - Heap - The heap. - Handle - The handle associated with the iSCSI session. - -Returns: - - None. - ---*/ { EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *Control; EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE *Initiator; @@ -181,7 +130,7 @@ Returns: Control->InitiatorOffset = (UINT16) ((UINTN) Initiator - (UINTN) Table); - NetZeroMem (Initiator, sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE)); + ZeroMem (Initiator, sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE)); Initiator->Header.StructureId = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_ID; Initiator->Header.Version = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_VERSION; @@ -209,32 +158,21 @@ Returns: Initiator->IScsiNameOffset = (UINT16) ((UINTN) *Heap - (UINTN) Table); } -STATIC +/** + Map the v4 IP address into v6 IP address. + + @param[in] V4 The v4 IP address. + @param[out] V6 The v6 IP address. +**/ VOID IScsiMapV4ToV6Addr ( IN EFI_IPv4_ADDRESS *V4, OUT EFI_IPv6_ADDRESS *V6 ) -/*++ - -Routine Description: - - Map the v4 IP address into v6 IP address. - -Arguments: - - V4 - The v4 IP address. - V6 - The v6 IP address. - -Returns: - - None. - ---*/ { UINTN Index; - NetZeroMem (V6, sizeof (EFI_IPv6_ADDRESS)); + ZeroMem (V6, sizeof (EFI_IPv6_ADDRESS)); V6->Addr[10] = 0xff; V6->Addr[11] = 0xff; @@ -244,27 +182,19 @@ Returns: } } -STATIC -UINT16 -IScsiGetNICPciLocation ( - IN EFI_HANDLE Controller - ) -/*++ - -Routine Description: - +/** Get the NIC's PCI location and return it accroding to the composited format defined in iSCSI Boot Firmware Table. - -Arguments: - - Controller - The handle of the controller. -Returns: + @param[in] Controller The handle of the controller. - UINT16 - The composited representation of the NIC PCI location. - ---*/ + @return UINT16 The composited representation of the NIC PCI location. + @retval 0 Other errors as indicated. +**/ +UINT16 +IScsiGetNICPciLocation ( + IN EFI_HANDLE Controller + ) { EFI_STATUS Status; EFI_DEVICE_PATH_PROTOCOL *DevicePath; @@ -306,26 +236,17 @@ Returns: return (UINT16) ((Bus << 8) | (Device << 3) | Function); } -STATIC +/** + Get the MAC address of the controller. + + @param[in] Controller The handle of the controller. + + @return EFI_MAC_ADDRESS * The mac address. +**/ EFI_MAC_ADDRESS * IScsiGetMacAddress ( IN EFI_HANDLE Controller ) -/*++ - -Routine Description: - - Get the MAC address of the controller. - -Arguments: - - Controller - The handle of the controller. - -Returns: - - EFI_MAC_ADDRESS * - The mac address. - ---*/ { EFI_STATUS Status; EFI_SIMPLE_NETWORK_PROTOCOL *Snp; @@ -340,7 +261,14 @@ Returns: return &Snp->Mode->PermanentAddress; } -STATIC +/** + Fill the NIC and target sections in iSCSI Boot Firmware Table. + + @param[in] Table The buffer of the ACPI table. + @param[in, out] Heap The heap buffer used to store the variable length parameters such as iSCSI name. + @param[in] HandleCount Count The number of handles having iSCSI private protocol installed. + @param[in] Handles The handle buffer. +**/ VOID IScsiFillNICAndTargetSections ( IN EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER *Table, @@ -348,24 +276,6 @@ IScsiFillNICAndTargetSections ( IN UINTN HandleCount, IN EFI_HANDLE *Handles ) -/*++ - -Routine Description: - - Fill the NIC and target sections in iSCSI Boot Firmware Table. - -Arguments: - - Table - The buffer of the ACPI table. - Heap - The heap buffer used to store the variable length parameters such as iSCSI name. - HandleCount - The number of handles having iSCSI private protocol installed. - Handles - The handle buffer. - -Returns: - - None. - ---*/ { EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE *Control; EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE *Nic; @@ -405,7 +315,7 @@ Returns: // // Fill the Nic section. // - NetZeroMem (Nic, sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE)); + ZeroMem (Nic, sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE)); Nic->Header.StructureId = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_ID; Nic->Header.Version = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_VERSION; @@ -435,7 +345,7 @@ Returns: IScsiMapV4ToV6Addr (&SessionConfigData->DhcpServer, &Nic->DhcpServer); Mac = IScsiGetMacAddress (DriverData->Controller); - NetCopyMem (Nic->Mac, Mac, sizeof (Nic->Mac)); + CopyMem (Nic->Mac, Mac, sizeof (Nic->Mac)); // // Get the PCI location of the Nic. @@ -448,7 +358,7 @@ Returns: // // Fill the Target section. // - NetZeroMem (Target, sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE)); + ZeroMem (Target, sizeof (EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE)); Target->Header.StructureId = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_ID; Target->Header.Version = EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_VERSION; @@ -460,7 +370,7 @@ Returns: Target->NicIndex = (UINT8) Index; IScsiMapV4ToV6Addr (&SessionConfigData->NvData.TargetIp, &Target->Ip); - NetCopyMem (Target->BootLun, SessionConfigData->NvData.BootLun, sizeof (Target->BootLun)); + CopyMem (Target->BootLun, SessionConfigData->NvData.BootLun, sizeof (Target->BootLun)); // // Target iSCSI Name, CHAP name/secret, reverse CHAP name/secret. @@ -520,26 +430,14 @@ Returns: } } +/** + Publish and remove the iSCSI Boot Firmware Table according to the iSCSI + session status. +**/ VOID IScsiPublishIbft ( - IN VOID + 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; @@ -572,7 +470,7 @@ Returns: } Signature = Table->Signature; - NetFreePool (Table); + gBS->FreePool (Table); if (Signature == EFI_ACPI_3_0_ISCSI_BOOT_FIRMWARE_TABLE_SIGNATURE) { // @@ -608,7 +506,7 @@ Returns: // // Allocate 4k bytes to hold the ACPI table. // - Table = NetAllocatePool (IBFT_MAX_SIZE); + Table = AllocatePool (IBFT_MAX_SIZE); if (Table == NULL) { return ; } @@ -623,7 +521,7 @@ Returns: IScsiFillInitiatorSection (Table, &Heap, HandleBuffer[0]); IScsiFillNICAndTargetSections (Table, &Heap, HandleCount, HandleBuffer); - NetFreePool (HandleBuffer); + gBS->FreePool (HandleBuffer); TableHandle = 0; @@ -641,5 +539,5 @@ Returns: AcpiSupport->PublishTables (AcpiSupport, EFI_ACPI_TABLE_VERSION_3_0); } - NetFreePool (Table); + gBS->FreePool (Table); }