mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 11:02:43 +00:00 
			
		
		
		
	 f5de4f24b2
			
		
	
	
		f5de4f24b2
		
	
	
	
	
		
			
			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.
		
			
				
	
	
		
			62 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			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 };
 | |
| };
 | |
| 
 | |
| }
 |