···9898its progress as it reads the transmitted data and saves it to `dataflash.bin`.
9999You may want to run it twice and compare checksums of the two resulting files.
100100101101+### `memdump.asm`
102102+103103+Mem Dump is used to read the contents of the current 64Kb of memory.
104104+It does not read additional pages of memory but shows the current layout of
105105+code page 0, the slot `0x4000` and `0x8000` devices, and page 0 of RAM.
106106+107107+You need to type the hex values of `z80/memdump.bin` into one of the
108108+application slots as detailed above.
109109+110110+Run `obj/recvdump -mem` to wait for the memory dump to begin.
111111+112112+Then run the new Mem Dump app on the Mailstation and `recvdump` should show
113113+its progress as it reads the transmitted data and saves it to `mem.bin`.
114114+101115### Extracting programs from `dataflash` dumps
102116103117While most of the core functionality of the Mailstation lives on the codeflash
+82
memdump.asm
···11+;
22+; Based off of spew.asm from Cyrano Jones on the mailstation Yahoo Group,
33+; modified to send 64kb of memory.
44+;
55+; Originally written to be assembled with AS80, converted to SDCC ASZ80 syntax.
66+;
77+88+ .module memdump
99+1010+ .area _DATA
1111+ .area _HEADER (ABS)
1212+ .org 0x4000 ; This is *always* #4000, regardless of
1313+ ; what page you use.
1414+1515+ jp eventhandler
1616+1717+ .dw (icons) ; icon location (in this page)
1818+ .dw (caption)
1919+ .dw (dunno)
2020+dunno:
2121+ .db #0
2222+xpos:
2323+ .dw #0
2424+ypos:
2525+ .dw #0
2626+caption:
2727+ .dw #0x0001 ; ?????
2828+ .dw (endcap - caption - 6) ; end of chars
2929+ .dw #0x0006 ; offset to first char
3030+ .ascii "Mem Dump" ; the caption string
3131+endcap:
3232+3333+icons:
3434+ .dw #0 ; size icon0
3535+ .dw (icon0 - icons) ; offset to icon0
3636+ .dw #0 ; size icon1
3737+ .dw (icon1 - icons) ; offset to icon1 (0x00b5)
3838+icon0:
3939+ .dw #0 ; icon width
4040+ .db #0 ; icon height
4141+icon1:
4242+ .dw #0 ; icon width
4343+ .db #0 ; icon height
4444+4545+4646+ .equ bsendbyte, #0x802D ; raises busy & sends byte.
4747+ ; We use the existing sendbyte from
4848+ ; original update code. This means
4949+ ; codeflash page #01 needs to be banked
5050+ ; in to slot8000 before calling bsendbyte.
5151+5252+ .equ done, #0x0000 ; Gotta go somewhere when done, we reboot.
5353+ ; Mailstation will call eventhandler 3
5454+ ; or 4 times when you select the new
5555+ ; application, and we only want to exec
5656+ ; once, so we do not return at end, we
5757+ ; reboot after first "event".
5858+5959+eventhandler:
6060+ ld a, #0 ; set slot8000device = codeflash
6161+ out (8), a
6262+ ld a, #1 ; bank bsendbyte into slot8000
6363+ out (7), a
6464+6565+ ld de, #0x0000
6666+byteloop:
6767+ ld a, (de)
6868+ ld h, a
6969+ push de
7070+ call bsendbyte ; send byte(H)
7171+ pop de
7272+7373+ ld a, d
7474+ cp #0xff
7575+ jr nz, incde
7676+ ld a, e
7777+ cp #0xff
7878+ jr nz, incde
7979+ jp done
8080+incde:
8181+ inc de
8282+ jr byteloop
+26-12
util/recvdump.c
···22 * recvdump
33 * based on win32/maildump.cpp by FyberOptic
44 *
55- * usage: recvdump [-data | -code]
55+ * usage: recvdump [-data | -code | -mem]
66 *
77 * must be run as root to set iopl and use inb/outb
88 *
···20202121#include "tribble.h"
22222323+void
2424+usage(void)
2525+{
2626+ printf("usage: %s [-code | -data | -mem]\n", getprogname());
2727+ exit(1);
2828+}
2929+2330int
2431main(int argc, char *argv[])
2532{
2633 FILE *pFile;
2734 unsigned int received = 0, expected = 0;
2828- unsigned char b;
3535+ int b;
2936 char fn[14];
3030- int codeflash = 0, dataflash = 0;
3737+ int codeflash = 0, dataflash = 0, mem = 0;
3138 int x;
32393340 for (x = 1; x < argc; x++) {
3434- if (strncmp((char *)argv[x], "-code", 5) == 0)
4141+ if (strncmp((char *)argv[x], "-code", 5) == 0) {
4242+ if (dataflash || mem)
4343+ usage();
3544 codeflash = 1;
3636- else if (strncmp((char *)argv[x], "-data", 5) == 0)
4545+ } else if (strncmp((char *)argv[x], "-data", 5) == 0) {
4646+ if (codeflash || mem)
4747+ usage();
3748 dataflash = 1;
3838- else
4949+ } else if (strncmp((char *)argv[x], "-mem", 4) == 0) {
5050+ if (codeflash || dataflash)
5151+ usage();
5252+ mem = 1;
5353+ } else
3954 printf("unknown parameter: %s\n", argv[x]);
4055 }
41564242- if (codeflash == dataflash) {
4343- printf("usage: %s [-code | -data]\n", argv[0]);
4444- return 1;
4545- }
4646-4757 if (codeflash) {
4858 expected = 1024 * 1024;
4959 strlcpy(fn, "codeflash.bin", sizeof(fn));
5060 } else if (dataflash) {
5161 expected = 1024 * 512;
5262 strlcpy(fn, "dataflash.bin", sizeof(fn));
5353- }
6363+ } else if (mem) {
6464+ expected = (1024 * 64) - 1;
6565+ strlcpy(fn, "mem.bin", sizeof(fn));
6666+ } else
6767+ usage();
54685569 if (geteuid() != 0)
5670 errx(1, "must be run as root");