[4704] Clean up MMIO TLB handling.
Revision: 4704
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4704 Author: pbrook Date: 2008-06-09 00:20:13 +0000 (Mon, 09 Jun 2008)
Log Message:
-----------
Clean up MMIO TLB handling.
The IO index is now stored in its own field, instead of being wedged into the vaddr field. This eliminates the ROMD and watchpoint host pointer weirdness. The IO index space is expanded by 1 bit, and several additional bits are made available in the TLB vaddr field.
Modified Paths:
--------------
trunk/cpu-all.h
trunk/cpu-defs.h
trunk/exec.c
trunk/gdbstub.c
trunk/hw/pflash_cfi01.c
trunk/hw/pflash_cfi02.c
trunk/softmmu_template.hModified: trunk/cpu-all.h
===================================================================
cpu-all.h +20 -7
@@ -797,7 +797,7 @@void cpu_interrupt (CPUState *s,int mask);void cpu_reset_interrupt (CPUState *env,int mask); -int cpu_watchpoint_insert (CPUState *env,target_ulong addr); +int cpu_watchpoint_insert (CPUState *env,target_ulong addr,int type);int cpu_watchpoint_remove (CPUState *env,target_ulong addr);void cpu_watchpoint_remove_all (CPUState *env);int cpu_breakpoint_insert (CPUState *env,target_ulong pc);
@@ -868,21 +868,34 @@extern ram_addr_t ram_size;/* physical memory access */ -#define TLB_INVALID_MASK (1 << 3) -#define IO_MEM_SHIFT 4 + +/* MMIO pages are identified by a combination of an IO device index and +3 flags. The ROMD code stores the page ram offset in iotlb entry, +so only a limited number of ids are avaiable. */ + +#define IO_MEM_SHIFT 3#define IO_MEM_NB_ENTRIES (1 << (TARGET_PAGE_BITS - IO_MEM_SHIFT))#define IO_MEM_RAM (0 << IO_MEM_SHIFT)/* hardcoded offset */ #define IO_MEM_ROM (1 << IO_MEM_SHIFT)/* hardcoded offset */ #define IO_MEM_UNASSIGNED (2 << IO_MEM_SHIFT) -#define IO_MEM_NOTDIRTY (4 << IO_MEM_SHIFT)/* used internally, never use directly */ -/* acts like a ROM when read and like a device when written. As an -exception, the write memory callback gets the ram offset instead of -the physical address */ +#define IO_MEM_NOTDIRTY (3 << IO_MEM_SHIFT) + +/* Acts like a ROM when read and like a device when written. */ #define IO_MEM_ROMD (1)#define IO_MEM_SUBPAGE (2)#define IO_MEM_SUBWIDTH (4) +/* Flags stored in the low bits of the TLB virtual address. These are +defined so that fast path ram access is all zeros. */ +/* Zero if TLB entry is valid. */ +#define TLB_INVALID_MASK (1 << 3) +/* Set if TLB entry references a clean RAM page. The iotlb entry will +contain the page physical address. */ +#define TLB_NOTDIRTY (1 << 4) +/* Set if TLB entry is an IO callback. */ +#define TLB_MMIO (1 << 5) +typedef void CPUWriteMemoryFunc (void *opaque,target_phys_addr_t addr,uint32_t value);typedef uint32_t CPUReadMemoryFunc (void *opaque,target_phys_addr_t addr);
Modified: trunk/cpu-defs.h
===================================================================
cpu-defs.h +7 -5
@@ -106,16 +106,17 @@#endif typedef struct CPUTLBEntry { - /* bit 31 to TARGET_PAGE_BITS : virtual address - bit TARGET_PAGE_BITS-1..IO_MEM_SHIFT : if non zero, memory io - zone number + /* bit TARGET_LONG_BITS to TARGET_PAGE_BITS : virtual address + bit TARGET_PAGE_BITS-1..4 : Nonzero for accesses that should not + go directly to ram. bit 3 : indicates that the entry is invalid bit 2..0 : zero */ target_ulong addr_read; target_ulong addr_write; target_ulong addr_code; - /* addend to virtual address to get physical address */ + /* Addend to virtual address to get physical address. IO accesses + use the correcponding iotlb value. */ #if TARGET_PHYS_ADDR_BITS == 64 /* on i386 Linux make sure it is aligned */ target_phys_addr_t addend __attribute__((aligned(8)));
@@ -143,6 +144,7 @@int halted;/* TRUE if the CPU is in suspend state */ \/* The meaning of the MMU modes is defined in the target code. */ \CPUTLBEntry tlb_table[NB_MMU_MODES ][CPU_TLB_SIZE ]; \ +target_phys_addr_t iotlb[NB_MMU_MODES ][CPU_TLB_SIZE ]; \struct TranslationBlock *tb_jmp_cache[TB_JMP_CACHE_SIZE ]; \/* buffer for temporaries in the code generator */ \long temp_buf[CPU_TEMP_BUF_NLONGS ]; \
@@ -155,7 +157,7 @@ \struct { \target_ulong vaddr; \ -target_phys_addr_t addend; \ +int type;/* PAGE_READ/PAGE_WRITE */ \ } watchpoint[MAX_WATCHPOINTS ]; \int nb_watchpoints; \int watchpoint_hit; \
Modified: trunk/exec.c
===================================================================
exec.c +112 -118
394 lines not on this page · raw message
Modified: trunk/gdbstub.c
===================================================================
gdbstub.c +24 -8
@@ -1117,21 +1117,37 @@if (*p ==',' ) p++; len =strtoull (p, (char **)&p,16 ); -if (type ==0 || type ==1 ) { +switch (type) { +case 0 : +case 1 :if (cpu_breakpoint_insert (env, addr) <0 ) goto breakpoint_error;put_packet (s,"OK" ); +break ;#ifndef CONFIG_USER_ONLY - }else if (type ==2 ) { -if (cpu_watchpoint_insert (env, addr) <0 ) +case 2 : + type =PAGE_WRITE ; + goto insert_watchpoint; +case 3 : + type =PAGE_READ ; + goto insert_watchpoint; +case 4 : + type =PAGE_READ |PAGE_WRITE ; + insert_watchpoint: +if (cpu_watchpoint_insert (env, addr, type) <0 ) goto breakpoint_error;put_packet (s,"OK" ); +break ;#endif - }else { - breakpoint_error: -put_packet (s,"E22" ); +default : +put_packet (s,"" ); +break ; }break ; + breakpoint_error: +put_packet (s,"E22" ); +break ; +case 'z' : type =strtoul (p, (char **)&p,16 );if (*p ==',' )
@@ -1144,12 +1160,12 @@cpu_breakpoint_remove (env, addr);put_packet (s,"OK" ); #ifndef CONFIG_USER_ONLY - }else if (type ==2 ) { + }else if (type >=2 || type <=4 ) {cpu_watchpoint_remove (env, addr);put_packet (s,"OK" );#endif }else { - goto breakpoint_error; +put_packet (s,"" ); }break ;case 'q' :
Modified: trunk/hw/pflash_cfi01.c
===================================================================
hw/pflash_cfi01.c +1 -7
@@ -202,15 +202,9 @@uint8_t *p;uint8_t cmd; -/* WARNING: when the memory area is in ROMD mode, the offset is a -ram offset, not a physical address */ cmd = value; + offset -= pfl->base; -if (pfl->wcycle ==0 ) - offset -= (target_ulong )(long )pfl->storage; -else - offset -= pfl->base; -DPRINTF ("%s: offset " TARGET_FMT_lx" %08x %d wcycle 0x%x\n" , __func__, offset, value, width, pfl->wcycle);
Modified: trunk/hw/pflash_cfi02.c
===================================================================
hw/pflash_cfi02.c +3 -9
@@ -112,13 +112,12 @@DPRINTF ("%s: offset " TARGET_FMT_lx"\n" , __func__, offset); ret =-1 ; + offset -= pfl->base;if (pfl->rom_mode) { - offset -= (uint32_t )(long )pfl->storage;/* Lazy reset of to ROMD mode */ if (pfl->wcycle ==0 )pflash_register_memory (pfl,1 ); - }else - offset -= pfl->base; + } offset &= pfl->chip_len -1 ; boff = offset &0xFF ;if (pfl->width ==2 )
@@ -242,12 +241,7 @@ }DPRINTF ("%s: offset " TARGET_FMT_lx" %08x %d %d\n" , __func__, offset, value, width, pfl->wcycle); -/* WARNING: when the memory area is in ROMD mode, the offset is a -ram offset, not a physical address */ -if (pfl->rom_mode) - offset -= (uint32_t )(long )pfl->storage; -else - offset -= pfl->base; + offset -= pfl->base; offset &= pfl->chip_len -1 ; DPRINTF("%s: offset " TARGET_FMT_lx " %08x %d\n", __func__,
Modified: trunk/softmmu_template.h
===================================================================
softmmu_template.h +27 -21
157 lines not on this page · raw message