mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:07:36 +00:00
Kernel: Harvest randomness from various drivers
Random now gets entropy from the following drivers: - KeyboardDevice - PATAChannel - PS2MouseDevice - E1000NetworkAdapter - RTL8139NetworkAdapter Of these devices, PS2MouseDevice and PATAChannel provide the vast majority of the entropy.
This commit is contained in:
parent
2e8cfe5435
commit
af0b2d1d86
12 changed files with 71 additions and 7 deletions
|
@ -204,6 +204,9 @@ void E1000NetworkAdapter::handle_irq(const RegisterState&)
|
|||
out32(REG_INTERRUPT_MASK_CLEAR, 0xffffffff);
|
||||
|
||||
u32 status = in32(REG_INTERRUPT_CAUSE_READ);
|
||||
|
||||
m_entropy_source.add_random_event(status);
|
||||
|
||||
if (status & 4) {
|
||||
u32 flags = in32(REG_CTRL);
|
||||
out32(REG_CTRL, flags | ECTRL_SLU);
|
||||
|
|
|
@ -28,11 +28,12 @@
|
|||
|
||||
#include <AK/NonnullOwnPtrVector.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <Kernel/IO.h>
|
||||
#include <Kernel/Interrupts/IRQHandler.h>
|
||||
#include <Kernel/Net/NetworkAdapter.h>
|
||||
#include <Kernel/PCI/Access.h>
|
||||
#include <Kernel/PCI/Device.h>
|
||||
#include <Kernel/IO.h>
|
||||
#include <Kernel/Random.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
|
@ -103,6 +104,7 @@ private:
|
|||
u8 m_interrupt_line { 0 };
|
||||
bool m_has_eeprom { false };
|
||||
bool m_use_mmio { false };
|
||||
EntropySource m_entropy_source;
|
||||
|
||||
static const size_t number_of_rx_descriptors = 32;
|
||||
static const size_t number_of_tx_descriptors = 8;
|
||||
|
|
|
@ -184,6 +184,8 @@ void RTL8139NetworkAdapter::handle_irq(const RegisterState&)
|
|||
int status = in16(REG_ISR);
|
||||
out16(REG_ISR, status);
|
||||
|
||||
m_entropy_source.add_random_event(status);
|
||||
|
||||
#ifdef RTL8139_DEBUG
|
||||
klog() << "RTL8139NetworkAdapter::handle_irq status=0x" << String::format("%x", status);
|
||||
#endif
|
||||
|
|
|
@ -27,10 +27,11 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <Kernel/IO.h>
|
||||
#include <Kernel/Net/NetworkAdapter.h>
|
||||
#include <Kernel/PCI/Access.h>
|
||||
#include <Kernel/PCI/Device.h>
|
||||
#include <Kernel/IO.h>
|
||||
#include <Kernel/Random.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
|
@ -73,5 +74,6 @@ private:
|
|||
u8 m_tx_next_buffer { 0 };
|
||||
OwnPtr<Region> m_packet_buffer;
|
||||
bool m_link_up { false };
|
||||
EntropySource m_entropy_source;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue