summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiav A <liavalb@gmail.com>2023-03-07 22:28:15 +0200
committerJelle Raaijmakers <jelle@gmta.nl>2023-03-08 01:41:51 +0100
commitdb72467e3150b974beed39bb7f12d36e2a95f956 (patch)
treec4983a20cd37e9b5d38a588c2afbe60d0d76670a
parent95b15e49010299902abd2aa65bcc71e4158b7326 (diff)
downloadserenity-db72467e3150b974beed39bb7f12d36e2a95f956.zip
Kernel: Remove ATAPI eject method from the AHCIPort class
We never actually used it. It never has been proved to work reliably, therefore it should be removed.
-rw-r--r--Kernel/Storage/ATA/AHCI/Port.cpp73
-rw-r--r--Kernel/Storage/ATA/AHCI/Port.h2
2 files changed, 0 insertions, 75 deletions
diff --git a/Kernel/Storage/ATA/AHCI/Port.cpp b/Kernel/Storage/ATA/AHCI/Port.cpp
index 416ada1946..33f6e787e9 100644
--- a/Kernel/Storage/ATA/AHCI/Port.cpp
+++ b/Kernel/Storage/ATA/AHCI/Port.cpp
@@ -194,79 +194,6 @@ void AHCIPort::recover_from_fatal_error()
m_interrupt_enable.clear();
}
-void AHCIPort::eject()
-{
- // FIXME: This operation (meant to be used on optical drives) doesn't work yet when I tested it on real hardware
- TODO();
-
- VERIFY(m_lock.is_locked());
- VERIFY(is_atapi_attached());
- VERIFY(is_operable());
- clear_sata_error_register();
-
- if (!spin_until_ready())
- return;
-
- auto unused_command_header = try_to_find_unused_command_header();
- VERIFY(unused_command_header.has_value());
- auto* command_list_entries = (volatile AHCI::CommandHeader*)m_command_list_region->vaddr().as_ptr();
- command_list_entries[unused_command_header.value()].ctba = m_command_table_pages[unused_command_header.value()]->paddr().get();
- command_list_entries[unused_command_header.value()].ctbau = 0;
- command_list_entries[unused_command_header.value()].prdbc = 0;
- command_list_entries[unused_command_header.value()].prdtl = 0;
-
- // Note: we must set the correct Dword count in this register. Real hardware
- // AHCI controllers do care about this field! QEMU doesn't care if we don't
- // set the correct CFL field in this register, real hardware will set an
- // handshake error bit in PxSERR register if CFL is incorrect.
- command_list_entries[unused_command_header.value()].attributes = (size_t)FIS::DwordCount::RegisterHostToDevice | AHCI::CommandHeaderAttributes::P | AHCI::CommandHeaderAttributes::C | AHCI::CommandHeaderAttributes::A;
-
- auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()]->paddr().page_base(), Memory::page_round_up(sizeof(AHCI::CommandTable)).value(), "AHCI Command Table"sv, Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::No).release_value();
- auto& command_table = *(volatile AHCI::CommandTable*)command_table_region->vaddr().as_ptr();
- memset(const_cast<u8*>(command_table.command_fis), 0, 64);
- auto& fis = *(volatile FIS::HostToDevice::Register*)command_table.command_fis;
- fis.header.fis_type = (u8)FIS::Type::RegisterHostToDevice;
- fis.command = ATA_CMD_PACKET;
-
- full_memory_barrier();
- memset(const_cast<u8*>(command_table.atapi_command), 0, 32);
-
- full_memory_barrier();
- command_table.atapi_command[0] = ATAPI_CMD_EJECT;
- command_table.atapi_command[1] = 0;
- command_table.atapi_command[2] = 0;
- command_table.atapi_command[3] = 0;
- command_table.atapi_command[4] = 0b10;
- command_table.atapi_command[5] = 0;
- command_table.atapi_command[6] = 0;
- command_table.atapi_command[7] = 0;
- command_table.atapi_command[8] = 0;
- command_table.atapi_command[9] = 0;
- command_table.atapi_command[10] = 0;
- command_table.atapi_command[11] = 0;
- fis.device = 0;
- fis.header.port_muliplier = fis.header.port_muliplier | (u8)FIS::HeaderAttributes::C;
-
- // The below loop waits until the port is no longer busy before issuing a new command
- if (!spin_until_ready())
- return;
-
- full_memory_barrier();
- mark_command_header_ready_to_process(unused_command_header.value());
-
- full_memory_barrier();
-
- while (1) {
- if (m_port_registers.serr != 0) {
- dbgln_if(AHCI_DEBUG, "AHCI Port {}: Eject Drive failed, SError {:#08x}", representative_port_index(), (u32)m_port_registers.serr);
- try_disambiguate_sata_error();
- VERIFY_NOT_REACHED();
- }
- }
- dbgln("AHCI Port {}: Eject Drive", representative_port_index());
- return;
-}
-
bool AHCIPort::reset()
{
MutexLocker locker(m_lock);
diff --git a/Kernel/Storage/ATA/AHCI/Port.h b/Kernel/Storage/ATA/AHCI/Port.h
index a43166ac0b..6b501bf26b 100644
--- a/Kernel/Storage/ATA/AHCI/Port.h
+++ b/Kernel/Storage/ATA/AHCI/Port.h
@@ -60,8 +60,6 @@ private:
ALWAYS_INLINE void clear_sata_error_register() const;
- void eject();
-
char const* try_disambiguate_sata_status();
void try_disambiguate_sata_error();