#include <hpcboot.h>
#include <hpcmenu.h>
#include <console.h>
#include <sh3/sh_arch.h>
#include <sh3/cpu/sh4.h>
#include <sh3/dev/sh_dev.h>
#include <sh3/dev/sh.h>
#include <sh3/dev/hd64465.h>
#include <sh3/dev/mq100.h>
struct SH4dev::intr_priority SH4dev::_ipr_table[] = {
{ "TMU0", SH4_IPRA, 12 },
{ "TMU1", SH4_IPRA, 8 },
{ "TMU2", SH4_IPRA, 4 },
{ "RTC", SH4_IPRA, 0 },
{ "WDT", SH4_IPRB, 12 },
{ "REF", SH4_IPRB, 8 },
{ "SCI", SH4_IPRB, 4 },
{ "reserve", SH4_IPRB, 0 },
{ "GPIO", SH4_IPRC, 12 },
{ "DMAC", SH4_IPRC, 8 },
{ "SCIF", SH4_IPRC, 4 },
{ "H-UDI", SH4_IPRC, 0 },
{ "IRL0", SH4_IPRD, 12 },
{ "IRL1", SH4_IPRD, 8 },
{ "IRL2", SH4_IPRD, 4 },
{ "IRL3", SH4_IPRD, 0 },
{ 0, 0, 0}
};
void
SH4dev::dump(uint8_t bit)
{
int kmode;
super::dump(bit);
kmode = SetKMode(1);
if (bit & DUMP_DEV) {
icu_dump();
}
if (bit & DUMP_COMPANION) {
hd64465_dump();
}
if (bit & DUMP_VIDEO) {
mq100_dump();
}
SetKMode(kmode);
}
void
SH4dev::icu_dump()
{
#define ON(x, c) ((x) & (c) ? check[1] : check[0])
#define _(n) DPRINTF((TEXT("%S %S "), #n, ON(r, SH4_ICR_ ## n)))
static const char *check[] = { "[_]", "[x]" };
uint16_t r;
super::icu_dump_priority(_ipr_table);
r = _reg_read_2(SH4_ICR);
DPRINTF((TEXT("ICR: ")));
_(NMIL);_(MAI);_(NMIB);_(NMIE);_(IRLM);
DPRINTF((TEXT("0x%04x\n"), r));
#if 0
suspendIntr();
_reg_write_2(SH4_IPRA, 0);
_reg_write_2(SH4_IPRB, 0);
_reg_write_2(SH4_IPRC, 0);
resumeIntr(0);
while (1) {
DPRINTF((TEXT("%04x ", _reg_read_2(HD64465_NIRR))));
bitdisp(_reg_read_4(SH4_INTEVT));
}
#endif
#undef _
#undef ON
}
void
SH4dev::hd64465_dump()
{
DPRINTF((TEXT("<<<HD64465>>>\n")));
if (_reg_read_2(HD64465_SDIDR) != 0x8122) {
DPRINTF((TEXT("not found.\n")));
return;
}
DPRINTF((TEXT("SMSCR: ")));
bitdisp(_reg_read_2(HD64465_SMSCR));
DPRINTF((TEXT("SPCCR: ")));
bitdisp(_reg_read_2(HD64465_SPCCR));
DPRINTF((TEXT("\nNIRR: ")));
bitdisp(_reg_read_2(HD64465_NIRR));
DPRINTF((TEXT("NIMR: ")));
bitdisp(_reg_read_2(HD64465_NIMR));
DPRINTF((TEXT("NITR: ")));
bitdisp(_reg_read_2(HD64465_NITR));
#if 0
suspendIntr();
while (1)
bitdisp(_reg_read_2(HD64465_NIRR));
#endif
}
void
SH4dev::mq100_dump()
{
uint32_t a, e;
int i;
DPRINTF((TEXT("<<<MQ100/HD64464>>>\n")));
a = MQ100_FB_BASE + 0x4b000;
e = a + 640 * 480 * sizeof(uint16_t);
while (a < e) {
for (i = 0; i < 640; i++, a += sizeof(uint16_t))
_reg_write_2(a, ~_reg_read_2(a) & 0xffff);
}
}