diff options
author | Luke <luke.wilde@live.co.uk> | 2021-01-29 19:37:40 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-29 21:20:38 +0100 |
commit | 40de84ba67ca79d18859a7530993e34bef878907 (patch) | |
tree | 1cca2f332e5f89d6455d6ed20974ae70823a5953 /Kernel/Storage/IDEChannel.h | |
parent | f9b1a9e60cfd39fa71a8a5fd28a7b5ee8db0f6aa (diff) | |
download | serenity-40de84ba67ca79d18859a7530993e34bef878907.zip |
Kernel/Storage: Rewrite IDE disk detection and disk access
This replaces the current disk detection and disk access code with
code based on https://wiki.osdev.org/IDE
This allows the system to boot on VirtualBox with serial debugging
enabled and VMWare Player.
I believe there were several issues with the current code:
- It didn't utilise the last 8 bits of the LBA in 24-bit mode.
- {read,write}_sectors_with_dma was not setting the obsolete bits,
which according to OSdev wiki aren't used but should be set.
- The PIO and DMA methods were using slightly different copy
and pasted access code, which is now put into a single
function called "ata_access"
- PIO mode doesn't work. This doesn't fix that and should
be looked into in the future.
- The detection code was not checking for ATA/ATAPI.
- The detection code accidentally had cyls/heads/spt as 8-bit,
when they're 16-bit.
- The capabilities of the device were not considered. This is now
brought in and is currently used to check if the device supports
LBA. If not, use CHS.
Diffstat (limited to 'Kernel/Storage/IDEChannel.h')
-rw-r--r-- | Kernel/Storage/IDEChannel.h | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/Kernel/Storage/IDEChannel.h b/Kernel/Storage/IDEChannel.h index d138a18bba..edf60473f8 100644 --- a/Kernel/Storage/IDEChannel.h +++ b/Kernel/Storage/IDEChannel.h @@ -117,21 +117,37 @@ private: //^ IRQHandler virtual void handle_irq(const RegisterState&) override; + enum class LBAMode : u8 { + None, // CHS + TwentyEightBit, + FortyEightBit, + }; + + enum class Direction : u8 { + Read, + Write, + }; + void initialize(bool force_pio); void detect_disks(); + String channel_type_string() const; + + void try_disambiguate_error(); + void wait_until_not_busy(); - void start_request(AsyncBlockDeviceRequest&, bool, bool); + void start_request(AsyncBlockDeviceRequest&, bool, bool, u16); void complete_current_request(AsyncDeviceRequest::RequestResult); - void ata_read_sectors_with_dma(bool); - void ata_read_sectors(bool); + void ata_access(Direction, bool, u32, u8, u16, bool); + void ata_read_sectors_with_dma(bool, u16); + void ata_read_sectors(bool, u16); bool ata_do_read_sector(); - void ata_write_sectors_with_dma(bool); - void ata_write_sectors(bool); + void ata_write_sectors_with_dma(bool, u16); + void ata_write_sectors(bool, u16); void ata_do_write_sector(); // Data members - u8 m_channel_number { 0 }; // Channel number. 0 = master, 1 = slave + ChannelType m_channel_type { ChannelType::Primary }; volatile u8 m_device_error { 0 }; |