prog: removed word-alignment buffering.

This commit is contained in:
Daniel Beer 2010-09-13 10:40:29 +12:00
parent 46fd2956cd
commit 93087e534d
4 changed files with 8 additions and 33 deletions

View File

@ -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

10
fet.c
View File

@ -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;
}

23
prog.c
View File

@ -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.

2
sim.c
View File

@ -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;