Kernel: Move Partition out of StorageDevice and rename functions

This commit is contained in:
Bananymous
2023-03-29 13:23:01 +03:00
parent ae05ad3f38
commit dd84a2175f
10 changed files with 51 additions and 48 deletions

View File

@@ -444,7 +444,7 @@ namespace Kernel
return index() == ext2_other.index();
}
BAN::ErrorOr<Ext2FS*> Ext2FS::create(StorageDevice::Partition& partition)
BAN::ErrorOr<Ext2FS*> Ext2FS::create(Partition& partition)
{
Ext2FS* ext2fs = new Ext2FS(partition);
if (ext2fs == nullptr)

View File

@@ -92,7 +92,7 @@ namespace Kernel
for (auto& partition : device->partitions())
{
if (partition.name() == "banan-root"sv)
if (partition.label() == "banan-root"sv)
{
if (root_inode())
dwarnln("multiple root partitions found");
@@ -127,7 +127,7 @@ namespace Kernel
{
for (auto& partition : device->partitions())
{
if (partition.name() == "mount-test"sv)
if (partition.label() == "mount-test"sv)
{
auto ext2fs = TRY(Ext2FS::create(partition));
TRY(mount(ext2fs, "/mnt"sv));

View File

@@ -89,7 +89,7 @@ namespace Kernel
ATABus& bus = m_buses[bus_index];
ATADevice& device = bus.devices[device_index];
device.type = ATADevice::Type::Unknown;
device.type = ATADevice::DeviceType::Unknown;
device.slave_bit = device_index << 4;
device.bus = &bus;
device.controller = this;
@@ -113,7 +113,7 @@ namespace Kernel
break;
}
auto type = ATADevice::Type::ATA;
auto type = ATADevice::DeviceType::ATA;
// Not a ATA device, maybe ATAPI
if (status & ATA_STATUS_ERR)
@@ -122,9 +122,9 @@ namespace Kernel
uint8_t lba2 = bus.read(ATA_PORT_LBA2);
if (lba1 == 0x14 && lba2 == 0xEB)
type = ATADevice::Type::ATAPI;
type = ATADevice::DeviceType::ATAPI;
else if (lba1 == 0x69 && lba2 == 0x96)
type = ATADevice::Type::ATAPI;
type = ATADevice::DeviceType::ATAPI;
else
continue;
@@ -171,12 +171,12 @@ namespace Kernel
for (uint32_t j = 0; j < 2; j++)
{
ATADevice& device = m_buses[i].devices[j];
if (device.type == ATADevice::Type::Unknown)
if (device.type == ATADevice::DeviceType::Unknown)
continue;
constexpr uint32_t words_per_mib = 1024 * 1024 / 2;
const char* device_type =
device.type == ATADevice::Type::ATA ? "ATA" :
device.type == ATADevice::Type::ATAPI ? "ATAPI" :
device.type == ATADevice::DeviceType::ATA ? "ATA" :
device.type == ATADevice::DeviceType::ATAPI ? "ATAPI" :
"Unknown";
dprintln("Found {} Drive ({} MiB) model {}", device_type, device.lba_count * device.sector_words / words_per_mib, device.model);
}

View File

@@ -185,7 +185,7 @@ namespace Kernel
return {};
}
StorageDevice::Partition::Partition(StorageDevice& device, const GUID& type, const GUID& guid, uint64_t start, uint64_t end, uint64_t attr, const char* name)
Partition::Partition(StorageDevice& device, const GUID& type, const GUID& guid, uint64_t start, uint64_t end, uint64_t attr, const char* label)
: m_device(device)
, m_type(type)
, m_guid(guid)
@@ -193,10 +193,10 @@ namespace Kernel
, m_lba_end(end)
, m_attributes(attr)
{
memcpy(m_name, name, sizeof(m_name));
memcpy(m_label, label, sizeof(m_label));
}
BAN::ErrorOr<void> StorageDevice::Partition::read_sectors(uint64_t lba, uint8_t sector_count, uint8_t* buffer)
BAN::ErrorOr<void> Partition::read_sectors(uint64_t lba, uint8_t sector_count, uint8_t* buffer)
{
const uint32_t sectors_in_partition = m_lba_end - m_lba_start;
if (lba + sector_count > sectors_in_partition)
@@ -205,7 +205,7 @@ namespace Kernel
return {};
}
BAN::ErrorOr<void> StorageDevice::Partition::write_sectors(uint64_t lba, uint8_t sector_count, const uint8_t* buffer)
BAN::ErrorOr<void> Partition::write_sectors(uint64_t lba, uint8_t sector_count, const uint8_t* buffer)
{
const uint32_t sectors_in_partition = m_lba_end - m_lba_start;
if (lba + sector_count > sectors_in_partition)