AltairZ80: Move find_unit_index() to altairz80_sys.c

This commit is contained in:
Howard M. Harte 2023-04-01 07:01:12 -07:00
parent c6e9acab8a
commit 94d0e78a2e
2 changed files with 17 additions and 27 deletions

View file

@ -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);
}

View file

@ -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; i<dptr->numunits; 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)
{