TianoCore EDK2 master
Loading...
Searching...
No Matches
VirtioRng.c File Reference

Go to the source code of this file.

Functions

STATIC EFI_STATUS EFIAPI VirtioRngGetInfo (IN EFI_RNG_PROTOCOL *This, IN OUT UINTN *RNGAlgorithmListSize, OUT EFI_RNG_ALGORITHM *RNGAlgorithmList)
 
STATIC EFI_STATUS EFIAPI VirtioRngGetRNG (IN EFI_RNG_PROTOCOL *This, IN EFI_RNG_ALGORITHM *RNGAlgorithm OPTIONAL, IN UINTN RNGValueLength, OUT UINT8 *RNGValue)
 
STATIC EFI_STATUS EFIAPI VirtioRngInit (IN OUT VIRTIO_RNG_DEV *Dev)
 
STATIC VOID EFIAPI VirtioRngUninit (IN OUT VIRTIO_RNG_DEV *Dev)
 
STATIC VOID EFIAPI VirtioRngExitBoot (IN EFI_EVENT Event, IN VOID *Context)
 
STATIC EFI_STATUS EFIAPI VirtioRngDriverBindingSupported (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE DeviceHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
STATIC EFI_STATUS EFIAPI VirtioRngDriverBindingStart (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE DeviceHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
STATIC EFI_STATUS EFIAPI VirtioRngDriverBindingStop (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE DeviceHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
 
STATIC EFI_STATUS EFIAPI VirtioRngGetDriverName (IN EFI_COMPONENT_NAME_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
 
STATIC EFI_STATUS EFIAPI VirtioRngGetDeviceName (IN EFI_COMPONENT_NAME_PROTOCOL *This, IN EFI_HANDLE DeviceHandle, IN EFI_HANDLE ChildHandle, IN CHAR8 *Language, OUT CHAR16 **ControllerName)
 
EFI_STATUS EFIAPI VirtioRngEntryPoint (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

STATIC EFI_DRIVER_BINDING_PROTOCOL gDriverBinding
 
STATIC EFI_UNICODE_STRING_TABLE mDriverNameTable []
 
STATIC EFI_COMPONENT_NAME_PROTOCOL gComponentName
 
STATIC EFI_COMPONENT_NAME2_PROTOCOL gComponentName2
 

Detailed Description

This driver produces EFI_RNG_PROTOCOL instances for virtio-rng devices.

The implementation is based on OvmfPkg/VirtioScsiDxe/VirtioScsi.c

Copyright (C) 2012, Red Hat, Inc. Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.
Copyright (c) 2017, AMD Inc, All rights reserved.

This driver:

Copyright (C) 2016, Linaro Ltd.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file VirtioRng.c.

Function Documentation

◆ VirtioRngDriverBindingStart()

STATIC EFI_STATUS EFIAPI VirtioRngDriverBindingStart ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  DeviceHandle,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Definition at line 523 of file VirtioRng.c.

◆ VirtioRngDriverBindingStop()

STATIC EFI_STATUS EFIAPI VirtioRngDriverBindingStop ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  DeviceHandle,
IN UINTN  NumberOfChildren,
IN EFI_HANDLE ChildHandleBuffer 
)

Definition at line 608 of file VirtioRng.c.

◆ VirtioRngDriverBindingSupported()

STATIC EFI_STATUS EFIAPI VirtioRngDriverBindingSupported ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  DeviceHandle,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Definition at line 475 of file VirtioRng.c.

◆ VirtioRngEntryPoint()

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

Definition at line 744 of file VirtioRng.c.

◆ VirtioRngExitBoot()

STATIC VOID EFIAPI VirtioRngExitBoot ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Definition at line 437 of file VirtioRng.c.

◆ VirtioRngGetDeviceName()

STATIC EFI_STATUS EFIAPI VirtioRngGetDeviceName ( IN EFI_COMPONENT_NAME_PROTOCOL This,
IN EFI_HANDLE  DeviceHandle,
IN EFI_HANDLE  ChildHandle,
IN CHAR8 *  Language,
OUT CHAR16 **  ControllerName 
)

Definition at line 714 of file VirtioRng.c.

◆ VirtioRngGetDriverName()

STATIC EFI_STATUS EFIAPI VirtioRngGetDriverName ( IN EFI_COMPONENT_NAME_PROTOCOL This,
IN CHAR8 *  Language,
OUT CHAR16 **  DriverName 
)

Definition at line 696 of file VirtioRng.c.

◆ VirtioRngGetInfo()

STATIC EFI_STATUS EFIAPI VirtioRngGetInfo ( IN EFI_RNG_PROTOCOL This,
IN OUT UINTN RNGAlgorithmListSize,
OUT EFI_RNG_ALGORITHM RNGAlgorithmList 
)

Returns information about the random number generation implementation.

Parameters
[in]ThisA pointer to the EFI_RNG_PROTOCOL instance.
[in,out]RNGAlgorithmListSizeOn input, the size in bytes of RNGAlgorithmList. On output with a return code of EFI_SUCCESS, the size in bytes of the data returned in RNGAlgorithmList. On output with a return code of EFI_BUFFER_TOO_SMALL, the size of RNGAlgorithmList required to obtain the list.
[out]RNGAlgorithmListA caller-allocated memory buffer filled by the driver with one EFI_RNG_ALGORITHM element for each supported RNG algorithm. The list must not change across multiple calls to the same driver. The first algorithm in the list is the default algorithm for the driver.
Return values
EFI_SUCCESSThe RNG algorithm list was returned successfully.
EFI_UNSUPPORTEDThe services is not supported by this driver.
EFI_DEVICE_ERRORThe list of algorithms could not be retrieved due to a hardware or firmware error.
EFI_INVALID_PARAMETEROne or more of the parameters are incorrect.
EFI_BUFFER_TOO_SMALLThe buffer RNGAlgorithmList is too small to hold the result.

Definition at line 66 of file VirtioRng.c.

◆ VirtioRngGetRNG()

STATIC EFI_STATUS EFIAPI VirtioRngGetRNG ( IN EFI_RNG_PROTOCOL This,
IN EFI_RNG_ALGORITHM *RNGAlgorithm  OPTIONAL,
IN UINTN  RNGValueLength,
OUT UINT8 *  RNGValue 
)

Produces and returns an RNG value using either the default or specified RNG algorithm.

Parameters
[in]ThisA pointer to the EFI_RNG_PROTOCOL instance.
[in]RNGAlgorithmA pointer to the EFI_RNG_ALGORITHM that identifies the RNG algorithm to use. May be NULL in which case the function will use its default RNG algorithm.
[in]RNGValueLengthThe length in bytes of the memory buffer pointed to by RNGValue. The driver shall return exactly this numbers of bytes.
[out]RNGValueA caller-allocated memory buffer filled by the driver with the resulting RNG value.
Return values
EFI_SUCCESSThe RNG value was returned successfully.
EFI_UNSUPPORTEDThe algorithm specified by RNGAlgorithm is not supported by this driver.
EFI_DEVICE_ERRORAn RNG value could not be retrieved due to a hardware or firmware error.
EFI_NOT_READYThere is not enough random data available to satisfy the length requested by RNGValueLength.
EFI_INVALID_PARAMETERRNGValue is NULL or RNGValueLength is zero.

Definition at line 123 of file VirtioRng.c.

◆ VirtioRngInit()

STATIC EFI_STATUS EFIAPI VirtioRngInit ( IN OUT VIRTIO_RNG_DEV Dev)

Definition at line 240 of file VirtioRng.c.

◆ VirtioRngUninit()

STATIC VOID EFIAPI VirtioRngUninit ( IN OUT VIRTIO_RNG_DEV Dev)

Definition at line 414 of file VirtioRng.c.

Variable Documentation

◆ gComponentName

Initial value:
= {
&VirtioRngGetDriverName,
&VirtioRngGetDeviceName,
"eng"
}

Definition at line 691 of file VirtioRng.c.

◆ gComponentName2

Initial value:
= {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME)&VirtioRngGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)&VirtioRngGetDeviceName,
"en"
}
EFI_STATUS(EFIAPI * EFI_COMPONENT_NAME2_GET_DRIVER_NAME)(IN EFI_COMPONENT_NAME2_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
EFI_STATUS(EFIAPI * EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)(IN EFI_COMPONENT_NAME2_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language, OUT CHAR16 **ControllerName)

Definition at line 733 of file VirtioRng.c.

◆ gDriverBinding

Initial value:
= {
&VirtioRngDriverBindingSupported,
&VirtioRngDriverBindingStart,
&VirtioRngDriverBindingStop,
0x10,
NULL,
}
#define NULL
Definition: Base.h:319

Definition at line 666 of file VirtioRng.c.

◆ mDriverNameTable

STATIC EFI_UNICODE_STRING_TABLE mDriverNameTable[]
Initial value:
= {
{ "eng;en", L"Virtio Random Number Generator Driver" },
{ NULL, NULL }
}

Definition at line 685 of file VirtioRng.c.