Compare commits
32 Commits
e50d23790e
...
d67fcd2ec0
Author | SHA1 | Date | |
---|---|---|---|
d67fcd2ec0 | |||
f5c949733b | |||
ad6df7c142 | |||
77f8fcb32f | |||
2d4c5557b8 | |||
85fe2dbb38 | |||
7f78960698 | |||
e0c34c571a | |||
0c5584913a | |||
4eaf089b87 | |||
8d284defad | |||
92dc8ac177 | |||
225c2c3d66 | |||
8bfdd83669 | |||
82d1fef9f9 | |||
4214c8f826 | |||
cecc82d588 | |||
2620156fb4 | |||
797959a8a5 | |||
b1039f6200 | |||
798cf801a3 | |||
5015703e9d | |||
94d394b75e | |||
bb3b0d6cf9 | |||
5f2c5921ad | |||
654bbbf253 | |||
7567068fbf | |||
52a84c9948 | |||
6295a663f3 | |||
925d327682 | |||
5de0b3f428 | |||
f45734c61d |
@ -161,7 +161,7 @@ namespace ATA
|
||||
{
|
||||
if (!(read_bm(BusmasterRegister::Status) & BMS_IRQPending)) return;
|
||||
|
||||
if (m_current_drive < 2 && m_drives[m_current_drive]) m_drives[m_current_drive]->irq_handler();
|
||||
if (m_current_drive < 2 && m_drives[m_current_drive].has_value()) m_drives[m_current_drive]->irq_handler();
|
||||
|
||||
m_irq_called = true;
|
||||
|
||||
@ -307,14 +307,7 @@ namespace ATA
|
||||
|
||||
kinfoln("ata: Channel %d has a drive on slot %d!", m_channel_index, drive);
|
||||
|
||||
auto rc = adopt_shared_if_nonnull(new (std::nothrow) Drive(this, drive, {}));
|
||||
if (rc.has_error())
|
||||
{
|
||||
kinfoln("ata: Failed to create drive object: %s", rc.error_string());
|
||||
return false;
|
||||
}
|
||||
|
||||
m_drives[drive] = rc.release_value();
|
||||
m_drives[drive] = Drive { this, drive, {} };
|
||||
|
||||
if (!m_drives[drive]->initialize())
|
||||
{
|
||||
@ -327,7 +320,7 @@ namespace ATA
|
||||
|
||||
for (u8 drive = 0; drive < 2; drive++)
|
||||
{
|
||||
if (m_drives[drive])
|
||||
if (m_drives[drive].has_value())
|
||||
{
|
||||
if (!m_drives[drive]->post_initialize())
|
||||
{
|
||||
@ -335,7 +328,7 @@ namespace ATA
|
||||
return false;
|
||||
}
|
||||
|
||||
auto rc = ATADevice::create(m_drives[drive]);
|
||||
auto rc = ATADevice::create(m_drives[drive].value_ptr());
|
||||
|
||||
if (rc.has_error())
|
||||
{
|
||||
@ -723,7 +716,7 @@ namespace ATA
|
||||
|
||||
static u32 next_minor = 0;
|
||||
|
||||
Result<String> ATA::Drive::create_drive_name(SharedPtr<ATA::Drive> drive)
|
||||
Result<String> ATA::Drive::create_drive_name(ATA::Drive* drive)
|
||||
{
|
||||
static u32 cd_index = 0;
|
||||
static u32 sd_index = 0;
|
||||
@ -731,7 +724,7 @@ Result<String> ATA::Drive::create_drive_name(SharedPtr<ATA::Drive> drive)
|
||||
return String::format("%s%d"_sv, drive->m_is_atapi ? "cd" : "sd", drive->m_is_atapi ? cd_index++ : sd_index++);
|
||||
}
|
||||
|
||||
Result<SharedPtr<Device>> ATADevice::create(SharedPtr<ATA::Drive> drive)
|
||||
Result<SharedPtr<Device>> ATADevice::create(ATA::Drive* drive)
|
||||
{
|
||||
auto device = TRY(adopt_shared_if_nonnull(new (std::nothrow) ATADevice()));
|
||||
device->m_drive = drive;
|
||||
|
@ -131,7 +131,7 @@ namespace ATA
|
||||
|
||||
static constexpr u16 END_OF_PRDT = (1 << 15);
|
||||
|
||||
class Drive : public Shareable
|
||||
class Drive
|
||||
{
|
||||
public:
|
||||
Drive(Channel* channel, u8 drive_index, Badge<Channel>);
|
||||
@ -164,7 +164,7 @@ namespace ATA
|
||||
|
||||
Result<void> read_lba(u64 lba, void* out, usize nblocks);
|
||||
|
||||
static Result<String> create_drive_name(SharedPtr<ATA::Drive> drive);
|
||||
static Result<String> create_drive_name(ATA::Drive* drive);
|
||||
|
||||
private:
|
||||
bool identify_ata();
|
||||
@ -271,7 +271,7 @@ namespace ATA
|
||||
|
||||
u8 m_current_drive = (u8)-1;
|
||||
|
||||
SharedPtr<Drive> m_drives[2];
|
||||
Option<Drive> m_drives[2];
|
||||
};
|
||||
|
||||
class Controller : public Shareable
|
||||
@ -301,7 +301,7 @@ class ATADevice : public Device
|
||||
{
|
||||
public:
|
||||
// Initializer for DeviceRegistry.
|
||||
static Result<SharedPtr<Device>> create(SharedPtr<ATA::Drive> drive);
|
||||
static Result<SharedPtr<Device>> create(ATA::Drive* drive);
|
||||
|
||||
Result<usize> read(u8*, usize, usize) const override;
|
||||
|
||||
@ -339,6 +339,6 @@ class ATADevice : public Device
|
||||
|
||||
private:
|
||||
ATADevice() = default;
|
||||
SharedPtr<ATA::Drive> m_drive;
|
||||
ATA::Drive* m_drive;
|
||||
String m_device_path;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user