mirror of
https://github.com/ipxe/ipxe
synced 2025-12-09 02:40:27 +03:00
[efi] Generalise EFI entropy generation to non-x86 CPUs
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -53,7 +53,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#define ERRFILE_cpuid_cmd ( ERRFILE_ARCH | ERRFILE_OTHER | 0x00000000 )
|
||||
#define ERRFILE_cpuid_settings ( ERRFILE_ARCH | ERRFILE_OTHER | 0x00010000 )
|
||||
#define ERRFILE_efi_entropy ( ERRFILE_ARCH | ERRFILE_OTHER | 0x00020000 )
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -351,6 +351,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#define ERRFILE_efi_usb ( ERRFILE_OTHER | 0x004b0000 )
|
||||
#define ERRFILE_efi_fbcon ( ERRFILE_OTHER | 0x004c0000 )
|
||||
#define ERRFILE_efi_local ( ERRFILE_OTHER | 0x004d0000 )
|
||||
#define ERRFILE_efi_entropy ( ERRFILE_OTHER | 0x004e0000 )
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#include <errno.h>
|
||||
#include <ipxe/entropy.h>
|
||||
#include <ipxe/crc32.h>
|
||||
#include <ipxe/profile.h>
|
||||
#include <ipxe/efi/efi.h>
|
||||
#include <ipxe/efi/Protocol/Rng.h>
|
||||
|
||||
@@ -104,13 +105,12 @@ static void efi_entropy_disable ( void ) {
|
||||
/**
|
||||
* Wait for a timer tick
|
||||
*
|
||||
* @ret low TSC low-order bits, or negative error
|
||||
* @ret low CPU profiling low-order bits, or negative error
|
||||
*/
|
||||
static int efi_entropy_tick ( void ) {
|
||||
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
|
||||
UINTN index;
|
||||
uint16_t low;
|
||||
uint32_t discard_d;
|
||||
EFI_STATUS efirc;
|
||||
int rc;
|
||||
|
||||
@@ -129,8 +129,8 @@ static int efi_entropy_tick ( void ) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Get current TSC low-order bits */
|
||||
__asm__ __volatile__ ( "rdtsc" : "=a" ( low ), "=d" ( discard_d ) );
|
||||
/* Get current CPU profiling timestamp low-order bits */
|
||||
low = profile_timestamp();
|
||||
|
||||
return low;
|
||||
}
|
||||
Reference in New Issue
Block a user