mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:47:34 +00:00
Kernel: Change the indexing of storage devices in IDEController class
Previously, the indexing scheme was that 0 is Primary-Master, 1 is Primary-Slave, 2 is Secondary-Master, 3 is Secondary-Slave. Instead of merely matching between numbers to the channel & position, the IDEController code will try to find all available drives connected to the two channels, then it will create a Vector with nonnull RefPtr to them. Then we take use the given index with this Vector.
This commit is contained in:
parent
6a691306b5
commit
78ae4b0530
2 changed files with 17 additions and 2 deletions
|
@ -95,7 +95,7 @@ void IDEController::initialize(bool force_pio)
|
||||||
m_channels.append(IDEChannel::create(*this, { base_io, control_io, bus_master_base.offset(8) }, IDEChannel::ChannelType::Secondary, force_pio));
|
m_channels.append(IDEChannel::create(*this, { base_io, control_io, bus_master_base.offset(8) }, IDEChannel::ChannelType::Secondary, force_pio));
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<StorageDevice> IDEController::device(u32 index) const
|
RefPtr<StorageDevice> IDEController::device_by_channel_and_position(u32 index) const
|
||||||
{
|
{
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -107,7 +107,21 @@ RefPtr<StorageDevice> IDEController::device(u32 index) const
|
||||||
case 3:
|
case 3:
|
||||||
return m_channels[1].slave_device();
|
return m_channels[1].slave_device();
|
||||||
}
|
}
|
||||||
return nullptr;
|
ASSERT_NOT_REACHED();
|
||||||
|
}
|
||||||
|
|
||||||
|
RefPtr<StorageDevice> IDEController::device(u32 index) const
|
||||||
|
{
|
||||||
|
NonnullRefPtrVector<StorageDevice> connected_devices;
|
||||||
|
for (size_t index = 0; index < 4; index++) {
|
||||||
|
auto checked_device = device_by_channel_and_position(index);
|
||||||
|
if (checked_device.is_null())
|
||||||
|
continue;
|
||||||
|
connected_devices.append(checked_device.release_nonnull());
|
||||||
|
}
|
||||||
|
if (index >= connected_devices.size())
|
||||||
|
return nullptr;
|
||||||
|
return connected_devices[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,7 @@ public:
|
||||||
private:
|
private:
|
||||||
IDEController(PCI::Address address, bool force_pio);
|
IDEController(PCI::Address address, bool force_pio);
|
||||||
|
|
||||||
|
RefPtr<StorageDevice> device_by_channel_and_position(u32 index) const;
|
||||||
void initialize(bool force_pio);
|
void initialize(bool force_pio);
|
||||||
void detect_disks();
|
void detect_disks();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue