feat: support for USB mass storage devices, hotplugging

This commit is contained in:
2026-05-18 17:47:12 +02:00
parent f8e8af1d78
commit 41d2841cc9
36 changed files with 1537 additions and 130 deletions
+24 -2
View File
@@ -234,8 +234,29 @@ namespace Montauk {
buf->sectorSizePhys = bdev->SectorSize;
dl_strcpy(buf->model, bdev->Model, 41);
switch (bdev->Kind) {
case Drivers::Storage::BLOCK_KIND_SATA:
buf->type = 1;
break;
case Drivers::Storage::BLOCK_KIND_SATAPI:
buf->type = 2;
break;
case Drivers::Storage::BLOCK_KIND_NVME:
buf->type = 3;
buf->rpm = 1;
break;
case Drivers::Storage::BLOCK_KIND_USB_MSC:
buf->type = 4;
break;
default:
break;
}
// Try to fill AHCI-specific fields if this is an AHCI device
if (Drivers::Storage::Ahci::IsInitialized()) {
if ((bdev->Kind == Drivers::Storage::BLOCK_KIND_SATA ||
bdev->Kind == Drivers::Storage::BLOCK_KIND_SATAPI ||
bdev->Kind == Drivers::Storage::BLOCK_KIND_UNKNOWN) &&
Drivers::Storage::Ahci::IsInitialized()) {
for (int p = 0; p < 32; p++) {
auto* info = Drivers::Storage::Ahci::GetPortInfo(p);
if (!info) continue;
@@ -262,7 +283,8 @@ namespace Montauk {
}
// For NVMe devices: set type=3 (NVMe), rpm=1 (SSD)
if (buf->type == 0 && Drivers::Storage::Nvme::IsInitialized()) {
if ((buf->type == 0 || bdev->Kind == Drivers::Storage::BLOCK_KIND_NVME) &&
Drivers::Storage::Nvme::IsInitialized()) {
for (int ns = 0; ns < Drivers::Storage::Nvme::GetNamespaceCount(); ns++) {
auto* nsInfo = Drivers::Storage::Nvme::GetNamespaceInfo(ns);
if (!nsInfo) continue;