fet: experimental support for Info A/BSL flash access.
This commit is contained in:
parent
fd0199901c
commit
2924dee3a2
|
@ -50,6 +50,7 @@ struct fet_device {
|
|||
int poll_enable;
|
||||
|
||||
struct fet_proto proto;
|
||||
fperm_t active_fperm;
|
||||
};
|
||||
|
||||
/**********************************************************************
|
||||
|
@ -112,6 +113,7 @@ struct fet_device {
|
|||
#define FET_CONFIG_FLASH_TESET 4
|
||||
#define FET_CONFIG_FLASH_LOCK 5
|
||||
#define FET_CONFIG_PROTOCOL 8
|
||||
#define FET_CONFIG_UNLOCK_BSL 11
|
||||
|
||||
#define FET_RUN_FREE 1
|
||||
#define FET_RUN_STEP 2
|
||||
|
@ -506,6 +508,41 @@ static int power_poll(struct fet_device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int refresh_fperm(struct fet_device *dev)
|
||||
{
|
||||
fperm_t fp = opdb_read_fperm();
|
||||
fperm_t delta = dev->active_fperm ^ fp;
|
||||
|
||||
if (delta & FPERM_LOCKED_FLASH) {
|
||||
int opt = (fp & FPERM_LOCKED_FLASH) ? 1 : 0;
|
||||
|
||||
printc_dbg("%s locked flash access\n",
|
||||
opt ? "Enabling" : "Disabling");
|
||||
if (fet_proto_xfer(&dev->proto,
|
||||
C_CONFIGURE, NULL, 0,
|
||||
2, FET_CONFIG_FLASH_LOCK, opt) < 0) {
|
||||
printc_err("fet: FET_CONFIG_FLASH_LOCK failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (delta & FPERM_BSL) {
|
||||
int opt = (fp & FPERM_BSL) ? 1 : 0;
|
||||
|
||||
printc_dbg("%s BSL access\n",
|
||||
opt ? "Enabling" : "Disabling");
|
||||
if (fet_proto_xfer(&dev->proto,
|
||||
C_CONFIGURE, NULL, 0,
|
||||
2, FET_CONFIG_UNLOCK_BSL, opt) < 0) {
|
||||
printc_err("fet: FET_CONFIG_UNLOCK_BSL failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
dev->active_fperm = fp;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_run(struct fet_device *dev, int type)
|
||||
{
|
||||
if (fet_proto_xfer(&dev->proto, C_RUN, NULL, 0, 2, type, 0) < 0) {
|
||||
|
@ -528,12 +565,7 @@ int fet_erase(device_t dev_base, device_erase_type_t type, address_t addr)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (fet_proto_xfer(&dev->proto,
|
||||
C_CONFIGURE, NULL, 0,
|
||||
2, FET_CONFIG_FLASH_LOCK, 0) < 0) {
|
||||
printc_err("fet: config (2) failed\n");
|
||||
return -1;
|
||||
}
|
||||
refresh_fperm(dev);
|
||||
|
||||
switch (type) {
|
||||
case DEVICE_ERASE_MAIN:
|
||||
|
@ -796,6 +828,8 @@ int fet_writemem(device_t dev_base, address_t addr,
|
|||
struct fet_device *dev = (struct fet_device *)dev_base;
|
||||
int block_size = get_adjusted_block_size();
|
||||
|
||||
refresh_fperm(dev);
|
||||
|
||||
if (addr & 1) {
|
||||
if (write_byte(dev, addr, *buffer) < 0)
|
||||
return -1;
|
||||
|
|
Loading…
Reference in New Issue