2021-02-26 01:25:45 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
|
|
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-02-26 01:25:45 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <AK/StringView.h>
|
2021-09-11 03:19:20 -03:00
|
|
|
#include <Kernel/Devices/DeviceManagement.h>
|
2021-09-07 08:39:11 -03:00
|
|
|
#include <Kernel/FileSystem/OpenFileDescription.h>
|
2021-02-26 01:25:45 -03:00
|
|
|
#include <Kernel/Storage/AHCIController.h>
|
|
|
|
|
#include <Kernel/Storage/IDEChannel.h>
|
|
|
|
|
#include <Kernel/Storage/SATADiskDevice.h>
|
|
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
2021-03-16 16:23:16 -03:00
|
|
|
NonnullRefPtr<SATADiskDevice> SATADiskDevice::create(const AHCIController& controller, const AHCIPort& port, size_t sector_size, u64 max_addressable_block)
|
2021-02-26 01:25:45 -03:00
|
|
|
{
|
2021-09-11 03:19:20 -03:00
|
|
|
auto device_or_error = DeviceManagement::try_create_device<SATADiskDevice>(controller, port, sector_size, max_addressable_block);
|
2021-09-10 08:44:46 -03:00
|
|
|
// FIXME: Find a way to propagate errors
|
|
|
|
|
VERIFY(!device_or_error.is_error());
|
|
|
|
|
return device_or_error.release_value();
|
2021-02-26 01:25:45 -03:00
|
|
|
}
|
|
|
|
|
|
2021-03-16 16:23:16 -03:00
|
|
|
SATADiskDevice::SATADiskDevice(const AHCIController& controller, const AHCIPort& port, size_t sector_size, u64 max_addressable_block)
|
2021-02-26 01:25:45 -03:00
|
|
|
: StorageDevice(controller, sector_size, max_addressable_block)
|
|
|
|
|
, m_port(port)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SATADiskDevice::~SATADiskDevice()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-10 20:46:09 -03:00
|
|
|
StringView SATADiskDevice::class_name() const
|
2021-02-26 01:25:45 -03:00
|
|
|
{
|
|
|
|
|
return "SATADiskDevice";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SATADiskDevice::start_request(AsyncBlockDeviceRequest& request)
|
|
|
|
|
{
|
2021-08-27 02:08:43 -03:00
|
|
|
m_port.strong_ref()->start_request(request);
|
2021-02-26 01:25:45 -03:00
|
|
|
}
|
|
|
|
|
|
2021-08-14 01:01:19 -03:00
|
|
|
String SATADiskDevice::storage_name() const
|
2021-02-26 01:25:45 -03:00
|
|
|
{
|
|
|
|
|
return String::formatted("hd{:c}", 'a' + minor());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|