Reviewed-By: Olivier Martin <[email protected]>

> -----Original Message-----
> From: Laszlo Ersek [mailto:[email protected]]
> Sent: 14 February 2015 22:02
> To: [email protected]; [email protected]; Peter Maydell; Ard
> Biesheuvel; Drew Jones; Wei Huang; Donald Dutile; Wei Liu
> Subject: [edk2] [PATCH 23/27] ArmVirtualizationPkg:
> PlatformIntelBdsLib: fix multiconsole setup
> 
> In the following call chain:
> 
> PlatformBdsPolicyBehavior()
>   PlatformBdsConnectConsole()
>     InitializeConsolePipe() x 3
>       BdsConnectDevicePath() [ArmPkg/Library/BdsLib/BdsFilePath.c]
> 
> the three InitializeConsolePipe() function calls pass through
> - (&gST->ConsoleOutHandle, &gST->ConOut),
> - (&gST->ConsoleInHandle, &gST->ConIn),
> - (&gST->StandardErrorHandle, &gST->StdErr)
> 
> to BdsConnectDevicePath(), in ArmPkg's BdsLib.
> 
> At least when more than one console device paths are specified in the
> ConIn / ConOut / ErrOut variables, the above resuls in:
> - unchanged protocol interfaces (ConOut, ConIn, StdErr) in the system
>   table (because ConSplitterDxe installs its non-NULL interfaces
> first),
> - but, changed handles in the system table.
> 
> This effectively separates the handle fields in the system table from
> the
> protocol interfaces in the same that should always be associated with
> the
> handles. The end result is that clients using the handles break
> (splitting
> / multiplexing doesn't work for them), while clients directly using the
> protocol interfaces work.
> 
> Therefore, do not attempt to connect consoles separately.
> ConSplitterDxe
> is dispatched before PlatformBdsPolicyBehavior() is called (the latter
> happens in the BDS phase), and ConSplitterDxe installs virtual handles
> and
> protocol interfaces for input / output / error.
> 
> BdsLibConnectAll() covers all devices, including consoles; as those
> consoles are connected, ConPlatformDxe and ConSplitterDxe pick them up
> nicely as "slaves". We just need to make sure that the variables are
> set
> first, for the variables -> ConPlatformDxe -> ConSplitterDxe dependency
> chain.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Laszlo Ersek <[email protected]>
> ---
> 
> ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/IntelBd
> sPlatform.c | 101 +-------------------
>  1 file changed, 3 insertions(+), 98 deletions(-)
> 
> diff --git
> a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/Intel
> BdsPlatform.c
> b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/Intel
> BdsPlatform.c
> index ae43f9c..667810f 100644
> ---
> a/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/Intel
> BdsPlatform.c
> +++
> b/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformIntelBdsLib/Intel
> BdsPlatform.c
> @@ -109,85 +109,8 @@ GetConsoleDevicePathFromVariable (
>  }
> 
>  STATIC
> -EFI_STATUS
> -InitializeConsolePipe (
> -  IN EFI_DEVICE_PATH    *ConsoleDevicePaths,
> -  IN EFI_GUID           *Protocol,
> -  OUT EFI_HANDLE        *Handle,
> -  OUT VOID*             *Interface
> -  )
> -{
> -  EFI_STATUS                Status;
> -  UINTN                     Size;
> -  UINTN                     NoHandles;
> -  EFI_HANDLE                *Buffer;
> -  EFI_DEVICE_PATH_PROTOCOL* DevicePath;
> -
> -  // Connect all the Device Path Consoles
> -  while (ConsoleDevicePaths != NULL) {
> -    DevicePath = GetNextDevicePathInstance (&ConsoleDevicePaths,
> &Size);
> -
> -    Status = BdsConnectDevicePath (DevicePath, Handle, NULL);
> -    DEBUG_CODE_BEGIN ();
> -      if (EFI_ERROR (Status)) {
> -        // We convert back to the text representation of the device
> Path
> -        EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;
> -        CHAR16* DevicePathTxt;
> -        EFI_STATUS Status;
> -
> -        Status = gBS->LocateProtocol
> (&gEfiDevicePathToTextProtocolGuid, NULL, (VOID
> **)&DevicePathToTextProtocol);
> -        if (!EFI_ERROR (Status)) {
> -          DevicePathTxt = DevicePathToTextProtocol-
> >ConvertDevicePathToText (DevicePath, TRUE, TRUE);
> -
> -          DEBUG ((EFI_D_ERROR, "Fail to start the console with the
> Device Path '%s'. (Error '%r')\n", DevicePathTxt, Status));
> -
> -          FreePool (DevicePathTxt);
> -        }
> -      }
> -    DEBUG_CODE_END ();
> -
> -    // If the console splitter driver is not supported by the platform
> then use the first Device Path
> -    // instance for the console interface.
> -    if (!EFI_ERROR (Status) && (*Interface == NULL)) {
> -      Status = gBS->HandleProtocol (*Handle, Protocol, Interface);
> -    }
> -  }
> -
> -  // No Device Path has been defined for this console interface. We
> take the first protocol implementation
> -  if (*Interface == NULL) {
> -    Status = gBS->LocateHandleBuffer (ByProtocol, Protocol, NULL,
> &NoHandles, &Buffer);
> -    if (EFI_ERROR (Status)) {
> -      BdsConnectAllDrivers ();
> -      Status = gBS->LocateHandleBuffer (ByProtocol, Protocol, NULL,
> &NoHandles, &Buffer);
> -    }
> -
> -    if (!EFI_ERROR (Status)) {
> -      *Handle = Buffer[0];
> -      Status = gBS->HandleProtocol (*Handle, Protocol, Interface);
> -      ASSERT_EFI_ERROR (Status);
> -    }
> -    FreePool (Buffer);
> -  } else {
> -    Status = EFI_SUCCESS;
> -  }
> -
> -  return Status;
> -}
> -
> -/**
> -  Connect the predefined platform default console device. Always try
> to find
> -  and enable the vga device if have.
> -
> -  @param PlatformConsole          Predefined platform default console
> device array.
> -
> -  @retval EFI_SUCCESS             Success connect at least one ConIn
> and ConOut
> -                                  device, there must have one ConOut
> device is
> -                                  active vga device.
> -  @return Return the status of BdsLibConnectAllDefaultConsoles ()
> -
> -**/
> -EFI_STATUS
> -PlatformBdsConnectConsole (
> +VOID
> +SetConsoleVariables (
>    VOID
>    )
>  {
> @@ -205,20 +128,6 @@ PlatformBdsConnectConsole (
>    ASSERT_EFI_ERROR (Status);
>    Status = GetConsoleDevicePathFromVariable (L"ErrOut",
> (CHAR16*)PcdGetPtr (PcdDefaultConOutPaths), &ConErrDevicePaths);
>    ASSERT_EFI_ERROR (Status);
> -
> -  // Initialize the Consoles
> -  Status = InitializeConsolePipe (ConOutDevicePaths,
> &gEfiSimpleTextOutProtocolGuid, &gST->ConsoleOutHandle, (VOID **)&gST-
> >ConOut);
> -  ASSERT_EFI_ERROR (Status);
> -  Status = InitializeConsolePipe (ConInDevicePaths,
> &gEfiSimpleTextInProtocolGuid, &gST->ConsoleInHandle, (VOID **)&gST-
> >ConIn);
> -  ASSERT_EFI_ERROR (Status);
> -  Status = InitializeConsolePipe (ConErrDevicePaths,
> &gEfiSimpleTextOutProtocolGuid, &gST->StandardErrorHandle, (VOID
> **)&gST->StdErr);
> -  if (EFI_ERROR (Status)) {
> -    // In case of error, we reuse the console output for the error
> output
> -    gST->StandardErrorHandle = gST->ConsoleOutHandle;
> -    gST->StdErr = gST->ConOut;
> -  }
> -
> -  return Status;
>  }
> 
>  /**
> @@ -284,11 +193,7 @@ PlatformBdsPolicyBehavior (
>    IN BASEM_MEMORY_TEST               BaseMemoryTest
>    )
>  {
> -  EFI_STATUS Status;
> -
> -  Status = PlatformBdsConnectConsole ();
> -  ASSERT_EFI_ERROR (Status);
> -
> +  SetConsoleVariables ();
>    BdsLibConnectAll ();
> 
>    //
> --
> 1.8.3.1
> 
> 
> 
> -----------------------------------------------------------------------
> -------
> Dive into the World of Parallel Programming. The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is
> your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more.
> Take a
> look and join the conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> edk2-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/edk2-devel





------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to