#include "ccdbg.h"
#include "ao-stmload.h"
+int ao_self_verbose;
+
+#define TRACE(...) if (ao_self_verbose) printf (__VA_ARGS__)
+
void
ao_self_block_read(struct cc_usb *cc, uint32_t address, uint8_t block[256])
{
int byte;
cc_usb_sync(cc);
cc_usb_printf(cc, "R %x\n", address);
-// printf ("read %08x\n", address);
for (byte = 0; byte < 0x100; byte++) {
block[byte] = cc_usb_getchar(cc);
-// printf (" %02x", block[byte]);
-// if ((byte & 0xf) == 0xf)
-// printf ("\n");
+ }
+ TRACE ("\nread %08x\n", address);
+ for (byte = 0; byte < 0x100; byte++) {
+ TRACE (" %02x", block[byte]);
+ if ((byte & 0xf) == 0xf)
+ TRACE ("\n");
}
}
int byte;
cc_usb_sync(cc);
cc_usb_printf(cc, "W %x\n", address);
-// printf ("write %08x\n", address);
+ TRACE ("write %08x\n", address);
+ for (byte = 0; byte < 0x100; byte++) {
+ TRACE (" %02x", block[byte]);
+ if ((byte & 0xf) == 0xf)
+ TRACE ("\n");
+ }
for (byte = 0; byte < 0x100; byte++) {
cc_usb_printf(cc, "%c", block[byte]);
-// printf (" %02x", block[byte]);
-// if ((byte & 0xf) == 0xf)
-// printf ("\n");
}
}
-struct hex_image *
+struct ao_hex_image *
ao_self_read(struct cc_usb *cc, uint32_t address, uint32_t length)
{
- struct hex_image *image;
+ struct ao_hex_image *image;
int pages;
int page;
uint32_t base = address & ~0xff;
uint32_t bound = (address + length + 0xff) & ~0xff;
- image = calloc(sizeof (struct hex_image) + (bound - base), 1);
+ image = calloc(sizeof (struct ao_hex_image) + (bound - base), 1);
image->address = base;
image->length = bound - base;
pages = image->length / 0x100;
}
int
-ao_self_write(struct cc_usb *cc, struct hex_image *image)
+ao_self_write(struct cc_usb *cc, struct ao_hex_image *image)
{
uint8_t block[256];
uint8_t check[256];
putchar('.'); fflush(stdout);
}
printf("done\n");
+ cc_usb_printf(cc,"a\n");
return 1;
}