3 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
8 MiscPortInternalConnectorDesignatorFunction.c
12 This driver parses the mMiscSubclassDataTable structure and reports
13 any generated data to the DataHub.
17 #include "MiscSubClassDriver.h"
20 MISC_SMBIOS_TABLE_FUNCTION (
21 MiscPortInternalConnectorDesignator
26 This function makes boot time changes to the contents of the
27 MiscPortConnectorInformation (Type 8).
32 Type of record to be processed from the Data Table.
33 mMiscSubclassDataTable[].RecordType
36 Size of static RecordData from the Data Table.
37 mMiscSubclassDataTable[].RecordLen
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.
45 Set *LogRecordData to TRUE to log RecordData to Data Hub.
46 Set *LogRecordData to FALSE when there is no more data to log.
51 All parameters were valid and *RecordData and *LogRecordData have
55 Unexpected RecordType value.
58 One of the following parameter conditions was true:
61 LogRecordData was NULL.
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
;
72 SMBIOS_TABLE_TYPE8
*SmbiosRecord
;
73 EFI_SMBIOS_HANDLE SmbiosHandle
;
74 EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR
*ForType8InputData
;
76 ForType8InputData
= (EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR
*)RecordData
;
78 // First check for invalid parameters.
80 if (RecordData
== NULL
) {
81 return EFI_INVALID_PARAMETER
;
87 switch (ForType8InputData
->PortInternalConnectorDesignator
) {
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
);
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
);
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
);
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
);
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
);
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
);
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
);
121 InternalRef
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenForInternal
, NULL
);
122 InternalRefStrLen
= StrLen(InternalRef
);
123 if (InternalRefStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
124 return EFI_UNSUPPORTED
;
127 ExternalRef
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenForExternal
, NULL
);
128 ExternalRefStrLen
= StrLen(ExternalRef
);
129 if (ExternalRefStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
130 return EFI_UNSUPPORTED
;
134 // Two zeros following the last string.
136 SmbiosRecord
= AllocatePool(sizeof (SMBIOS_TABLE_TYPE8
) + InternalRefStrLen
+ 1 + ExternalRefStrLen
+ 1 + 1);
137 ZeroMem(SmbiosRecord
, sizeof (SMBIOS_TABLE_TYPE8
) + InternalRefStrLen
+ 1 + ExternalRefStrLen
+ 1 + 1);
139 SmbiosRecord
->Hdr
.Type
= EFI_SMBIOS_TYPE_PORT_CONNECTOR_INFORMATION
;
140 SmbiosRecord
->Hdr
.Length
= sizeof (SMBIOS_TABLE_TYPE8
);
142 // Make handle chosen by smbios protocol.add automatically.
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
;
151 OptionalStrStart
= (CHAR8
*)(SmbiosRecord
+ 1);
152 UnicodeStrToAsciiStr(InternalRef
, OptionalStrStart
);
153 UnicodeStrToAsciiStr(ExternalRef
, OptionalStrStart
+ InternalRefStrLen
+ 1);
156 // Now we have got the full smbios record, call smbios protocol to add this record.
158 Status
= AddSmbiosRecord (Smbios
, &SmbiosHandle
, (EFI_SMBIOS_TABLE_HEADER
*) SmbiosRecord
);
160 FreePool(SmbiosRecord
);
166 /* eof - MiscSystemManufacturerFunction.c */