blob: beaaca0d57e28c32d5c3534ce49611530cf1ad7d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#pragma once
#include <AK/Lock.h>
#include <AK/RetainPtr.h>
#include <Kernel/DiskDevice.h>
#include "IRQHandler.h"
class IDEDiskDevice final : public IRQHandler, public DiskDevice {
public:
static RetainPtr<IDEDiskDevice> create();
virtual ~IDEDiskDevice() override;
// ^DiskDevice
virtual unsigned block_size() const override;
virtual bool read_block(unsigned index, byte*) const override;
virtual bool write_block(unsigned index, const byte*) override;
protected:
IDEDiskDevice();
private:
// ^IRQHandler
virtual void handle_irq() override;
// ^DiskDevice
virtual const char* class_name() const override;
struct CHS {
dword cylinder;
word head;
word sector;
};
CHS lba_to_chs(dword) const;
void initialize();
bool wait_for_irq();
bool read_sectors(dword start_sector, word count, byte* buffer);
bool write_sectors(dword start_sector, word count, const byte* data);
Lock m_lock;
word m_cylinders { 0 };
word m_heads { 0 };
word m_sectors_per_track { 0 };
volatile bool m_interrupted { false };
volatile byte m_device_error { 0 };
};
|