VirtualBox

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

最後變更 在這個檔案從105668是 101291,由 vboxsync 提交於 18 月 前

EFI/FirmwareNew: Make edk2-stable202308 build on all supported platforms (using gcc at least, msvc not tested yet), bugref:4643

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

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