static uint64_t sh7750_mmct_read(void *opaque, target_phys_addr_t addr, unsigned size) { SH7750State *s = opaque; uint32_t ret = 0; if (size != 4) { return invalid_read(opaque, addr); } switch (MM_REGION_TYPE(addr)) { case MM_ICACHE_ADDR: case MM_ICACHE_DATA: /* do nothing */ break; case MM_ITLB_ADDR: ret = cpu_sh4_read_mmaped_itlb_addr(s->cpu, addr); break; case MM_ITLB_DATA: ret = cpu_sh4_read_mmaped_itlb_data(s->cpu, addr); break; case MM_OCACHE_ADDR: case MM_OCACHE_DATA: /* do nothing */ break; case MM_UTLB_ADDR: ret = cpu_sh4_read_mmaped_utlb_addr(s->cpu, addr); break; case MM_UTLB_DATA: ret = cpu_sh4_read_mmaped_utlb_data(s->cpu, addr); break; default: abort(); } return ret; }
static unsigned8 read_byte(device *me, hw_eeprom_device *eeprom, unsigned_word address) { /* may need multiple iterations of this */ while (1) { switch (eeprom->state) { case read_reset: return eeprom->memory[address]; case autoselect: if ((address & 0xff) == 0x00) return eeprom->manufacture_code; else if ((address & 0xff) == 0x01) return eeprom->device_code; else return 0; /* not certain about this */ case byte_programming: if (device_event_queue_time(me) > eeprom->program_finish_time) { finish_programming_byte(me, eeprom); eeprom->state = read_reset; continue; } else if (address == eeprom->byte_program_address) { return toggle(eeprom, eeprom->memory[address]); } else { /* trash that memory location */ invalid_read(me, eeprom->state, address, "not byte program address"); eeprom->memory[address] = (eeprom->memory[address] & eeprom->byte_program_byte); return toggle(eeprom, eeprom->memory[eeprom->byte_program_address]); } case chip_erase: if (device_event_queue_time(me) > eeprom->program_finish_time) { finish_erasing_chip(me, eeprom); eeprom->state = read_reset; continue; } else { return toggle(eeprom, eeprom->memory[address]); } case sector_erase: if (device_event_queue_time(me) > eeprom->program_finish_time) { finish_erasing_sector(me, eeprom); eeprom->state = read_reset; continue; } else if (!eeprom->sectors[address / eeprom->sizeof_sector]) { /* read to wrong sector */ invalid_read(me, eeprom->state, address, "sector not being erased"); return toggle(eeprom, eeprom->memory[address]) & ~0x8; } else if (device_event_queue_time(me) > eeprom->sector_start_time) { return toggle(eeprom, eeprom->memory[address]) | 0x8; } else { return toggle(eeprom, eeprom->memory[address]) & ~0x8; } case sector_erase_suspend: if (!eeprom->sectors[address / eeprom->sizeof_sector]) { return eeprom->memory[address]; } else { invalid_read(me, eeprom->state, address, "sector being erased"); return eeprom->memory[address]; } default: invalid_read(me, eeprom->state, address, "invalid state"); return eeprom->memory[address]; } } return 0; }