Skip to content

Commit

Permalink
tcg-ppc: Merge cache-utils into the backend
Browse files Browse the repository at this point in the history
As a "utility", it only supported ppc, and in a way that other
tcg backends provided directly in tcg-target.h.  Removing this
disparity is easier now that the two ppc backends are merged.

Tested-by: Tom Musta <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
  • Loading branch information
rth7680 committed Jun 23, 2014
1 parent 2b45c3f commit 224f9fd
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 139 deletions.
1 change: 0 additions & 1 deletion exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@

#include "exec/memory-internal.h"
#include "exec/ram_addr.h"
#include "qemu/cache-utils.h"

#include "qemu/range.h"

Expand Down
44 changes: 0 additions & 44 deletions include/qemu/cache-utils.h

This file was deleted.

3 changes: 0 additions & 3 deletions linux-user/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

#include "qemu.h"
#include "qemu-common.h"
#include "qemu/cache-utils.h"
#include "cpu.h"
#include "tcg.h"
#include "qemu/timer.h"
Expand Down Expand Up @@ -3829,8 +3828,6 @@ int main(int argc, char **argv, char **envp)

module_call_init(MODULE_INIT_QOM);

qemu_cache_utils_init();

if ((envlist = envlist_create()) == NULL) {
(void) fprintf(stderr, "Unable to allocate envlist\n");
exit(1);
Expand Down
96 changes: 96 additions & 0 deletions tcg/ppc/tcg-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -2538,3 +2538,99 @@ void tcg_register_jit(void *buf, size_t buf_size)
tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame));
}
#endif /* __ELF__ */

static size_t dcache_bsize = 16;
static size_t icache_bsize = 16;

void flush_icache_range(uintptr_t start, uintptr_t stop)
{
uintptr_t p, start1, stop1;
size_t dsize = dcache_bsize;
size_t isize = icache_bsize;

start1 = start & ~(dsize - 1);
stop1 = (stop + dsize - 1) & ~(dsize - 1);
for (p = start1; p < stop1; p += dsize) {
asm volatile ("dcbst 0,%0" : : "r"(p) : "memory");
}
asm volatile ("sync" : : : "memory");

start &= start & ~(isize - 1);
stop1 = (stop + isize - 1) & ~(isize - 1);
for (p = start1; p < stop1; p += isize) {
asm volatile ("icbi 0,%0" : : "r"(p) : "memory");
}
asm volatile ("sync" : : : "memory");
asm volatile ("isync" : : : "memory");
}

#if defined _AIX
#include <sys/systemcfg.h>

static void __attribute__((constructor)) tcg_cache_init(void)
{
icache_bsize = _system_configuration.icache_line;
dcache_bsize = _system_configuration.dcache_line;
}

#elif defined __linux__
static void __attribute__((constructor)) tcg_cache_init(void)
{
unsigned long dsize = qemu_getauxval(AT_DCACHEBSIZE);
unsigned long isize = qemu_getauxval(AT_ICACHEBSIZE);

if (dsize == 0 || isize == 0) {
if (dsize == 0) {
fprintf(stderr, "getauxval AT_DCACHEBSIZE failed\n");
}
if (isize == 0) {
fprintf(stderr, "getauxval AT_ICACHEBSIZE failed\n");
}
exit(1);
}
dcache_bsize = dsize;
icache_bsize = isize;
}

#elif defined __APPLE__
#include <stdio.h>
#include <sys/types.h>
#include <sys/sysctl.h>

static void __attribute__((constructor)) tcg_cache_init(void)
{
size_t len;
unsigned cacheline;
int name[2] = { CTL_HW, HW_CACHELINE };

len = sizeof(cacheline);
if (sysctl(name, 2, &cacheline, &len, NULL, 0)) {
perror("sysctl CTL_HW HW_CACHELINE failed");
exit(1);
}
dcache_bsize = cacheline;
icache_bsize = cacheline;
}

#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/sysctl.h>

static void __attribute__((constructor)) tcg_cache_init(void)
{
size_t len = 4;
unsigned cacheline;

if (sysctlbyname ("machdep.cacheline_size", &cacheline, &len, NULL, 0)) {
fprintf(stderr, "sysctlbyname machdep.cacheline_size failed: %s\n",
strerror(errno));
exit(1);
}
dcache_bsize = cacheline;
icache_bsize = cacheline;
}
#endif
2 changes: 2 additions & 0 deletions tcg/ppc/tcg-target.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,6 @@ typedef enum {
#define TCG_TARGET_HAS_mulsh_i64 1
#endif

void flush_icache_range(uintptr_t start, uintptr_t stop);

#endif
1 change: 0 additions & 1 deletion tcg/tcg.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#endif

#include "qemu-common.h"
#include "qemu/cache-utils.h"
#include "qemu/host-utils.h"
#include "qemu/timer.h"

Expand Down
2 changes: 1 addition & 1 deletion util/Makefile.objs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
util-obj-y = osdep.o cutils.o unicode.o qemu-timer-common.o
util-obj-$(CONFIG_WIN32) += oslib-win32.o qemu-thread-win32.o event_notifier-win32.o
util-obj-$(CONFIG_POSIX) += oslib-posix.o qemu-thread-posix.o event_notifier-posix.o qemu-openpty.o
util-obj-y += envlist.o path.o host-utils.o cache-utils.o module.o
util-obj-y += envlist.o path.o host-utils.o module.o
util-obj-y += bitmap.o bitops.o hbitmap.o
util-obj-y += fifo8.o
util-obj-y += acl.o
Expand Down
86 changes: 0 additions & 86 deletions util/cache-utils.c

This file was deleted.

3 changes: 0 additions & 3 deletions vl.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ int main(int argc, char **argv)
#include "qemu/timer.h"
#include "sysemu/char.h"
#include "qemu/bitmap.h"
#include "qemu/cache-utils.h"
#include "sysemu/blockdev.h"
#include "hw/block/block.h"
#include "migration/block.h"
Expand Down Expand Up @@ -2974,8 +2973,6 @@ int main(int argc, char **argv, char **envp)

rtc_clock = QEMU_CLOCK_HOST;

qemu_cache_utils_init();

QLIST_INIT (&vm_change_state_head);
os_setup_early_signal_handling();

Expand Down

0 comments on commit 224f9fd

Please sign in to comment.