]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Nt32Pkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorFunction.c
BaseTools/BinToPcd: Fix Python 2.7.x compatibility issue
[mirror_edk2.git] / Nt32Pkg / MiscSubClassPlatformDxe / MiscPortInternalConnectorDesignatorFunction.c
index d493ef0bc755a5f16d73e4ee5216cfeaadd2b6f6..1636abc4fa86402a4052341648ce80b2a0ab23a4 100644 (file)
@@ -1,7 +1,7 @@
-/*++\r
+/**@file\r
  \r
-Copyright (c) 2006, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 http://opensource.org/licenses/bsd-license.php                                            \r
@@ -18,19 +18,12 @@ Abstract:
   This driver parses the mMiscSubclassDataTable structure and reports\r
   any generated data to the DataHub.\r
 \r
---*/\r
-\r
-//\r
-// Include common header file for this module.\r
-//\r
-#include "CommonHeader.h"\r
+**/\r
 \r
 #include "MiscSubclassDriver.h"\r
 \r
-//\r
-//\r
-//\r
-MISC_SUBCLASS_TABLE_FUNCTION (\r
+\r
+MISC_SMBIOS_TABLE_FUNCTION (\r
   MiscPortInternalConnectorDesignator\r
   )\r
 /*++\r
@@ -74,198 +67,106 @@ Returns:
       LogRecordData was NULL.\r
 --*/\r
 {\r
-  STATIC BOOLEAN                    Done                    = FALSE;\r
-  STATIC PS2_CONN_DEVICE_PATH       mPs2KeyboardDevicePath  = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0303, 0), DP_END };\r
-  STATIC PS2_CONN_DEVICE_PATH       mPs2MouseDevicePath     = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0303, 1), DP_END };\r
-  STATIC SERIAL_CONN_DEVICE_PATH    mCom1DevicePath         = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0501, 0), DP_END };\r
-  STATIC SERIAL_CONN_DEVICE_PATH    mCom2DevicePath         = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0501, 1), DP_END };\r
-  STATIC PARALLEL_CONN_DEVICE_PATH  mLpt1DevicePath         = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0401, 0), DP_END };\r
-  STATIC FLOOPY_CONN_DEVICE_PATH    mFloopyADevicePath      = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0604, 0), DP_END };\r
-  STATIC FLOOPY_CONN_DEVICE_PATH    mFloopyBDevicePath      = { DP_ACPI, DP_PCI (0x1F, 0x00), DP_LPC (0x0604, 1), DP_END };\r
-  STATIC USB_PORT_DEVICE_PATH       mUsb0DevicePath         = { DP_ACPI, DP_PCI (0x1d, 0x00), DP_END };\r
-  STATIC USB_PORT_DEVICE_PATH       mUsb1DevicePath         = { DP_ACPI, DP_PCI (0x1d, 0x01), DP_END };\r
-  STATIC USB_PORT_DEVICE_PATH       mUsb2DevicePath         = { DP_ACPI, DP_PCI (0x1d, 0x02), DP_END };\r
-  STATIC USB_PORT_DEVICE_PATH       mUsb3DevicePath         = { DP_ACPI, DP_PCI (0x1d, 0x07), DP_END };\r
-  STATIC IDE_DEVICE_PATH            mIdeDevicePath          = { DP_ACPI, DP_PCI (0x1F, 0x01), DP_END };\r
-  STATIC GB_NIC_DEVICE_PATH         mGbNicDevicePath        = { DP_ACPI, DP_PCI( 0x03,0x00 ),DP_PCI( 0x1F,0x00 ),DP_PCI( 0x07,0x00 ), DP_END };\r
-  EFI_DEVICE_PATH_PROTOCOL          EndDevicePath           = DP_END;\r
-\r
+  CHAR8                                        *OptionalStrStart;\r
+  UINTN                                        InternalRefStrLen;\r
+  UINTN                                        ExternalRefStrLen;  \r
+  EFI_STRING                                   InternalRef;\r
+  EFI_STRING                                   ExternalRef;\r
+  STRING_REF                                   TokenForInternal;\r
+  STRING_REF                                   TokenForExternal;\r
+  EFI_STATUS                                   Status;\r
+  SMBIOS_TABLE_TYPE8                           *SmbiosRecord;\r
+  EFI_SMBIOS_HANDLE                            SmbiosHandle;\r
+  EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR  *ForType8InputData;\r
+  \r
+  ForType8InputData = (EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR *)RecordData;\r
   //\r
   // First check for invalid parameters.\r
   //\r
-  // Shanmu >> to fix the Device Path Issue...\r
-  // if (RecordLen == 0 || RecordData == NULL || LogRecordData == NULL) {\r
-  //\r
-  if (*RecordLen == 0 || RecordData == NULL || LogRecordData == NULL) {\r
-    //\r
-    // End Shanmu\r
-    //\r
+  if (RecordData == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
-  //\r
-  // Then check for unsupported RecordType.\r
-  //\r
-  if (RecordType != EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_RECORD_NUMBER) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  //\r
-  // Is this the first time through this function?\r
-  //\r
-  if (!Done) {\r
-    //\r
-    // Yes, this is the first time.  Inspect/Change the contents of the\r
-    // RecordData structure.\r
-    //\r
-    //\r
-    // Device path is only updated here as it was not taking that in static data\r
-    //\r
-    // Shanmu >> to fix the Device Path Issue...\r
-    //\r
 \r
-    /*\r
-    switch (((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortInternalConnectorDesignator) \r
-    {\r
-      case STR_MISC_PORT_INTERNAL_MOUSE:\r
-        {\r
-          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mPs2MouseDevicePath);          \r
-        }break;\r
-      case STR_MISC_PORT_INTERNAL_KEYBOARD:\r
-        {\r
-          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mPs2KeyboardDevicePath);          \r
-        }break;\r
-      case STR_MISC_PORT_INTERNAL_COM1:\r
-        {\r
-          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mCom1DevicePath);          \r
-        }break;\r
-      case STR_MISC_PORT_INTERNAL_COM2:\r
-        {\r
-          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mCom2DevicePath);          \r
-        }break;\r
-      case STR_MISC_PORT_INTERNAL_LPT1:\r
-        {\r
-          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mLpt1DevicePath);          \r
-        }break;\r
-      case STR_MISC_PORT_INTERNAL_USB1:\r
-        {\r
-          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mUsb0DevicePath);          \r
-        }break;\r
-      case STR_MISC_PORT_INTERNAL_USB2:\r
-        {\r
-          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mUsb1DevicePath);          \r
-        }break;\r
-      case STR_MISC_PORT_INTERNAL_USB3:\r
-        {\r
-          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mUsb2DevicePath);          \r
-        }break;\r
-      case STR_MISC_PORT_INTERNAL_NETWORK:\r
-        {\r
-          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mGbNicDevicePath);          \r
-        }break;\r
-      case STR_MISC_PORT_INTERNAL_FLOPPY:\r
-        {\r
-          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mFloopyADevicePath);          \r
-        }break;\r
-      case STR_MISC_PORT_INTERNAL_IDE1:\r
-        {\r
-          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mIdeDevicePath);          \r
-        }break;\r
-      case STR_MISC_PORT_INTERNAL_IDE2:\r
-        {\r
-          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = *((EFI_DEVICE_PATH_PROTOCOL*)&mIdeDevicePath);          \r
-        }break;\r
-      default:\r
-        {\r
-          (EFI_DEVICE_PATH_PROTOCOL)((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *)RecordData)->PortPath = EndDevicePath;\r
-        }break;    \r
-    }\r
-    */\r
-    switch (((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortInternalConnectorDesignator) {\r
-    case STR_MISC_PORT_INTERNAL_MOUSE:\r
-      {\r
-        CopyMem (\r
-          &((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,\r
-          &mPs2MouseDevicePath,\r
-          GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mPs2MouseDevicePath)\r
-          );\r
-        *RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mPs2MouseDevicePath);\r
-      }\r
-      break;\r
+  TokenForInternal = 0;\r
+  TokenForExternal = 0;\r
+  \r
+  switch (ForType8InputData->PortInternalConnectorDesignator) { \r
 \r
+    case STR_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR:\r
+      TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR);\r
+      TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_CONNECTOR_DESIGNATOR);\r
+      break;\r
     case STR_MISC_PORT_INTERNAL_KEYBOARD:\r
-      {\r
-        CopyMem (\r
-          &((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,\r
-          &mPs2KeyboardDevicePath,\r
-          GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mPs2KeyboardDevicePath)\r
-          );\r
-        *RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mPs2KeyboardDevicePath);\r
-      }\r
+      TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_KEYBOARD);\r
+      TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_KEYBOARD);\r
+      break;\r
+    case STR_MISC_PORT_INTERNAL_MOUSE:\r
+      TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_MOUSE);\r
+      TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_MOUSE);\r
       break;\r
-\r
     case STR_MISC_PORT_INTERNAL_COM1:\r
-      {\r
-        CopyMem (\r
-          &((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,\r
-          &mCom1DevicePath,\r
-          GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mCom1DevicePath)\r
-          );\r
-        *RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mCom1DevicePath);\r
-      }\r
+      TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_COM1);\r
+      TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_COM1);\r
       break;\r
-\r
     case STR_MISC_PORT_INTERNAL_COM2:\r
-      {\r
-        CopyMem (\r
-          &((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,\r
-          &mCom2DevicePath,\r
-          GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mCom2DevicePath)\r
-          );\r
-        *RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mCom2DevicePath);\r
-      }\r
+      TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_COM2);\r
+      TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_COM2);\r
+      break;\r
+    case STR_MISC_PORT_INTERNAL_EXTENSION_POWER:\r
+      TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_EXTENSION_POWER);\r
+      TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_EXTENSION_POWER);\r
       break;\r
-\r
     case STR_MISC_PORT_INTERNAL_FLOPPY:\r
-      {\r
-        CopyMem (\r
-          &((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,\r
-          &mFloopyADevicePath,\r
-          GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mFloopyADevicePath)\r
-          );\r
-        *RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &mFloopyADevicePath);\r
-      }\r
+      TokenForInternal = STRING_TOKEN (STR_MISC_PORT_INTERNAL_FLOPPY);\r
+      TokenForExternal = STRING_TOKEN(STR_MISC_PORT_EXTERNAL_FLOPPY);\r
       break;\r
-\r
     default:\r
-      {\r
-        CopyMem (\r
-          &((EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA *) RecordData)->PortPath,\r
-          &EndDevicePath,\r
-          GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &EndDevicePath)\r
-          );\r
-        *RecordLen = *RecordLen - sizeof (EFI_MISC_PORT_DEVICE_PATH) + GetDevicePathSize ((EFI_DEVICE_PATH_PROTOCOL *) &EndDevicePath);\r
-      }\r
       break;\r
-    }\r
-    //\r
-    // End Shanmu\r
-    //\r
-    // Set Done flag to TRUE for next pass through this function.\r
-    // Set *LogRecordData to TRUE so data will get logged to Data Hub.\r
-    //\r
-    Done            = TRUE;\r
-    *LogRecordData  = TRUE;\r
-  } else {\r
-    //\r
-    // No, this is the second time.  Reset the state of the Done flag\r
-    // to FALSE and tell the data logger that there is no more data\r
-    // to be logged for this record type.  If any memory allocations\r
-    // were made by earlier passes, they must be released now.\r
-    //\r
-    Done            = FALSE;\r
-    *LogRecordData  = FALSE;\r
   }\r
 \r
-  return EFI_SUCCESS;\r
+  InternalRef = HiiGetPackageString(&gEfiCallerIdGuid, TokenForInternal, NULL);\r
+  InternalRefStrLen = StrLen(InternalRef);\r
+  if (InternalRefStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  ExternalRef = HiiGetPackageString(&gEfiCallerIdGuid, TokenForExternal, NULL);\r
+  ExternalRefStrLen = StrLen(ExternalRef);\r
+  if (ExternalRefStrLen > SMBIOS_STRING_MAX_LENGTH) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Two zeros following the last string.\r
+  //\r
+  SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE8) + InternalRefStrLen + 1 + ExternalRefStrLen + 1 + 1);\r
+  ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE8) + InternalRefStrLen + 1 + ExternalRefStrLen + 1 + 1);\r
+\r
+  SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_PORT_CONNECTOR_INFORMATION;\r
+  SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE8);\r
+  //\r
+  // Make handle chosen by smbios protocol.add automatically.\r
+  //\r
+  SmbiosRecord->Hdr.Handle = 0;  \r
+  SmbiosRecord->InternalReferenceDesignator = 1;\r
+  SmbiosRecord->InternalConnectorType = (UINT8)ForType8InputData->PortInternalConnectorType;\r
+  SmbiosRecord->ExternalReferenceDesignator = 2;\r
+  SmbiosRecord->ExternalConnectorType = (UINT8)ForType8InputData->PortExternalConnectorType;\r
+  SmbiosRecord->PortType = (UINT8)ForType8InputData->PortType;\r
+  \r
+  OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);\r
+  UnicodeStrToAsciiStr(InternalRef, OptionalStrStart);\r
+  UnicodeStrToAsciiStr(ExternalRef, OptionalStrStart + InternalRefStrLen + 1);\r
+\r
+  //\r
+  // Now we have got the full smbios record, call smbios protocol to add this record.\r
+  //\r
+  Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord);\r
+\r
+  FreePool(SmbiosRecord);\r
+  return Status;\r
 }\r
 \r
+\r
+\r
 /* eof - MiscSystemManufacturerFunction.c */\r