[5973] Introduce and use cache-utils.[ch]
Revision: 5973
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5973 Author: malc Date: 2008-12-10 19:18:40 +0000 (Wed, 10 Dec 2008)
Log Message:
-----------
Introduce and use cache-utils.[ch]
Thanks to Segher Boessenkool and Holis Blanchard.
AIX and Darwin cache inquiry:
http://gcc.gnu.org/ml/gcc-patches/2007-08/msg00388.html
Auxiliary vectors:
http://manugarg.googlepages.com/aboutelfauxiliaryvectors
Modified Paths:
--------------
trunk/Makefile
trunk/linux-user/main.c
trunk/tcg/ppc/tcg-target.h
trunk/tcg/ppc64/tcg-target.h
trunk/tcg/tcg.c
trunk/vl.c
Added Paths:
-----------
trunk/cache-utils.c
trunk/cache-utils.h
Modified: trunk/Makefile
===================================================================
Makefile +2 -2
@@ -79,7 +79,7 @@ OBJS+=sd.o ssi-sd.o OBJS+=bt.o bt-host.o bt-vhci.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o usb-bt.o OBJS+=buffered_file.o migration.o migration-tcp.o net.o qemu-sockets.o -OBJS+=qemu-char.o aio.o net-checksum.o savevm.o +OBJS+=qemu-char.o aio.o net-checksum.o savevm.o cache-utils.o ifdef CONFIG_BRLAPI OBJS+= baum.o
@@ -178,7 +178,7 @@ ####################################################################### # USER_OBJS is code used by qemu userspace emulation -USER_OBJS=cutils.o +USER_OBJS=cutils.o cache-utils.o libqemu_user.a: $(USER_OBJS) rm -f $@
Added: trunk/cache-utils.c
===================================================================
cache-utils.c +68 -0
68 lines not on this page · raw message
Added: trunk/cache-utils.h
===================================================================
cache-utils.h +41 -0
41 lines not on this page · raw message
Modified: trunk/linux-user/main.c
===================================================================
linux-user/main.c +4 -1
@@ -27,6 +27,7 @@#include "qemu.h" #include "qemu-common.h" +#include "cache-utils.h" /* For tb_lock */ #include "exec-all.h"
@@ -2214,7 +2215,7 @@ ts->sigqueue_table[i].next =NULL ; } -int main (int argc,char **argv) +int main (int argc,char **argv,char **envp) {const char *filename;const char *cpu_model;
@@ -2231,6 +2232,8 @@if (argc <=1 )usage (); +qemu_cache_utils_init (envp); +/* init debug */ cpu_set_log_filename (DEBUG_LOGFILE );
Modified: trunk/tcg/ppc/tcg-target.h
===================================================================
tcg/ppc/tcg-target.h +0 -21
@@ -86,24 +86,3 @@#define TCG_AREG1 TCG_REG_R24#define TCG_AREG2 TCG_REG_R25#define TCG_AREG3 TCG_REG_R26 - -/* taken directly from tcg-dyngen.c */ -#define MIN_CACHE_LINE_SIZE 8/* conservative value */ - -static inline void flush_icache_range (unsigned long start,unsigned long stop) -{ -unsigned long p; - - start &= ~(MIN_CACHE_LINE_SIZE -1 ); - stop = (stop +MIN_CACHE_LINE_SIZE -1 ) & ~(MIN_CACHE_LINE_SIZE -1 ); - -for (p = start; p < stop; p +=MIN_CACHE_LINE_SIZE ) { - asmvolatile ("dcbst 0,%0" : :"r" (p) :"memory" ); - } - asmvolatile ("sync" : : :"memory" ); -for (p = start; p < stop; p +=MIN_CACHE_LINE_SIZE ) { - asmvolatile ("icbi 0,%0" : :"r" (p) :"memory" ); - } - asmvolatile ("sync" : : :"memory" ); - asmvolatile ("isync" : : :"memory" ); -}
Modified: trunk/tcg/ppc64/tcg-target.h
===================================================================
tcg/ppc64/tcg-target.h +0 -21
@@ -82,24 +82,3 @@#define TCG_AREG1 TCG_REG_R24#define TCG_AREG2 TCG_REG_R25#define TCG_AREG3 TCG_REG_R26 - -/* taken directly from tcg-dyngen.c */ -#define MIN_CACHE_LINE_SIZE 8/* conservative value */ - -static inline void flush_icache_range (unsigned long start,unsigned long stop) -{ -unsigned long p; - - start &= ~(MIN_CACHE_LINE_SIZE -1 ); - stop = (stop +MIN_CACHE_LINE_SIZE -1 ) & ~(MIN_CACHE_LINE_SIZE -1 ); - -for (p = start; p < stop; p +=MIN_CACHE_LINE_SIZE ) { - asmvolatile ("dcbst 0,%0" : :"r" (p) :"memory" ); - } - asmvolatile ("sync" : : :"memory" ); -for (p = start; p < stop; p +=MIN_CACHE_LINE_SIZE ) { - asmvolatile ("icbi 0,%0" : :"r" (p) :"memory" ); - } - asmvolatile ("sync" : : :"memory" ); - asmvolatile ("isync" : : :"memory" ); -}
Modified: trunk/tcg/tcg.c
===================================================================
tcg/tcg.c +1 -0
@@ -43,6 +43,7 @@#include "config.h" #include "qemu-common.h" +#include "cache-utils.h" /* Note: the long term plan is to reduce the dependancies on the QEMU CPU definitions. Currently they are used for qemu_ld/st
Modified: trunk/vl.c
===================================================================
vl.c +4 -1
@@ -36,6 +36,7 @@#include "gdbstub.h" #include "qemu-timer.h" #include "qemu-char.h" +#include "cache-utils.h" #include "block.h" #include "audio/audio.h" #include "migration.h"
@@ -4456,7 +4457,7 @@#endif -int main (int argc,char **argv) +int main (int argc,char **argv,char **envp) {#ifdef CONFIG_GDBSTUB int use_gdbstub;
@@ -4494,6 +4495,8 @@int autostart;const char *incoming =NULL ; +qemu_cache_utils_init (envp); +LIST_INIT (&vm_change_state_head);#ifndef _WIN32 {
Quoted 7 lines · malc
(quoted diff) +7
-0+#elif defined __linux__ +#include <linux/auxvec.h> + +static void ppc_init_cacheline_sizes(char **envp) +{ + unsigned long *auxv; +
Review
Quoted 10 lines
(quoted diff) +10
-0+ while (*envp++); + + for (auxv = (unsigned long *) envp; *auxv != AT_NULL; auxv += 2) { + switch (*auxv) { + case AT_DCACHEBSIZE: qemu_cache_conf.dcache_bsize = auxv[1]; break; + case AT_ICACHEBSIZE: qemu_cache_conf.icache_bsize = auxv[1]; break; + default: break; + } + } +}
I'm cross-compiling, and linux/auxvec.h was not installed with my glibc headers. How about this:
Don't require linux/auxvec.h, which isn't always installed with libc.
cache-utils.c +7 -4
@@ -16,7 +16,10 @@ static void ppc_init_cacheline_sizes(void) }#elif defined __linux__ -#include <linux/auxvec.h> + +#define QEMU_AT_NULL 0 +#define QEMU_AT_DCACHEBSIZE 19 +#define QEMU_AT_ICACHEBSIZE 20static void ppc_init_cacheline_sizes (char **envp) {
@@ -24,10 +27,10 @@ static void ppc_init_cacheline_sizes(char **envp)while (*envp++); -for (auxv = (unsigned long *) envp; *auxv !=AT_NULL ; auxv +=2 ) { +for (auxv = (unsigned long *) envp; *auxv !=QEMU_AT_NULL ; auxv +=2 ) {switch (*auxv) { -case AT_DCACHEBSIZE : qemu_cache_conf.dcache_bsize = auxv[1 ];break ; -case AT_ICACHEBSIZE : qemu_cache_conf.icache_bsize = auxv[1 ];break ; + case QEMU_AT_DCACHEBSIZE: qemu_cache_conf.dcache_bsize = auxv[1]; break + case QEMU_AT_ICACHEBSIZE: qemu_cache_conf.icache_bsize = auxv[1]; breakdefault :break ; } }
Signature · 2 lines
Hollis Blanchard IBM Linux Technology Center
Quoted 24 lines · Hollis Blanchard
Quoted 7 lines · malc
(quoted diff) +7
-0+#elif defined __linux__ +#include <linux/auxvec.h> + +static void ppc_init_cacheline_sizes(char **envp) +{ + unsigned long *auxv; +Review
Quoted 10 lines
(quoted diff) +10
-0+ while (*envp++); + + for (auxv = (unsigned long *) envp; *auxv != AT_NULL; auxv += 2) { + switch (*auxv) { + case AT_DCACHEBSIZE: qemu_cache_conf.dcache_bsize = auxv[1]; break; + case AT_ICACHEBSIZE: qemu_cache_conf.icache_bsize = auxv[1]; break; + default: break; + } + } +}I'm cross-compiling, and
linux/auxvec.hwas not installed with my glibc headers. How about this:
Quoted 3 lines
Don't require
linux/auxvec.h, which isn't always installed with libc.Signed-off-by Hollis Blanchard <[email protected]>
Funny you mention it.. My initial code was exactly like this only the defines where called QAT_...
[..snip..]
Signature · 1 line
mailto:[email protected]