2023-05-26 21:28:51 +00:00
|
|
|
#pragma once
|
|
|
|
|
2023-06-04 09:25:16 +00:00
|
|
|
#include "fs/devices/DeviceRegistry.h"
|
2023-05-26 21:28:51 +00:00
|
|
|
#include <luna/Types.h>
|
|
|
|
|
|
|
|
#define MBR_BOOTABLE 0x80
|
|
|
|
|
|
|
|
#define MBR_SIGNATURE_1 0x55
|
|
|
|
#define MBR_SIGNATURE_2 0xAA
|
|
|
|
|
|
|
|
namespace MBR
|
|
|
|
{
|
|
|
|
struct [[gnu::packed]] PartitionHeader
|
|
|
|
{
|
|
|
|
u8 attributes;
|
|
|
|
u8 chs_start[3];
|
|
|
|
u8 partition_type;
|
|
|
|
u8 chs_end[3];
|
|
|
|
u32 start_lba;
|
|
|
|
u32 num_sectors;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct [[gnu::packed]] DiskHeader
|
|
|
|
{
|
|
|
|
u8 mbr_code[440];
|
|
|
|
u8 disk_id[4];
|
|
|
|
u8 reserved[2];
|
|
|
|
PartitionHeader partitions[4];
|
|
|
|
u8 signature[2];
|
|
|
|
};
|
|
|
|
|
|
|
|
static_assert(sizeof(DiskHeader) == 512ul);
|
|
|
|
|
2023-06-04 09:25:16 +00:00
|
|
|
Result<bool> identify(SharedPtr<Device> device);
|
2023-05-26 21:28:51 +00:00
|
|
|
};
|