2020-12-19 13:50:57 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Liav A. <liavalb@hotmail.co.il>
|
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-12-19 13:50:57 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/OwnPtr.h>
|
|
|
|
#include <AK/RefPtr.h>
|
2021-06-25 09:46:17 +03:00
|
|
|
#include <Kernel/Bus/PCI/Access.h>
|
2021-08-21 06:58:43 +03:00
|
|
|
#include <Kernel/Bus/PCI/Device.h>
|
2020-12-19 13:50:57 +03:00
|
|
|
#include <Kernel/Devices/Device.h>
|
|
|
|
#include <Kernel/IO.h>
|
2021-07-18 10:10:27 +03:00
|
|
|
#include <Kernel/Locking/Mutex.h>
|
2021-08-06 11:45:34 +03:00
|
|
|
#include <Kernel/Memory/PhysicalPage.h>
|
2020-12-19 13:50:57 +03:00
|
|
|
#include <Kernel/PhysicalAddress.h>
|
|
|
|
#include <Kernel/Random.h>
|
|
|
|
#include <Kernel/WaitQueue.h>
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
class AsyncBlockDeviceRequest;
|
|
|
|
class StorageDevice;
|
2021-01-18 23:40:47 +03:00
|
|
|
class StorageController : public RefCounted<StorageController> {
|
2020-12-19 13:50:57 +03:00
|
|
|
AK_MAKE_ETERNAL
|
2021-01-18 23:40:47 +03:00
|
|
|
|
2021-04-11 19:53:01 +03:00
|
|
|
public:
|
2021-01-18 23:40:47 +03:00
|
|
|
virtual ~StorageController() = default;
|
|
|
|
|
2020-12-19 14:56:12 +03:00
|
|
|
virtual RefPtr<StorageDevice> device(u32 index) const = 0;
|
|
|
|
virtual size_t devices_count() const = 0;
|
2020-12-19 14:47:25 +03:00
|
|
|
|
2020-12-19 13:50:57 +03:00
|
|
|
protected:
|
|
|
|
virtual void start_request(const StorageDevice&, AsyncBlockDeviceRequest&) = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual bool reset() = 0;
|
|
|
|
virtual bool shutdown() = 0;
|
|
|
|
|
|
|
|
virtual void complete_current_request(AsyncDeviceRequest::RequestResult) = 0;
|
|
|
|
};
|
|
|
|
}
|