From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:45081) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UekGp-0004hn-N3 for qemu-devel@nongnu.org; Tue, 21 May 2013 06:58:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UekGo-0005Ro-LP for qemu-devel@nongnu.org; Tue, 21 May 2013 06:58:19 -0400 Received: from mail-ee0-f45.google.com ([74.125.83.45]:59383) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UekGo-0005Qc-D5 for qemu-devel@nongnu.org; Tue, 21 May 2013 06:58:18 -0400 Received: by mail-ee0-f45.google.com with SMTP id l10so312089eei.32 for ; Tue, 21 May 2013 03:58:17 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 21 May 2013 12:57:19 +0200 Message-Id: <1369133851-1894-19-git-send-email-pbonzini@redhat.com> In-Reply-To: <1369133851-1894-1-git-send-email-pbonzini@redhat.com> References: <1369133851-1894-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 18/30] memory: add return value to address_space_rw/read/write List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, jan.kiszka@gmail.com, David Gibson Signed-off-by: Paolo Bonzini --- exec.c | 23 ++++++++++------------- include/exec/memory.h | 12 +++++++++--- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/exec.c b/exec.c index e5ee8ff..4cc5ecb 100644 --- a/exec.c +++ b/exec.c @@ -1901,7 +1901,7 @@ static void invalidate_and_set_dirty(hwaddr addr, xen_modified_memory(addr, length); } -void address_space_rw(AddressSpace *as, hwaddr addr, uint8_t *buf, +bool address_space_rw(AddressSpace *as, hwaddr addr, uint8_t *buf, int len, bool is_write) { hwaddr l; @@ -1909,10 +1909,12 @@ void address_space_rw(AddressSpace *as, hwaddr addr, uint8_t *buf, uint32_t val; hwaddr addr1; MemoryRegionSection *section; + bool error = false; while (len > 0) { l = len; section = address_space_translate(as, addr, &addr1, &l, is_write); + error |= (section == &phys_sections[phys_section_unassigned]); if (is_write) { if (!memory_region_is_ram(section->mr)) { @@ -1971,31 +1973,26 @@ void address_space_rw(AddressSpace *as, hwaddr addr, uint8_t *buf, buf += l; addr += l; } + + return error; } -void address_space_write(AddressSpace *as, hwaddr addr, +bool address_space_write(AddressSpace *as, hwaddr addr, const uint8_t *buf, int len) { - address_space_rw(as, addr, (uint8_t *)buf, len, true); + return address_space_rw(as, addr, (uint8_t *)buf, len, true); } -/** - * address_space_read: read from an address space. - * - * @as: #AddressSpace to be accessed - * @addr: address within that address space - * @buf: buffer with the data transferred - */ -void address_space_read(AddressSpace *as, hwaddr addr, uint8_t *buf, int len) +bool address_space_read(AddressSpace *as, hwaddr addr, uint8_t *buf, int len) { - address_space_rw(as, addr, buf, len, false); + return address_space_rw(as, addr, buf, len, false); } void cpu_physical_memory_rw(hwaddr addr, uint8_t *buf, int len, int is_write) { - return address_space_rw(&address_space_memory, addr, buf, len, is_write); + address_space_rw(&address_space_memory, addr, buf, len, is_write); } /* used for ROM loading : can write in RAM and ROM */ diff --git a/include/exec/memory.h b/include/exec/memory.h index 809a958..94709d1 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -816,32 +816,38 @@ void address_space_destroy(AddressSpace *as); /** * address_space_rw: read from or write to an address space. * + * Return true if the operation hit any unassigned memory. + * * @as: #AddressSpace to be accessed * @addr: address within that address space * @buf: buffer with the data transferred * @is_write: indicates the transfer direction */ -void address_space_rw(AddressSpace *as, hwaddr addr, uint8_t *buf, +bool address_space_rw(AddressSpace *as, hwaddr addr, uint8_t *buf, int len, bool is_write); /** * address_space_write: write to address space. * + * Return true if the operation hit any unassigned memory. + * * @as: #AddressSpace to be accessed * @addr: address within that address space * @buf: buffer with the data transferred */ -void address_space_write(AddressSpace *as, hwaddr addr, +bool address_space_write(AddressSpace *as, hwaddr addr, const uint8_t *buf, int len); /** * address_space_read: read from an address space. * + * Return true if the operation hit any unassigned memory. + * * @as: #AddressSpace to be accessed * @addr: address within that address space * @buf: buffer with the data transferred */ -void address_space_read(AddressSpace *as, hwaddr addr, uint8_t *buf, int len); +bool address_space_read(AddressSpace *as, hwaddr addr, uint8_t *buf, int len); /* address_space_translate: translate an address range into an address space * into a MemoryRegionSection and an address range into that section -- 1.8.1.4