iPXE
|
RTC-based entropy source. More...
#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <biosint.h>
#include <pic8259.h>
#include <rtc.h>
#include <ipxe/cpuid.h>
#include <ipxe/entropy.h>
Go to the source code of this file.
Macros | |
#define | RTC_MAX_WAIT_MS 100 |
Maximum time to wait for an RTC interrupt, in milliseconds. More... | |
#define | RTC_CHECK_COUNT 3 |
Number of RTC interrupts to check for. More... | |
#define | rtc_flag __use_text16 ( rtc_flag ) |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
struct entropy_source rtc_entropy | __entropy_source (ENTROPY_NORMAL) |
RTC entropy source. More... | |
void | rtc_isr (void) |
RTC interrupt handler. More... | |
volatile uint8_t | __text16 (rtc_flag) |
Flag set by RTC interrupt handler. More... | |
static void | rtc_hook_isr (void) |
Hook RTC interrupt handler. More... | |
static void | rtc_unhook_isr (void) |
Unhook RTC interrupt handler. More... | |
static void | rtc_enable_int (void) |
Enable RTC interrupts. More... | |
static void | rtc_disable_int (void) |
Disable RTC interrupts. More... | |
static int | rtc_entropy_check (void) |
Check that entropy gathering is functional. More... | |
static int | rtc_entropy_enable (void) |
Enable entropy gathering. More... | |
static void | rtc_entropy_disable (void) |
Disable entropy gathering. More... | |
static int | rtc_get_noise (noise_sample_t *noise) |
Get noise sample. More... | |
Variables | |
static struct segoff | rtc_old_handler |
Previous RTC interrupt handler. More... | |
RTC-based entropy source.
Definition in file rtc_entropy.c.
#define RTC_MAX_WAIT_MS 100 |
Maximum time to wait for an RTC interrupt, in milliseconds.
Definition at line 45 of file rtc_entropy.c.
#define RTC_CHECK_COUNT 3 |
Number of RTC interrupts to check for.
Definition at line 48 of file rtc_entropy.c.
#define rtc_flag __use_text16 ( rtc_flag ) |
Definition at line 58 of file rtc_entropy.c.
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
struct entropy_source rtc_entropy __entropy_source | ( | ENTROPY_NORMAL | ) |
RTC entropy source.
void rtc_isr | ( | void | ) |
RTC interrupt handler.
Referenced by rtc_hook_isr(), and rtc_unhook_isr().
|
static |
Hook RTC interrupt handler.
Definition at line 64 of file rtc_entropy.c.
References __asm__(), __volatile__(), CMOS_ADDRESS, CMOS_DATA, hook_bios_interrupt(), RTC_INT, rtc_isr(), rtc_old_handler, RTC_STATUS_C, and TEXT16_CODE.
Referenced by rtc_entropy_enable().
|
static |
Unhook RTC interrupt handler.
Definition at line 99 of file rtc_entropy.c.
References assert(), rc, RTC_INT, rtc_isr(), rtc_old_handler, and unhook_bios_interrupt().
Referenced by rtc_entropy_disable(), and rtc_entropy_enable().
|
static |
Enable RTC interrupts.
Definition at line 111 of file rtc_entropy.c.
References CMOS_ADDRESS, CMOS_DATA, CMOS_DEFAULT_ADDRESS, CMOS_DISABLE_NMI, inb(), outb, RTC_STATUS_B, RTC_STATUS_B_PIE, and RTC_STATUS_C.
Referenced by rtc_entropy_enable().
|
static |
Disable RTC interrupts.
Definition at line 133 of file rtc_entropy.c.
References CMOS_ADDRESS, CMOS_DATA, CMOS_DEFAULT_ADDRESS, CMOS_DISABLE_NMI, inb(), outb, RTC_STATUS_B, and RTC_STATUS_B_PIE.
Referenced by rtc_entropy_disable(), and rtc_entropy_enable().
|
static |
Check that entropy gathering is functional.
rc | Return status code |
Definition at line 152 of file rtc_entropy.c.
References __asm__(), __volatile__(), count, DBGC, ETIMEDOUT, mdelay(), RTC_CHECK_COUNT, rtc_flag, and RTC_MAX_WAIT_MS.
Referenced by rtc_entropy_enable().
|
static |
Enable entropy gathering.
rc | Return status code |
Definition at line 187 of file rtc_entropy.c.
References CPUID_FEATURES_INTEL_EDX_TSC, DBGC, disable_irq, enable_irq, ENOTSUP, entropy_init(), features, MIN_ENTROPY, rc, rtc_disable_int(), rtc_enable_int(), rtc_entropy_check(), rtc_flag, rtc_hook_isr(), RTC_IRQ, rtc_unhook_isr(), and x86_features().
|
static |
Disable entropy gathering.
Definition at line 237 of file rtc_entropy.c.
References disable_irq, rtc_disable_int(), RTC_IRQ, and rtc_unhook_isr().
|
static |
Get noise sample.
noise | Noise sample |
rc | Return status code |
Definition at line 251 of file rtc_entropy.c.
References __asm__(), __volatile__(), and REAL_CODE.
|
static |
Previous RTC interrupt handler.
Definition at line 54 of file rtc_entropy.c.
Referenced by rtc_hook_isr(), and rtc_unhook_isr().