3 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
4 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
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.
14 MiscPortInternalConnectorDesignatorFunction.c
18 This driver parses the mMiscSubclassDataTable structure and reports
19 any generated data to the DataHub.
23 #include "MiscSubclassDriver.h"
26 MISC_SMBIOS_TABLE_FUNCTION (
27 MiscPortInternalConnectorDesignator
32 This function makes boot time changes to the contents of the
33 MiscPortConnectorInformation (Type 8).
38 Type of record to be processed from the Data Table.
39 mMiscSubclassDataTable[].RecordType
42 Size of static RecordData from the Data Table.
43 mMiscSubclassDataTable[].RecordLen
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.
51 Set *LogRecordData to TRUE to log RecordData to Data Hub.
52 Set *LogRecordData to FALSE when there is no more data to log.
57 All parameters were valid and *RecordData and *LogRecordData have
61 Unexpected RecordType value.
64 One of the following parameter conditions was true:
67 LogRecordData was NULL.
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
;
78 SMBIOS_TABLE_TYPE8
*SmbiosRecord
;
79 EFI_SMBIOS_HANDLE SmbiosHandle
;
80 EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR
*ForType8InputData
;
82 ForType8InputData
= (EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR
*)RecordData
;
84 // First check for invalid parameters.
86 if (RecordData
== NULL
) {
87 return EFI_INVALID_PARAMETER
;
93 switch (ForType8InputData
->PortInternalConnectorDesignator
) {
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
);
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
);
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
);
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
);
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
);
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
);
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
);
127 InternalRef
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenForInternal
, NULL
);
128 InternalRefStrLen
= StrLen(InternalRef
);
129 if (InternalRefStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
130 return EFI_UNSUPPORTED
;
133 ExternalRef
= HiiGetPackageString(&gEfiCallerIdGuid
, TokenForExternal
, NULL
);
134 ExternalRefStrLen
= StrLen(ExternalRef
);
135 if (ExternalRefStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
136 return EFI_UNSUPPORTED
;
140 // Two zeros following the last string.
142 SmbiosRecord
= AllocatePool(sizeof (SMBIOS_TABLE_TYPE8
) + InternalRefStrLen
+ 1 + ExternalRefStrLen
+ 1 + 1);
143 ZeroMem(SmbiosRecord
, sizeof (SMBIOS_TABLE_TYPE8
) + InternalRefStrLen
+ 1 + ExternalRefStrLen
+ 1 + 1);
145 SmbiosRecord
->Hdr
.Type
= EFI_SMBIOS_TYPE_PORT_CONNECTOR_INFORMATION
;
146 SmbiosRecord
->Hdr
.Length
= sizeof (SMBIOS_TABLE_TYPE8
);
148 // Make handle chosen by smbios protocol.add automatically.
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
;
157 OptionalStrStart
= (CHAR8
*)(SmbiosRecord
+ 1);
158 UnicodeStrToAsciiStr(InternalRef
, OptionalStrStart
);
159 UnicodeStrToAsciiStr(ExternalRef
, OptionalStrStart
+ InternalRefStrLen
+ 1);
162 // Now we have got the full smbios record, call smbios protocol to add this record.
164 Status
= AddSmbiosRecord (Smbios
, &SmbiosHandle
, (EFI_SMBIOS_TABLE_HEADER
*) SmbiosRecord
);
166 FreePool(SmbiosRecord
);
172 /* eof - MiscSystemManufacturerFunction.c */