Implement an ATA driver, Add vfsmount/vfsunmount syscalls

This commit is contained in:
2025-10-14 00:39:59 +02:00
parent cb9e15330e
commit 25cb309105
19 changed files with 455 additions and 58 deletions

View File

@ -6,6 +6,7 @@
#include "errors.h"
#include "dlmalloc/malloc.h"
#include "ramsd.h"
#include "atasd.h"
#include "util/util.h"
#include "dev/dev.h"
#include "hshtb.h"
@ -19,16 +20,20 @@ void storedev_init(void) {
STOREDEV_LIST.head = NULL;
LOG("storedev", "init\n");
ata_probe();
}
void storedev_register_dev_entry(StoreDev *sd, int32_t sdtype) {
char uniq[5];
randcrypto_gen_uniqid(uniq, 4);
char key[20];
hal_memset(key, 0, sizeof(key));
if (sdtype == STOREDEV_RAMSD) {
char uniq[5];
randcrypto_gen_uniqid(uniq, 4);
ksprintf(key, "ramsd-%s", uniq);
} else if (sdtype == STOREDEV_ATASD) {
ksprintf(key, "atasd-%s", sd->sd.atasd.devno == 0x00 ? "mst" : "slv");
}
spinlock_acquire(&DEVTABLE.spinlock);
@ -70,18 +75,29 @@ StoreDev *storedev_create(int32_t sdtype, void *extra) {
sd->read = &ramsd_read;
sd->write = &ramsd_write;
sd->capacity = &ramsd_capacity;
int32_t err = sd->init(sd, extra);
if (err != E_OK) {
spinlock_release(&STOREDEV_LIST.spinlock);
return NULL;
}
LL_APPEND(STOREDEV_LIST.head, sd);
sd->sectorsize = STOREDEV_RAMSD_SECTORSIZE;
} break;
case STOREDEV_ATASD: {
spinlock_init(&sd->spinlock);
sd->sdtype = STOREDEV_ATASD;
sd->init = &atasd_init;
sd->cleanup = &atasd_cleanup;
sd->read = &atasd_read;
sd->write = &atasd_write;
sd->capacity = &atasd_capacity;
sd->sectorsize = STOREDEV_ATASD_SECTORSIZE;
} break;
default:
spinlock_release(&STOREDEV_LIST.spinlock);
return NULL;
}
int32_t err = sd->init(sd, extra);
if (err != E_OK) {
dlfree(sd);
spinlock_release(&STOREDEV_LIST.spinlock);
return NULL;
}
LL_APPEND(STOREDEV_LIST.head, sd);
spinlock_release(&STOREDEV_LIST.spinlock);
storedev_register_dev_entry(sd, sdtype);