diff --git a/AltairZ80/altairz80_sys.c b/AltairZ80/altairz80_sys.c index 2c239175..6e526027 100644 --- a/AltairZ80/altairz80_sys.c +++ b/AltairZ80/altairz80_sys.c @@ -952,3 +952,19 @@ t_stat show_iobase(FILE *st, UNIT *uptr, int32 val, CONST void *desc) return SCPE_OK; } +/* find_unit_index find index of a unit + + Inputs: + uptr = pointer to unit + Outputs: + result = index of device +*/ +int32 find_unit_index(UNIT* uptr) +{ + DEVICE *dptr = find_dev_from_unit(uptr); + + if (dptr == NULL) + return -1; + + return (uptr - dptr->units); +} diff --git a/AltairZ80/i8272.c b/AltairZ80/i8272.c index 7e1bb4b7..cd8161bd 100644 --- a/AltairZ80/i8272.c +++ b/AltairZ80/i8272.c @@ -129,6 +129,7 @@ extern t_stat set_iobase(UNIT *uptr, int32 val, CONST char *cptr, void *desc); extern t_stat show_iobase(FILE *st, UNIT *uptr, int32 val, CONST void *desc); extern uint32 sim_map_resource(uint32 baseaddr, uint32 size, uint32 resource_type, int32 (*routine)(const int32, const int32, const int32), const char* name, uint8 unmap); +extern int32 find_unit_index(UNIT* uptr); /* These are needed for DMA. PIO Mode has not been implemented yet. */ extern void PutByteDMA(const uint32 Addr, const uint32 Value); @@ -166,7 +167,6 @@ extern uint8 GetByteDMA(const uint32 Addr); static void raise_i8272_interrupt(void); static int32 i8272dev(const int32 port, const int32 io, const int32 data); static t_stat i8272_reset(DEVICE *dptr); -int32 find_unit_index (UNIT *uptr); static const char* i8272_description(DEVICE *dptr); I8272_INFO i8272_info_data = { { 0x0, 0, 0xC0, 2 } }; @@ -243,32 +243,6 @@ static t_stat i8272_reset(DEVICE *dptr) } -/* find_unit_index find index of a unit - - Inputs: - uptr = pointer to unit - Outputs: - result = index of device -*/ -int32 find_unit_index (UNIT *uptr) -{ - DEVICE *dptr; - uint32 i; - - if (uptr == NULL) - return (-1); - dptr = find_dev_from_unit(uptr); - for(i=0; inumunits; i++) { - if(dptr->units + i == uptr) { - break; - } - } - if(i == dptr->numunits) { - return (-1); - } - return (i); -} - /* Attach routine */ t_stat i8272_attach(UNIT *uptr, CONST char *cptr) {