mirror of
https://github.com/justinian/jsix.git
synced 2025-12-12 09:24:31 -08:00
Add block device management to device manager
This commit is contained in:
@@ -16,13 +16,3 @@ ahci_driver::register_device(pci_device *device)
|
||||
|
||||
ahci::hba &hba = m_devices.emplace(device);
|
||||
}
|
||||
|
||||
ahci::port *
|
||||
ahci_driver::find_disk()
|
||||
{
|
||||
for (auto &hba : m_devices) {
|
||||
ahci::port *d = hba.find_disk();
|
||||
if (d) return d;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -22,9 +22,6 @@ public:
|
||||
/// \arg device The PCI device to remove
|
||||
void unregister_device(pci_device *device);
|
||||
|
||||
/// Debug: find the first disk
|
||||
ahci::port * find_disk();
|
||||
|
||||
private:
|
||||
kutil::vector<ahci::hba> m_devices;
|
||||
};
|
||||
|
||||
@@ -57,6 +57,7 @@ void irq_cb(void *data)
|
||||
hba::hba(pci_device *device)
|
||||
{
|
||||
page_manager *pm = page_manager::get();
|
||||
device_manager &dm = device_manager::get();
|
||||
|
||||
uint32_t bar5 = device->get_bar(5);
|
||||
m_data = reinterpret_cast<hba_data *>(bar5 & ~0xfffull);
|
||||
@@ -83,6 +84,9 @@ hba::hba(pci_device *device)
|
||||
port &p = m_ports.emplace(i, kutil::offset_pointer(pd, 0x80 * i), impl);
|
||||
if (p.get_state() == port::state::active)
|
||||
needs_interrupt = true;
|
||||
|
||||
if (p.get_type() == sata_signature::sata_drive)
|
||||
dm.register_block_device(&p);
|
||||
}
|
||||
|
||||
if (needs_interrupt) {
|
||||
@@ -91,18 +95,6 @@ hba::hba(pci_device *device)
|
||||
}
|
||||
}
|
||||
|
||||
port *
|
||||
hba::find_disk()
|
||||
{
|
||||
for (auto &port : m_ports) {
|
||||
if (port.get_state() == port::state::active &&
|
||||
port.get_type() == sata_signature::sata_drive)
|
||||
return &port;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
hba::handle_interrupt()
|
||||
{
|
||||
|
||||
@@ -25,9 +25,6 @@ public:
|
||||
/// Interrupt handler.
|
||||
void handle_interrupt();
|
||||
|
||||
/// Debug: find the first disk
|
||||
port * find_disk();
|
||||
|
||||
private:
|
||||
pci_device *m_device;
|
||||
hba_data *m_data;
|
||||
|
||||
Reference in New Issue
Block a user