exec.c: Convert subpage memory ops to _with_attrs

Convert the subpage memory ops to _with_attrs; this will allow
us to pass the attributes through to the underlying access
functions. (Nothing uses the attributes yet.)

Backports commit f25a49e0057bbfcc2b1111f60785d919b6ddaeea from qemu
This commit is contained in:
Peter Maydell 2018-02-12 18:43:37 -05:00 committed by Lioncash
parent 933e3bd8d1
commit 6143189cce
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -1249,8 +1249,8 @@ found:
return block->mr; return block->mr;
} }
static uint64_t subpage_read(struct uc_struct* uc, void *opaque, hwaddr addr, static MemTxResult subpage_read(struct uc_struct* uc, void *opaque, hwaddr addr,
unsigned len) uint64_t *data, unsigned len, MemTxAttrs attrs)
{ {
subpage_t *subpage = opaque; subpage_t *subpage = opaque;
uint8_t buf[4]; uint8_t buf[4];
@ -1259,21 +1259,29 @@ static uint64_t subpage_read(struct uc_struct* uc, void *opaque, hwaddr addr,
printf("%s: subpage %p len %u addr " TARGET_FMT_plx "\n", __func__, printf("%s: subpage %p len %u addr " TARGET_FMT_plx "\n", __func__,
subpage, len, addr); subpage, len, addr);
#endif #endif
address_space_read(subpage->as, addr + subpage->base, buf, len); if (address_space_read(subpage->as, addr + subpage->base, buf, len)) {
return MEMTX_DECODE_ERROR;
}
switch (len) { switch (len) {
case 1: case 1:
return ldub_p(buf); *data = ldub_p(buf);
case 2: return MEMTX_OK;
return lduw_p(buf); case 2:
case 4: *data = lduw_p(buf);
return ldl_p(buf); return MEMTX_OK;
default: case 4:
abort(); *data = ldl_p(buf);
return MEMTX_OK;
case 8:
*data = ldq_p(buf);
return MEMTX_OK;
default:
abort();
} }
} }
static void subpage_write(struct uc_struct* uc, void *opaque, hwaddr addr, static MemTxResult subpage_write(struct uc_struct* uc, void *opaque, hwaddr addr,
uint64_t value, unsigned len) uint64_t value, unsigned len, MemTxAttrs attrs)
{ {
subpage_t *subpage = opaque; subpage_t *subpage = opaque;
uint8_t buf[4]; uint8_t buf[4];
@ -1284,19 +1292,25 @@ static void subpage_write(struct uc_struct* uc, void *opaque, hwaddr addr,
__func__, subpage, len, addr, value); __func__, subpage, len, addr, value);
#endif #endif
switch (len) { switch (len) {
case 1: case 1:
stb_p(buf, value); stb_p(buf, value);
break; break;
case 2: case 2:
stw_p(buf, value); stw_p(buf, value);
break; break;
case 4: case 4:
stl_p(buf, value); stl_p(buf, value);
break; break;
default: case 8:
abort(); stq_p(buf, value);
break;
default:
abort();
} }
address_space_write(subpage->as, addr + subpage->base, buf, len); if (address_space_write(subpage->as, addr + subpage->base, buf, len)) {
return MEMTX_DECODE_ERROR;
}
return MEMTX_OK;
} }
static bool subpage_accepts(void *opaque, hwaddr addr, static bool subpage_accepts(void *opaque, hwaddr addr,
@ -1313,10 +1327,10 @@ static bool subpage_accepts(void *opaque, hwaddr addr,
} }
static const MemoryRegionOps subpage_ops = { static const MemoryRegionOps subpage_ops = {
NULL,
NULL,
subpage_read, subpage_read,
subpage_write, subpage_write,
NULL,
NULL,
DEVICE_NATIVE_ENDIAN, DEVICE_NATIVE_ENDIAN,
{ {
0, 0, false, subpage_accepts, 0, 0, false, subpage_accepts,