]> git.proxmox.com Git - mirror_edk2.git/blob - Nt32Pkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorFunction.c
Nt32Pkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / Nt32Pkg / MiscSubClassPlatformDxe / MiscPortInternalConnectorDesignatorFunction.c
1 /**@file
2
3 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
5
6 Module Name:
7
8 MiscPortInternalConnectorDesignatorFunction.c
9
10 Abstract:
11
12 This driver parses the mMiscSubclassDataTable structure and reports
13 any generated data to the DataHub.
14
15 **/
16
17 #include "MiscSubclassDriver.h"
18
19
20 MISC_SMBIOS_TABLE_FUNCTION (
21 MiscPortInternalConnectorDesignator
22 )
23 /*++
24 Description:
25
26 This function makes boot time changes to the contents of the
27 MiscPortConnectorInformation (Type 8).
28
29 Parameters:
30
31 RecordType
32 Type of record to be processed from the Data Table.
33 mMiscSubclassDataTable[].RecordType
34
35 RecordLen
36 Size of static RecordData from the Data Table.
37 mMiscSubclassDataTable[].RecordLen
38
39 RecordData
40 Pointer to copy of RecordData from the Data Table. Changes made
41 to this copy will be written to the Data Hub but will not alter
42 the contents of the static Data Table.
43
44 LogRecordData
45 Set *LogRecordData to TRUE to log RecordData to Data Hub.
46 Set *LogRecordData to FALSE when there is no more data to log.
47
48 Returns:
49
50 EFI_SUCCESS
51 All parameters were valid and *RecordData and *LogRecordData have
52 been set.
53
54 EFI_UNSUPPORTED
55 Unexpected RecordType value.
56
57 EFI_INVALID_PARAMETER
58 One of the following parameter conditions was true:
59 RecordLen was zero.
60 RecordData was NULL.
61 LogRecordData was NULL.
62 --*/
63 {
64 CHAR8 *OptionalStrStart;
65 UINTN InternalRefStrLen;
66 UINTN ExternalRefStrLen;
67 EFI_STRING InternalRef;
68 EFI_STRING ExternalRef;
69 STRING_REF TokenForInternal;
70 STRING_REF TokenForExternal;
71 EFI_STATUS Status;
72 SMBIOS_TABLE_TYPE8 *SmbiosRecord;
73 EFI_SMBIOS_HANDLE SmbiosHandle;
74 EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR *ForType8InputData;
75
76 ForType8InputData = (EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR *)RecordData;
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_CONNECTOR_DESIGNATOR:
90 TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR);
91 TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_CONNECTOR_DESIGNATOR);
92 break;
93 case STR_MISC_PORT_INTERNAL_KEYBOARD:
94 TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_KEYBOARD);
95 TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_KEYBOARD);
96 break;
97 case STR_MISC_PORT_INTERNAL_MOUSE:
98 TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_MOUSE);
99 TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_MOUSE);
100 break;
101 case STR_MISC_PORT_INTERNAL_COM1:
102 TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_COM1);
103 TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_COM1);
104 break;
105 case STR_MISC_PORT_INTERNAL_COM2:
106 TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_COM2);
107 TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_COM2);
108 break;
109 case STR_MISC_PORT_INTERNAL_EXTENSION_POWER:
110 TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_EXTENSION_POWER);
111 TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_EXTENSION_POWER);
112 break;
113 case STR_MISC_PORT_INTERNAL_FLOPPY:
114 TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_FLOPPY);
115 TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_FLOPPY);
116 break;
117 default:
118 break;
119 }
120
121 InternalRef = HiiGetPackageString(&gEfiCallerIdGuid, TokenForInternal, NULL);
122 InternalRefStrLen = StrLen(InternalRef);
123 if (InternalRefStrLen > SMBIOS_STRING_MAX_LENGTH) {
124 return EFI_UNSUPPORTED;
125 }
126
127 ExternalRef = HiiGetPackageString(&gEfiCallerIdGuid, TokenForExternal, NULL);
128 ExternalRefStrLen = StrLen(ExternalRef);
129 if (ExternalRefStrLen > SMBIOS_STRING_MAX_LENGTH) {
130 return EFI_UNSUPPORTED;
131 }
132
133 //
134 // Two zeros following the last string.
135 //
136 SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE8) + InternalRefStrLen + 1 + ExternalRefStrLen + 1 + 1);
137 ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE8) + InternalRefStrLen + 1 + ExternalRefStrLen + 1 + 1);
138
139 SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_PORT_CONNECTOR_INFORMATION;
140 SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE8);
141 //
142 // Make handle chosen by smbios protocol.add automatically.
143 //
144 SmbiosRecord->Hdr.Handle = 0;
145 SmbiosRecord->InternalReferenceDesignator = 1;
146 SmbiosRecord->InternalConnectorType = (UINT8)ForType8InputData->PortInternalConnectorType;
147 SmbiosRecord->ExternalReferenceDesignator = 2;
148 SmbiosRecord->ExternalConnectorType = (UINT8)ForType8InputData->PortExternalConnectorType;
149 SmbiosRecord->PortType = (UINT8)ForType8InputData->PortType;
150
151 OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
152 UnicodeStrToAsciiStr(InternalRef, OptionalStrStart);
153 UnicodeStrToAsciiStr(ExternalRef, OptionalStrStart + InternalRefStrLen + 1);
154
155 //
156 // Now we have got the full smbios record, call smbios protocol to add this record.
157 //
158 Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord);
159
160 FreePool(SmbiosRecord);
161 return Status;
162 }
163
164
165
166 /* eof - MiscSystemManufacturerFunction.c */