Home | History | Annotate | Download | only in EmuThunkDxe
      1 /*++ @file
      2 
      3 Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
      4 Portions copyright (c) 2011, Apple Inc. All rights reserved.
      5 This program and the accompanying materials
      6 are licensed and made available under the terms and conditions of the BSD License
      7 which accompanies this distribution.  The full text of the license may be found at
      8 http://opensource.org/licenses/bsd-license.php
      9 
     10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     12 
     13 
     14 **/
     15 #include <PiDxe.h>
     16 
     17 #include <Protocol/DevicePath.h>
     18 #include <Protocol/EmuThunk.h>
     19 
     20 #include <Library/DebugLib.h>
     21 #include <Library/UefiLib.h>
     22 #include <Library/UefiDriverEntryPoint.h>
     23 #include <Library/EmuThunkLib.h>
     24 #include <Library/MemoryAllocationLib.h>
     25 #include <Library/UefiBootServicesTableLib.h>
     26 #include <Library/DevicePathLib.h>
     27 
     28 //
     29 // EmuThunk Device Path Protocol Instance
     30 //
     31 EMU_THUNK_DEVICE_PATH mEmuThunkDevicePath = {
     32   {
     33     {
     34       {
     35         HARDWARE_DEVICE_PATH,
     36         HW_VENDOR_DP,
     37         {
     38           (UINT8) (sizeof (EMU_VENDOR_DEVICE_PATH_NODE)),
     39           (UINT8) ((sizeof (EMU_VENDOR_DEVICE_PATH_NODE)) >> 8)
     40         }
     41       },
     42       EMU_THUNK_PROTOCOL_GUID
     43     },
     44     0
     45   },
     46   {
     47     END_DEVICE_PATH_TYPE,
     48     END_ENTIRE_DEVICE_PATH_SUBTYPE,
     49     {
     50       END_DEVICE_PATH_LENGTH,
     51       0
     52     }
     53   }
     54 };
     55 
     56 
     57 EFI_STATUS
     58 EFIAPI
     59 InitializeEmuThunk (
     60   IN EFI_HANDLE                            ImageHandle,
     61   IN EFI_SYSTEM_TABLE                      *SystemTable
     62   )
     63 /*++
     64 
     65 Routine Description:
     66   Install UnixThunk Protocol and it's associated Device Path protocol
     67 
     68 Arguments:
     69   (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
     70 
     71 Returns:
     72   EFI_SUCEESS - UnixThunk protocol is added or error status from
     73                 gBS->InstallMultiProtocolInterfaces().
     74 
     75 **/
     76 {
     77   EFI_STATUS  Status;
     78   EFI_HANDLE  Handle;
     79 
     80   Handle = NULL;
     81   Status = gBS->InstallMultipleProtocolInterfaces (
     82                   &Handle,
     83                   &gEmuThunkProtocolGuid,       gEmuThunk,
     84                   &gEfiDevicePathProtocolGuid,  &mEmuThunkDevicePath,
     85                   NULL
     86                   );
     87 
     88   return Status;
     89 }
     90