1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-22 01:55:07 +00:00
serenity/Kernel/Storage/SATADiskDevice.h
Liav A f5de4f24b2 Kernel/Devices: Defer creation of SysFS component after the constructor
Instead of doing so in the constructor, let's do immediately after the
constructor, so we can safely pass a reference of a Device, so the
SysFSDeviceComponent constructor can use that object to identify whether
it's a block device or a character device.
This allows to us to not hold a device in SysFSDeviceComponent with a
RefPtr.
Also, we also call the before_removing method in both SlavePTY::unref
and File::unref, so because Device has that method being overrided, it
can ensure the device is removed always cleanly.
2021-09-11 11:41:14 +02:00

44 lines
1.1 KiB
C++

/*
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <Kernel/Interrupts/IRQHandler.h>
#include <Kernel/Locking/Mutex.h>
#include <Kernel/Storage/AHCIPort.h>
#include <Kernel/Storage/StorageDevice.h>
namespace Kernel {
class AHCIController;
class SATADiskDevice final : public StorageDevice {
friend class AHCIController;
public:
enum class InterfaceType : u8 {
SATA,
SATAPI,
};
public:
static NonnullRefPtr<SATADiskDevice> create(const AHCIController&, const AHCIPort&, size_t sector_size, u64 max_addressable_block);
virtual ~SATADiskDevice() override;
// ^StorageDevice
// ^BlockDevice
virtual void start_request(AsyncBlockDeviceRequest&) override;
virtual String storage_name() const override;
// FIXME: We expose this constructor to make try_create_device helper to work
SATADiskDevice(const AHCIController&, const AHCIPort&, size_t sector_size, u64 max_addressable_block);
private:
// ^DiskDevice
virtual StringView class_name() const override;
WeakPtr<AHCIPort> m_port;
};
}