Browse Source

[efi] Generalise EFI entropy generation to non-x86 CPUs

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
57d0ea7c46

+ 0
- 1
src/arch/x86/include/bits/errfile.h View File

53
 
53
 
54
 #define ERRFILE_cpuid_cmd      ( ERRFILE_ARCH | ERRFILE_OTHER | 0x00000000 )
54
 #define ERRFILE_cpuid_cmd      ( ERRFILE_ARCH | ERRFILE_OTHER | 0x00000000 )
55
 #define ERRFILE_cpuid_settings ( ERRFILE_ARCH | ERRFILE_OTHER | 0x00010000 )
55
 #define ERRFILE_cpuid_settings ( ERRFILE_ARCH | ERRFILE_OTHER | 0x00010000 )
56
-#define ERRFILE_efi_entropy    ( ERRFILE_ARCH | ERRFILE_OTHER | 0x00020000 )
57
 
56
 
58
 /** @} */
57
 /** @} */
59
 
58
 

+ 1
- 0
src/include/ipxe/errfile.h View File

351
 #define ERRFILE_efi_usb		      ( ERRFILE_OTHER | 0x004b0000 )
351
 #define ERRFILE_efi_usb		      ( ERRFILE_OTHER | 0x004b0000 )
352
 #define ERRFILE_efi_fbcon	      ( ERRFILE_OTHER | 0x004c0000 )
352
 #define ERRFILE_efi_fbcon	      ( ERRFILE_OTHER | 0x004c0000 )
353
 #define ERRFILE_efi_local	      ( ERRFILE_OTHER | 0x004d0000 )
353
 #define ERRFILE_efi_local	      ( ERRFILE_OTHER | 0x004d0000 )
354
+#define ERRFILE_efi_entropy	      ( ERRFILE_OTHER | 0x004e0000 )
354
 
355
 
355
 /** @} */
356
 /** @} */
356
 
357
 

src/arch/x86/interface/efi/efi_entropy.c → src/interface/efi/efi_entropy.c View File

26
 #include <errno.h>
26
 #include <errno.h>
27
 #include <ipxe/entropy.h>
27
 #include <ipxe/entropy.h>
28
 #include <ipxe/crc32.h>
28
 #include <ipxe/crc32.h>
29
+#include <ipxe/profile.h>
29
 #include <ipxe/efi/efi.h>
30
 #include <ipxe/efi/efi.h>
30
 #include <ipxe/efi/Protocol/Rng.h>
31
 #include <ipxe/efi/Protocol/Rng.h>
31
 
32
 
104
 /**
105
 /**
105
  * Wait for a timer tick
106
  * Wait for a timer tick
106
  *
107
  *
107
- * @ret low		TSC low-order bits, or negative error
108
+ * @ret low		CPU profiling low-order bits, or negative error
108
  */
109
  */
109
 static int efi_entropy_tick ( void ) {
110
 static int efi_entropy_tick ( void ) {
110
 	EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
111
 	EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
111
 	UINTN index;
112
 	UINTN index;
112
 	uint16_t low;
113
 	uint16_t low;
113
-	uint32_t discard_d;
114
 	EFI_STATUS efirc;
114
 	EFI_STATUS efirc;
115
 	int rc;
115
 	int rc;
116
 
116
 
129
 		return rc;
129
 		return rc;
130
 	}
130
 	}
131
 
131
 
132
-	/* Get current TSC low-order bits */
133
-	__asm__ __volatile__ ( "rdtsc" : "=a" ( low ), "=d" ( discard_d ) );
132
+	/* Get current CPU profiling timestamp low-order bits */
133
+	low = profile_timestamp();
134
 
134
 
135
 	return low;
135
 	return low;
136
 }
136
 }

Loading…
Cancel
Save