#ifndef STOREDEV_STOREDEV_H_ #define STOREDEV_STOREDEV_H_ #include #include #include "spinlock/spinlock.h" #include "storedev/ramsd.h" #include "storedev/atasd.h" #include "storedev/partsd.h" #include "compiler/attr.h" #include "dev/dev.h" #define STOREDEV_MAGIC 0x50FA enum { STOREDEV_RAMSD, STOREDEV_ATASD, STOREDEV_PARTSD, }; UNUSED static const char *storedev_strings[] = { "RAMSD", "ATASD", "PARTSD", }; typedef struct StoreDev { uint32_t _magic; struct StoreDev *next; int32_t sdtype; size_t sectorsize; int32_t (*init)(struct StoreDev *sd, void *extra); int32_t (*read)(struct StoreDev *sd, uint8_t *const buffer, ptrdiff_t sector, ptrdiff_t off, size_t size); int32_t (*write)(struct StoreDev *sd, const uint8_t *const buffer, ptrdiff_t sector, ptrdiff_t off, size_t size); int32_t (*cleanup)(struct StoreDev *sd); size_t (*capacity)(struct StoreDev *sd); union { RamSd ramsd; AtaSd atasd; PartSd partsd; } sd; SpinLock spinlock; } StoreDev; typedef struct { StoreDev *head; SpinLock spinlock; } StoreDevList; extern StoreDevList STOREDEV_LIST; void storedev_init(void); StoreDev *storedev_create(int32_t sdtype, char *name, void *extra); int32_t storedev_delete(StoreDev *sd); void storedev_register_dev_entry(StoreDev *sd, char *name); void storedev_unregister_dev_entry(Dev *dev); #endif // STOREDEV_STOREDEV_H_