2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
|
*
|
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
|
|
|
* list of conditions and the following disclaimer.
|
|
|
|
|
*
|
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-07-28 23:44:01 +10:00
|
|
|
//
|
|
|
|
|
// A Disk Device Connected to a PATA Channel
|
|
|
|
|
//
|
2020-05-28 20:40:53 +02:00
|
|
|
|
2018-10-16 14:17:43 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2020-02-22 19:53:03 +02:00
|
|
|
#include <Kernel/Interrupts/IRQHandler.h>
|
2019-05-28 11:53:16 +02:00
|
|
|
#include <Kernel/Lock.h>
|
2020-12-19 12:50:57 +02:00
|
|
|
#include <Kernel/Storage/StorageDevice.h>
|
2019-09-04 11:04:50 +02:00
|
|
|
|
2020-02-16 01:27:42 +01:00
|
|
|
namespace Kernel {
|
|
|
|
|
|
2020-12-19 12:50:57 +02:00
|
|
|
class IDEController;
|
2021-02-05 16:41:50 +02:00
|
|
|
class IDEChannel;
|
2020-12-19 12:50:57 +02:00
|
|
|
class PATADiskDevice final : public StorageDevice {
|
|
|
|
|
friend class IDEController;
|
2019-05-19 03:46:50 +02:00
|
|
|
AK_MAKE_ETERNAL
|
2018-10-16 14:17:43 +02:00
|
|
|
public:
|
2019-07-08 06:16:52 +00:00
|
|
|
// 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 {
|
2019-07-28 23:44:01 +10:00
|
|
|
Master,
|
|
|
|
|
Slave
|
2019-07-08 06:16:52 +00:00
|
|
|
};
|
|
|
|
|
|
2021-01-29 19:37:40 +00:00
|
|
|
enum class InterfaceType : u8 {
|
|
|
|
|
ATA,
|
|
|
|
|
ATAPI,
|
|
|
|
|
};
|
|
|
|
|
|
2019-07-08 06:16:52 +00:00
|
|
|
public:
|
2021-03-16 20:23:16 +01:00
|
|
|
static NonnullRefPtr<PATADiskDevice> create(const IDEController&, IDEChannel&, DriveType, InterfaceType, u16, u64);
|
2019-07-28 23:44:01 +10:00
|
|
|
virtual ~PATADiskDevice() override;
|
2018-10-16 14:17:43 +02:00
|
|
|
|
2019-08-02 23:18:47 +10:00
|
|
|
// ^BlockDevice
|
2020-11-02 11:16:01 -07:00
|
|
|
virtual void start_request(AsyncBlockDeviceRequest&) override;
|
2021-01-21 18:49:56 +01:00
|
|
|
virtual String device_name() const override;
|
2018-10-16 14:17:43 +02:00
|
|
|
|
|
|
|
|
private:
|
2021-03-16 20:23:16 +01:00
|
|
|
PATADiskDevice(const IDEController&, IDEChannel&, DriveType, InterfaceType, u16, u64);
|
2020-12-19 12:50:57 +02:00
|
|
|
|
2018-11-10 15:15:31 +01:00
|
|
|
// ^DiskDevice
|
2018-11-15 15:36:35 +01:00
|
|
|
virtual const char* class_name() const override;
|
2018-11-10 15:15:31 +01:00
|
|
|
|
2019-07-08 06:16:52 +00:00
|
|
|
bool is_slave() const;
|
|
|
|
|
|
2019-05-02 03:28:20 +02:00
|
|
|
Lock m_lock { "IDEDiskDevice" };
|
2021-01-29 19:37:40 +00:00
|
|
|
u16 m_capabilities { 0 };
|
2021-03-27 06:22:55 +03:00
|
|
|
NonnullRefPtr<IDEChannel> m_channel;
|
2019-07-28 23:44:01 +10:00
|
|
|
DriveType m_drive_type { DriveType::Master };
|
2021-01-29 19:37:40 +00:00
|
|
|
InterfaceType m_interface_type { InterfaceType::ATA };
|
2018-10-16 14:17:43 +02:00
|
|
|
};
|
2020-02-16 01:27:42 +01:00
|
|
|
|
|
|
|
|
}
|