Skip to content

Commit

Permalink
ProxyLoaderPkg: Create initial proof of concept
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
  • Loading branch information
mcb30 committed Sep 1, 2018
0 parents commit de0e3e0
Show file tree
Hide file tree
Showing 5 changed files with 206 additions and 0 deletions.
57 changes: 57 additions & 0 deletions Application/ProxyLoader/ProxyLoader.c
@@ -0,0 +1,57 @@
/** @file
UEFI loader protocol proxy
Copyright (C) 2018 Michael Brown <mbrown@fensystems.co.uk>.
This program and the accompanying materials are licensed and made
available under the terms and conditions of the BSD License which
accompanies this distribution. The full text of the license may be
found at http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
EXPRESS OR IMPLIED.
**/

#include <Library/UefiBootServicesTableLib.h>
#include "ProxyLoader.h"

/**
Image entry point.
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI System Table.
@retval Status Function execution status.
**/
EFI_STATUS
EFIAPI
UefiMain (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
PROXY_LOADER_PROTOCOL *ProxyLoader;
EFI_STATUS Status;

//
// Get ProxyLoader protocol installed on image handle
//
Status = gBS->OpenProtocol (
ImageHandle,
&gProxyLoaderProtocolGuid,
(VOID **)&ProxyLoader,
ImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR(Status)) {
return Status;
}

//
// Transfer control to proxied entry point
//
return ProxyLoader->Entry ( ImageHandle, SystemTable );
}
37 changes: 37 additions & 0 deletions Application/ProxyLoader/ProxyLoader.h
@@ -0,0 +1,37 @@
/** @file
Proxy loader protocol definition.
**/

#ifndef __PROXY_LOADER_PROTOCOL_H__
#define __PROXY_LOADER_PROTOCOL_H__

#define PROXY_LOADER_PROTOCOL_GUID \
{ \
0x6766FF22, 0xE98C, 0x47D2, {0x9B, 0x7A, 0xD3, 0x27, 0x73, 0xD9, 0x80, 0xBB} \
}

typedef struct _PROXY_LOADER_PROTOCOL PROXY_LOADER_PROTOCOL;

/**
Image entry point.
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI System Table.
@retval Status Function execution status.
**/
typedef
EFI_STATUS
(EFIAPI *PROXY_LOADER_ENTRY)(
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);

struct _PROXY_LOADER_PROTOCOL {
PROXY_LOADER_ENTRY Entry;
};

extern EFI_GUID gProxyLoaderProtocolGuid;

#endif
41 changes: 41 additions & 0 deletions Application/ProxyLoader/ProxyLoader.inf
@@ -0,0 +1,41 @@
## @file
# UEFI loader protocol proxy
#
# This UEFI application calls an entry point provided by a proxy
# loader protocol installed on the image handle.
#
# Copyright (C) 2018 Michael Brown <mbrown@fensystems.co.uk>.
#
# This program and the accompanying materials are licensed and made
# available under the terms and conditions of the BSD License which
# accompanies this distribution. The full text of the license may be
# found at http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
# BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
# EXPRESS OR IMPLIED.
#
##

[Defines]
INF_VERSION = 0x00010005
BASE_NAME = ProxyLoader
FILE_GUID = 65B0742A-E017-4A30-8BAC-030DAAB0170F
MODULE_TYPE = UEFI_APPLICATION
VERSION_STRING = 1.0
ENTRY_POINT = UefiMain

[Sources]
ProxyLoader.c

[Packages]
MdePkg/MdePkg.dec
ProxyLoaderPkg/ProxyLoaderPkg.dec

[LibraryClasses]
UefiApplicationEntryPoint
BaseLib
UefiLib

[Protocols]
gProxyLoaderProtocolGuid
27 changes: 27 additions & 0 deletions ProxyLoaderPkg.dec
@@ -0,0 +1,27 @@
## @file
# UEFI loader protocol proxy
#
# This UEFI application calls an entry point provided by a proxy
# loader protocol installed on the image handle.
#
# Copyright (C) 2018 Michael Brown <mbrown@fensystems.co.uk>.
#
# This program and the accompanying materials are licensed and made
# available under the terms and conditions of the BSD License which
# accompanies this distribution. The full text of the license may be
# found at http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
# BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
# EXPRESS OR IMPLIED.
#
##

[Defines]
DEC_SPECIFICATION = 0x00010005
PACKAGE_NAME = ProxyLoaderPkg
PACKAGE_GUID = DBF844DF-CD7C-444E-85A4-653365293A66
PACKAGE_VERSION = 1.0

[Protocols]
gProxyLoaderProtocolGuid = {0x6766FF22, 0xE98C, 0x47D2, {0x9B, 0x7A, 0xD3, 0x27, 0x73, 0xD9, 0x80, 0xBB}}
44 changes: 44 additions & 0 deletions ProxyLoaderPkg.dsc
@@ -0,0 +1,44 @@
## @file
# UEFI loader protocol proxy
#
# This DSC file is used for Package Level build.
#
# Copyright (C) 2018 Michael Brown <mbrown@fensystems.co.uk>.
#
# This program and the accompanying materials are licensed and made
# available under the terms and conditions of the BSD License which
# accompanies this distribution. The full text of the license may be
# found at http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
# BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
# EXPRESS OR IMPLIED.
#
##

[Defines]
PLATFORM_NAME = ProxyLoader
PLATFORM_GUID = 2387386F-92F8-41A1-A5B3-1B4024465FD4
PLATFORM_VERSION = 1.0
DSC_SPECIFICATION = 0x00010005
OUTPUT_DIRECTORY = Build/ProxyLoader
SUPPORTED_ARCHITECTURES = IA32|X64|EBC|ARM|AARCH64
BUILD_TARGETS = DEBUG|RELEASE|NOOPT
SKUID_IDENTIFIER = DEFAULT

[LibraryClasses]
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
DebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf

[Components]
ProxyLoaderPkg/Application/ProxyLoader/ProxyLoader.inf

0 comments on commit de0e3e0

Please sign in to comment.