1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-22 01:55:07 +00:00
serenity/Kernel/Storage/PATADiskDevice.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

62 lines
1.6 KiB
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
//
// A Disk Device Connected to a PATA Channel
//
#pragma once
#include <Kernel/Interrupts/IRQHandler.h>
#include <Kernel/Locking/Mutex.h>
#include <Kernel/Storage/StorageDevice.h>
namespace Kernel {
class IDEController;
class IDEChannel;
class PATADiskDevice final : public StorageDevice {
friend class IDEController;
AK_MAKE_ETERNAL
public:
// Type of drive this IDEDiskDevice is on the ATA channel.
//
// Each PATA channel can contain only two devices, which (I think) are
// jumper selectable on the drive itself by shorting two pins.
enum class DriveType : u8 {
Master,
Slave
};
enum class InterfaceType : u8 {
ATA,
ATAPI,
};
public:
static NonnullRefPtr<PATADiskDevice> create(const IDEController&, IDEChannel&, DriveType, InterfaceType, u16, u64);
virtual ~PATADiskDevice() override;
// ^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
PATADiskDevice(const IDEController&, IDEChannel&, DriveType, InterfaceType, u16, u64);
private:
// ^DiskDevice
virtual StringView class_name() const override;
bool is_slave() const;
u16 m_capabilities { 0 };
NonnullRefPtr<IDEChannel> m_channel;
DriveType m_drive_type { DriveType::Master };
InterfaceType m_interface_type { InterfaceType::ATA };
};
}