--- ./src/promemul/yamon.c.orig Sat May 5 14:02:45 2007 +++ ./src/promemul/yamon.c Sat May 5 16:43:21 2007 @@ -188,17 +188,47 @@ CACHE_DATA | NO_EXCEPTIONS); break; - case YAMON_SYSCON_READ_OFS: + case YAMON_SYSCON_READ_OFS: { /* - * syscon + * syscon_read(oid [a0], addr [a1], size [a2]) */ - fatal("[ yamon_emul(): syscon: TODO ]\n"); + uint32_t oid; + void *paddr; + uint32_t psize; - /* TODO. For now, return some kind of "failure": */ - cpu->cd.mips.gpr[MIPS_GPR_V0] = 1; + oid = cpu->cd.mips.gpr[MIPS_GPR_A0]; + paddr = (void *)(intptr_t)cpu->cd.mips.gpr[MIPS_GPR_A1]; + psize = cpu->cd.mips.gpr[MIPS_GPR_A2]; + + switch (oid) { + case SYSCON_BOARD_CPU_CLOCK_FREQ_ID: + if (psize == sizeof(uint32_t)) { + uint32_t freq = cpu->machine->emulated_hz; + + debug("[ yamon_emul(): reporting CPU " + "frequency of %u ]\n", freq); + + cpu->memory_rw(cpu, cpu->mem, (int32_t)paddr, + (void *)&freq, sizeof(freq), + MEM_WRITE, CACHE_DATA | NO_EXCEPTIONS); + + cpu->cd.mips.gpr[MIPS_GPR_V0] = 0; + break; + } else { + cpu->cd.mips.gpr[MIPS_GPR_V0] = 1; + } + break; + default: + fatal("[ yamon_emul(): unimplemented object id 0x%" + PRIx32" ]\n", oid); + cpu->cd.mips.gpr[MIPS_GPR_V0] = 1; + break; + } /* oid */ + } /* read ofs */ break; - default:cpu_register_dump(cpu->machine, cpu, 1, 0); + default: + cpu_register_dump(cpu->machine, cpu, 1, 0); printf("\n"); fatal("[ yamon_emul(): unimplemented yamon function 0x%" PRIx32" ]\n", ofs);