From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45525) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UulGr-00032e-J2 for qemu-devel@nongnu.org; Thu, 04 Jul 2013 11:16:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UulGq-00062w-LT for qemu-devel@nongnu.org; Thu, 04 Jul 2013 11:16:33 -0400 Received: from mail-wi0-x22f.google.com ([2a00:1450:400c:c05::22f]:38198) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UulGq-00061m-8P for qemu-devel@nongnu.org; Thu, 04 Jul 2013 11:16:32 -0400 Received: by mail-wi0-f175.google.com with SMTP id m6so6430310wiv.2 for ; Thu, 04 Jul 2013 08:16:31 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 4 Jul 2013 17:13:55 +0200 Message-Id: <1372950842-32422-60-git-send-email-pbonzini@redhat.com> In-Reply-To: <1372950842-32422-1-git-send-email-pbonzini@redhat.com> References: <1372950842-32422-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 59/66] exec: change well-known physical sections to macros List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Liu Ping Fan , Liu Ping Fan From: Liu Ping Fan Sections like phys_section_unassigned always have fixed address in phys_sections. Declared as macro, so we can use them when having more than one phys_sections array. Signed-off-by: Liu Ping Fan Signed-off-by: Liu Ping Fan Signed-off-by: Paolo Bonzini --- exec.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/exec.c b/exec.c index b339c23..ada2ff2 100644 --- a/exec.c +++ b/exec.c @@ -107,10 +107,10 @@ typedef struct subpage_t { static MemoryRegionSection *phys_sections; static unsigned phys_sections_nb, phys_sections_nb_alloc; -static uint16_t phys_section_unassigned; -static uint16_t phys_section_notdirty; -static uint16_t phys_section_rom; -static uint16_t phys_section_watch; +#define PHYS_SECTION_UNASSIGNED 0 +#define PHYS_SECTION_NOTDIRTY 1 +#define PHYS_SECTION_ROM 2 +#define PHYS_SECTION_WATCH 3 /* Simple allocator for PhysPageEntry nodes */ static PhysPageEntry (*phys_map_nodes)[L2_SIZE]; @@ -168,7 +168,7 @@ static void phys_page_set_level(PhysPageEntry *lp, hwaddr *index, if (level == 0) { for (i = 0; i < L2_SIZE; i++) { p[i].is_leaf = 1; - p[i].ptr = phys_section_unassigned; + p[i].ptr = PHYS_SECTION_UNASSIGNED; } } } else { @@ -207,7 +207,7 @@ static MemoryRegionSection *phys_page_find(AddressSpaceDispatch *d, hwaddr index for (i = P_L2_LEVELS - 1; i >= 0 && !lp.is_leaf; i--) { if (lp.ptr == PHYS_MAP_NODE_NIL) { - return &phys_sections[phys_section_unassigned]; + return &phys_sections[PHYS_SECTION_UNASSIGNED]; } p = phys_map_nodes[lp.ptr]; lp = p[(index >> (i * L2_BITS)) & (L2_SIZE - 1)]; @@ -717,9 +717,9 @@ hwaddr memory_region_section_get_iotlb(CPUArchState *env, iotlb = (memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK) + xlat; if (!section->readonly) { - iotlb |= phys_section_notdirty; + iotlb |= PHYS_SECTION_NOTDIRTY; } else { - iotlb |= phys_section_rom; + iotlb |= PHYS_SECTION_ROM; } } else { iotlb = section - phys_sections; @@ -732,7 +732,7 @@ hwaddr memory_region_section_get_iotlb(CPUArchState *env, if (vaddr == (wp->vaddr & TARGET_PAGE_MASK)) { /* Avoid trapping reads of pages with a write breakpoint. */ if ((prot & PAGE_WRITE) || (wp->flags & BP_MEM_READ)) { - iotlb = phys_section_watch + paddr; + iotlb = PHYS_SECTION_WATCH + paddr; *address |= TLB_MMIO; break; } @@ -1656,7 +1656,7 @@ static subpage_t *subpage_init(AddressSpace *as, hwaddr base) printf("%s: %p base " TARGET_FMT_plx " len %08x %d\n", __func__, mmio, base, TARGET_PAGE_SIZE, subpage_memory); #endif - subpage_register(mmio, 0, TARGET_PAGE_SIZE-1, phys_section_unassigned); + subpage_register(mmio, 0, TARGET_PAGE_SIZE-1, PHYS_SECTION_UNASSIGNED); return mmio; } @@ -1698,11 +1698,17 @@ static void mem_begin(MemoryListener *listener) static void core_begin(MemoryListener *listener) { + uint16_t n; + phys_sections_clear(); - phys_section_unassigned = dummy_section(&io_mem_unassigned); - phys_section_notdirty = dummy_section(&io_mem_notdirty); - phys_section_rom = dummy_section(&io_mem_rom); - phys_section_watch = dummy_section(&io_mem_watch); + n = dummy_section(&io_mem_unassigned); + assert(n == PHYS_SECTION_UNASSIGNED); + n = dummy_section(&io_mem_notdirty); + assert(n == PHYS_SECTION_NOTDIRTY); + n = dummy_section(&io_mem_rom); + assert(n == PHYS_SECTION_ROM); + n = dummy_section(&io_mem_watch); + assert(n == PHYS_SECTION_WATCH); } static void tcg_commit(MemoryListener *listener) -- 1.8.1.4