mirror of
https://github.com/BoredDevNL/BoredOS.git
synced 2026-05-15 10:48:38 +00:00
fix: ensure partitions are recognized after fdisk and fix AHCI slot bug
This commit is contained in:
parent
82226ddbe5
commit
36ed0d4a9e
3 changed files with 34 additions and 4 deletions
|
|
@ -120,11 +120,12 @@ static void ahci_port_rebase(ahci_port_state_t *ps) {
|
||||||
if (!ps->cmd_tbl) return;
|
if (!ps->cmd_tbl) return;
|
||||||
mem_memset(ps->cmd_tbl, 0, cmd_tbl_size);
|
mem_memset(ps->cmd_tbl, 0, cmd_tbl_size);
|
||||||
|
|
||||||
// Set command header 0 to point to our command table
|
|
||||||
uint64_t ctba_phys = v2p((uint64_t)ps->cmd_tbl);
|
uint64_t ctba_phys = v2p((uint64_t)ps->cmd_tbl);
|
||||||
ps->cmd_list[0].ctba = (uint32_t)(ctba_phys & 0xFFFFFFFF);
|
for (int i = 0; i < 32; i++) {
|
||||||
ps->cmd_list[0].ctbau = (uint32_t)(ctba_phys >> 32);
|
ps->cmd_list[i].ctba = (uint32_t)(ctba_phys & 0xFFFFFFFF);
|
||||||
ps->cmd_list[0].prdtl = 1; // 1 PRDT entry default
|
ps->cmd_list[i].ctbau = (uint32_t)(ctba_phys >> 32);
|
||||||
|
ps->cmd_list[i].prdtl = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Clear error and interrupt status
|
// Clear error and interrupt status
|
||||||
port->serr = 0xFFFFFFFF;
|
port->serr = 0xFFFFFFFF;
|
||||||
|
|
|
||||||
|
|
@ -362,5 +362,8 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
if (ret != 0) { printf("[ERROR] Partition write failed.\n"); return 1; }
|
if (ret != 0) { printf("[ERROR] Partition write failed.\n"); return 1; }
|
||||||
printf("Partition table written to /dev/%s.\n", devname);
|
printf("Partition table written to /dev/%s.\n", devname);
|
||||||
|
|
||||||
|
sys_disk_rescan(devname);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
26
src/userland/cli/rescan.c
Normal file
26
src/userland/cli/rescan.c
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
// Copyright (c) 2023-2026 Chris (boreddevnl)
|
||||||
|
// This software is released under the GNU General Public License v3.0. See LICENSE file for details.
|
||||||
|
#include "../libc/syscall.h"
|
||||||
|
#include "../libc/stdio.h"
|
||||||
|
#include "../libc/string.h"
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
if (argc < 2) {
|
||||||
|
printf("Usage: rescan /dev/DEVICE\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *devname = argv[1];
|
||||||
|
if (devname[0] == '/' && devname[1] == 'd' && devname[2] == 'e' && devname[3] == 'v' && devname[4] == '/')
|
||||||
|
devname += 5;
|
||||||
|
|
||||||
|
printf("Rescanning /dev/%s...\n", devname);
|
||||||
|
int ret = sys_disk_rescan(devname);
|
||||||
|
if (ret != 0) {
|
||||||
|
printf("[ERROR] Rescan failed (ret=%d)\n", ret);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Done.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue