ladybird/Kernel/Storage/ATA/GenericIDE/Controller.h
Liav A 0050358cd3 Kernel/Storage: Modernize ATA IDE controller initialization code
This is done by 2 ways which both fit very well together:
- We stop use LockRefPtrs. We also don't allow expansion of the
  m_channels member, by setting it to be a fixed Array of 2
  IDEChannels.
- More error propagation through the code, in the construction point of
  IDEChannel(s). This means that in the future we could technically do
  something meaningful with OOM conditions when initializing an IDE
  controller.
2023-04-14 19:20:43 +02:00

36 lines
1 KiB
C++

/*
* Copyright (c) 2020-2022, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/OwnPtr.h>
#include <AK/Types.h>
#include <Kernel/Library/LockRefPtr.h>
#include <Kernel/Storage/ATA/ATAController.h>
#include <Kernel/Storage/StorageDevice.h>
namespace Kernel {
class AsyncBlockDeviceRequest;
class IDEChannel;
class IDEController : public ATAController {
public:
virtual ~IDEController() override;
virtual LockRefPtr<StorageDevice> device(u32 index) const override final;
virtual ErrorOr<void> reset() override final;
virtual ErrorOr<void> shutdown() override final;
virtual size_t devices_count() const override final;
virtual void start_request(ATADevice const&, AsyncBlockDeviceRequest&) override final;
virtual void complete_current_request(AsyncDeviceRequest::RequestResult) override final;
protected:
IDEController();
LockRefPtr<StorageDevice> device_by_channel_and_position(u32 index) const;
Array<RefPtr<IDEChannel>, 2> m_channels;
};
}