MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / flash_write

Function flash_write

src/flashrom.cpp:744–874  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

742}
743
744bool flash_write(void *fdv, uaecptr addr, uae_u8 v)
745{
746 struct flashrom_data *fd = (struct flashrom_data*)fdv;
747 int other_byte_mult = 1;
748
749 if (!fd)
750 return false;
751
752 if (fd->flags & (FLASHROM_SKIP_EVERY_OTHER_BYTE | FLASHROM_EVERY_OTHER_BYTE)) {
753 addr >>= 1;
754 other_byte_mult = 2;
755 }
756
757 if (addr * other_byte_mult >= fd->allocsize) {
758 return false;
759 }
760
761 int oldstate = fd->state;
762 bool det = false;
763
764#if FLASH_LOG > 1
765 write_log(_T("flash write %08x %02x (%d) PC=%08x\n"), addr, v, fd->state, m68k_getpc());
766#endif
767
768 addr &= fd->mask;
769
770 if (fd->state == 7 || fd->state == 8) {
771 int a = addr * other_byte_mult;
772 writeflash(fd, a, v);
773 return true;
774 }
775
776 if (v == 0xf0 && fd->state > 0 && fd->state < 7) {
777 fd->state = 0;
778 return false;
779 }
780
781 // unlock
782 if (addr == 0x5555 && fd->state <= 2 && v == 0xaa) {
783 fd->state = 1;
784 det = true;
785 }
786 if (addr == 0x2aaa && fd->state == 1 && v == 0x55) {
787 fd->state = 2;
788 det = true;
789 }
790
791 // software id exit and reset first byte
792 if (addr == 0x5555 && fd->state == 3 && v == 0xaa) {
793 fd->state = 1;
794 det = true;
795 }
796
797 // autoselect
798 if (addr == 0x5555 && fd->state == 2 && v == 0x90) {
799 fd->state = 3;
800 det = true;
801 }

Callers 6

blizzardf0_bputFunction · 0.85
blizzardea_bputFunction · 0.85
dummy_putFunction · 0.85
ide_write_byteFunction · 0.85
special_pcem_putFunction · 0.85
write_rombyteFunction · 0.85

Calls 5

m68k_getpcFunction · 0.85
writeflashFunction · 0.85
setmodifiedFunction · 0.85
write_logFunction · 0.70
gui_flicker_ledFunction · 0.50

Tested by

no test coverage detected