]> git.proxmox.com Git - mirror_edk2.git/blob - Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscPortInternalConnectorDesignatorFunction.c
Vlv2TbltDevicePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / Vlv2TbltDevicePkg / SmBiosMiscDxe / MiscPortInternalConnectorDesignatorFunction.c
1 /** @file
2
3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
4
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7
8
9
10 Module Name:
11
12 MiscPortInternalConnectorDesignatorFunction.c
13
14 Abstract:
15
16 Create the device path for the Port internal connector designator.
17 Port internal connector designator information is Misc. subclass type 6
18 and SMBIOS type 8.
19
20
21 **/
22
23
24 #include "CommonHeader.h"
25
26 #include "MiscSubclassDriver.h"
27
28
29 /**
30 This is a macro defined function, in fact, the function is
31 MiscPortInternalConnectorDesignatorFunction (RecordType, RecordLen, RecordData, LogRecordData)
32 This function makes boot time changes to the contents of the
33 MiscPortConnectorInformation.
34
35 @param MiscPortInternalConnectorDesignator The string which is used to create
36 the function
37 The Arguments in fact:
38 @param RecordType Type of record to be processed from
39 the Data Table.
40 mMiscSubclassDataTable[].RecordType
41 @param RecordLen Size of static RecordData from the
42 Data Table.
43 mMiscSubclassDataTable[].RecordLen
44 @param RecordData Pointer to RecordData, which will be
45 written to the Data Hub
46 @param LogRecordData TRUE to log RecordData to Data Hub.
47 FALSE when there is no more data to
48 log.
49
50 @retval EFI_SUCCESS *RecordData and *LogRecordData have
51 been set.
52 @retval EFI_UNSUPPORTED Unexpected RecordType value.
53 @retval EFI_INVALID_PARAMETER One of the following parameter
54 conditions was true: RecordLen was
55 zero. RecordData was NULL.
56 LogRecordData was NULL.
57
58 **/
59 MISC_SMBIOS_TABLE_FUNCTION (
60 MiscPortInternalConnectorDesignator
61 )
62 {
63 CHAR8 *OptionalStrStart;
64 UINTN InternalRefStrLen;
65 UINTN ExternalRefStrLen;
66 EFI_STRING InternalRef;
67 EFI_STRING ExternalRef;
68 STRING_REF TokenForInternal;
69 STRING_REF TokenForExternal;
70 EFI_STATUS Status;
71 SMBIOS_TABLE_TYPE8 *SmbiosRecord;
72 EFI_SMBIOS_HANDLE SmbiosHandle;
73 EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR *ForType8InputData;
74
75 ForType8InputData = (EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR *)RecordData;
76
77 //
78 // First check for invalid parameters.
79 //
80 if (RecordData == NULL) {
81 return EFI_INVALID_PARAMETER;
82 }
83
84 TokenForInternal = 0;
85 TokenForExternal = 0;
86
87 switch (ForType8InputData->PortInternalConnectorDesignator) {
88
89 case STR_MISC_PORT_INTERNAL_IDE1:
90 TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_IDE1);
91 TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_IDE1);
92 break;
93 case STR_MISC_PORT_INTERNAL_IDE2:
94 TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_IDE2);
95 TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_IDE2);
96 break;
97 case STR_MISC_PORT_INTERNAL_ATX_POWER:
98 TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_ATX_POWER);
99 TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_ATX_POWER);
100 break;
101 default:
102 break;
103 }
104
105 InternalRef = SmbiosMiscGetString (TokenForInternal);
106 InternalRefStrLen = StrLen(InternalRef);
107 if (InternalRefStrLen > SMBIOS_STRING_MAX_LENGTH) {
108 return EFI_UNSUPPORTED;
109 }
110
111 ExternalRef = SmbiosMiscGetString (TokenForExternal);
112 ExternalRefStrLen = StrLen(ExternalRef);
113 if (ExternalRefStrLen > SMBIOS_STRING_MAX_LENGTH) {
114 return EFI_UNSUPPORTED;
115 }
116
117 //
118 // Two zeros following the last string.
119 //
120 SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE8) + InternalRefStrLen + 1 + ExternalRefStrLen + 1 + 1);
121 ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE8) + InternalRefStrLen + 1 + ExternalRefStrLen + 1 + 1);
122
123 SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_PORT_CONNECTOR_INFORMATION;
124 SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE8);
125
126 //
127 // Make handle chosen by smbios protocol.add automatically.
128 //
129 SmbiosRecord->Hdr.Handle = 0;
130 SmbiosRecord->InternalReferenceDesignator = 1;
131 SmbiosRecord->InternalConnectorType = (UINT8)ForType8InputData->PortInternalConnectorType;
132 SmbiosRecord->ExternalReferenceDesignator = 2;
133 SmbiosRecord->ExternalConnectorType = (UINT8)ForType8InputData->PortExternalConnectorType;
134 SmbiosRecord->PortType = (UINT8)ForType8InputData->PortType;
135
136 OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
137 UnicodeStrToAsciiStr(InternalRef, OptionalStrStart);
138 UnicodeStrToAsciiStr(ExternalRef, OptionalStrStart + InternalRefStrLen + 1);
139
140 //
141 // Now we have got the full smbios record, call smbios protocol to add this record.
142 //
143 SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
144 Status = Smbios-> Add(
145 Smbios,
146 NULL,
147 &SmbiosHandle,
148 (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord
149 );
150 FreePool(SmbiosRecord);
151 return Status;
152 }