1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:57:43 +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:
Peter Elliott 2020-06-24 14:07:28 -06:00 committed by Andreas Kling
parent 2e8cfe5435
commit af0b2d1d86
12 changed files with 71 additions and 7 deletions

View file

@ -29,9 +29,9 @@
#include <Kernel/Devices/PATAChannel.h>
#include <Kernel/Devices/PATADiskDevice.h>
#include <Kernel/FileSystem/ProcFS.h>
#include <Kernel/IO.h>
#include <Kernel/Process.h>
#include <Kernel/VM/MemoryManager.h>
#include <Kernel/IO.h>
namespace Kernel {
@ -186,6 +186,9 @@ void PATAChannel::handle_irq(const RegisterState&)
// FIXME: We might get random interrupts due to malfunctioning hardware, so we should check that we actually requested something to happen.
u8 status = m_io_base.offset(ATA_REG_STATUS).in<u8>();
m_entropy_source.add_random_event(status);
if (status & ATA_SR_ERR) {
print_ide_status(status);
m_device_error = m_io_base.offset(ATA_REG_ERROR).in<u8>();