Kernel: Add support for ATA CHS addressing and cleanup code

I thought that I had an PC without LBA support so I implement support
for CHS. Turns out that my ATA device detection was broken and was no
device on that port and initialize data was just garbage.

Now that I added CHS, I guess I should just keep it in :)

Both ATA read and write are now combined into a single function to avoid
code duplication.
This commit is contained in:
2024-11-19 00:28:43 +02:00
parent 1de50a2a94
commit c07fd265f0
6 changed files with 75 additions and 56 deletions

View File

@@ -14,7 +14,6 @@ namespace Kernel
Ext2_NoInodes,
Storage_Boundaries,
Storage_GPTHeader,
ATA_NoLBA,
ATA_AMNF,
ATA_TKZNF,
ATA_ABRT,

View File

@@ -35,6 +35,8 @@ namespace Kernel
{}
BAN::ErrorOr<void> initialize();
BAN::ErrorOr<void> send_command(ATADevice&, uint64_t lba, uint64_t sector_count, bool write);
void select_device(bool is_secondary);
BAN::ErrorOr<DeviceType> identify(bool is_secondary, BAN::Span<uint16_t> buffer);

View File

@@ -26,11 +26,12 @@ namespace Kernel
uint32_t words_per_sector() const { return m_sector_words; }
uint64_t sector_count() const { return m_lba_count; }
bool has_lba() const { return m_has_lba; }
BAN::StringView model() const { return m_model; }
BAN::StringView name() const { return m_name; }
BAN::StringView name() const override { return m_name; }
virtual dev_t rdev() const override { return m_rdev; }
dev_t rdev() const override { return m_rdev; }
protected:
ATABaseDevice();
@@ -42,6 +43,7 @@ namespace Kernel
uint32_t m_command_set;
uint32_t m_sector_words;
uint64_t m_lba_count;
bool m_has_lba;
char m_model[41];
char m_name[4] {};