1 /** @file 2 Execute 32-bit code in Protected Mode. 3 4 Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR> 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 <Uefi.h> 16 #include <FspEas.h> 17 18 /** 19 FSP API functions. 20 21 @param[in] Param1 The first parameter to pass to 32bit code. 22 @param[in] Param2 The second parameter to pass to 32bit code. 23 24 @return EFI_STATUS. 25 **/ 26 typedef 27 EFI_STATUS 28 (EFIAPI *FSP_FUNCTION) ( 29 IN VOID *Param1, 30 IN VOID *Param2 31 ); 32 33 /** 34 Wrapper for a thunk to transition from long mode to compatibility mode to execute 32-bit code and then transit back to 35 long mode. 36 37 @param[in] Function The 32bit code entry to be executed. 38 @param[in] Param1 The first parameter to pass to 32bit code. 39 @param[in] Param2 The second parameter to pass to 32bit code. 40 41 @return EFI_STATUS. 42 **/ 43 EFI_STATUS 44 Execute32BitCode ( 45 IN UINT64 Function, 46 IN UINT64 Param1, 47 IN UINT64 Param2 48 ) 49 { 50 FSP_FUNCTION EntryFunc; 51 EFI_STATUS Status; 52 53 EntryFunc = (FSP_FUNCTION) (UINTN) (Function); 54 Status = EntryFunc ((VOID *)(UINTN)Param1, (VOID *)(UINTN)Param2); 55 56 return Status; 57 } 58 59