hla: cleanup read/write api

This is the first part in moving the adapter specific api back into the
driver.

The next task is to also move the hla read/write buffer size handling.

Change-Id: I86a19144b50b6de18659bfcd05b3729b2cafc051
Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-on: http://openocd.zylin.com/1621
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
This commit is contained in:
Spencer Oliver
2013-09-11 21:31:50 +01:00
parent 06fb3bf8cd
commit 3a32dff089
4 changed files with 49 additions and 58 deletions

View File

@@ -259,8 +259,8 @@ static int adapter_examine_debug_reason(struct target *target)
static int hl_dcc_read(struct hl_interface_s *hl_if, uint8_t *value, uint8_t *ctrl)
{
uint16_t dcrdr;
int retval = hl_if->layout->api->read_mem8(hl_if->fd,
DCB_DCRDR, sizeof(dcrdr), (uint8_t *)&dcrdr);
int retval = hl_if->layout->api->read_mem(hl_if->fd,
DCB_DCRDR, 1, sizeof(dcrdr), (uint8_t *)&dcrdr);
if (retval == ERROR_OK) {
*ctrl = (uint8_t)dcrdr;
*value = (uint8_t)(dcrdr >> 8);
@@ -272,8 +272,7 @@ static int hl_dcc_read(struct hl_interface_s *hl_if, uint8_t *value, uint8_t *ct
* to signify we have read data */
/* atomically clear just the byte containing the busy bit */
static const uint8_t zero;
retval = hl_if->layout->api->write_mem8(
hl_if->fd, DCB_DCRDR, 1, &zero);
retval = hl_if->layout->api->write_mem(hl_if->fd, DCB_DCRDR, 1, 1, &zero);
}
}
return retval;
@@ -784,13 +783,7 @@ static int adapter_read_memory(struct target *target, uint32_t address,
else
c = count;
if (size != 4)
res = adapter->layout->api->read_mem8(adapter->fd,
address, c, buffer);
else
res = adapter->layout->api->read_mem32(adapter->fd,
address, c, buffer);
res = adapter->layout->api->read_mem(adapter->fd, address, size, c, buffer);
if (res != ERROR_OK)
return res;
@@ -832,13 +825,7 @@ static int adapter_write_memory(struct target *target, uint32_t address,
else
c = count;
if (size != 4)
res = adapter->layout->api->write_mem8(adapter->fd,
address, c, buffer);
else
res = adapter->layout->api->write_mem32(adapter->fd,
address, c, buffer);
res = adapter->layout->api->write_mem(adapter->fd, address, size, c, buffer);
if (res != ERROR_OK)
return res;