]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[efi] Generalise EFI entropy generation to non-x86 CPUs
authorMichael Brown <mcb30@ipxe.org>
Wed, 4 May 2016 13:13:44 +0000 (14:13 +0100)
committerMichael Brown <mcb30@ipxe.org>
Wed, 4 May 2016 13:34:24 +0000 (14:34 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/x86/include/bits/errfile.h
src/include/ipxe/errfile.h
src/interface/efi/efi_entropy.c [moved from src/arch/x86/interface/efi/efi_entropy.c with 96% similarity]

index 9eb4b54881e6b94e3883ea6a95b85192ddd48409..42792242d9626f7464010acd733cda5ab79cb4fc 100644 (file)
@@ -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 )
 
 /** @} */
 
index 4681567b91017c92b424755c8c2b0b56c21acf5f..2cd9fb5b12457d68537ed5d92c4b1bd144961a87 100644 (file)
@@ -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 )
 
 /** @} */
 
similarity index 96%
rename from src/arch/x86/interface/efi/efi_entropy.c
rename to src/interface/efi/efi_entropy.c
index a54bd12e641949c8bd7700b633a3768be112cc0a..881c4c9a221e3205f4cbd8e0786eda30ededc84a 100644 (file)
@@ -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;
 }