prog: removed word-alignment buffering.
This commit is contained in:
parent
46fd2956cd
commit
93087e534d
6
device.h
6
device.h
|
@ -54,12 +54,6 @@ struct device_breakpoint {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct device {
|
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.
|
/* Breakpoint table. This should not be modified directly.
|
||||||
* Instead, you should use the device_setbrk() helper function. This
|
* Instead, you should use the device_setbrk() helper function. This
|
||||||
* will set the appropriate flags and ensure that the breakpoint is
|
* will set the appropriate flags and ensure that the breakpoint is
|
||||||
|
|
10
fet.c
10
fet.c
|
@ -43,6 +43,8 @@ struct fet_device {
|
||||||
int version;
|
int version;
|
||||||
|
|
||||||
/* Device-specific information */
|
/* Device-specific information */
|
||||||
|
address_t code_start;
|
||||||
|
|
||||||
uint8_t fet_buf[65538];
|
uint8_t fet_buf[65538];
|
||||||
int fet_len;
|
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)
|
static void show_dev_info(const char *name, const struct fet_device *dev)
|
||||||
{
|
{
|
||||||
printc("Device: %s\n", name);
|
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);
|
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);
|
memcpy(idtext, dev->fet_reply.data + 4, 32);
|
||||||
idtext[32] = 0;
|
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);
|
dev->base.max_breakpoints = LE_WORD(dev->fet_reply.data, 0x2a);
|
||||||
|
|
||||||
show_dev_info(idtext, dev);
|
show_dev_info(idtext, dev);
|
||||||
|
@ -533,7 +535,7 @@ static int identify_new(struct fet_device *dev, const char *force_id)
|
||||||
return -1;
|
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);
|
dev->base.max_breakpoints = LE_WORD(r->msg29_data, 0x14);
|
||||||
|
|
||||||
show_dev_info(r->name, dev);
|
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,
|
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");
|
printc_err("fet: erase command failed\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
21
prog.c
21
prog.c
|
@ -41,15 +41,6 @@ int prog_flush(struct prog_data *prog)
|
||||||
prog->have_erased = 1;
|
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);
|
printc_dbg("Writing %3d bytes to %04x...\n", prog->len, prog->addr);
|
||||||
if (device_default->writemem(device_default, prog->addr,
|
if (device_default->writemem(device_default, prog->addr,
|
||||||
prog->buf, prog->len) < 0)
|
prog->buf, prog->len) < 0)
|
||||||
|
@ -68,18 +59,8 @@ int prog_feed(struct prog_data *prog, address_t addr,
|
||||||
prog_flush(prog) < 0)
|
prog_flush(prog) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!prog->len) {
|
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;
|
prog->addr = addr;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add the buffer in piece by piece, flushing when it gets
|
/* Add the buffer in piece by piece, flushing when it gets
|
||||||
* full.
|
* full.
|
||||||
|
|
2
sim.c
2
sim.c
|
@ -27,7 +27,6 @@
|
||||||
#include "sim.h"
|
#include "sim.h"
|
||||||
|
|
||||||
#define MEM_SIZE 65536
|
#define MEM_SIZE 65536
|
||||||
#define MEM_CODE_START 0x8000
|
|
||||||
#define MEM_IO_END 0x200
|
#define MEM_IO_END 0x200
|
||||||
|
|
||||||
struct sim_device {
|
struct sim_device {
|
||||||
|
@ -580,7 +579,6 @@ device_t sim_open(sim_fetch_func_t fetch_func,
|
||||||
|
|
||||||
memset(dev, 0, sizeof(*dev));
|
memset(dev, 0, sizeof(*dev));
|
||||||
|
|
||||||
dev->base.code_start = MEM_CODE_START;
|
|
||||||
dev->base.max_breakpoints = DEVICE_MAX_BREAKPOINTS;
|
dev->base.max_breakpoints = DEVICE_MAX_BREAKPOINTS;
|
||||||
dev->base.destroy = sim_destroy;
|
dev->base.destroy = sim_destroy;
|
||||||
dev->base.readmem = sim_readmem;
|
dev->base.readmem = sim_readmem;
|
||||||
|
|
Loading…
Reference in New Issue