VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c@ 99396

最後變更 在這個檔案從99396是 89983,由 vboxsync 提交於 4 年 前

Devices/EFI: Merge edk-stable202105 and openssl 1.1.1j and make it build, bugref:4643

  • 屬性 svn:eol-style 設為 native
檔案大小: 3.9 KB
 
1/** @file
2 RedfishSmbiosHostInterface.c
3
4 Discover Redfish SMBIOS Host Interface.
5
6 (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
7
8 SPDX-License-Identifier: BSD-2-Clause-Patent
9
10**/
11
12#include "RedfishDiscoverInternal.h"
13
14SMBIOS_TABLE_TYPE42 *mType42Record;
15
16/**
17 The function gets information reported in Redfish Host Interface.
18
19 It simply frees the packet.
20
21 @param[in] Smbios SMBIOS protocol.
22 @param[out] DeviceDescriptor Pointer to REDFISH_INTERFACE_DATA.
23 @param[out] ProtocolData Pointer to REDFISH_OVER_IP_PROTOCOL_DATA.
24
25 @retval EFI_SUCCESS Get host interface succesfully.
26 @retval Otherwise Fail to tet host interface.
27
28**/
29EFI_STATUS
30RedfishGetHostInterfaceProtocolData (
31 IN EFI_SMBIOS_PROTOCOL *Smbios,
32 OUT REDFISH_INTERFACE_DATA **DeviceDescriptor,
33 OUT REDFISH_OVER_IP_PROTOCOL_DATA **ProtocolData
34 )
35{
36 EFI_STATUS Status;
37 EFI_SMBIOS_HANDLE SmbiosHandle;
38 EFI_SMBIOS_TABLE_HEADER *Record;
39 UINT16 Offset;
40 UINT8 *RecordTmp;
41 UINT8 ProtocolLength;
42 UINT8 SpecificDataLen;
43
44 if ((Smbios == NULL) || (ProtocolData == NULL)) {
45 return EFI_INVALID_PARAMETER;
46 }
47
48 SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
49 Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
50 while (!EFI_ERROR (Status) && SmbiosHandle != SMBIOS_HANDLE_PI_RESERVED) {
51 if (Record->Type == SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE) {
52 //
53 // Check Interface Type, should be Network Host Interface = 40h
54 //
55 mType42Record = (SMBIOS_TABLE_TYPE42 *) Record;
56 if (mType42Record->InterfaceType == MCHostInterfaceTypeNetworkHostInterface) {
57 ASSERT (Record->Length >= 9);
58 Offset = 5;
59 RecordTmp = (UINT8 *) Record + Offset;
60 //
61 // Get interface specific data length.
62 //
63 SpecificDataLen = *RecordTmp;
64 Offset += 1;
65 RecordTmp = (UINT8 *) Record + Offset;
66
67 //
68 // Check Device Type, only PCI/PCIe Network Interface v2 is supported now.
69 //
70 if (*RecordTmp == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) {
71 ASSERT (SpecificDataLen == sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1);
72 *DeviceDescriptor = (REDFISH_INTERFACE_DATA *)RecordTmp;
73 Offset = Offset + SpecificDataLen;
74 RecordTmp = (UINT8 *) Record + Offset;
75 //
76 // Check Protocol count. if > 1, only use the first protocol.
77 //
78 ASSERT (*RecordTmp == 1);
79 Offset += 1;
80 RecordTmp = (UINT8 *) Record + Offset;
81 //
82 // Check protocol identifier.
83 //
84 if (*RecordTmp == MCHostInterfaceProtocolTypeRedfishOverIP) {
85 Offset += 1;
86 RecordTmp = (UINT8 *) Record + Offset;
87 ProtocolLength = *RecordTmp;
88
89 Offset += 1;
90 RecordTmp = (UINT8 *) Record + Offset;
91
92 //
93 // This SMBIOS record is invalid, if the length of protocol specific data for
94 // Redfish Over IP protocol is wrong.
95 //
96 if ((*(RecordTmp + 90) + sizeof (REDFISH_OVER_IP_PROTOCOL_DATA) - 1) != ProtocolLength) {
97 return EFI_SECURITY_VIOLATION;
98 }
99
100 Offset += ProtocolLength;
101 //
102 // This SMBIOS record is invalid, if the length is smaller than the offset.
103 //
104 if (Offset > mType42Record->Hdr.Length) {
105 return EFI_SECURITY_VIOLATION;
106 }
107 *ProtocolData = (REDFISH_OVER_IP_PROTOCOL_DATA *)RecordTmp;
108 return EFI_SUCCESS;
109 }
110 }
111 }
112 }
113 Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
114 }
115
116 *ProtocolData = NULL;
117 return EFI_NOT_FOUND;
118}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette