AltairZ80: Move find_unit_index() to altairz80_sys.c
This commit is contained in:
parent
c6e9acab8a
commit
94d0e78a2e
2 changed files with 17 additions and 27 deletions
|
@ -952,3 +952,19 @@ t_stat show_iobase(FILE *st, UNIT *uptr, int32 val, CONST void *desc)
|
||||||
return SCPE_OK;
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -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 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,
|
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);
|
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. */
|
/* These are needed for DMA. PIO Mode has not been implemented yet. */
|
||||||
extern void PutByteDMA(const uint32 Addr, const uint32 Value);
|
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 void raise_i8272_interrupt(void);
|
||||||
static int32 i8272dev(const int32 port, const int32 io, const int32 data);
|
static int32 i8272dev(const int32 port, const int32 io, const int32 data);
|
||||||
static t_stat i8272_reset(DEVICE *dptr);
|
static t_stat i8272_reset(DEVICE *dptr);
|
||||||
int32 find_unit_index (UNIT *uptr);
|
|
||||||
static const char* i8272_description(DEVICE *dptr);
|
static const char* i8272_description(DEVICE *dptr);
|
||||||
|
|
||||||
I8272_INFO i8272_info_data = { { 0x0, 0, 0xC0, 2 } };
|
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 */
|
/* Attach routine */
|
||||||
t_stat i8272_attach(UNIT *uptr, CONST char *cptr)
|
t_stat i8272_attach(UNIT *uptr, CONST char *cptr)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue