EmuThunk.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*++ @file
  2. Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
  3. Portions copyright (c) 2011, Apple Inc. All rights reserved.
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include <PiDxe.h>
  7. #include <Protocol/DevicePath.h>
  8. #include <Protocol/EmuThunk.h>
  9. #include <Library/DebugLib.h>
  10. #include <Library/UefiLib.h>
  11. #include <Library/UefiDriverEntryPoint.h>
  12. #include <Library/EmuThunkLib.h>
  13. #include <Library/MemoryAllocationLib.h>
  14. #include <Library/UefiBootServicesTableLib.h>
  15. #include <Library/DevicePathLib.h>
  16. //
  17. // EmuThunk Device Path Protocol Instance
  18. //
  19. EMU_THUNK_DEVICE_PATH mEmuThunkDevicePath = {
  20. {
  21. {
  22. {
  23. HARDWARE_DEVICE_PATH,
  24. HW_VENDOR_DP,
  25. {
  26. (UINT8)(sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
  27. (UINT8)((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
  28. }
  29. },
  30. EMU_THUNK_PROTOCOL_GUID
  31. },
  32. 0
  33. },
  34. {
  35. END_DEVICE_PATH_TYPE,
  36. END_ENTIRE_DEVICE_PATH_SUBTYPE,
  37. {
  38. END_DEVICE_PATH_LENGTH,
  39. 0
  40. }
  41. }
  42. };
  43. EFI_STATUS
  44. EFIAPI
  45. InitializeEmuThunk (
  46. IN EFI_HANDLE ImageHandle,
  47. IN EFI_SYSTEM_TABLE *SystemTable
  48. )
  49. /*++
  50. Routine Description:
  51. Install UnixThunk Protocol and it's associated Device Path protocol
  52. Arguments:
  53. (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
  54. Returns:
  55. EFI_SUCEESS - UnixThunk protocol is added or error status from
  56. gBS->InstallMultiProtocolInterfaces().
  57. **/
  58. {
  59. EFI_STATUS Status;
  60. EFI_HANDLE Handle;
  61. Handle = NULL;
  62. Status = gBS->InstallMultipleProtocolInterfaces (
  63. &Handle,
  64. &gEmuThunkProtocolGuid,
  65. gEmuThunk,
  66. &gEfiDevicePathProtocolGuid,
  67. &mEmuThunkDevicePath,
  68. NULL
  69. );
  70. return Status;
  71. }