OcInterface: Implement initial OcInterface protocol with test sample

This commit is contained in:
vit9696 2019-06-18 12:49:10 +03:00
parent 1981d037c1
commit d3a626cdc5
12 changed files with 248 additions and 18 deletions

View File

@ -402,6 +402,24 @@ OcScanForBootEntries (
IN BOOLEAN Describe
);
/**
Obtain default entry from the list.
@param[in,out] BootEntries Described list of entries, may get updated.
@param[in] NumBootEntries Positive number of boot entries.
@param[in] CustomBootGuid Use custom GUID for Boot#### lookup.
@param[in] LoadHandle Handle to skip (potential OpenCore handle).
@retval boot entry or NULL.
**/
OC_BOOT_ENTRY *
OcGetDefaultBootEntry (
IN OUT OC_BOOT_ENTRY *BootEntries,
IN UINTN NumBootEntries,
IN BOOLEAN CustomBootGuid,
IN EFI_HANDLE LoadHandle OPTIONAL
);
/**
Show simple boot entry selection menu and return chosen entry.

View File

@ -0,0 +1,71 @@
/** @file
Copyright (C) 2019, vit9696. All rights reserved.
All rights reserved.
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.
**/
#ifndef OC_INTERFACE_PROTOCOL_H
#define OC_INTERFACE_PROTOCOL_H
#include <Library/OcBootManagementLib.h>
#include <Library/OcStorageLib.h>
/**
Current supported interface protocol revision.
It is changed every time the contract changes.
WARNING: This protocol currently undergoes design process.
**/
#define OC_INTERFACE_REVISION 0x1
/**
The GUID of the OC_INTERFACE_PROTOCOL.
**/
#define OC_INTERFACE_PROTOCOL_GUID \
{ 0x53027CDF, 0x3A89, 0x4255, \
{ 0xAE, 0x29, 0xD6, 0x66, 0x6E, 0xFE, 0x99, 0xEF } }
/**
The forward declaration for the protocol for the OC_INTERFACE_PROTOCOL_H.
**/
typedef struct OC_INTERFACE_PROTOCOL_ OC_INTERFACE_PROTOCOL;
/**
Add an entry to the log buffer
@param[in] This This protocol.
@param[in] Storage File system access storage.
@param[in] Picker User interface configuration.
@retval does not return unless a fatal error happened.
**/
typedef
EFI_STATUS
(EFIAPI *OC_INTERFACE_RUN) (
IN OC_INTERFACE_PROTOCOL *This,
IN OC_STORAGE_CONTEXT *Storage,
IN OC_PICKER_CONTEXT *Picker
);
/**
The structure exposed by the OC_INTERFACE_PROTOCOL.
**/
struct OC_INTERFACE_PROTOCOL_ {
UINT32 Revision; ///< The revision of the installed protocol.
OC_INTERFACE_RUN ShowInteface; ///< A pointer to the ShowInterface function.
};
/**
A global variable storing the GUID of the OC_INTERFACE_PROTOCOL.
**/
extern EFI_GUID gOcInterfaceProtocolGuid;
#endif // OC_INTERFACE_PROTOCOL_H

View File

@ -38,10 +38,9 @@ typedef UINT32 OC_LOG_OPTIONS;
/**
The GUID of the OC_LOG_PROTOCOL.
**/
#define OC_LOG_PROTOCOL_GUID \
{ \
0xDBB6008F, 0x89E4, 0x4272, { 0x98, 0x81, 0xCE, 0x3A, 0xFD, 0x97, 0x24, 0xD0 } \
}
#define OC_LOG_PROTOCOL_GUID \
{ 0xDBB6008F, 0x89E4, 0x4272, \
{ 0x98, 0x81, 0xCE, 0x3A, 0xFD, 0x97, 0x24, 0xD0 } }
/**
The forward declaration for the protocol for the OC_LOG_PROTOCOL.

View File

@ -49,14 +49,6 @@ InternalUnloadDmg (
IN INTERNAL_DMG_LOAD_CONTEXT *DmgLoadContext
);
OC_BOOT_ENTRY *
InternalGetDefaultBootEntry (
IN OUT OC_BOOT_ENTRY *BootEntries,
IN UINTN NumBootEntries,
IN BOOLEAN CustomBootGuid,
IN EFI_HANDLE LoadHandle OPTIONAL
);
CHAR16 *
InternalGetAppleDiskLabel (
IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FileSystem,

View File

@ -350,7 +350,7 @@ InternalIsAppleLegacyLoadApp (
}
OC_BOOT_ENTRY *
InternalGetDefaultBootEntry (
OcGetDefaultBootEntry (
IN OUT OC_BOOT_ENTRY *BootEntries,
IN UINTN NumBootEntries,
IN BOOLEAN CustomBootGuid,

View File

@ -870,7 +870,7 @@ OcRunSimpleBootPicker (
DEBUG ((DEBUG_INFO, "Performing OcShowSimpleBootMenu...\n"));
DefaultEntry = 0;
Entry = InternalGetDefaultBootEntry (Entries, EntryCount, Context->CustomBootGuid, Context->ExcludeHandle);
Entry = OcGetDefaultBootEntry (Entries, EntryCount, Context->CustomBootGuid, Context->ExcludeHandle);
if (Entry != NULL) {
DefaultEntry = (UINT32)(Entry - Entries);
}

View File

@ -158,7 +158,7 @@ InternalCheckScanPolicy (
//
DevicePolicy = OcGetDevicePolicyType (Handle, External);
if ((Policy & OC_SCAN_DEVICE_LOCK) != 0 && (Policy & DevicePolicy) == 0) {
DEBUG ((DEBUG_INFO, "OCB: invalid device policy (%u/%u) for %p\n", DevicePolicy, Policy, Handle));
DEBUG ((DEBUG_INFO, "OCB: Invalid device policy (%x/%x) for %p\n", DevicePolicy, Policy, Handle));
return EFI_SECURITY_VIOLATION;
}
@ -166,7 +166,7 @@ InternalCheckScanPolicy (
FileSystemPolicy = OcGetFileSystemPolicyType (Handle);
if ((Policy & FileSystemPolicy) == 0) {
DEBUG ((DEBUG_INFO, "OCB: invalid file system policy (%u/%u) for %p\n", FileSystemPolicy, Policy, Handle));
DEBUG ((DEBUG_INFO, "OCB: Invalid file system policy (%x/%x) for %p\n", FileSystemPolicy, Policy, Handle));
return EFI_SECURITY_VIOLATION;
}
}

View File

@ -35,8 +35,11 @@
gOcCustomSmbiosTableGuid = { 0xEB9D2D35, 0x2D88, 0x11D3, { 0x9A, 0x16, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }}
[Protocols]
gOcLogProtocolGuid = { 0xDBB6008F, 0x89E4, 0x4272, { 0x98, 0x81, 0xCE, 0x3A, 0xFD, 0x97, 0x24, 0xD0 }}
## Include/Protocol/OcInterface.h
gOcInterfaceProtocolGuid = { 0x53027CDF, 0x3A89, 0x4255, { 0xAE, 0x29, 0xD6, 0x66, 0x6E, 0xFE, 0x99, 0xEF }}
## Include/Protocol/OcLog.h
gOcLogProtocolGuid = { 0xDBB6008F, 0x89E4, 0x4272, { 0x98, 0x81, 0xCE, 0x3A, 0xFD, 0x97, 0x24, 0xD0 }}
## Include/Protocol/LegacyRegion.h
gEfiLegacyRegionProtocolGuid = { 0x0fc9013a, 0x0568, 0x4ba9, { 0x9b, 0x7e, 0xc9, 0xc3, 0x90, 0xa6, 0x60, 0x9b }}

View File

@ -123,6 +123,7 @@
OcSupportPkg/Tests/BlessTest/BlessTestApp.inf
OcSupportPkg/Tests/DataHubTest/DataHubTest.inf
OcSupportPkg/Tests/DataHubTest/DataHubTestApp.inf
OcSupportPkg/Tests/ExternalUi/ExternalUi.inf
OcSupportPkg/Tests/KernelTest/KernelTest.inf
OcSupportPkg/Tests/KernelTest/KernelTestApp.inf
OcSupportPkg/Tests/PropertyTest/PropertyTest.inf

View File

@ -0,0 +1,94 @@
/** @file
Test external interface support.
Copyright (c) 2019, vit9696. All rights reserved.<BR>
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/DebugLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Protocol/OcInterface.h>
STATIC
EFI_STATUS
EFIAPI
ExternalGuiRun (
IN OC_INTERFACE_PROTOCOL *This,
IN OC_STORAGE_CONTEXT *Storage,
IN OC_PICKER_CONTEXT *Picker
)
{
//
// Storage could be used to access custom graphical theme.
// One must NOT access disk bypassing Storage as other
// data may not be protected by vaulting.
// Always use OcStorageReadFileUnicode.
//
(VOID) Storage;
//
// For simplicity this example just calls reference boot picker,
// however, a more advanced user interface should reimplement
// OcRunSimpleBootPicker logic.
//
return OcRunSimpleBootPicker (Picker);
}
STATIC
OC_INTERFACE_PROTOCOL
mOcInterfaceProtocol = {
OC_INTERFACE_REVISION,
ExternalGuiRun
};
EFI_STATUS
EFIAPI
UefiMain (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
VOID *PrevInterface;
EFI_HANDLE NewHandle;
//
// Check for previous GUI protocols.
//
Status = gBS->LocateProtocol (
&gOcInterfaceProtocolGuid,
NULL,
&PrevInterface
);
if (!EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "OCE: Another GUI is already present\n"));
return EFI_ALREADY_STARTED;
}
//
// Install new GUI protocol
//
NewHandle = NULL;
Status = gBS->InstallMultipleProtocolInterfaces (
&NewHandle,
&gOcInterfaceProtocolGuid,
&mOcInterfaceProtocol,
NULL
);
if (!EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "OCE: Registered custom GUI protocol\n"));
} else {
DEBUG ((DEBUG_ERROR, "OCE: Failed to install GUI protocol - %r\n", Status));
}
return Status;
}

View File

@ -0,0 +1,53 @@
## @file
# External OpenCore GUI application.
#
# Copyright (c) 2019, vit9696. All rights reserved.<BR>
#
# 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 = ExternalUi
FILE_GUID = 34773042-6AED-4617-BCDB-AD3DF0592EE9
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
INF_VERSION = 0x00010005
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00010000
ENTRY_POINT = UefiMain
#
# This flag specifies whether HII resource section is generated into PE image.
#
UEFI_HII_RESOURCE_SECTION = TRUE
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]
ExternalUi.c
[Packages]
OcSupportPkg/OcSupportPkg.dec
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
UefiCpuPkg/UefiCpuPkg.dec
EfiPkg/EfiPkg.dec
[Protocols]
gOcInterfaceProtocolGuid ## SOMETIMES_PRODUCES
[LibraryClasses]
OcBootManagementLib
UefiBootServicesTableLib
UefiDriverEntryPoint

View File

@ -66,4 +66,3 @@
OcSmbiosLib
OcDataHubLib
OcVirtualFsLib