mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:27:43 +00:00
Kernel: Make IDEChannel Ref-counted
Technically not supported by the original ATA specification, IDE hot swapping is still in practice possible, so the only sane way to start support it is with ref-counting the IDEChannel object so if we remove a PATADiskDevice, it's not gone with it.
This commit is contained in:
parent
531037db7e
commit
dfb6b296cf
5 changed files with 11 additions and 9 deletions
|
@ -45,9 +45,9 @@ namespace Kernel {
|
||||||
#define PCI_Mass_Storage_Class 0x1
|
#define PCI_Mass_Storage_Class 0x1
|
||||||
#define PCI_IDE_Controller_Subclass 0x1
|
#define PCI_IDE_Controller_Subclass 0x1
|
||||||
|
|
||||||
UNMAP_AFTER_INIT NonnullOwnPtr<IDEChannel> IDEChannel::create(const IDEController& controller, IOAddressGroup io_group, ChannelType type, bool force_pio)
|
UNMAP_AFTER_INIT NonnullRefPtr<IDEChannel> IDEChannel::create(const IDEController& controller, IOAddressGroup io_group, ChannelType type, bool force_pio)
|
||||||
{
|
{
|
||||||
return make<IDEChannel>(controller, io_group, type, force_pio);
|
return adopt(*new IDEChannel(controller, io_group, type, force_pio));
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StorageDevice> IDEChannel::master_device() const
|
RefPtr<StorageDevice> IDEChannel::master_device() const
|
||||||
|
|
|
@ -60,7 +60,8 @@ struct PhysicalRegionDescriptor {
|
||||||
};
|
};
|
||||||
|
|
||||||
class IDEController;
|
class IDEController;
|
||||||
class IDEChannel final : public IRQHandler {
|
class IDEChannel final : public RefCounted<IDEChannel>
|
||||||
|
, public IRQHandler {
|
||||||
friend class IDEController;
|
friend class IDEController;
|
||||||
friend class PATADiskDevice;
|
friend class PATADiskDevice;
|
||||||
AK_MAKE_ETERNAL
|
AK_MAKE_ETERNAL
|
||||||
|
@ -104,8 +105,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static NonnullOwnPtr<IDEChannel> create(const IDEController&, IOAddressGroup, ChannelType type, bool force_pio);
|
static NonnullRefPtr<IDEChannel> create(const IDEController&, IOAddressGroup, ChannelType type, bool force_pio);
|
||||||
IDEChannel(const IDEController&, IOAddressGroup, ChannelType type, bool force_pio);
|
|
||||||
virtual ~IDEChannel() override;
|
virtual ~IDEChannel() override;
|
||||||
|
|
||||||
RefPtr<StorageDevice> master_device() const;
|
RefPtr<StorageDevice> master_device() const;
|
||||||
|
@ -114,6 +114,8 @@ public:
|
||||||
virtual const char* purpose() const override { return "PATA Channel"; }
|
virtual const char* purpose() const override { return "PATA Channel"; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
IDEChannel(const IDEController&, IOAddressGroup, ChannelType type, bool force_pio);
|
||||||
|
|
||||||
//^ IRQHandler
|
//^ IRQHandler
|
||||||
virtual void handle_irq(const RegisterState&) override;
|
virtual void handle_irq(const RegisterState&) override;
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,6 @@ private:
|
||||||
void initialize(bool force_pio);
|
void initialize(bool force_pio);
|
||||||
void detect_disks();
|
void detect_disks();
|
||||||
|
|
||||||
NonnullOwnPtrVector<IDEChannel> m_channels;
|
NonnullRefPtrVector<IDEChannel> m_channels;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,8 +58,8 @@ const char* PATADiskDevice::class_name() const
|
||||||
|
|
||||||
void PATADiskDevice::start_request(AsyncBlockDeviceRequest& request)
|
void PATADiskDevice::start_request(AsyncBlockDeviceRequest& request)
|
||||||
{
|
{
|
||||||
bool use_dma = !m_channel.m_io_group.bus_master_base().is_null() && m_channel.m_dma_enabled.resource();
|
bool use_dma = !m_channel->m_io_group.bus_master_base().is_null() && m_channel->m_dma_enabled.resource();
|
||||||
m_channel.start_request(request, use_dma, is_slave(), m_capabilities);
|
m_channel->start_request(request, use_dma, is_slave(), m_capabilities);
|
||||||
}
|
}
|
||||||
|
|
||||||
String PATADiskDevice::device_name() const
|
String PATADiskDevice::device_name() const
|
||||||
|
|
|
@ -77,7 +77,7 @@ private:
|
||||||
|
|
||||||
Lock m_lock { "IDEDiskDevice" };
|
Lock m_lock { "IDEDiskDevice" };
|
||||||
u16 m_capabilities { 0 };
|
u16 m_capabilities { 0 };
|
||||||
IDEChannel& m_channel;
|
NonnullRefPtr<IDEChannel> m_channel;
|
||||||
DriveType m_drive_type { DriveType::Master };
|
DriveType m_drive_type { DriveType::Master };
|
||||||
InterfaceType m_interface_type { InterfaceType::ATA };
|
InterfaceType m_interface_type { InterfaceType::ATA };
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue