]>
Commit | Line | Data |
---|---|---|
3cbfba02 DW |
1 | /** @file\r |
2 | \r | |
3 | Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r | |
4 | \r\r | |
5 | This program and the accompanying materials are licensed and made available under\r\r | |
6 | the terms and conditions of the BSD License that accompanies this distribution. \r\r | |
7 | The full text of the license may be found at \r\r | |
8 | http://opensource.org/licenses/bsd-license.php. \r\r | |
9 | \r\r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r\r | |
12 | \r\r | |
13 | \r | |
14 | \r | |
15 | Module Name:\r | |
16 | \r | |
17 | MiscPortInternalConnectorDesignatorFunction.c\r | |
18 | \r | |
19 | Abstract:\r | |
20 | \r | |
21 | Create the device path for the Port internal connector designator.\r | |
22 | Port internal connector designator information is Misc. subclass type 6\r | |
23 | and SMBIOS type 8.\r | |
24 | \r | |
25 | \r | |
26 | **/\r | |
27 | \r | |
28 | \r | |
29 | #include "CommonHeader.h"\r | |
30 | \r | |
31 | #include "MiscSubclassDriver.h"\r | |
32 | \r | |
33 | \r | |
34 | /**\r | |
35 | This is a macro defined function, in fact, the function is\r | |
36 | MiscPortInternalConnectorDesignatorFunction (RecordType, RecordLen, RecordData, LogRecordData)\r | |
37 | This function makes boot time changes to the contents of the\r | |
38 | MiscPortConnectorInformation.\r | |
39 | \r | |
40 | @param MiscPortInternalConnectorDesignator The string which is used to create\r | |
41 | the function\r | |
42 | The Arguments in fact:\r | |
43 | @param RecordType Type of record to be processed from\r | |
44 | the Data Table.\r | |
45 | mMiscSubclassDataTable[].RecordType\r | |
46 | @param RecordLen Size of static RecordData from the\r | |
47 | Data Table.\r | |
48 | mMiscSubclassDataTable[].RecordLen\r | |
49 | @param RecordData Pointer to RecordData, which will be\r | |
50 | written to the Data Hub\r | |
51 | @param LogRecordData TRUE to log RecordData to Data Hub.\r | |
52 | FALSE when there is no more data to\r | |
53 | log.\r | |
54 | \r | |
55 | @retval EFI_SUCCESS *RecordData and *LogRecordData have\r | |
56 | been set.\r | |
57 | @retval EFI_UNSUPPORTED Unexpected RecordType value.\r | |
58 | @retval EFI_INVALID_PARAMETER One of the following parameter\r | |
59 | conditions was true: RecordLen was\r | |
60 | zero. RecordData was NULL.\r | |
61 | LogRecordData was NULL.\r | |
62 | \r | |
63 | **/\r | |
64 | MISC_SMBIOS_TABLE_FUNCTION (\r | |
65 | MiscPortInternalConnectorDesignator\r | |
66 | )\r | |
67 | {\r | |
68 | CHAR8 *OptionalStrStart;\r | |
69 | UINTN InternalRefStrLen;\r | |
70 | UINTN ExternalRefStrLen;\r | |
71 | EFI_STRING InternalRef;\r | |
72 | EFI_STRING ExternalRef;\r | |
73 | STRING_REF TokenForInternal;\r | |
74 | STRING_REF TokenForExternal;\r | |
75 | EFI_STATUS Status;\r | |
76 | SMBIOS_TABLE_TYPE8 *SmbiosRecord;\r | |
77 | EFI_SMBIOS_HANDLE SmbiosHandle;\r | |
78 | EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR *ForType8InputData;\r | |
79 | \r | |
80 | ForType8InputData = (EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR *)RecordData;\r | |
81 | \r | |
82 | //\r | |
83 | // First check for invalid parameters.\r | |
84 | //\r | |
85 | if (RecordData == NULL) {\r | |
86 | return EFI_INVALID_PARAMETER;\r | |
87 | }\r | |
88 | \r | |
89 | TokenForInternal = 0;\r | |
90 | TokenForExternal = 0;\r | |
91 | \r | |
92 | switch (ForType8InputData->PortInternalConnectorDesignator) {\r | |
93 | \r | |
94 | case STR_MISC_PORT_INTERNAL_IDE1:\r | |
95 | TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_IDE1);\r | |
96 | TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_IDE1);\r | |
97 | break;\r | |
98 | case STR_MISC_PORT_INTERNAL_IDE2:\r | |
99 | TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_IDE2);\r | |
100 | TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_IDE2);\r | |
101 | break;\r | |
102 | case STR_MISC_PORT_INTERNAL_ATX_POWER:\r | |
103 | TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_ATX_POWER);\r | |
104 | TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_ATX_POWER);\r | |
105 | break;\r | |
106 | default:\r | |
107 | break;\r | |
108 | }\r | |
109 | \r | |
110 | InternalRef = SmbiosMiscGetString (TokenForInternal);\r | |
111 | InternalRefStrLen = StrLen(InternalRef);\r | |
112 | if (InternalRefStrLen > SMBIOS_STRING_MAX_LENGTH) {\r | |
113 | return EFI_UNSUPPORTED;\r | |
114 | }\r | |
115 | \r | |
116 | ExternalRef = SmbiosMiscGetString (TokenForExternal);\r | |
117 | ExternalRefStrLen = StrLen(ExternalRef);\r | |
118 | if (ExternalRefStrLen > SMBIOS_STRING_MAX_LENGTH) {\r | |
119 | return EFI_UNSUPPORTED;\r | |
120 | }\r | |
121 | \r | |
122 | //\r | |
123 | // Two zeros following the last string.\r | |
124 | //\r | |
125 | SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE8) + InternalRefStrLen + 1 + ExternalRefStrLen + 1 + 1);\r | |
126 | ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE8) + InternalRefStrLen + 1 + ExternalRefStrLen + 1 + 1);\r | |
127 | \r | |
128 | SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_PORT_CONNECTOR_INFORMATION;\r | |
129 | SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE8);\r | |
130 | \r | |
131 | //\r | |
132 | // Make handle chosen by smbios protocol.add automatically.\r | |
133 | //\r | |
134 | SmbiosRecord->Hdr.Handle = 0;\r | |
135 | SmbiosRecord->InternalReferenceDesignator = 1;\r | |
136 | SmbiosRecord->InternalConnectorType = (UINT8)ForType8InputData->PortInternalConnectorType;\r | |
137 | SmbiosRecord->ExternalReferenceDesignator = 2;\r | |
138 | SmbiosRecord->ExternalConnectorType = (UINT8)ForType8InputData->PortExternalConnectorType;\r | |
139 | SmbiosRecord->PortType = (UINT8)ForType8InputData->PortType;\r | |
140 | \r | |
141 | OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r | |
142 | UnicodeStrToAsciiStr(InternalRef, OptionalStrStart);\r | |
143 | UnicodeStrToAsciiStr(ExternalRef, OptionalStrStart + InternalRefStrLen + 1);\r | |
144 | \r | |
145 | //\r | |
146 | // Now we have got the full smbios record, call smbios protocol to add this record.\r | |
147 | //\r | |
148 | SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;\r | |
149 | Status = Smbios-> Add(\r | |
150 | Smbios,\r | |
151 | NULL,\r | |
152 | &SmbiosHandle,\r | |
153 | (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord\r | |
154 | );\r | |
155 | FreePool(SmbiosRecord);\r | |
156 | return Status;\r | |
157 | }\r |