TianoCore EDK2 master
DriverSample.c File Reference
#include "DriverSample.h"

Go to the source code of this file.

Macros

#define DISPLAY_ONLY_MY_ITEM   0x0002
 

Functions

VOID SetArrayData (IN VOID *Array, IN UINT8 Type, IN UINTN Index, IN UINT64 Value)
 
EFI_STATUS EFIAPI NotificationFunction (IN EFI_KEY_DATA *KeyData)
 
EFI_STATUS EFIAPI InternalStartMonitor (VOID)
 
EFI_STATUS EFIAPI InternalStopMonitor (VOID)
 
EFI_STATUS LoadNameValueNames (IN DRIVER_SAMPLE_PRIVATE_DATA *PrivateData)
 
EFI_STATUS GetValueOfNumber (IN EFI_STRING StringPtr, OUT UINT8 **Number, OUT UINTN *Len)
 
EFI_STRING CreateAltCfgString (IN EFI_STRING Result, IN EFI_STRING ConfigHdr, IN UINTN Offset, IN UINTN Width)
 
VOID AppendAltCfgString (IN OUT EFI_STRING *RequestResult, IN EFI_STRING ConfigRequestHdr)
 
EFI_STATUS EFIAPI ExtractConfig (IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Request, OUT EFI_STRING *Progress, OUT EFI_STRING *Results)
 
EFI_STATUS EFIAPI RouteConfig (IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Configuration, OUT EFI_STRING *Progress)
 
EFI_STATUS EFIAPI DriverCallback (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)
 
EFI_STATUS EFIAPI DriverSampleInit (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
EFI_STATUS EFIAPI DriverSampleUnload (IN EFI_HANDLE ImageHandle)
 

Variables

CHAR16 VariableName [] = L"MyIfrNVData"
 
CHAR16 MyEfiVar [] = L"MyEfiVar"
 
CHAR16 MyEfiBitVar [] = L"MyEfiBitVar"
 
CHAR16 MyEfiUnionVar [] = L"MyEfiUnionVar"
 
EFI_HANDLE DriverHandle [2] = { NULL, NULL }
 
DRIVER_SAMPLE_PRIVATE_DATAmPrivateData = NULL
 
EFI_EVENT mEvent
 
HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath0
 
HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath1
 

Detailed Description

This is an example of how a driver might export data to the HII protocol to be later utilized by the Setup Protocol

Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file DriverSample.c.

Macro Definition Documentation

◆ DISPLAY_ONLY_MY_ITEM

#define DISPLAY_ONLY_MY_ITEM   0x0002

Definition at line 12 of file DriverSample.c.

Function Documentation

◆ AppendAltCfgString()

VOID AppendAltCfgString ( IN OUT EFI_STRING *  RequestResult,
IN EFI_STRING  ConfigRequestHdr 
)

Check whether need to add the altcfg string. if need to add, add the altcfg string.

Parameters
RequestResultThe request result string.
ConfigRequestHdrThe request head info. <ConfigHdr> format.

Definition at line 459 of file DriverSample.c.

◆ CreateAltCfgString()

EFI_STRING CreateAltCfgString ( IN EFI_STRING  Result,
IN EFI_STRING  ConfigHdr,
IN UINTN  Offset,
IN UINTN  Width 
)

Create altcfg string.

Parameters
ResultThe request result string.
ConfigHdrThe request head info. <ConfigHdr> format.
OffsetThe offset of the parameter int he structure.
WidthThe width of the parameter.
Return values
Thestring with altcfg info append at the end.

Definition at line 381 of file DriverSample.c.

◆ DriverCallback()

EFI_STATUS EFIAPI DriverCallback ( 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 
)

This function processes the results of changes in configuration.

Parameters
ThisPoints to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
ActionSpecifies the type of action taken by the browser.
QuestionIdA unique value which is sent to the original exporting driver so that it can identify the type of data to expect.
TypeThe type of value for the question.
ValueA pointer to the data being sent to the original exporting driver.
ActionRequestOn return, points to the action requested by the callback function.
Return values
EFI_SUCCESSThe callback successfully handled the action.
EFI_OUT_OF_RESOURCESNot enough storage is available to hold the variable and its data.
EFI_DEVICE_ERRORThe variable could not be saved.
EFI_UNSUPPORTEDThe specified Action is not supported by the callback.

Definition at line 1106 of file DriverSample.c.

◆ DriverSampleInit()

EFI_STATUS EFIAPI DriverSampleInit ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

Main entry for this driver.

Parameters
ImageHandleImage handle this driver.
SystemTablePointer to SystemTable.
Return values
EFI_SUCESSThis function always complete successfully.

Definition at line 1741 of file DriverSample.c.

◆ DriverSampleUnload()

EFI_STATUS EFIAPI DriverSampleUnload ( IN EFI_HANDLE  ImageHandle)

Unloads the application and its installed protocol.

Parameters
[in]ImageHandleHandle that identifies the image to be unloaded.
Return values
EFI_SUCCESSThe image has been unloaded.

Definition at line 2239 of file DriverSample.c.

◆ ExtractConfig()

EFI_STATUS EFIAPI ExtractConfig ( IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL This,
IN CONST EFI_STRING  Request,
OUT EFI_STRING *  Progress,
OUT EFI_STRING *  Results 
)

This function allows a caller to extract the current configuration for one or more named elements from the target driver.

Parameters
ThisPoints to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
RequestA null-terminated Unicode string in <ConfigRequest> format.
ProgressOn 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.
ResultsA 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.
Return values
EFI_SUCCESSThe Results is filled with the requested values.
EFI_OUT_OF_RESOURCESNot enough memory to store the results.
EFI_INVALID_PARAMETERRequest is illegal syntax, or unknown name.
EFI_NOT_FOUNDRouting data doesn't match any storage in this driver.

Definition at line 590 of file DriverSample.c.

◆ GetValueOfNumber()

EFI_STATUS GetValueOfNumber ( IN EFI_STRING  StringPtr,
OUT UINT8 **  Number,
OUT UINTN Len 
)

Get the value of <Number> in <BlockConfig> format, i.e. the value of OFFSET or WIDTH or VALUE. <BlockConfig> ::= 'OFFSET='<Number>&'WIDTH='<Number>&'VALUE'=<Number>

This is a internal function.

Parameters
StringPtrString in <BlockConfig> format and points to the first character of <Number>.
NumberThe output value. Caller takes the responsibility to free memory.
LenLength of the <Number>, in characters.
Return values
EFI_OUT_OF_RESOURCESInsufficient resources to store neccessary structures.
EFI_SUCCESSValue of <Number> is outputted in Number successfully.

Definition at line 301 of file DriverSample.c.

◆ InternalStartMonitor()

EFI_STATUS EFIAPI InternalStartMonitor ( VOID  )

Function to start monitoring for CTRL-C using SimpleTextInputEx.

Return values
EFI_SUCCESSThe feature is enabled.
EFI_OUT_OF_RESOURCESThere is not enough mnemory available.

Definition at line 134 of file DriverSample.c.

◆ InternalStopMonitor()

EFI_STATUS EFIAPI InternalStopMonitor ( VOID  )

Function to stop monitoring for CTRL-C using SimpleTextInputEx.

Return values
EFI_SUCCESSThe feature is enabled.
EFI_OUT_OF_RESOURCESThere is not enough mnemory available.

Definition at line 195 of file DriverSample.c.

◆ LoadNameValueNames()

EFI_STATUS LoadNameValueNames ( IN DRIVER_SAMPLE_PRIVATE_DATA PrivateData)

Update names of Name/Value storage to current language.

Parameters
PrivateDataPoints to the driver private data.
Return values
EFI_SUCCESSAll names are successfully updated.
EFI_NOT_FOUNDFailed to get Name from HII database.

Definition at line 258 of file DriverSample.c.

◆ NotificationFunction()

EFI_STATUS EFIAPI NotificationFunction ( IN EFI_KEY_DATA KeyData)

Notification function for keystrokes.

Parameters
[in]KeyDataThe key that was pressed.
Return values
EFI_SUCCESSThe operation was successful.

Definition at line 117 of file DriverSample.c.

◆ RouteConfig()

EFI_STATUS EFIAPI RouteConfig ( IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL This,
IN CONST EFI_STRING  Configuration,
OUT EFI_STRING *  Progress 
)

This function processes the results of changes in configuration.

Parameters
ThisPoints to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
ConfigurationA null-terminated Unicode string in <ConfigResp> format.
ProgressA 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.
Return values
EFI_SUCCESSThe Results is processed successfully.
EFI_INVALID_PARAMETERConfiguration is NULL.
EFI_NOT_FOUNDRouting data doesn't match any storage in this driver.

Definition at line 865 of file DriverSample.c.

◆ SetArrayData()

VOID SetArrayData ( IN VOID Array,
IN UINT8  Type,
IN UINTN  Index,
IN UINT64  Value 
)

Set value of a data element in an Array by its Index.

Parameters
ArrayThe data array.
TypeType of the data in this array.
IndexZero based index for data in this array.
ValueThe value to be set.

Definition at line 77 of file DriverSample.c.

Variable Documentation

◆ DriverHandle

EFI_HANDLE DriverHandle[2] = { NULL, NULL }

Definition at line 19 of file DriverSample.c.

◆ mEvent

EFI_EVENT mEvent

Definition at line 21 of file DriverSample.c.

◆ mHiiVendorDevicePath0

HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath0
Initial value:
= {
{
{
{
(UINT8)(sizeof (VENDOR_DEVICE_PATH)),
(UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
DRIVER_SAMPLE_FORMSET_GUID
},
{
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
(UINT8)(END_DEVICE_PATH_LENGTH),
(UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
}
}
}
#define HARDWARE_DEVICE_PATH
Definition: DevicePath.h:68
#define HW_VENDOR_DP
Definition: DevicePath.h:133

Definition at line 23 of file DriverSample.c.

◆ mHiiVendorDevicePath1

HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath1
Initial value:
= {
{
{
{
(UINT8)(sizeof (VENDOR_DEVICE_PATH)),
(UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
DRIVER_SAMPLE_INVENTORY_GUID
},
{
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
(UINT8)(END_DEVICE_PATH_LENGTH),
(UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
}
}
}

Definition at line 45 of file DriverSample.c.

◆ mPrivateData

Definition at line 20 of file DriverSample.c.

◆ MyEfiBitVar

CHAR16 MyEfiBitVar[] = L"MyEfiBitVar"

Definition at line 16 of file DriverSample.c.

◆ MyEfiUnionVar

CHAR16 MyEfiUnionVar[] = L"MyEfiUnionVar"

Definition at line 17 of file DriverSample.c.

◆ MyEfiVar

CHAR16 MyEfiVar[] = L"MyEfiVar"

Definition at line 15 of file DriverSample.c.

◆ VariableName

CHAR16 VariableName[] = L"MyIfrNVData"

Definition at line 14 of file DriverSample.c.