1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:28:12 +00:00

Kernel: Add a method to gather the devices count of a Storage controller

Also, change device() method to be const.
This commit is contained in:
Liav A 2020-12-19 13:56:12 +02:00 committed by Andreas Kling
parent e3b3805abf
commit 6a691306b5
5 changed files with 19 additions and 7 deletions

View file

@ -47,6 +47,16 @@ bool IDEController::shutdown()
TODO();
}
size_t IDEController::devices_count() const
{
size_t count = 0;
for (u32 index = 0; index < 4; index++) {
if (!device(index).is_null())
count++;
}
return count;
}
void IDEController::start_request(const StorageDevice&, AsyncBlockDeviceRequest&)
{
ASSERT_NOT_REACHED();
@ -85,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));
}
RefPtr<StorageDevice> IDEController::device(u32 index)
RefPtr<StorageDevice> IDEController::device(u32 index) const
{
switch (index) {
case 0: