Kernel+LibPartition: Move GUIDPartitionTable into LibPartition

This commit is contained in:
Samuel Bowman 2022-03-01 20:21:35 -05:00 committed by Linus Groh
parent 9053d86b82
commit 25de9de7dc
Notes: sideshowbarker 2024-07-17 08:41:30 +09:00
7 changed files with 17 additions and 25 deletions

View file

@ -174,6 +174,10 @@
#cmakedefine01 GLOBAL_DTORS_DEBUG
#endif
#ifndef GPT_DEBUG
#cmakedefine01 GPT_DEBUG
#endif
#ifndef GZIP_DEBUG
#cmakedefine01 GZIP_DEBUG
#endif

View file

@ -104,7 +104,6 @@ set(KERNEL_SOURCES
Storage/ATA/ATAPIDiscDevice.cpp
Storage/ATA/ATAPort.cpp
Storage/Partition/DiskPartition.cpp
Storage/Partition/GUIDPartitionTable.cpp
Storage/NVMe/NVMeController.cpp
Storage/NVMe/NVMeNameSpace.cpp
Storage/NVMe/NVMeInterruptQueue.cpp
@ -404,6 +403,7 @@ set(CRYPTO_SOURCES
set(PARTITION_SOURCES
../Userland/Libraries/LibPartition/DiskPartitionMetadata.cpp
../Userland/Libraries/LibPartition/EBRPartitionTable.cpp
../Userland/Libraries/LibPartition/GUIDPartitionTable.cpp
../Userland/Libraries/LibPartition/MBRPartitionTable.cpp
../Userland/Libraries/LibPartition/PartitionTable.cpp
)

View file

@ -107,10 +107,6 @@
#cmakedefine01 FUTEXQUEUE_DEBUG
#endif
#ifndef GPT_DEBUG
#cmakedefine01 GPT_DEBUG
#endif
#ifndef HPET_COMPARATOR_DEBUG
#cmakedefine01 HPET_COMPARATOR_DEBUG
#endif

View file

@ -21,10 +21,10 @@
#include <Kernel/Storage/ATA/GenericIDE/ISAController.h>
#include <Kernel/Storage/ATA/GenericIDE/PCIController.h>
#include <Kernel/Storage/NVMe/NVMeController.h>
#include <Kernel/Storage/Partition/GUIDPartitionTable.h>
#include <Kernel/Storage/Ramdisk/Controller.h>
#include <Kernel/Storage/StorageManagement.h>
#include <LibPartition/EBRPartitionTable.h>
#include <LibPartition/GUIDPartitionTable.h>
#include <LibPartition/MBRPartitionTable.h>
namespace Kernel {
@ -140,7 +140,7 @@ UNMAP_AFTER_INIT ErrorOr<NonnullOwnPtr<Partition::PartitionTable>> StorageManage
if (!ebr_table_or_error.is_error()) {
return ebr_table_or_error.release_value();
}
return TRY(GUIDPartitionTable::try_to_initialize(device));
return TRY(Partition::GUIDPartitionTable::try_to_initialize(device));
}
UNMAP_AFTER_INIT void StorageManagement::enumerate_disk_partitions()

View file

@ -1,6 +1,7 @@
set(SOURCES
DiskPartitionMetadata.cpp
EBRPartitionTable.cpp
GUIDPartitionTable.cpp
MBRPartitionTable.cpp
PartitionTable.cpp
)

View file

@ -4,16 +4,13 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/AllOf.h>
#include <AK/Array.h>
#include <Kernel/Debug.h>
#include <Kernel/Storage/Partition/GUIDPartitionTable.h>
#include <AK/Debug.h>
#include <LibPartition/GUIDPartitionTable.h>
namespace Kernel {
namespace Partition {
#define GPT_SIGNATURE2 0x54524150
#define GPT_SIGNATURE 0x20494645
#define BytesPerSector 512
struct [[gnu::packed]] GPTPartitionEntry {
u8 partition_guid[16];
@ -47,7 +44,7 @@ struct [[gnu::packed]] GUIDPartitionHeader {
u32 crc32_entries_array;
};
ErrorOr<NonnullOwnPtr<GUIDPartitionTable>> GUIDPartitionTable::try_to_initialize(StorageDevice const& device)
ErrorOr<NonnullOwnPtr<GUIDPartitionTable>> GUIDPartitionTable::try_to_initialize(Kernel::StorageDevice const& device)
{
auto table = TRY(adopt_nonnull_own_or_enomem(new (nothrow) GUIDPartitionTable(device)));
if (!table->is_valid())
@ -55,7 +52,7 @@ ErrorOr<NonnullOwnPtr<GUIDPartitionTable>> GUIDPartitionTable::try_to_initialize
return table;
}
GUIDPartitionTable::GUIDPartitionTable(StorageDevice const& device)
GUIDPartitionTable::GUIDPartitionTable(Kernel::StorageDevice const& device)
: MBRPartitionTable(device)
{
// FIXME: Handle OOM failure here.

View file

@ -6,23 +6,17 @@
#pragma once
#include <AK/Error.h>
#include <AK/RefPtr.h>
#include <AK/Result.h>
#include <AK/Types.h>
#include <AK/Vector.h>
#include <LibPartition/MBRPartitionTable.h>
namespace Kernel {
namespace Partition {
struct GUIDPartitionHeader;
class GUIDPartitionTable final : public Partition::MBRPartitionTable {
class GUIDPartitionTable final : public MBRPartitionTable {
public:
virtual ~GUIDPartitionTable() = default;
;
static ErrorOr<NonnullOwnPtr<GUIDPartitionTable>> try_to_initialize(StorageDevice const&);
explicit GUIDPartitionTable(StorageDevice const&);
static ErrorOr<NonnullOwnPtr<GUIDPartitionTable>> try_to_initialize(Kernel::StorageDevice const&);
explicit GUIDPartitionTable(Kernel::StorageDevice const&);
virtual bool is_valid() const override { return m_valid; };