Files
my-os-project2/kernel/storedev/storedev.h

45 lines
912 B
C

#ifndef STOREDEV_STOREDEV_H_
#define STOREDEV_STOREDEV_H_
#include <stdint.h>
#include <stddef.h>
#include "spinlock/spinlock.h"
#include "ramsd.h"
enum {
STOREDEV_RAMSD,
};
static const char *storedev_strings[] = {
"RAMSD",
};
typedef struct StoreDev {
struct StoreDev *next;
int32_t sdtype;
int32_t (*init)(struct StoreDev *sd, void *extra);
int32_t (*read)(struct StoreDev *sd, uint8_t *const buffer, size_t n, size_t off);
int32_t (*write)(struct StoreDev *sd, const uint8_t *const buffer, size_t n, size_t off);
int32_t (*cleanup)(struct StoreDev *sd);
union {
RamSd ramsd;
} 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, void *extra);
int32_t storedev_delete(StoreDev *sd);
#endif // STOREDEV_STOREDEV_H_