3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
12 MiscPortInternalConnectorDesignatorFunction.c
16 Create the device path for the Port internal connector designator.
17 Port internal connector designator information is Misc. subclass type 6
24 #include "CommonHeader.h"
26 #include "MiscSubclassDriver.h"
30 This is a macro defined function, in fact, the function is
31 MiscPortInternalConnectorDesignatorFunction (RecordType, RecordLen, RecordData, LogRecordData)
32 This function makes boot time changes to the contents of the
33 MiscPortConnectorInformation.
35 @param MiscPortInternalConnectorDesignator The string which is used to create
37 The Arguments in fact:
38 @param RecordType Type of record to be processed from
40 mMiscSubclassDataTable[].RecordType
41 @param RecordLen Size of static RecordData from the
43 mMiscSubclassDataTable[].RecordLen
44 @param RecordData Pointer to RecordData, which will be
45 written to the Data Hub
46 @param LogRecordData TRUE to log RecordData to Data Hub.
47 FALSE when there is no more data to
50 @retval EFI_SUCCESS *RecordData and *LogRecordData have
52 @retval EFI_UNSUPPORTED Unexpected RecordType value.
53 @retval EFI_INVALID_PARAMETER One of the following parameter
54 conditions was true: RecordLen was
55 zero. RecordData was NULL.
56 LogRecordData was NULL.
59 MISC_SMBIOS_TABLE_FUNCTION (
60 MiscPortInternalConnectorDesignator
63 CHAR8
*OptionalStrStart
;
64 UINTN InternalRefStrLen
;
65 UINTN ExternalRefStrLen
;
66 EFI_STRING InternalRef
;
67 EFI_STRING ExternalRef
;
68 STRING_REF TokenForInternal
;
69 STRING_REF TokenForExternal
;
71 SMBIOS_TABLE_TYPE8
*SmbiosRecord
;
72 EFI_SMBIOS_HANDLE SmbiosHandle
;
73 EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR
*ForType8InputData
;
75 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_IDE1
:
90 TokenForInternal
= STRING_TOKEN (STR_MISC_PORT_INTERNAL_IDE1
);
91 TokenForExternal
= STRING_TOKEN(STR_MISC_PORT_EXTERNAL_IDE1
);
93 case STR_MISC_PORT_INTERNAL_IDE2
:
94 TokenForInternal
= STRING_TOKEN (STR_MISC_PORT_INTERNAL_IDE2
);
95 TokenForExternal
= STRING_TOKEN(STR_MISC_PORT_EXTERNAL_IDE2
);
97 case STR_MISC_PORT_INTERNAL_ATX_POWER
:
98 TokenForInternal
= STRING_TOKEN (STR_MISC_PORT_INTERNAL_ATX_POWER
);
99 TokenForExternal
= STRING_TOKEN(STR_MISC_PORT_EXTERNAL_ATX_POWER
);
105 InternalRef
= SmbiosMiscGetString (TokenForInternal
);
106 InternalRefStrLen
= StrLen(InternalRef
);
107 if (InternalRefStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
108 return EFI_UNSUPPORTED
;
111 ExternalRef
= SmbiosMiscGetString (TokenForExternal
);
112 ExternalRefStrLen
= StrLen(ExternalRef
);
113 if (ExternalRefStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
114 return EFI_UNSUPPORTED
;
118 // Two zeros following the last string.
120 SmbiosRecord
= AllocatePool(sizeof (SMBIOS_TABLE_TYPE8
) + InternalRefStrLen
+ 1 + ExternalRefStrLen
+ 1 + 1);
121 ZeroMem(SmbiosRecord
, sizeof (SMBIOS_TABLE_TYPE8
) + InternalRefStrLen
+ 1 + ExternalRefStrLen
+ 1 + 1);
123 SmbiosRecord
->Hdr
.Type
= EFI_SMBIOS_TYPE_PORT_CONNECTOR_INFORMATION
;
124 SmbiosRecord
->Hdr
.Length
= sizeof (SMBIOS_TABLE_TYPE8
);
127 // Make handle chosen by smbios protocol.add automatically.
129 SmbiosRecord
->Hdr
.Handle
= 0;
130 SmbiosRecord
->InternalReferenceDesignator
= 1;
131 SmbiosRecord
->InternalConnectorType
= (UINT8
)ForType8InputData
->PortInternalConnectorType
;
132 SmbiosRecord
->ExternalReferenceDesignator
= 2;
133 SmbiosRecord
->ExternalConnectorType
= (UINT8
)ForType8InputData
->PortExternalConnectorType
;
134 SmbiosRecord
->PortType
= (UINT8
)ForType8InputData
->PortType
;
136 OptionalStrStart
= (CHAR8
*)(SmbiosRecord
+ 1);
137 UnicodeStrToAsciiStr(InternalRef
, OptionalStrStart
);
138 UnicodeStrToAsciiStr(ExternalRef
, OptionalStrStart
+ InternalRefStrLen
+ 1);
141 // Now we have got the full smbios record, call smbios protocol to add this record.
143 SmbiosHandle
= SMBIOS_HANDLE_PI_RESERVED
;
144 Status
= Smbios
-> Add(
148 (EFI_SMBIOS_TABLE_HEADER
*) SmbiosRecord
150 FreePool(SmbiosRecord
);