mirror of https://github.com/ipxe/ipxe.git
[rng] Allow entropy_enable() to return an error
Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/6/head
parent
66f200bdac
commit
196f0bb081
|
@ -165,12 +165,15 @@ static void rtc_disable_int ( void ) {
|
||||||
/**
|
/**
|
||||||
* Enable entropy gathering
|
* Enable entropy gathering
|
||||||
*
|
*
|
||||||
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
static void rtc_entropy_enable ( void ) {
|
static int rtc_entropy_enable ( void ) {
|
||||||
|
|
||||||
rtc_hook_isr();
|
rtc_hook_isr();
|
||||||
enable_irq ( RTC_IRQ );
|
enable_irq ( RTC_IRQ );
|
||||||
rtc_enable_int();
|
rtc_enable_int();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -422,7 +422,8 @@ int get_entropy_input_tmp ( unsigned int num_samples, uint8_t *tmp,
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* Enable entropy gathering */
|
/* Enable entropy gathering */
|
||||||
entropy_enable();
|
if ( ( rc = entropy_enable() ) != 0 )
|
||||||
|
return rc;
|
||||||
|
|
||||||
/* Perform mandatory startup tests, if not yet performed */
|
/* Perform mandatory startup tests, if not yet performed */
|
||||||
for ( ; startup_tested < startup_test_count() ; startup_tested++ ) {
|
for ( ; startup_tested < startup_test_count() ; startup_tested++ ) {
|
||||||
|
|
|
@ -61,8 +61,9 @@ typedef uint8_t entropy_sample_t;
|
||||||
/**
|
/**
|
||||||
* Enable entropy gathering
|
* Enable entropy gathering
|
||||||
*
|
*
|
||||||
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
void entropy_enable ( void );
|
int entropy_enable ( void );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable entropy gathering
|
* Disable entropy gathering
|
||||||
|
|
|
@ -19,9 +19,10 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
#define ENTROPY_PREFIX_null __null_
|
#define ENTROPY_PREFIX_null __null_
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline __always_inline void
|
static inline __always_inline int
|
||||||
ENTROPY_INLINE ( null, entropy_enable ) ( void ) {
|
ENTROPY_INLINE ( null, entropy_enable ) ( void ) {
|
||||||
/* Do nothing */
|
/* Do nothing */
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline __always_inline void
|
static inline __always_inline void
|
||||||
|
|
|
@ -48,7 +48,8 @@ static void entropy_sample_test_exec ( void ) {
|
||||||
for ( i = 0 ; i < ( SAMPLE_COUNT / SAMPLE_BLOCKSIZE ) ; i++ ) {
|
for ( i = 0 ; i < ( SAMPLE_COUNT / SAMPLE_BLOCKSIZE ) ; i++ ) {
|
||||||
|
|
||||||
/* Collect one block of samples */
|
/* Collect one block of samples */
|
||||||
entropy_enable();
|
rc = entropy_enable();
|
||||||
|
ok ( rc == 0 );
|
||||||
for ( j = 0 ; j < SAMPLE_BLOCKSIZE ; j++ ) {
|
for ( j = 0 ; j < SAMPLE_BLOCKSIZE ; j++ ) {
|
||||||
rc = get_noise ( &samples[j] );
|
rc = get_noise ( &samples[j] );
|
||||||
ok ( rc == 0 );
|
ok ( rc == 0 );
|
||||||
|
|
Loading…
Reference in New Issue