Other data shuffled around

This commit is contained in:
Angelo Salese 2013-08-17 19:10:48 +00:00
parent 58d7e9116f
commit 42ce257553
3 changed files with 245 additions and 341 deletions

View File

@ -115,7 +115,7 @@ static ADDRESS_MAP_START( dc_map, AS_PROGRAM, 64, dc_cons_state )
AM_RANGE(0x00200000, 0x0021ffff) AM_ROM AM_REGION("maincpu", 0x200000) // flash
AM_RANGE(0x005f6800, 0x005f69ff) AM_READWRITE(dc_sysctrl_r, dc_sysctrl_w )
AM_RANGE(0x005f6c00, 0x005f6cff) AM_DEVICE32( "maple_dc", maple_dc_device, amap, U64(0xffffffffffffffff) )
AM_RANGE(0x005f7000, 0x005f70ff) AM_READWRITE(dc_mess_gdrom_r, dc_mess_gdrom_w )
AM_RANGE(0x005f7000, 0x005f70ff) AM_READWRITE32(dc_mess_gdrom_r, dc_mess_gdrom_w, U64(0xffffffffffffffff) )
AM_RANGE(0x005f7400, 0x005f74ff) AM_READWRITE32(dc_mess_g1_ctrl_r, dc_mess_g1_ctrl_w, U64(0xffffffffffffffff) )
AM_RANGE(0x005f7800, 0x005f78ff) AM_READWRITE(dc_g2_ctrl_r, dc_g2_ctrl_w )
AM_RANGE(0x005f7c00, 0x005f7cff) AM_DEVICE32("powervr2", powervr2_device, pd_dma_map, U64(0xffffffffffffffff))

View File

@ -33,13 +33,11 @@ public:
void atapi_cmd_identify_packet();
void atapi_cmd_set_features();
READ32_MEMBER( atapi_r );
WRITE32_MEMBER( atapi_w );
void dreamcast_atapi_init();
void dreamcast_atapi_reset();
inline int decode_reg32_64(UINT32 offset, UINT64 mem_mask, UINT64 *shift);
READ64_MEMBER( dc_mess_gdrom_r );
WRITE64_MEMBER( dc_mess_gdrom_w );
READ32_MEMBER( dc_mess_gdrom_r );
WRITE32_MEMBER( dc_mess_gdrom_w );
READ32_MEMBER( dc_mess_g1_ctrl_r );
WRITE32_MEMBER( dc_mess_g1_ctrl_w );

View File

@ -295,15 +295,87 @@ TIMER_CALLBACK_MEMBER(dc_cons_state::atapi_xfer_end )
printf( "atapi_xfer_end: %d %d\n", atapi_xferlen, atapi_xfermod );
}
READ32_MEMBER(dc_cons_state::atapi_r )
void dc_cons_state::dreamcast_atapi_init()
{
int reg, data;
xfer_mode = ATAPI_XFER_PIO;
if (mem_mask == 0x0000ffff) // word-wide command read
atapi_regs = auto_alloc_array_clear(machine(), UINT8, ATAPI_REG_MAX);
atapi_regs[ATAPI_REG_CMDSTATUS] = 0;
atapi_regs[ATAPI_REG_ERROR] = 1;
atapi_regs[ATAPI_REG_COUNTLOW] = 0x14;
atapi_regs[ATAPI_REG_COUNTHIGH] = 0xeb;
atapi_data_ptr = 0;
atapi_data_len = 0;
atapi_cdata_wait = 0;
atapi_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(dc_cons_state::atapi_xfer_end),this));
atapi_timer->adjust(attotime::never);
atapi_cmd_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(dc_cons_state::atapi_cmd_exec),this));
atapi_cmd_timer->adjust(attotime::never);
gdrom = NULL;
atapi_data = auto_alloc_array(machine(), UINT8, ATAPI_DATA_SIZE );
save_pointer(NAME(atapi_regs), ATAPI_REG_MAX );
save_pointer(NAME(atapi_data), ATAPI_DATA_SIZE / 2 );
save_item(NAME(atapi_data_ptr));
save_item(NAME(atapi_data_len));
save_item(NAME(atapi_xferlen));
save_item(NAME(atapi_xferbase));
save_item(NAME(atapi_cdata_wait));
save_item(NAME(atapi_xfermod));
gdrom = machine().device<gdrom_device>( "cdrom" );
}
void dc_cons_state::dreamcast_atapi_reset()
{
atapi_regs[ATAPI_REG_CMDSTATUS] = 0;
atapi_regs[ATAPI_REG_ERROR] = 1;
atapi_regs[ATAPI_REG_COUNTLOW] = 0x14;
atapi_regs[ATAPI_REG_COUNTHIGH] = 0xeb;
atapi_data_ptr = 0;
atapi_data_len = 0;
atapi_cdata_wait = 0;
atapi_xferlen = 0;
atapi_xfermod = 0;
}
/*
GDROM regsters:
5f7018: alternate status/device control
5f7080: data
5f7084: error/features
5f7088: interrupt reason/sector count
5f708c: sector number
5f7090: byte control low
5f7094: byte control high
5f7098: drive select
5f709c: status/command
c002910 - ATAPI packet writes
c002796 - aux status read after that
c000776 - DMA triggered to c008000
*/
READ32_MEMBER(dc_cons_state::dc_mess_gdrom_r)
{
// printf("gdrom_r: @ %x (off %x), mask %llx (PC %x)\n", offset, off, mem_mask, space.device().safe_pc());
switch(offset)
{
// mame_printf_debug("ATAPI: packet read = %04x\n", atapi_data[atapi_data_ptr]);
// assert IRQ and drop DRQ
case 0x18/4:
return atapi_regs[ATAPI_REG_CMDSTATUS];
case 0x80/4:
UINT32 data;
if (atapi_data_ptr == 0 && atapi_data_len == 0)
{
// get the data from the device
@ -365,67 +437,39 @@ READ32_MEMBER(dc_cons_state::atapi_r )
{
data = 0;
}
}
else
{
reg = offset;
// get read-only side of read-only/write-only registers from elsewhere
if (reg == ATAPI_REG_FEATURES)
{
reg = ATAPI_REG_ERROR;
}
if (reg == ATAPI_REG_CMDSTATUS)
{
return data;
case 0x84/4:
return atapi_regs[ATAPI_REG_ERROR];
case 0x88/4:
return atapi_regs[ATAPI_REG_INTREASON];
case 0x8c/4:
return atapi_regs[ATAPI_REG_SAMTAG];
case 0x90/4:
return atapi_regs[ATAPI_REG_COUNTLOW];
case 0x94/4:
return atapi_regs[ATAPI_REG_COUNTHIGH];
case 0x98/4:
return atapi_regs[ATAPI_REG_DRIVESEL];
case 0x9c/4:
dc_sysctrl_regs[SB_ISTEXT] &= ~IST_EXT_GDROM;
dc_update_interrupt_status();
}
data = atapi_regs[reg];
#if 0
switch( reg )
{
case ATAPI_REG_DATA:
printf( "atapi_r: data=%02x\n", data );
break;
case ATAPI_REG_ERROR:
printf( "atapi_r: error=%02x\n", data );
break;
case ATAPI_REG_INTREASON:
printf( "atapi_r: intreason=%02x\n", data );
break;
case ATAPI_REG_SAMTAG:
printf( "atapi_r: samtag=%02x\n", data );
break;
case ATAPI_REG_COUNTLOW:
printf( "atapi_r: countlow=%02x\n", data );
break;
case ATAPI_REG_COUNTHIGH:
printf( "atapi_r: counthigh=%02x\n", data );
break;
case ATAPI_REG_DRIVESEL:
printf( "atapi_r: drivesel=%02x\n", data );
break;
case ATAPI_REG_CMDSTATUS:
printf( "atapi_r: cmdstatus=%02x\n", data );
break;
}
#endif
mame_printf_debug("ATAPI: read reg %d = %x (PC=%x)\n", reg, data, space.device().safe_pc());
return atapi_regs[ATAPI_REG_CMDSTATUS];
}
// printf( "atapi_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
return data;
return 0;
}
WRITE32_MEMBER(dc_cons_state::atapi_w )
WRITE32_MEMBER(dc_cons_state::dc_mess_gdrom_w )
{
int reg;
// printf( "atapi_w( %08x, %08x, %08x )\n", offset, mem_mask, data );
if (mem_mask == 0x0000ffff) // word-wide command write
switch(offset)
{
case 0x18/4:
/* Device Control */
//COMBINE_DATA(&atapi_regs[ATAPI_REG_CMDSTATUS]);
return;
/* TODO: move this behind a timer */
case 0x80/4:
{
// printf("atapi_w: data=%04x\n", data );
@ -451,7 +495,6 @@ WRITE32_MEMBER(dc_cons_state::atapi_w )
printf("cdata wait status\n");
}
}
else if ( atapi_data_ptr == 12 )
{
int phase;
@ -545,42 +588,26 @@ WRITE32_MEMBER(dc_cons_state::atapi_w )
}
}
}
else
{
reg = offset;
#if 0
switch( reg )
{
case ATAPI_REG_DATA:
printf( "atapi_w: data=%02x\n", data );
break;
case ATAPI_REG_FEATURES:
printf( "atapi_w: features=%02x\n", data );
break;
case ATAPI_REG_INTREASON:
printf( "atapi_w: intreason=%02x\n", data );
break;
case ATAPI_REG_SAMTAG:
printf( "atapi_w: samtag=%02x\n", data );
break;
case ATAPI_REG_COUNTLOW:
printf( "atapi_w: countlow=%02x\n", data );
break;
case ATAPI_REG_COUNTHIGH:
printf( "atapi_w: counthigh=%02x\n", data );
break;
case ATAPI_REG_DRIVESEL:
printf( "atapi_w: drivesel=%02x\n", data );
break;
case ATAPI_REG_CMDSTATUS:
printf( "atapi_w: cmdstatus=%02x\n", data );
break;
}
#endif
atapi_regs[reg] = data;
// mame_printf_debug("ATAPI: reg %d = %x (offset %x mask %x PC=%x)\n", reg, data, offset, mem_mask, space.device().safe_pc());
if (reg == ATAPI_REG_CMDSTATUS)
return;
case 0x84/4:
COMBINE_DATA(&atapi_regs[ATAPI_REG_FEATURES]);
return;
case 0x88/4:
COMBINE_DATA(&atapi_regs[ATAPI_REG_INTREASON]);
return;
case 0x8c/4:
COMBINE_DATA(&atapi_regs[ATAPI_REG_SAMTAG]);
return;
case 0x90/4:
COMBINE_DATA(&atapi_regs[ATAPI_REG_COUNTLOW]);
return;
case 0x94/4:
COMBINE_DATA(&atapi_regs[ATAPI_REG_COUNTHIGH]);
return;
case 0x98/4:
COMBINE_DATA(&atapi_regs[ATAPI_REG_DRIVESEL]);
return;
case 0x9c/4:
{
printf("ATAPI command %x issued! (PC=%x)\n", data, space.device().safe_pc());
@ -591,130 +618,9 @@ WRITE32_MEMBER(dc_cons_state::atapi_w )
/* TODO: timing of this */
atapi_cmd_timer->adjust(m_maincpu->cycles_to_attotime(ATAPI_CYCLES_PER_SECTOR));
}
}
}
void dc_cons_state::dreamcast_atapi_init()
{
xfer_mode = ATAPI_XFER_PIO;
atapi_regs = auto_alloc_array_clear(machine(), UINT8, ATAPI_REG_MAX);
atapi_regs[ATAPI_REG_CMDSTATUS] = 0;
atapi_regs[ATAPI_REG_ERROR] = 1;
atapi_regs[ATAPI_REG_COUNTLOW] = 0x14;
atapi_regs[ATAPI_REG_COUNTHIGH] = 0xeb;
atapi_data_ptr = 0;
atapi_data_len = 0;
atapi_cdata_wait = 0;
atapi_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(dc_cons_state::atapi_xfer_end),this));
atapi_timer->adjust(attotime::never);
atapi_cmd_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(dc_cons_state::atapi_cmd_exec),this));
atapi_cmd_timer->adjust(attotime::never);
gdrom = NULL;
atapi_data = auto_alloc_array(machine(), UINT8, ATAPI_DATA_SIZE );
save_pointer(NAME(atapi_regs), ATAPI_REG_MAX );
save_pointer(NAME(atapi_data), ATAPI_DATA_SIZE / 2 );
save_item(NAME(atapi_data_ptr));
save_item(NAME(atapi_data_len));
save_item(NAME(atapi_xferlen));
save_item(NAME(atapi_xferbase));
save_item(NAME(atapi_cdata_wait));
save_item(NAME(atapi_xfermod));
gdrom = machine().device<gdrom_device>( "cdrom" );
}
void dc_cons_state::dreamcast_atapi_reset()
{
atapi_regs[ATAPI_REG_CMDSTATUS] = 0;
atapi_regs[ATAPI_REG_ERROR] = 1;
atapi_regs[ATAPI_REG_COUNTLOW] = 0x14;
atapi_regs[ATAPI_REG_COUNTHIGH] = 0xeb;
atapi_data_ptr = 0;
atapi_data_len = 0;
atapi_cdata_wait = 0;
atapi_xferlen = 0;
atapi_xfermod = 0;
}
/*
GDROM regsters:
5f7018: alternate status/device control
5f7080: data
5f7084: error/features
5f7088: interrupt reason/sector count
5f708c: sector number
5f7090: byte control low
5f7094: byte control high
5f7098: drive select
5f709c: status/command
c002910 - ATAPI packet writes
c002796 - aux status read after that
c000776 - DMA triggered to c008000
*/
READ64_MEMBER(dc_cons_state::dc_mess_gdrom_r )
{
UINT32 off;
if ((int)~mem_mask & 1)
{
off=(offset << 1) | 1;
}
else
{
off=offset << 1;
return;
}
// printf("gdrom_r: @ %x (off %x), mask %llx (PC %x)\n", offset, off, mem_mask, space.device().safe_pc());
if (offset == 3)
{
//debugger_break(machine());
//printf("%08x\n",atapi_regs[ATAPI_REG_CMDSTATUS]);
return atapi_regs[ATAPI_REG_CMDSTATUS];
}
else if (off >= 0x20)
{
return atapi_r(space, off-0x20, 0xff);
}
return 0;
}
WRITE64_MEMBER(dc_cons_state::dc_mess_gdrom_w )
{
UINT32 dat,off;
if ((int)~mem_mask & 1)
{
dat=(UINT32)(data >> 32);
off=(offset << 1) | 1;
}
else
{
dat=(UINT32)data;
off=offset << 1;
}
// printf("GDROM: [%08x=%x]write %llx to %x, mask %llx (PC %x)\n", 0x5f7000+off*4, dat, data, offset, mem_mask, space.device().safe_pc());
if (off >= 0x20)
{
atapi_w(space, off-0x20, dat, (UINT32)mem_mask);
}
}
// register decode helpers