Kernel: ATA now uses irqs instead of polling
Reading is now much slower at ~500 kB/s it was around 3 MB/s.
This is probably mostly due semaphore blocking taking atleast
until next reschedule (1 ms itervals). This will be a problem
as long as we are using only single processor.
I could try to use {READ/WRITE}_MULTIPLE commands, but since
most of the disk reads are 2 sectors (inode block size) this
will at most double the speed.
Most efficient speed up would of course be caching disk access
data and inodes overall.
This commit is contained in:
68
kernel/include/kernel/Storage/ATABus.h
Normal file
68
kernel/include/kernel/Storage/ATABus.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
#include <BAN/Errors.h>
|
||||
#include <kernel/Semaphore.h>
|
||||
#include <kernel/SpinLock.h>
|
||||
#include <kernel/Storage/ATAController.h>
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
|
||||
class ATADevice;
|
||||
|
||||
class ATABus
|
||||
{
|
||||
public:
|
||||
enum class DeviceType
|
||||
{
|
||||
None,
|
||||
ATA,
|
||||
ATAPI,
|
||||
};
|
||||
|
||||
public:
|
||||
static ATABus* create(ATAController*, uint16_t base, uint16_t ctrl, uint8_t irq);
|
||||
|
||||
BAN::ErrorOr<void> read(ATADevice*, uint64_t, uint8_t, uint8_t*);
|
||||
BAN::ErrorOr<void> write(ATADevice*, uint64_t, uint8_t, const uint8_t*);
|
||||
|
||||
ATAController* controller() { return m_controller; }
|
||||
|
||||
void on_irq();
|
||||
|
||||
private:
|
||||
ATABus(ATAController* controller, uint16_t base, uint16_t ctrl)
|
||||
: m_controller(controller)
|
||||
, m_base(base)
|
||||
, m_ctrl(ctrl)
|
||||
{}
|
||||
void initialize(uint8_t irq);
|
||||
|
||||
void select_device(const ATADevice*);
|
||||
DeviceType identify(const ATADevice*, uint16_t*);
|
||||
|
||||
void block_until_irq();
|
||||
uint8_t device_index(const ATADevice*) const;
|
||||
|
||||
uint8_t io_read(uint16_t);
|
||||
void io_write(uint16_t, uint8_t);
|
||||
void read_buffer(uint16_t, uint16_t*, size_t);
|
||||
void write_buffer(uint16_t, const uint16_t*, size_t);
|
||||
BAN::ErrorOr<void> wait(bool);
|
||||
BAN::Error error();
|
||||
|
||||
private:
|
||||
ATAController* m_controller;
|
||||
const uint16_t m_base;
|
||||
const uint16_t m_ctrl;
|
||||
SpinLock m_lock;
|
||||
Semaphore m_semaphore;
|
||||
|
||||
bool m_has_got_irq { false };
|
||||
|
||||
ATADevice* m_devices[2] { nullptr, nullptr };
|
||||
|
||||
friend class ATAController;
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user