Device Management
Posted: Fri Feb 07, 2003 1:27 pm
I'm writing my DM and have chosen to keep a 3D array of pointers for the device open, read, write, close, seek etc. functions. My code (below) goes to the read(...) function but causes an Invalid Opcode (0x06) exception before geting to the beginning of the function pointed to. Has anyone got any ideas why?
Thanks
Main DM File
Header file
Thanks
Main DM File
Code: Select all
static volatile dev_t devices[NUM_TYPES][MAX_DEVS];
static volatile unsigned int totaldev[NUM_TYPES];
int add_dev(int type, dev_t *device)
{
memcpy(&devices[type][totaldev[type]], &device, sizeof(dev_t));
totaldev[type]++;
return totaldev[type] - 1;
}
void read(int type, int id, int location, char *buffer)
{
devices[type][id].p_read(location, buffer);
}
Code: Select all
typedef void (*ptr_t)(int location, char *buffer);
typedef struct
{
ptr_t p_open, p_read, p_write, p_seek, p_close;
} dev_t;
#define NUM_TYPES 7
#define MAX_DEVS 10
#define FDD 0
#define HDD 1
#define NIC 2
#define SOUND 3
#define PRINT 4
#define VIDEO 5
#define CDD 6
int add_dev(int type, dev_t *device);
void read(int type, int id, int location, char *buffer);