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