I have a small problem.
My implementation is fairly similar to the one recommended by
gerry400.
In my header I declare a struct,
ata_info, and declare my pointers, one for each possbile ATA hard drive:
Code: Select all
static struct ata_info *pri_master;
static struct ata_info *pri_slave;
static struct ata_info *sec_master;
static struct ata_info *sec_slave;
I set the members in these pointer structures by calling the
identify function:
Code: Select all
pri_master = identify(PRI_CONTROLLER, MASTER_DISK);
pri_slave = identify(PRI_CONTROLLER, SLAVE_DISK);
They both detect the ATA information correctly, but calling the
pri_slave = ... function seems to overwrite the pri_master pointer. So, if I go to print any of the members of pri_master, the results in pri_slave are printed.
A cut down version of the
identify function is:
Code: Select all
struct ata_info *identify(uword controller, ubyte drive) {
uword buffer[256];
struct ata_info *funcptr = {0};
...
funcptr->atapi = buffer[0];
return funcptr;
Do I need to allocate memory with malloc()? (I don't have a malloc function yet, but I can write one if I have to)
Or do I need to have a function to destroy the funcptr pointer, as gerryg suggested? If so, how would I go about that?
All help is appreciated.