mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 06:32:44 +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.
		
			
				
	
	
		
			44 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			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;
 | |
| };
 | |
| 
 | |
| }
 |