[Simh] Pointer Question
Bill Beech (NJ7P)
nj7p at nj7p.org
Sun Dec 16 13:05:17 EST 2012
Guys,
I am having trouble with pointers. I would like to be able to register
I/O devices with my bus manager. Currently I have only multibus.c
performing this function.
Here are some snippets of the code:
/* Internal I/O address space functions */
extern int32 i8251s(int32 io, int32 data);
extern int32 i8251d(int32 io, int32 data);
extern int32 i8255a(int32 io, int32 data);
extern int32 i8255b(int32 io, int32 data);
extern int32 i8255c(int32 io, int32 data);
extern int32 i8255s(int32 io, int32 data);
/* This is the I/O configuration table. There are 256 possible
device addresses, if a device is plugged to a port it's routine
address is here, 'nulldev' means no device is available
*/
struct idev {
int32 (*routine)();
};
struct idev dev_table[256] = {
{&nulldev}, {&nulldev}, {&nulldev}, {&nulldev}, /*
000H */
.........
{&i8255a},{&i8255b},{&i8255c},{&i8255s}, /* 0E4H */
{&nulldev}, {&nulldev}, {&nulldev}, {&nulldev}, /* 0E8H */
{&i8251d},{&i8251s},{&i8251d},{&i8251s}, /* 0ECH */
{&nulldev}, {&nulldev}, {&nulldev}, {&nulldev}, /* 0F0H */
{&nulldev}, {&nulldev}, {&nulldev}, {&nulldev}, /* 0F4H */
{&nulldev}, {&nulldev}, {&nulldev}, {&nulldev}, /* 0F8H */
{&nulldev}, {&nulldev}, {&nulldev}, {&nulldev} /* 0FCH */
};
int32 nulldev(int32 flag, int32 data)
{
SET_XACK(0); /* set no XACK */
if (flag == 0)
return (0xFF);
return 0;
}
/*this mess gives only a warning in this state */
int32 reg_dev(int32 (*routine)(), int32 port)
{
if (dev_table[port].routine(0, 0) != &nulldev) { /* port already
assigned */
printf("Port %02X is already assigned\n", port);
} else {
printf("Port %02X is assigned\n", port);
// dev_table[port].routine(0, 0) = routine;
}
}
I would like to be able to call reg_dev with an I/O routine address and
the port number, and have it place the address into dev_table[port] IFF
dev_table[port] is currently nulldev.
I know I am messing up the pointers horribly. If I remove the
".routine(0, 0)" it errors with dissimilar variables. I have tried all
sorts of casts to no avail.
Thanks for your help and don't laugh too hard!
Bill
More information about the Simh
mailing list