X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp.git/blobdiff_plain/f66d9570ec64ecaa1f879619a0e4fed8d5fa7803..226d32211880a061265faf6b8eadaf6ca1ec7a38:/avr/z80-if.c diff --git a/avr/z80-if.c b/avr/z80-if.c index 180a27f..7a953f0 100644 --- a/avr/z80-if.c +++ b/avr/z80-if.c @@ -506,6 +506,8 @@ int32_t z80_memsize_detect(void) return addr; } +/*--------------------------------------------------------------------------*/ + void z80_write(uint32_t addr, uint8_t data) { z80_setaddress(addr); @@ -605,6 +607,7 @@ void z80_read_block (uint8_t *dest, uint32_t src, size_t length) Z80_O_MREQ = 1; } +/*--------------------------------------------------------------------------*/ /* 0179' rx.bs_mask: ds 1 ; (buf_len - 1) @@ -745,3 +748,31 @@ void z80_memfifo_putc(fifo_t f, uint8_t val) z80_write(fifo_dsc[f].base+FIFO_INDEX_IN, fifo_dsc[f].idx_in); z80_bus_cmd(Release); } + +/*--------------------------------------------------------------------------*/ + +void z80_load_mem(int_fast8_t verbosity, + const FLASH unsigned char data[], + const FLASH unsigned long *sections, + const FLASH unsigned long address[], + const FLASH unsigned long length_of_sections[]) +{ + uint32_t sec_base = 0; + + if (verbosity > 1) + printf_P(PSTR("Loading Z180 memory... \n")); + + for (unsigned sec = 0; sec < *sections; sec++) { + if (verbosity > 0) { + printf_P(PSTR(" From: 0x%.5lX to: 0x%.5lX (%5li bytes)\n"), + address[sec], + address[sec]+length_of_sections[sec] - 1, + length_of_sections[sec]); + } + + z80_write_block_P((const FLASH unsigned char *) &data[sec_base], /* src */ + address[sec], /* dest */ + length_of_sections[sec]); /* len */ + sec_base += length_of_sections[sec]; + } +}