3 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 MiscPortInternalConnectorDesignatorFunction.c
21 Create the device path for the Port internal connector designator.
22 Port internal connector designator information is Misc. subclass type 6
29 #include "CommonHeader.h"
31 #include "MiscSubclassDriver.h"
35 This is a macro defined function, in fact, the function is
36 MiscPortInternalConnectorDesignatorFunction (RecordType, RecordLen, RecordData, LogRecordData)
37 This function makes boot time changes to the contents of the
38 MiscPortConnectorInformation.
40 @param MiscPortInternalConnectorDesignator The string which is used to create
42 The Arguments in fact:
43 @param RecordType Type of record to be processed from
45 mMiscSubclassDataTable[].RecordType
46 @param RecordLen Size of static RecordData from the
48 mMiscSubclassDataTable[].RecordLen
49 @param RecordData Pointer to RecordData, which will be
50 written to the Data Hub
51 @param LogRecordData TRUE to log RecordData to Data Hub.
52 FALSE when there is no more data to
55 @retval EFI_SUCCESS *RecordData and *LogRecordData have
57 @retval EFI_UNSUPPORTED Unexpected RecordType value.
58 @retval EFI_INVALID_PARAMETER One of the following parameter
59 conditions was true: RecordLen was
60 zero. RecordData was NULL.
61 LogRecordData was NULL.
64 MISC_SMBIOS_TABLE_FUNCTION (
65 MiscPortInternalConnectorDesignator
68 CHAR8
*OptionalStrStart
;
69 UINTN InternalRefStrLen
;
70 UINTN ExternalRefStrLen
;
71 EFI_STRING InternalRef
;
72 EFI_STRING ExternalRef
;
73 STRING_REF TokenForInternal
;
74 STRING_REF TokenForExternal
;
76 SMBIOS_TABLE_TYPE8
*SmbiosRecord
;
77 EFI_SMBIOS_HANDLE SmbiosHandle
;
78 EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR
*ForType8InputData
;
80 ForType8InputData
= (EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR
*)RecordData
;
83 // First check for invalid parameters.
85 if (RecordData
== NULL
) {
86 return EFI_INVALID_PARAMETER
;
92 switch (ForType8InputData
->PortInternalConnectorDesignator
) {
94 case STR_MISC_PORT_INTERNAL_IDE1
:
95 TokenForInternal
= STRING_TOKEN (STR_MISC_PORT_INTERNAL_IDE1
);
96 TokenForExternal
= STRING_TOKEN(STR_MISC_PORT_EXTERNAL_IDE1
);
98 case STR_MISC_PORT_INTERNAL_IDE2
:
99 TokenForInternal
= STRING_TOKEN (STR_MISC_PORT_INTERNAL_IDE2
);
100 TokenForExternal
= STRING_TOKEN(STR_MISC_PORT_EXTERNAL_IDE2
);
102 case STR_MISC_PORT_INTERNAL_ATX_POWER
:
103 TokenForInternal
= STRING_TOKEN (STR_MISC_PORT_INTERNAL_ATX_POWER
);
104 TokenForExternal
= STRING_TOKEN(STR_MISC_PORT_EXTERNAL_ATX_POWER
);
110 InternalRef
= SmbiosMiscGetString (TokenForInternal
);
111 InternalRefStrLen
= StrLen(InternalRef
);
112 if (InternalRefStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
113 return EFI_UNSUPPORTED
;
116 ExternalRef
= SmbiosMiscGetString (TokenForExternal
);
117 ExternalRefStrLen
= StrLen(ExternalRef
);
118 if (ExternalRefStrLen
> SMBIOS_STRING_MAX_LENGTH
) {
119 return EFI_UNSUPPORTED
;
123 // Two zeros following the last string.
125 SmbiosRecord
= AllocatePool(sizeof (SMBIOS_TABLE_TYPE8
) + InternalRefStrLen
+ 1 + ExternalRefStrLen
+ 1 + 1);
126 ZeroMem(SmbiosRecord
, sizeof (SMBIOS_TABLE_TYPE8
) + InternalRefStrLen
+ 1 + ExternalRefStrLen
+ 1 + 1);
128 SmbiosRecord
->Hdr
.Type
= EFI_SMBIOS_TYPE_PORT_CONNECTOR_INFORMATION
;
129 SmbiosRecord
->Hdr
.Length
= sizeof (SMBIOS_TABLE_TYPE8
);
132 // Make handle chosen by smbios protocol.add automatically.
134 SmbiosRecord
->Hdr
.Handle
= 0;
135 SmbiosRecord
->InternalReferenceDesignator
= 1;
136 SmbiosRecord
->InternalConnectorType
= (UINT8
)ForType8InputData
->PortInternalConnectorType
;
137 SmbiosRecord
->ExternalReferenceDesignator
= 2;
138 SmbiosRecord
->ExternalConnectorType
= (UINT8
)ForType8InputData
->PortExternalConnectorType
;
139 SmbiosRecord
->PortType
= (UINT8
)ForType8InputData
->PortType
;
141 OptionalStrStart
= (CHAR8
*)(SmbiosRecord
+ 1);
142 UnicodeStrToAsciiStr(InternalRef
, OptionalStrStart
);
143 UnicodeStrToAsciiStr(ExternalRef
, OptionalStrStart
+ InternalRefStrLen
+ 1);
146 // Now we have got the full smbios record, call smbios protocol to add this record.
148 SmbiosHandle
= SMBIOS_HANDLE_PI_RESERVED
;
149 Status
= Smbios
-> Add(
153 (EFI_SMBIOS_TABLE_HEADER
*) SmbiosRecord
155 FreePool(SmbiosRecord
);