/* device table */
struct device_table {
char *dt_string; /* device name */
int dt_type; /* device "type" */
int dt_bsize; /* block size */
char *dt_desc; /* device description */
int (*dt_init)(); /* device init routine */
int (*dt_open)(); /* device open routine */
int (*dt_strategy)(); /* device strategy routine, returns cnt */
int (*dt_close)(); /* device close routine */
int (*dt_ioctl)(); /* device ioctl routine */
int (*dt_read)(); /* fs read routine, returns count */
int (*dt_write)(); /* fs write routine, return count */
int (*dt_delete)(); /* file delete routine */
int (*dt_undelete)();/* file delete routine */
int (*dt_firstfile)(); /* directory serach routine */
int (*dt_nextfile)(); /* directory serach routine */
int (*dt_format)();
int (*dt_cd)();
int (*dt_rename)();
int (*dt_remove)();
int (*dt_else)();
};
/* device types */
#define DTTYPE_CHAR 0x1 /* character device */
#define DTTYPE_CONS 0x2 /* can be console */
#define DTTYPE_BLOCK 0x4 /* block device */
#define DTTYPE_RAW 0x8 /* raw device that uses fs switch */
#define DTTYPE_FS 0x10
#define MAXDEVICE 10
#define DTEMPTY { NULL, 0, 0, NULL, \ /* default device table entry */
dev_stub, dev_stub, dev_stub, dev_stub, dev_stub, dev_stub, dev_stub, dev_stub, \
dev_stub, dev_stub, dev_stub, dev_stub, dev_stub, dev_stub, dev_stub, dev_stub }
static int dev_num = MAXDEVICE;
static device_table dev_t[MAXDEVICE] = {
DTEMPTY, DTEMPTY, DTEMPTY, DTEMPTY, DTEMPTY,
DTEMPTY, DTEMPTY, DTEMPTY, DTEMPTY, DTEMPTY
};
/* 00003C2C */
int AddDevice(device_table *device)
{
device_table *cur, *last;
cur = dev_t[0];
last = dev_t[dev_num];
while(cur < last)
{
if(cur->dt_string == NULL)
{
/* install device */
memcpy(cur, device, sizeof(device));
FlushCache();
/* initialize device */
cur->dt_init();
return 1;
}
else cur++;
}
return 0;
}