You've already forked DasharoModulePkg
mirror of
https://github.com/Dasharo/DasharoModulePkg.git
synced 2026-03-06 14:50:17 -08:00
482db63a0d
This commit adds option in security menu to enable Firmware Update Mode. As a result, UEFI variable is set, which will be later caught by coreboot and acted upon to disable firmware write protections. Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
162 lines
5.9 KiB
C
162 lines
5.9 KiB
C
/** @file
|
|
The Dasharo system features implementation
|
|
|
|
Copyright (c) 2022, 3mdeb Sp. z o.o. All rights reserved.<BR>
|
|
SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
**/
|
|
|
|
#ifndef _DASHARO_SYSTEM_FEATURES_H_
|
|
#define _DASHARO_SYSTEM_FEATURES_H_
|
|
|
|
#include <Guid/MdeModuleHii.h>
|
|
#include <Guid/HiiPlatformSetupFormset.h>
|
|
|
|
#include <Protocol/AcpiSystemDescriptionTable.h>
|
|
#include <Protocol/HiiConfigAccess.h>
|
|
|
|
#include <IndustryStandard/Acpi.h>
|
|
|
|
#include <Library/PcdLib.h>
|
|
#include <Library/PrintLib.h>
|
|
#include <Library/DebugLib.h>
|
|
#include <Library/BaseMemoryLib.h>
|
|
#include <Library/UefiBootServicesTableLib.h>
|
|
#include <Library/UefiRuntimeServicesTableLib.h>
|
|
#include <Library/MemoryAllocationLib.h>
|
|
#include <Library/BaseLib.h>
|
|
#include <Library/IoLib.h>
|
|
#include <Library/HiiLib.h>
|
|
#include <Library/DevicePathLib.h>
|
|
#include <Library/UefiHiiServicesLib.h>
|
|
#include <Library/UefiLib.h>
|
|
|
|
#include "DasharoSystemFeaturesHii.h"
|
|
|
|
//
|
|
// These are the VFR compiler generated data representing our VFR data.
|
|
//
|
|
extern UINT8 DasharoSystemFeaturesVfrBin[];
|
|
|
|
#define DASHARO_SYSTEM_FEATURES_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('D', 'S', 'F', 'p')
|
|
|
|
///
|
|
/// HII specific Vendor Device Path definition.
|
|
///
|
|
typedef struct {
|
|
VENDOR_DEVICE_PATH VendorDevicePath;
|
|
EFI_DEVICE_PATH_PROTOCOL End;
|
|
} HII_VENDOR_DEVICE_PATH;
|
|
|
|
typedef struct {
|
|
UINTN Signature;
|
|
|
|
///
|
|
/// Device Manager HII relative handles
|
|
///
|
|
EFI_HII_HANDLE HiiHandle;
|
|
|
|
EFI_HANDLE DriverHandle;
|
|
|
|
///
|
|
/// Produced protocols
|
|
///
|
|
EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
|
|
|
|
///
|
|
/// Configuration data
|
|
///
|
|
DASHARO_FEATURES_DATA DasharoFeaturesData;
|
|
} DASHARO_SYSTEM_FEATURES_PRIVATE_DATA;
|
|
|
|
#define DASHARO_SYSTEM_FEATURES_PRIVATE_DATA_FROM_THIS(a) \
|
|
CR (a, \
|
|
DASHARO_SYSTEM_FEATURES_PRIVATE_DATA, \
|
|
ConfigAccess, \
|
|
DASHARO_SYSTEM_FEATURES_PRIVATE_DATA_SIGNATURE \
|
|
)
|
|
|
|
/**
|
|
This function allows a caller to extract the current configuration for one
|
|
or more named elements from the target driver.
|
|
|
|
|
|
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
|
|
@param Request A null-terminated Unicode string in <ConfigRequest> format.
|
|
@param Progress On return, points to a character in the Request string.
|
|
Points to the string's null terminator if request was successful.
|
|
Points to the most recent '&' before the first failing name/value
|
|
pair (or the beginning of the string if the failure is in the
|
|
first name/value pair) if the request was not successful.
|
|
@param Results A null-terminated Unicode string in <ConfigAltResp> format which
|
|
has all values filled in for the names in the Request string.
|
|
String to be allocated by the called function.
|
|
|
|
@retval EFI_SUCCESS The Results is filled with the requested values.
|
|
@retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
|
|
@retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.
|
|
@retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
|
|
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
DasharoSystemFeaturesExtractConfig (
|
|
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
|
|
IN CONST EFI_STRING Request,
|
|
OUT EFI_STRING *Progress,
|
|
OUT EFI_STRING *Results
|
|
);
|
|
|
|
/**
|
|
This function processes the results of changes in configuration.
|
|
|
|
|
|
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
|
|
@param Configuration A null-terminated Unicode string in <ConfigResp> format.
|
|
@param Progress A pointer to a string filled in with the offset of the most
|
|
recent '&' before the first failing name/value pair (or the
|
|
beginning of the string if the failure is in the first
|
|
name/value pair) or the terminating NULL if all was successful.
|
|
|
|
@retval EFI_SUCCESS The Results is processed successfully.
|
|
@retval EFI_INVALID_PARAMETER Configuration is NULL.
|
|
@retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
|
|
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
DasharoSystemFeaturesRouteConfig (
|
|
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
|
|
IN CONST EFI_STRING Configuration,
|
|
OUT EFI_STRING *Progress
|
|
);
|
|
|
|
/**
|
|
This function is invoked if user selected a interactive opcode from Dasharo System Features'
|
|
Formset. If user set VBIOS, the new value is saved to EFI variable.
|
|
|
|
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
|
|
@param Action Specifies the type of action taken by the browser.
|
|
@param QuestionId A unique value which is sent to the original exporting driver
|
|
so that it can identify the type of data to expect.
|
|
@param Type The type of value for the question.
|
|
@param Value A pointer to the data being sent to the original exporting driver.
|
|
@param ActionRequest On return, points to the action requested by the callback function.
|
|
|
|
@retval EFI_SUCCESS The callback successfully handled the action.
|
|
@retval EFI_INVALID_PARAMETER The setup browser call this function with invalid parameters.
|
|
|
|
**/
|
|
EFI_STATUS
|
|
EFIAPI
|
|
DasharoSystemFeaturesCallback (
|
|
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
|
|
IN EFI_BROWSER_ACTION Action,
|
|
IN EFI_QUESTION_ID QuestionId,
|
|
IN UINT8 Type,
|
|
IN EFI_IFR_TYPE_VALUE *Value,
|
|
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
|
|
);
|
|
|
|
#endif
|