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