From 93087e534db10b77c036d2873576037bde2a6df4 Mon Sep 17 00:00:00 2001 From: Daniel Beer Date: Mon, 13 Sep 2010 10:40:29 +1200 Subject: [PATCH] prog: removed word-alignment buffering. --- device.h | 6 ------ fet.c | 10 ++++++---- prog.c | 23 ++--------------------- sim.c | 2 -- 4 files changed, 8 insertions(+), 33 deletions(-) diff --git a/device.h b/device.h index 22fca3b..fed2b2f 100644 --- a/device.h +++ b/device.h @@ -54,12 +54,6 @@ struct device_breakpoint { }; struct device { - /* Start of code memory. Required to distinguish between flash - * writes (which may require alignment) and RAM writes (which - * don't). - */ - address_t code_start; - /* Breakpoint table. This should not be modified directly. * Instead, you should use the device_setbrk() helper function. This * will set the appropriate flags and ensure that the breakpoint is diff --git a/fet.c b/fet.c index 632c238..6e83311 100644 --- a/fet.c +++ b/fet.c @@ -43,6 +43,8 @@ struct fet_device { int version; /* Device-specific information */ + address_t code_start; + uint8_t fet_buf[65538]; int fet_len; @@ -476,7 +478,7 @@ static int xfer(struct fet_device *dev, static void show_dev_info(const char *name, const struct fet_device *dev) { printc("Device: %s\n", name); - printc_dbg("Code memory starts at 0x%04x\n", dev->base.code_start); + printc_dbg("Code memory starts at 0x%04x\n", dev->code_start); printc_dbg("Number of breakpoints: %d\n", dev->base.max_breakpoints); } @@ -495,7 +497,7 @@ static int identify_old(struct fet_device *dev) memcpy(idtext, dev->fet_reply.data + 4, 32); idtext[32] = 0; - dev->base.code_start = LE_WORD(dev->fet_reply.data, 0x24); + dev->code_start = LE_WORD(dev->fet_reply.data, 0x24); dev->base.max_breakpoints = LE_WORD(dev->fet_reply.data, 0x2a); show_dev_info(idtext, dev); @@ -533,7 +535,7 @@ static int identify_new(struct fet_device *dev, const char *force_id) return -1; } - dev->base.code_start = LE_WORD(r->msg29_data, 0); + dev->code_start = LE_WORD(r->msg29_data, 0); dev->base.max_breakpoints = LE_WORD(r->msg29_data, 0x14); show_dev_info(r->name, dev); @@ -590,7 +592,7 @@ static int do_erase(struct fet_device *dev) } if (xfer(dev, C_ERASE, NULL, 0, 3, FET_ERASE_MAIN, - dev->base.code_start, 0) < 0) { + dev->code_start, 0) < 0) { printc_err("fet: erase command failed\n"); return -1; } diff --git a/prog.c b/prog.c index 3948b03..1b7e577 100644 --- a/prog.c +++ b/prog.c @@ -41,15 +41,6 @@ int prog_flush(struct prog_data *prog) prog->have_erased = 1; } - /* If writing an odd number of bytes to flash memory, add a - * trailing pad byte. - */ - if (prog->addr + prog->len >= device_default->code_start && - (prog->len & 1)) { - printc_dbg("prog: adding trailing pad byte\n"); - prog->buf[prog->len++] = 0xff; - } - printc_dbg("Writing %3d bytes to %04x...\n", prog->len, prog->addr); if (device_default->writemem(device_default, prog->addr, prog->buf, prog->len) < 0) @@ -68,18 +59,8 @@ int prog_feed(struct prog_data *prog, address_t addr, prog_flush(prog) < 0) return -1; - if (!prog->len) { - /* If starting at an odd address, add a leading pad byte. */ - if (prog->addr + len >= device_default->code_start && - (addr & 1)) { - printc_dbg("prog: adding initial pad byte\n"); - prog->addr = addr - 1; - prog->len = 1; - prog->buf[0] = 0xff; - } else { - prog->addr = addr; - } - } + if (!prog->len) + prog->addr = addr; /* Add the buffer in piece by piece, flushing when it gets * full. diff --git a/sim.c b/sim.c index 111b534..5fd00b8 100644 --- a/sim.c +++ b/sim.c @@ -27,7 +27,6 @@ #include "sim.h" #define MEM_SIZE 65536 -#define MEM_CODE_START 0x8000 #define MEM_IO_END 0x200 struct sim_device { @@ -580,7 +579,6 @@ device_t sim_open(sim_fetch_func_t fetch_func, memset(dev, 0, sizeof(*dev)); - dev->base.code_start = MEM_CODE_START; dev->base.max_breakpoints = DEVICE_MAX_BREAKPOINTS; dev->base.destroy = sim_destroy; dev->base.readmem = sim_readmem;