The implementation of Consplitter driver should check the child handle to follow...
authorqhuang8 <qhuang8@de2fecce-e211-0410-80a6-f3fac2684e05>
Fri, 1 Feb 2008 15:11:11 +0000 (15:11 +0000)
committerqhuang8 <qhuang8@de2fecce-e211-0410-80a6-f3fac2684e05>
Fri, 1 Feb 2008 15:11:11 +0000 (15:11 +0000)
git-svn-id: https://edk2.tianocore.org/svn/edk2/trunk@4657 de2fecce-e211-0410-80a6-f3fac2684e05

edk2/MdeModulePkg/Universal/Console/ConSplitterDxe/ComponentName.c
edk2/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h

index b13a859..45b7cf7 100644 (file)
@@ -234,6 +234,65 @@ ConSplitterComponentNameGetDriverName (
            );\r
 }\r
 \r
+/**\r
+  Tests whether a controller handle is being managed by a specific driver and\r
+  the child handle is a child device of the controller.\r
+\r
+  @param  ControllerHandle     A handle for a controller to test.\r
+  @param  DriverBindingHandle  Specifies the driver binding handle for the\r
+                               driver.\r
+  @param  ProtocolGuid         Specifies the protocol that the driver specified\r
+                               by DriverBindingHandle opens in its Start()\r
+                               function.\r
+  @param  ChildHandle          A child handle to test.\r
+  @param  ConsumsedGuid        Supplies the protocol that the child controller\r
+                               opens on its parent controller.\r
+\r
+  @retval EFI_SUCCESS          ControllerHandle is managed by the driver\r
+                               specifed by DriverBindingHandle and ChildHandle\r
+                               is a child of the ControllerHandle.\r
+  @retval EFI_UNSUPPORTED      ControllerHandle is not managed by the driver\r
+                               specifed by DriverBindingHandle.\r
+  @retval EFI_UNSUPPORTED      ChildHandle is not a child of the\r
+                               ControllerHandle.\r
+\r
+**/\r
+EFI_STATUS\r
+ConSplitterTestControllerHandles (\r
+  IN  CONST EFI_HANDLE       ControllerHandle,\r
+  IN  CONST EFI_HANDLE       DriverBindingHandle,\r
+  IN  CONST EFI_GUID         *ProtocolGuid,\r
+  IN  EFI_HANDLE             ChildHandle,\r
+  IN  CONST EFI_GUID         *ConsumsedGuid\r
+  )\r
+{\r
+  EFI_STATUS                 Status;\r
+\r
+  //\r
+  // here ChildHandle is not an Optional parameter.\r
+  //\r
+  if (ChildHandle == NULL) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Status = EfiTestManagedDevice (\r
+             ControllerHandle,\r
+             DriverBindingHandle,\r
+             ProtocolGuid\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  Status = EfiTestChildHandle (\r
+             ControllerHandle,\r
+             ChildHandle,\r
+             ConsumsedGuid\r
+             );\r
+\r
+  return Status;\r
+}\r
+\r
 /**\r
   Retrieves a Unicode string that is the user readable name of the controller\r
   that is being managed by a driver.\r
@@ -313,24 +372,16 @@ ConSplitterConInComponentNameGetControllerName (
   )\r
 {\r
   EFI_STATUS                     Status;\r
-  EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn;\r
-  //\r
-  // here ChildHandle is not an Optional parameter.\r
-  //\r
-  if (ChildHandle == NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
 \r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiSimpleTextInProtocolGuid,\r
-                  (VOID **) &TextIn,\r
-                  NULL,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
+  Status = ConSplitterTestControllerHandles (\r
+             ControllerHandle,\r
+             gConSplitterConInDriverBinding.DriverBindingHandle,\r
+             &gEfiSimpleTextInProtocolGuid,\r
+             ChildHandle,\r
+             &gEfiConsoleInDeviceGuid\r
+             );\r
   if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
+    return Status;\r
   }\r
 \r
   return LookupUnicodeString2 (\r
@@ -421,24 +472,16 @@ ConSplitterSimplePointerComponentNameGetControllerName (
   )\r
 {\r
   EFI_STATUS                  Status;\r
-  EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer;\r
-  //\r
-  // here ChildHandle is not an Optional parameter.\r
-  //\r
-  if (ChildHandle == NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
 \r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiSimplePointerProtocolGuid,\r
-                  (VOID **) &SimplePointer,\r
-                  NULL,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
+  Status = ConSplitterTestControllerHandles (\r
+             ControllerHandle,\r
+             gConSplitterSimplePointerDriverBinding.DriverBindingHandle,\r
+             &gEfiSimplePointerProtocolGuid,\r
+             ChildHandle,\r
+             &gEfiSimplePointerProtocolGuid\r
+             );\r
   if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
+    return Status;\r
   }\r
 \r
   return LookupUnicodeString2 (\r
@@ -506,33 +549,25 @@ ConSplitterAbsolutePointerComponentNameGetControllerName (
 --*/\r
 {\r
   EFI_STATUS                    Status;\r
-  EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointer;\r
-  //\r
-  // here ChildHandle is not an Optional parameter.\r
-  //\r
-  if (ChildHandle == NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
 \r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiAbsolutePointerProtocolGuid,\r
-                  (VOID **) &AbsolutePointer,\r
-                  NULL,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
+  Status = ConSplitterTestControllerHandles (\r
+             ControllerHandle,\r
+             gConSplitterAbsolutePointerDriverBinding.DriverBindingHandle,\r
+             &gEfiAbsolutePointerProtocolGuid,\r
+             ChildHandle,\r
+             &gEfiAbsolutePointerProtocolGuid\r
+             );\r
   if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
+    return Status;\r
   }\r
 \r
-return LookupUnicodeString2 (\r
-       Language,\r
-       This->SupportedLanguages,\r
-       mConSplitterAbsolutePointerControllerNameTable,\r
-       ControllerName,\r
-       (BOOLEAN)(This == &gConSplitterAbsolutePointerComponentName)\r
-       );\r
+  return LookupUnicodeString2 (\r
+           Language,\r
+           This->SupportedLanguages,\r
+           mConSplitterAbsolutePointerControllerNameTable,\r
+           ControllerName,\r
+           (BOOLEAN)(This == &gConSplitterAbsolutePointerComponentName)\r
+           );\r
 }\r
 \r
 /**\r
@@ -614,24 +649,16 @@ ConSplitterConOutComponentNameGetControllerName (
   )\r
 {\r
   EFI_STATUS                       Status;\r
-  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *TextOut;\r
-  //\r
-  // here ChildHandle is not an Optional parameter.\r
-  //\r
-  if (ChildHandle == NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
 \r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiSimpleTextOutProtocolGuid,\r
-                  (VOID **) &TextOut,\r
-                  NULL,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
+  Status = ConSplitterTestControllerHandles (\r
+             ControllerHandle,\r
+             gConSplitterConOutDriverBinding.DriverBindingHandle,\r
+             &gEfiSimpleTextOutProtocolGuid,\r
+             ChildHandle,\r
+             &gEfiConsoleOutDeviceGuid\r
+             );\r
   if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
+    return Status;\r
   }\r
 \r
   return LookupUnicodeString2 (\r
@@ -722,24 +749,16 @@ ConSplitterStdErrComponentNameGetControllerName (
   )\r
 {\r
   EFI_STATUS                       Status;\r
-  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *ErrOut;\r
-  //\r
-  // here ChildHandle is not an Optional parameter.\r
-  //\r
-  if (ChildHandle == NULL) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
 \r
-  Status = gBS->OpenProtocol (\r
-                  ControllerHandle,\r
-                  &gEfiSimpleTextOutProtocolGuid,\r
-                  (VOID **) &ErrOut,\r
-                  NULL,\r
-                  ControllerHandle,\r
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                  );\r
+  Status = ConSplitterTestControllerHandles (\r
+             ControllerHandle,\r
+             gConSplitterStdErrDriverBinding.DriverBindingHandle,\r
+             &gEfiSimpleTextOutProtocolGuid,\r
+             ChildHandle,\r
+             &gEfiStandardErrorDeviceGuid\r
+             );\r
   if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
+    return Status;\r
   }\r
 \r
   return LookupUnicodeString2 (\r
index 587c6c1..9fcbab3 100644 (file)
@@ -48,6 +48,7 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gConSplitterConInComponentName2;
 extern EFI_DRIVER_BINDING_PROTOCOL  gConSplitterSimplePointerDriverBinding;\r
 extern EFI_COMPONENT_NAME_PROTOCOL  gConSplitterSimplePointerComponentName;\r
 extern EFI_COMPONENT_NAME2_PROTOCOL gConSplitterSimplePointerComponentName2;\r
+extern EFI_DRIVER_BINDING_PROTOCOL  gConSplitterAbsolutePointerDriverBinding;\r
 extern EFI_COMPONENT_NAME_PROTOCOL  gConSplitterAbsolutePointerComponentName;\r
 extern EFI_COMPONENT_NAME2_PROTOCOL gConSplitterAbsolutePointerComponentName2;\r
 extern EFI_DRIVER_BINDING_PROTOCOL  gConSplitterConOutDriverBinding;\r