]> git.proxmox.com Git - mirror_edk2.git/blob - UnixPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorFunction.c
1. PI SMBIOS Checkin. Major change include:
[mirror_edk2.git] / UnixPkg / MiscSubClassPlatformDxe / MiscPortInternalConnectorDesignatorFunction.c
1 /*++
2
3 Copyright (c) 2006 - 2009, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 MiscPortInternalConnectorDesignatorFunction.c
15
16 Abstract:
17
18 This driver parses the mMiscSubclassDataTable structure and reports
19 any generated data to the DataHub.
20
21 --*/
22
23 #include "MiscSubClassDriver.h"
24
25
26 MISC_SMBIOS_TABLE_FUNCTION (
27 MiscPortInternalConnectorDesignator
28 )
29 /*++
30 Description:
31
32 This function makes boot time changes to the contents of the
33 MiscPortConnectorInformation (Type 8).
34
35 Parameters:
36
37 RecordType
38 Type of record to be processed from the Data Table.
39 mMiscSubclassDataTable[].RecordType
40
41 RecordLen
42 Size of static RecordData from the Data Table.
43 mMiscSubclassDataTable[].RecordLen
44
45 RecordData
46 Pointer to copy of RecordData from the Data Table. Changes made
47 to this copy will be written to the Data Hub but will not alter
48 the contents of the static Data Table.
49
50 LogRecordData
51 Set *LogRecordData to TRUE to log RecordData to Data Hub.
52 Set *LogRecordData to FALSE when there is no more data to log.
53
54 Returns:
55
56 EFI_SUCCESS
57 All parameters were valid and *RecordData and *LogRecordData have
58 been set.
59
60 EFI_UNSUPPORTED
61 Unexpected RecordType value.
62
63 EFI_INVALID_PARAMETER
64 One of the following parameter conditions was true:
65 RecordLen was zero.
66 RecordData was NULL.
67 LogRecordData was NULL.
68 --*/
69 {
70 CHAR8 *OptionalStrStart;
71 UINTN InternalRefStrLen;
72 UINTN ExternalRefStrLen;
73 EFI_STRING InternalRef;
74 EFI_STRING ExternalRef;
75 STRING_REF TokenForInternal;
76 STRING_REF TokenForExternal;
77 EFI_STATUS Status;
78 SMBIOS_TABLE_TYPE8 *SmbiosRecord;
79 EFI_SMBIOS_HANDLE SmbiosHandle;
80 EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR *ForType8InputData;
81
82 ForType8InputData = (EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR *)RecordData;
83 //
84 // First check for invalid parameters.
85 //
86 if (RecordData == NULL) {
87 return EFI_INVALID_PARAMETER;
88 }
89
90 TokenForInternal = 0;
91 TokenForExternal = 0;
92
93 switch (ForType8InputData->PortInternalConnectorDesignator) {
94
95 case STR_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR:
96 TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR);
97 TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_CONNECTOR_DESIGNATOR);
98 break;
99 case STR_MISC_PORT_INTERNAL_KEYBOARD:
100 TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_KEYBOARD);
101 TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_KEYBOARD);
102 break;
103 case STR_MISC_PORT_INTERNAL_MOUSE:
104 TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_MOUSE);
105 TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_MOUSE);
106 break;
107 case STR_MISC_PORT_INTERNAL_COM1:
108 TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_COM1);
109 TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_COM1);
110 break;
111 case STR_MISC_PORT_INTERNAL_COM2:
112 TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_COM2);
113 TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_COM2);
114 break;
115 case STR_MISC_PORT_INTERNAL_EXTENSION_POWER:
116 TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_EXTENSION_POWER);
117 TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_EXTENSION_POWER);
118 break;
119 case STR_MISC_PORT_INTERNAL_FLOPPY:
120 TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_FLOPPY);
121 TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_FLOPPY);
122 break;
123 default:
124 break;
125 }
126
127 InternalRef = HiiGetPackageString(&gEfiCallerIdGuid, TokenForInternal, NULL);
128 InternalRefStrLen = StrLen(InternalRef);
129 if (InternalRefStrLen > SMBIOS_STRING_MAX_LENGTH) {
130 return EFI_UNSUPPORTED;
131 }
132
133 ExternalRef = HiiGetPackageString(&gEfiCallerIdGuid, TokenForExternal, NULL);
134 ExternalRefStrLen = StrLen(ExternalRef);
135 if (ExternalRefStrLen > SMBIOS_STRING_MAX_LENGTH) {
136 return EFI_UNSUPPORTED;
137 }
138
139 //
140 // Two zeros following the last string.
141 //
142 SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE8) + InternalRefStrLen + 1 + ExternalRefStrLen + 1 + 1);
143 ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE8) + InternalRefStrLen + 1 + ExternalRefStrLen + 1 + 1);
144
145 SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_PORT_CONNECTOR_INFORMATION;
146 SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE8);
147 //
148 // Make handle chosen by smbios protocol.add automatically.
149 //
150 SmbiosRecord->Hdr.Handle = 0;
151 SmbiosRecord->InternalReferenceDesignator = 1;
152 SmbiosRecord->InternalConnectorType = (UINT8)ForType8InputData->PortInternalConnectorType;
153 SmbiosRecord->ExternalReferenceDesignator = 2;
154 SmbiosRecord->ExternalConnectorType = (UINT8)ForType8InputData->PortExternalConnectorType;
155 SmbiosRecord->PortType = (UINT8)ForType8InputData->PortType;
156
157 OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
158 UnicodeStrToAsciiStr(InternalRef, OptionalStrStart);
159 UnicodeStrToAsciiStr(ExternalRef, OptionalStrStart + InternalRefStrLen + 1);
160
161 //
162 // Now we have got the full smbios record, call smbios protocol to add this record.
163 //
164 SmbiosHandle = 0;
165 Status = Smbios-> Add(
166 Smbios,
167 NULL,
168 &SmbiosHandle,
169 (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord
170 );
171 FreePool(SmbiosRecord);
172 return Status;
173 }
174
175
176
177 /* eof - MiscSystemManufacturerFunction.c */