mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge remote-tracking branch 'remotes/bonzini/softmmu-smap' into staging
* remotes/bonzini/softmmu-smap: (33 commits) target-i386: cleanup x86_cpu_get_phys_page_debug target-i386: fix protection bits in the TLB for SMEP target-i386: support long addresses for 4MB pages (PSE-36) target-i386: raise page fault for reserved bits in large pages target-i386: unify reserved bits and NX bit check target-i386: simplify pte/vaddr calculation target-i386: raise page fault for reserved physical address bits target-i386: test reserved PS bit on PML4Es target-i386: set correct error code for reserved bit access target-i386: introduce support for 1 GB pages target-i386: introduce do_check_protect label target-i386: tweak handling of PG_NX_MASK target-i386: commonize checks for PAE and non-PAE target-i386: commonize checks for 4MB and 4KB pages target-i386: commonize checks for 2MB and 4KB pages target-i386: fix coding standards in x86_cpu_handle_mmu_fault target-i386: simplify SMAP handling in MMU_KSMAP_IDX target-i386: fix kernel accesses with SMAP and CPL = 3 target-i386: move check_io helpers to seg_helper.c target-i386: rename KSMAP to KNOSMAP ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "cpu.h"
|
||||
#include "exec/cpu_ldst.h"
|
||||
|
||||
#undef DEBUG_REMAP
|
||||
#ifdef DEBUG_REMAP
|
||||
|
||||
@@ -22,11 +22,13 @@
|
||||
#include "exec/exec-all.h"
|
||||
#include "exec/memory.h"
|
||||
#include "exec/address-spaces.h"
|
||||
#include "exec/cpu_ldst.h"
|
||||
|
||||
#include "exec/cputlb.h"
|
||||
|
||||
#include "exec/memory-internal.h"
|
||||
#include "exec/ram_addr.h"
|
||||
#include "tcg/tcg.h"
|
||||
|
||||
//#define DEBUG_TLB
|
||||
//#define DEBUG_TLB_CHECK
|
||||
@@ -330,21 +332,36 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr)
|
||||
return qemu_ram_addr_from_host_nofail(p);
|
||||
}
|
||||
|
||||
#define MMUSUFFIX _mmu
|
||||
|
||||
#define SHIFT 0
|
||||
#include "softmmu_template.h"
|
||||
|
||||
#define SHIFT 1
|
||||
#include "softmmu_template.h"
|
||||
|
||||
#define SHIFT 2
|
||||
#include "softmmu_template.h"
|
||||
|
||||
#define SHIFT 3
|
||||
#include "softmmu_template.h"
|
||||
#undef MMUSUFFIX
|
||||
|
||||
#define MMUSUFFIX _cmmu
|
||||
#undef GETPC
|
||||
#define GETPC() ((uintptr_t)0)
|
||||
#undef GETPC_ADJ
|
||||
#define GETPC_ADJ 0
|
||||
#undef GETRA
|
||||
#define GETRA() ((uintptr_t)0)
|
||||
#define SOFTMMU_CODE_ACCESS
|
||||
|
||||
#define SHIFT 0
|
||||
#include "exec/softmmu_template.h"
|
||||
#include "softmmu_template.h"
|
||||
|
||||
#define SHIFT 1
|
||||
#include "exec/softmmu_template.h"
|
||||
#include "softmmu_template.h"
|
||||
|
||||
#define SHIFT 2
|
||||
#include "exec/softmmu_template.h"
|
||||
#include "softmmu_template.h"
|
||||
|
||||
#define SHIFT 3
|
||||
#include "exec/softmmu_template.h"
|
||||
|
||||
#undef env
|
||||
#include "softmmu_template.h"
|
||||
|
||||
@@ -34,7 +34,7 @@ static void virtio_9p_get_config(VirtIODevice *vdev, uint8_t *config)
|
||||
|
||||
len = strlen(s->tag);
|
||||
cfg = g_malloc0(sizeof(struct virtio_9p_config) + len);
|
||||
stw_raw(&cfg->tag_len, len);
|
||||
stw_p(&cfg->tag_len, len);
|
||||
/* We don't copy the terminating null to config space */
|
||||
memcpy(cfg->tag, s->tag, len);
|
||||
memcpy(config, cfg, s->config_size);
|
||||
|
||||
+167
-149
File diff suppressed because it is too large
Load Diff
@@ -487,12 +487,12 @@ static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config)
|
||||
|
||||
bdrv_get_geometry(s->bs, &capacity);
|
||||
memset(&blkcfg, 0, sizeof(blkcfg));
|
||||
stq_raw(&blkcfg.capacity, capacity);
|
||||
stl_raw(&blkcfg.seg_max, 128 - 2);
|
||||
stw_raw(&blkcfg.cylinders, s->conf->cyls);
|
||||
stl_raw(&blkcfg.blk_size, blk_size);
|
||||
stw_raw(&blkcfg.min_io_size, s->conf->min_io_size / blk_size);
|
||||
stw_raw(&blkcfg.opt_io_size, s->conf->opt_io_size / blk_size);
|
||||
stq_p(&blkcfg.capacity, capacity);
|
||||
stl_p(&blkcfg.seg_max, 128 - 2);
|
||||
stw_p(&blkcfg.cylinders, s->conf->cyls);
|
||||
stl_p(&blkcfg.blk_size, blk_size);
|
||||
stw_p(&blkcfg.min_io_size, s->conf->min_io_size / blk_size);
|
||||
stw_p(&blkcfg.opt_io_size, s->conf->opt_io_size / blk_size);
|
||||
blkcfg.heads = s->conf->heads;
|
||||
/*
|
||||
* We must ensure that the block device capacity is a multiple of
|
||||
|
||||
@@ -50,7 +50,7 @@ static void glue(draw_line2_, DEPTH)(void *opaque,
|
||||
uint8_t v, r, g, b;
|
||||
|
||||
do {
|
||||
v = ldub_raw((void *) s);
|
||||
v = ldub_p((void *) s);
|
||||
r = (pal[v & 3] >> 4) & 0xf0;
|
||||
g = pal[v & 3] & 0xf0;
|
||||
b = (pal[v & 3] << 4) & 0xf0;
|
||||
@@ -89,7 +89,7 @@ static void glue(draw_line4_, DEPTH)(void *opaque,
|
||||
uint8_t v, r, g, b;
|
||||
|
||||
do {
|
||||
v = ldub_raw((void *) s);
|
||||
v = ldub_p((void *) s);
|
||||
r = (pal[v & 0xf] >> 4) & 0xf0;
|
||||
g = pal[v & 0xf] & 0xf0;
|
||||
b = (pal[v & 0xf] << 4) & 0xf0;
|
||||
@@ -116,7 +116,7 @@ static void glue(draw_line8_, DEPTH)(void *opaque,
|
||||
uint8_t v, r, g, b;
|
||||
|
||||
do {
|
||||
v = ldub_raw((void *) s);
|
||||
v = ldub_p((void *) s);
|
||||
r = (pal[v] >> 4) & 0xf0;
|
||||
g = pal[v] & 0xf0;
|
||||
b = (pal[v] << 4) & 0xf0;
|
||||
@@ -136,7 +136,7 @@ static void glue(draw_line12_, DEPTH)(void *opaque,
|
||||
uint8_t r, g, b;
|
||||
|
||||
do {
|
||||
v = lduw_raw((void *) s);
|
||||
v = lduw_p((void *) s);
|
||||
r = (v >> 4) & 0xf0;
|
||||
g = v & 0xf0;
|
||||
b = (v << 4) & 0xf0;
|
||||
@@ -159,7 +159,7 @@ static void glue(draw_line16_, DEPTH)(void *opaque,
|
||||
uint8_t r, g, b;
|
||||
|
||||
do {
|
||||
v = lduw_raw((void *) s);
|
||||
v = lduw_p((void *) s);
|
||||
r = (v >> 8) & 0xf8;
|
||||
g = (v >> 3) & 0xfc;
|
||||
b = (v << 3) & 0xf8;
|
||||
|
||||
@@ -47,7 +47,7 @@ static void glue(draw_line8_, PIXEL_NAME)(
|
||||
{
|
||||
uint8_t v, r, g, b;
|
||||
do {
|
||||
v = ldub_raw(s);
|
||||
v = ldub_p(s);
|
||||
r = (pal[v] >> 16) & 0xff;
|
||||
g = (pal[v] >> 8) & 0xff;
|
||||
b = (pal[v] >> 0) & 0xff;
|
||||
@@ -64,7 +64,7 @@ static void glue(draw_line16_, PIXEL_NAME)(
|
||||
uint8_t r, g, b;
|
||||
|
||||
do {
|
||||
rgb565 = lduw_raw(s);
|
||||
rgb565 = lduw_p(s);
|
||||
r = ((rgb565 >> 11) & 0x1f) << 3;
|
||||
g = ((rgb565 >> 5) & 0x3f) << 2;
|
||||
b = ((rgb565 >> 0) & 0x1f) << 3;
|
||||
@@ -80,7 +80,7 @@ static void glue(draw_line32_, PIXEL_NAME)(
|
||||
uint8_t r, g, b;
|
||||
|
||||
do {
|
||||
ldub_raw(s);
|
||||
ldub_p(s);
|
||||
#if defined(TARGET_WORDS_BIGENDIAN)
|
||||
r = s[1];
|
||||
g = s[2];
|
||||
|
||||
@@ -361,7 +361,7 @@ static void glue(vga_draw_line15_, PIXEL_NAME)(VGACommonState *s1, uint8_t *d,
|
||||
|
||||
w = width;
|
||||
do {
|
||||
v = lduw_raw((void *)s);
|
||||
v = lduw_p((void *)s);
|
||||
r = (v >> 7) & 0xf8;
|
||||
g = (v >> 2) & 0xf8;
|
||||
b = (v << 3) & 0xf8;
|
||||
@@ -386,7 +386,7 @@ static void glue(vga_draw_line16_, PIXEL_NAME)(VGACommonState *s1, uint8_t *d,
|
||||
|
||||
w = width;
|
||||
do {
|
||||
v = lduw_raw((void *)s);
|
||||
v = lduw_p((void *)s);
|
||||
r = (v >> 8) & 0xf8;
|
||||
g = (v >> 3) & 0xfc;
|
||||
b = (v << 3) & 0xf8;
|
||||
|
||||
+14
-14
@@ -178,24 +178,24 @@ static void write_bootloader (CPUMIPSState *env, uint8_t *base, int64_t kernel_a
|
||||
/* Small bootloader */
|
||||
p = (uint32_t *) base;
|
||||
|
||||
stl_raw(p++, 0x0bf00010); /* j 0x1fc00040 */
|
||||
stl_raw(p++, 0x00000000); /* nop */
|
||||
stl_p(p++, 0x0bf00010); /* j 0x1fc00040 */
|
||||
stl_p(p++, 0x00000000); /* nop */
|
||||
|
||||
/* Second part of the bootloader */
|
||||
p = (uint32_t *) (base + 0x040);
|
||||
|
||||
stl_raw(p++, 0x3c040000); /* lui a0, 0 */
|
||||
stl_raw(p++, 0x34840002); /* ori a0, a0, 2 */
|
||||
stl_raw(p++, 0x3c050000 | ((ENVP_ADDR >> 16) & 0xffff)); /* lui a1, high(ENVP_ADDR) */
|
||||
stl_raw(p++, 0x34a50000 | (ENVP_ADDR & 0xffff)); /* ori a1, a0, low(ENVP_ADDR) */
|
||||
stl_raw(p++, 0x3c060000 | (((ENVP_ADDR + 8) >> 16) & 0xffff)); /* lui a2, high(ENVP_ADDR + 8) */
|
||||
stl_raw(p++, 0x34c60000 | ((ENVP_ADDR + 8) & 0xffff)); /* ori a2, a2, low(ENVP_ADDR + 8) */
|
||||
stl_raw(p++, 0x3c070000 | (loaderparams.ram_size >> 16)); /* lui a3, high(env->ram_size) */
|
||||
stl_raw(p++, 0x34e70000 | (loaderparams.ram_size & 0xffff)); /* ori a3, a3, low(env->ram_size) */
|
||||
stl_raw(p++, 0x3c1f0000 | ((kernel_addr >> 16) & 0xffff)); /* lui ra, high(kernel_addr) */;
|
||||
stl_raw(p++, 0x37ff0000 | (kernel_addr & 0xffff)); /* ori ra, ra, low(kernel_addr) */
|
||||
stl_raw(p++, 0x03e00008); /* jr ra */
|
||||
stl_raw(p++, 0x00000000); /* nop */
|
||||
stl_p(p++, 0x3c040000); /* lui a0, 0 */
|
||||
stl_p(p++, 0x34840002); /* ori a0, a0, 2 */
|
||||
stl_p(p++, 0x3c050000 | ((ENVP_ADDR >> 16) & 0xffff)); /* lui a1, high(ENVP_ADDR) */
|
||||
stl_p(p++, 0x34a50000 | (ENVP_ADDR & 0xffff)); /* ori a1, a0, low(ENVP_ADDR) */
|
||||
stl_p(p++, 0x3c060000 | (((ENVP_ADDR + 8) >> 16) & 0xffff)); /* lui a2, high(ENVP_ADDR + 8) */
|
||||
stl_p(p++, 0x34c60000 | ((ENVP_ADDR + 8) & 0xffff)); /* ori a2, a2, low(ENVP_ADDR + 8) */
|
||||
stl_p(p++, 0x3c070000 | (loaderparams.ram_size >> 16)); /* lui a3, high(env->ram_size) */
|
||||
stl_p(p++, 0x34e70000 | (loaderparams.ram_size & 0xffff)); /* ori a3, a3, low(env->ram_size) */
|
||||
stl_p(p++, 0x3c1f0000 | ((kernel_addr >> 16) & 0xffff)); /* lui ra, high(kernel_addr) */;
|
||||
stl_p(p++, 0x37ff0000 | (kernel_addr & 0xffff)); /* ori ra, ra, low(kernel_addr) */
|
||||
stl_p(p++, 0x03e00008); /* jr ra */
|
||||
stl_p(p++, 0x00000000); /* nop */
|
||||
}
|
||||
|
||||
|
||||
|
||||
+88
-88
@@ -609,136 +609,136 @@ static void write_bootloader (CPUMIPSState *env, uint8_t *base,
|
||||
|
||||
/* Small bootloader */
|
||||
p = (uint32_t *)base;
|
||||
stl_raw(p++, 0x0bf00160); /* j 0x1fc00580 */
|
||||
stl_raw(p++, 0x00000000); /* nop */
|
||||
stl_p(p++, 0x0bf00160); /* j 0x1fc00580 */
|
||||
stl_p(p++, 0x00000000); /* nop */
|
||||
|
||||
/* YAMON service vector */
|
||||
stl_raw(base + 0x500, 0xbfc00580); /* start: */
|
||||
stl_raw(base + 0x504, 0xbfc0083c); /* print_count: */
|
||||
stl_raw(base + 0x520, 0xbfc00580); /* start: */
|
||||
stl_raw(base + 0x52c, 0xbfc00800); /* flush_cache: */
|
||||
stl_raw(base + 0x534, 0xbfc00808); /* print: */
|
||||
stl_raw(base + 0x538, 0xbfc00800); /* reg_cpu_isr: */
|
||||
stl_raw(base + 0x53c, 0xbfc00800); /* unred_cpu_isr: */
|
||||
stl_raw(base + 0x540, 0xbfc00800); /* reg_ic_isr: */
|
||||
stl_raw(base + 0x544, 0xbfc00800); /* unred_ic_isr: */
|
||||
stl_raw(base + 0x548, 0xbfc00800); /* reg_esr: */
|
||||
stl_raw(base + 0x54c, 0xbfc00800); /* unreg_esr: */
|
||||
stl_raw(base + 0x550, 0xbfc00800); /* getchar: */
|
||||
stl_raw(base + 0x554, 0xbfc00800); /* syscon_read: */
|
||||
stl_p(base + 0x500, 0xbfc00580); /* start: */
|
||||
stl_p(base + 0x504, 0xbfc0083c); /* print_count: */
|
||||
stl_p(base + 0x520, 0xbfc00580); /* start: */
|
||||
stl_p(base + 0x52c, 0xbfc00800); /* flush_cache: */
|
||||
stl_p(base + 0x534, 0xbfc00808); /* print: */
|
||||
stl_p(base + 0x538, 0xbfc00800); /* reg_cpu_isr: */
|
||||
stl_p(base + 0x53c, 0xbfc00800); /* unred_cpu_isr: */
|
||||
stl_p(base + 0x540, 0xbfc00800); /* reg_ic_isr: */
|
||||
stl_p(base + 0x544, 0xbfc00800); /* unred_ic_isr: */
|
||||
stl_p(base + 0x548, 0xbfc00800); /* reg_esr: */
|
||||
stl_p(base + 0x54c, 0xbfc00800); /* unreg_esr: */
|
||||
stl_p(base + 0x550, 0xbfc00800); /* getchar: */
|
||||
stl_p(base + 0x554, 0xbfc00800); /* syscon_read: */
|
||||
|
||||
|
||||
/* Second part of the bootloader */
|
||||
p = (uint32_t *) (base + 0x580);
|
||||
stl_raw(p++, 0x24040002); /* addiu a0, zero, 2 */
|
||||
stl_raw(p++, 0x3c1d0000 | (((ENVP_ADDR - 64) >> 16) & 0xffff)); /* lui sp, high(ENVP_ADDR) */
|
||||
stl_raw(p++, 0x37bd0000 | ((ENVP_ADDR - 64) & 0xffff)); /* ori sp, sp, low(ENVP_ADDR) */
|
||||
stl_raw(p++, 0x3c050000 | ((ENVP_ADDR >> 16) & 0xffff)); /* lui a1, high(ENVP_ADDR) */
|
||||
stl_raw(p++, 0x34a50000 | (ENVP_ADDR & 0xffff)); /* ori a1, a1, low(ENVP_ADDR) */
|
||||
stl_raw(p++, 0x3c060000 | (((ENVP_ADDR + 8) >> 16) & 0xffff)); /* lui a2, high(ENVP_ADDR + 8) */
|
||||
stl_raw(p++, 0x34c60000 | ((ENVP_ADDR + 8) & 0xffff)); /* ori a2, a2, low(ENVP_ADDR + 8) */
|
||||
stl_raw(p++, 0x3c070000 | (loaderparams.ram_size >> 16)); /* lui a3, high(ram_size) */
|
||||
stl_raw(p++, 0x34e70000 | (loaderparams.ram_size & 0xffff)); /* ori a3, a3, low(ram_size) */
|
||||
stl_p(p++, 0x24040002); /* addiu a0, zero, 2 */
|
||||
stl_p(p++, 0x3c1d0000 | (((ENVP_ADDR - 64) >> 16) & 0xffff)); /* lui sp, high(ENVP_ADDR) */
|
||||
stl_p(p++, 0x37bd0000 | ((ENVP_ADDR - 64) & 0xffff)); /* ori sp, sp, low(ENVP_ADDR) */
|
||||
stl_p(p++, 0x3c050000 | ((ENVP_ADDR >> 16) & 0xffff)); /* lui a1, high(ENVP_ADDR) */
|
||||
stl_p(p++, 0x34a50000 | (ENVP_ADDR & 0xffff)); /* ori a1, a1, low(ENVP_ADDR) */
|
||||
stl_p(p++, 0x3c060000 | (((ENVP_ADDR + 8) >> 16) & 0xffff)); /* lui a2, high(ENVP_ADDR + 8) */
|
||||
stl_p(p++, 0x34c60000 | ((ENVP_ADDR + 8) & 0xffff)); /* ori a2, a2, low(ENVP_ADDR + 8) */
|
||||
stl_p(p++, 0x3c070000 | (loaderparams.ram_size >> 16)); /* lui a3, high(ram_size) */
|
||||
stl_p(p++, 0x34e70000 | (loaderparams.ram_size & 0xffff)); /* ori a3, a3, low(ram_size) */
|
||||
|
||||
/* Load BAR registers as done by YAMON */
|
||||
stl_raw(p++, 0x3c09b400); /* lui t1, 0xb400 */
|
||||
stl_p(p++, 0x3c09b400); /* lui t1, 0xb400 */
|
||||
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
stl_raw(p++, 0x3c08df00); /* lui t0, 0xdf00 */
|
||||
stl_p(p++, 0x3c08df00); /* lui t0, 0xdf00 */
|
||||
#else
|
||||
stl_raw(p++, 0x340800df); /* ori t0, r0, 0x00df */
|
||||
stl_p(p++, 0x340800df); /* ori t0, r0, 0x00df */
|
||||
#endif
|
||||
stl_raw(p++, 0xad280068); /* sw t0, 0x0068(t1) */
|
||||
stl_p(p++, 0xad280068); /* sw t0, 0x0068(t1) */
|
||||
|
||||
stl_raw(p++, 0x3c09bbe0); /* lui t1, 0xbbe0 */
|
||||
stl_p(p++, 0x3c09bbe0); /* lui t1, 0xbbe0 */
|
||||
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
stl_raw(p++, 0x3c08c000); /* lui t0, 0xc000 */
|
||||
stl_p(p++, 0x3c08c000); /* lui t0, 0xc000 */
|
||||
#else
|
||||
stl_raw(p++, 0x340800c0); /* ori t0, r0, 0x00c0 */
|
||||
stl_p(p++, 0x340800c0); /* ori t0, r0, 0x00c0 */
|
||||
#endif
|
||||
stl_raw(p++, 0xad280048); /* sw t0, 0x0048(t1) */
|
||||
stl_p(p++, 0xad280048); /* sw t0, 0x0048(t1) */
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
stl_raw(p++, 0x3c084000); /* lui t0, 0x4000 */
|
||||
stl_p(p++, 0x3c084000); /* lui t0, 0x4000 */
|
||||
#else
|
||||
stl_raw(p++, 0x34080040); /* ori t0, r0, 0x0040 */
|
||||
stl_p(p++, 0x34080040); /* ori t0, r0, 0x0040 */
|
||||
#endif
|
||||
stl_raw(p++, 0xad280050); /* sw t0, 0x0050(t1) */
|
||||
stl_p(p++, 0xad280050); /* sw t0, 0x0050(t1) */
|
||||
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
stl_raw(p++, 0x3c088000); /* lui t0, 0x8000 */
|
||||
stl_p(p++, 0x3c088000); /* lui t0, 0x8000 */
|
||||
#else
|
||||
stl_raw(p++, 0x34080080); /* ori t0, r0, 0x0080 */
|
||||
stl_p(p++, 0x34080080); /* ori t0, r0, 0x0080 */
|
||||
#endif
|
||||
stl_raw(p++, 0xad280058); /* sw t0, 0x0058(t1) */
|
||||
stl_p(p++, 0xad280058); /* sw t0, 0x0058(t1) */
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
stl_raw(p++, 0x3c083f00); /* lui t0, 0x3f00 */
|
||||
stl_p(p++, 0x3c083f00); /* lui t0, 0x3f00 */
|
||||
#else
|
||||
stl_raw(p++, 0x3408003f); /* ori t0, r0, 0x003f */
|
||||
stl_p(p++, 0x3408003f); /* ori t0, r0, 0x003f */
|
||||
#endif
|
||||
stl_raw(p++, 0xad280060); /* sw t0, 0x0060(t1) */
|
||||
stl_p(p++, 0xad280060); /* sw t0, 0x0060(t1) */
|
||||
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
stl_raw(p++, 0x3c08c100); /* lui t0, 0xc100 */
|
||||
stl_p(p++, 0x3c08c100); /* lui t0, 0xc100 */
|
||||
#else
|
||||
stl_raw(p++, 0x340800c1); /* ori t0, r0, 0x00c1 */
|
||||
stl_p(p++, 0x340800c1); /* ori t0, r0, 0x00c1 */
|
||||
#endif
|
||||
stl_raw(p++, 0xad280080); /* sw t0, 0x0080(t1) */
|
||||
stl_p(p++, 0xad280080); /* sw t0, 0x0080(t1) */
|
||||
#ifdef TARGET_WORDS_BIGENDIAN
|
||||
stl_raw(p++, 0x3c085e00); /* lui t0, 0x5e00 */
|
||||
stl_p(p++, 0x3c085e00); /* lui t0, 0x5e00 */
|
||||
#else
|
||||
stl_raw(p++, 0x3408005e); /* ori t0, r0, 0x005e */
|
||||
stl_p(p++, 0x3408005e); /* ori t0, r0, 0x005e */
|
||||
#endif
|
||||
stl_raw(p++, 0xad280088); /* sw t0, 0x0088(t1) */
|
||||
stl_p(p++, 0xad280088); /* sw t0, 0x0088(t1) */
|
||||
|
||||
/* Jump to kernel code */
|
||||
stl_raw(p++, 0x3c1f0000 | ((kernel_entry >> 16) & 0xffff)); /* lui ra, high(kernel_entry) */
|
||||
stl_raw(p++, 0x37ff0000 | (kernel_entry & 0xffff)); /* ori ra, ra, low(kernel_entry) */
|
||||
stl_raw(p++, 0x03e00008); /* jr ra */
|
||||
stl_raw(p++, 0x00000000); /* nop */
|
||||
stl_p(p++, 0x3c1f0000 | ((kernel_entry >> 16) & 0xffff)); /* lui ra, high(kernel_entry) */
|
||||
stl_p(p++, 0x37ff0000 | (kernel_entry & 0xffff)); /* ori ra, ra, low(kernel_entry) */
|
||||
stl_p(p++, 0x03e00008); /* jr ra */
|
||||
stl_p(p++, 0x00000000); /* nop */
|
||||
|
||||
/* YAMON subroutines */
|
||||
p = (uint32_t *) (base + 0x800);
|
||||
stl_raw(p++, 0x03e00008); /* jr ra */
|
||||
stl_raw(p++, 0x24020000); /* li v0,0 */
|
||||
stl_p(p++, 0x03e00008); /* jr ra */
|
||||
stl_p(p++, 0x24020000); /* li v0,0 */
|
||||
/* 808 YAMON print */
|
||||
stl_raw(p++, 0x03e06821); /* move t5,ra */
|
||||
stl_raw(p++, 0x00805821); /* move t3,a0 */
|
||||
stl_raw(p++, 0x00a05021); /* move t2,a1 */
|
||||
stl_raw(p++, 0x91440000); /* lbu a0,0(t2) */
|
||||
stl_raw(p++, 0x254a0001); /* addiu t2,t2,1 */
|
||||
stl_raw(p++, 0x10800005); /* beqz a0,834 */
|
||||
stl_raw(p++, 0x00000000); /* nop */
|
||||
stl_raw(p++, 0x0ff0021c); /* jal 870 */
|
||||
stl_raw(p++, 0x00000000); /* nop */
|
||||
stl_raw(p++, 0x08000205); /* j 814 */
|
||||
stl_raw(p++, 0x00000000); /* nop */
|
||||
stl_raw(p++, 0x01a00008); /* jr t5 */
|
||||
stl_raw(p++, 0x01602021); /* move a0,t3 */
|
||||
stl_p(p++, 0x03e06821); /* move t5,ra */
|
||||
stl_p(p++, 0x00805821); /* move t3,a0 */
|
||||
stl_p(p++, 0x00a05021); /* move t2,a1 */
|
||||
stl_p(p++, 0x91440000); /* lbu a0,0(t2) */
|
||||
stl_p(p++, 0x254a0001); /* addiu t2,t2,1 */
|
||||
stl_p(p++, 0x10800005); /* beqz a0,834 */
|
||||
stl_p(p++, 0x00000000); /* nop */
|
||||
stl_p(p++, 0x0ff0021c); /* jal 870 */
|
||||
stl_p(p++, 0x00000000); /* nop */
|
||||
stl_p(p++, 0x08000205); /* j 814 */
|
||||
stl_p(p++, 0x00000000); /* nop */
|
||||
stl_p(p++, 0x01a00008); /* jr t5 */
|
||||
stl_p(p++, 0x01602021); /* move a0,t3 */
|
||||
/* 0x83c YAMON print_count */
|
||||
stl_raw(p++, 0x03e06821); /* move t5,ra */
|
||||
stl_raw(p++, 0x00805821); /* move t3,a0 */
|
||||
stl_raw(p++, 0x00a05021); /* move t2,a1 */
|
||||
stl_raw(p++, 0x00c06021); /* move t4,a2 */
|
||||
stl_raw(p++, 0x91440000); /* lbu a0,0(t2) */
|
||||
stl_raw(p++, 0x0ff0021c); /* jal 870 */
|
||||
stl_raw(p++, 0x00000000); /* nop */
|
||||
stl_raw(p++, 0x254a0001); /* addiu t2,t2,1 */
|
||||
stl_raw(p++, 0x258cffff); /* addiu t4,t4,-1 */
|
||||
stl_raw(p++, 0x1580fffa); /* bnez t4,84c */
|
||||
stl_raw(p++, 0x00000000); /* nop */
|
||||
stl_raw(p++, 0x01a00008); /* jr t5 */
|
||||
stl_raw(p++, 0x01602021); /* move a0,t3 */
|
||||
stl_p(p++, 0x03e06821); /* move t5,ra */
|
||||
stl_p(p++, 0x00805821); /* move t3,a0 */
|
||||
stl_p(p++, 0x00a05021); /* move t2,a1 */
|
||||
stl_p(p++, 0x00c06021); /* move t4,a2 */
|
||||
stl_p(p++, 0x91440000); /* lbu a0,0(t2) */
|
||||
stl_p(p++, 0x0ff0021c); /* jal 870 */
|
||||
stl_p(p++, 0x00000000); /* nop */
|
||||
stl_p(p++, 0x254a0001); /* addiu t2,t2,1 */
|
||||
stl_p(p++, 0x258cffff); /* addiu t4,t4,-1 */
|
||||
stl_p(p++, 0x1580fffa); /* bnez t4,84c */
|
||||
stl_p(p++, 0x00000000); /* nop */
|
||||
stl_p(p++, 0x01a00008); /* jr t5 */
|
||||
stl_p(p++, 0x01602021); /* move a0,t3 */
|
||||
/* 0x870 */
|
||||
stl_raw(p++, 0x3c08b800); /* lui t0,0xb400 */
|
||||
stl_raw(p++, 0x350803f8); /* ori t0,t0,0x3f8 */
|
||||
stl_raw(p++, 0x91090005); /* lbu t1,5(t0) */
|
||||
stl_raw(p++, 0x00000000); /* nop */
|
||||
stl_raw(p++, 0x31290040); /* andi t1,t1,0x40 */
|
||||
stl_raw(p++, 0x1120fffc); /* beqz t1,878 <outch+0x8> */
|
||||
stl_raw(p++, 0x00000000); /* nop */
|
||||
stl_raw(p++, 0x03e00008); /* jr ra */
|
||||
stl_raw(p++, 0xa1040000); /* sb a0,0(t0) */
|
||||
stl_p(p++, 0x3c08b800); /* lui t0,0xb400 */
|
||||
stl_p(p++, 0x350803f8); /* ori t0,t0,0x3f8 */
|
||||
stl_p(p++, 0x91090005); /* lbu t1,5(t0) */
|
||||
stl_p(p++, 0x00000000); /* nop */
|
||||
stl_p(p++, 0x31290040); /* andi t1,t1,0x40 */
|
||||
stl_p(p++, 0x1120fffc); /* beqz t1,878 <outch+0x8> */
|
||||
stl_p(p++, 0x00000000); /* nop */
|
||||
stl_p(p++, 0x03e00008); /* jr ra */
|
||||
stl_p(p++, 0xa1040000); /* sb a0,0(t0) */
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -164,8 +164,8 @@ static void vhost_scsi_set_config(VirtIODevice *vdev,
|
||||
VirtIOSCSIConfig *scsiconf = (VirtIOSCSIConfig *)config;
|
||||
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(vdev);
|
||||
|
||||
if ((uint32_t) ldl_raw(&scsiconf->sense_size) != vs->sense_size ||
|
||||
(uint32_t) ldl_raw(&scsiconf->cdb_size) != vs->cdb_size) {
|
||||
if ((uint32_t) ldl_p(&scsiconf->sense_size) != vs->sense_size ||
|
||||
(uint32_t) ldl_p(&scsiconf->cdb_size) != vs->cdb_size) {
|
||||
error_report("vhost-scsi does not support changing the sense data and CDB sizes");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
+14
-14
@@ -425,16 +425,16 @@ static void virtio_scsi_get_config(VirtIODevice *vdev,
|
||||
VirtIOSCSIConfig *scsiconf = (VirtIOSCSIConfig *)config;
|
||||
VirtIOSCSICommon *s = VIRTIO_SCSI_COMMON(vdev);
|
||||
|
||||
stl_raw(&scsiconf->num_queues, s->conf.num_queues);
|
||||
stl_raw(&scsiconf->seg_max, 128 - 2);
|
||||
stl_raw(&scsiconf->max_sectors, s->conf.max_sectors);
|
||||
stl_raw(&scsiconf->cmd_per_lun, s->conf.cmd_per_lun);
|
||||
stl_raw(&scsiconf->event_info_size, sizeof(VirtIOSCSIEvent));
|
||||
stl_raw(&scsiconf->sense_size, s->sense_size);
|
||||
stl_raw(&scsiconf->cdb_size, s->cdb_size);
|
||||
stw_raw(&scsiconf->max_channel, VIRTIO_SCSI_MAX_CHANNEL);
|
||||
stw_raw(&scsiconf->max_target, VIRTIO_SCSI_MAX_TARGET);
|
||||
stl_raw(&scsiconf->max_lun, VIRTIO_SCSI_MAX_LUN);
|
||||
stl_p(&scsiconf->num_queues, s->conf.num_queues);
|
||||
stl_p(&scsiconf->seg_max, 128 - 2);
|
||||
stl_p(&scsiconf->max_sectors, s->conf.max_sectors);
|
||||
stl_p(&scsiconf->cmd_per_lun, s->conf.cmd_per_lun);
|
||||
stl_p(&scsiconf->event_info_size, sizeof(VirtIOSCSIEvent));
|
||||
stl_p(&scsiconf->sense_size, s->sense_size);
|
||||
stl_p(&scsiconf->cdb_size, s->cdb_size);
|
||||
stw_p(&scsiconf->max_channel, VIRTIO_SCSI_MAX_CHANNEL);
|
||||
stw_p(&scsiconf->max_target, VIRTIO_SCSI_MAX_TARGET);
|
||||
stl_p(&scsiconf->max_lun, VIRTIO_SCSI_MAX_LUN);
|
||||
}
|
||||
|
||||
static void virtio_scsi_set_config(VirtIODevice *vdev,
|
||||
@@ -443,14 +443,14 @@ static void virtio_scsi_set_config(VirtIODevice *vdev,
|
||||
VirtIOSCSIConfig *scsiconf = (VirtIOSCSIConfig *)config;
|
||||
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(vdev);
|
||||
|
||||
if ((uint32_t) ldl_raw(&scsiconf->sense_size) >= 65536 ||
|
||||
(uint32_t) ldl_raw(&scsiconf->cdb_size) >= 256) {
|
||||
if ((uint32_t) ldl_p(&scsiconf->sense_size) >= 65536 ||
|
||||
(uint32_t) ldl_p(&scsiconf->cdb_size) >= 256) {
|
||||
error_report("bad data written to virtio-scsi configuration space");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
vs->sense_size = ldl_raw(&scsiconf->sense_size);
|
||||
vs->cdb_size = ldl_raw(&scsiconf->cdb_size);
|
||||
vs->sense_size = ldl_p(&scsiconf->sense_size);
|
||||
vs->cdb_size = ldl_p(&scsiconf->cdb_size);
|
||||
}
|
||||
|
||||
static uint32_t virtio_scsi_get_features(VirtIODevice *vdev,
|
||||
|
||||
@@ -198,127 +198,8 @@ extern unsigned long reserved_va;
|
||||
#define RESERVED_VA 0ul
|
||||
#endif
|
||||
|
||||
/* All direct uses of g2h and h2g need to go away for usermode softmmu. */
|
||||
#define g2h(x) ((void *)((unsigned long)(target_ulong)(x) + GUEST_BASE))
|
||||
|
||||
#if HOST_LONG_BITS <= TARGET_VIRT_ADDR_SPACE_BITS
|
||||
#define h2g_valid(x) 1
|
||||
#else
|
||||
#define h2g_valid(x) ({ \
|
||||
unsigned long __guest = (unsigned long)(x) - GUEST_BASE; \
|
||||
(__guest < (1ul << TARGET_VIRT_ADDR_SPACE_BITS)) && \
|
||||
(!RESERVED_VA || (__guest < RESERVED_VA)); \
|
||||
})
|
||||
#endif
|
||||
|
||||
#define h2g_nocheck(x) ({ \
|
||||
unsigned long __ret = (unsigned long)(x) - GUEST_BASE; \
|
||||
(abi_ulong)__ret; \
|
||||
})
|
||||
|
||||
#define h2g(x) ({ \
|
||||
/* Check if given address fits target address space */ \
|
||||
assert(h2g_valid(x)); \
|
||||
h2g_nocheck(x); \
|
||||
})
|
||||
|
||||
#define saddr(x) g2h(x)
|
||||
#define laddr(x) g2h(x)
|
||||
|
||||
#else /* !CONFIG_USER_ONLY */
|
||||
/* NOTE: we use double casts if pointers and target_ulong have
|
||||
different sizes */
|
||||
#define saddr(x) (uint8_t *)(intptr_t)(x)
|
||||
#define laddr(x) (uint8_t *)(intptr_t)(x)
|
||||
#endif
|
||||
|
||||
#define ldub_raw(p) ldub_p(laddr((p)))
|
||||
#define ldsb_raw(p) ldsb_p(laddr((p)))
|
||||
#define lduw_raw(p) lduw_p(laddr((p)))
|
||||
#define ldsw_raw(p) ldsw_p(laddr((p)))
|
||||
#define ldl_raw(p) ldl_p(laddr((p)))
|
||||
#define ldq_raw(p) ldq_p(laddr((p)))
|
||||
#define ldfl_raw(p) ldfl_p(laddr((p)))
|
||||
#define ldfq_raw(p) ldfq_p(laddr((p)))
|
||||
#define stb_raw(p, v) stb_p(saddr((p)), v)
|
||||
#define stw_raw(p, v) stw_p(saddr((p)), v)
|
||||
#define stl_raw(p, v) stl_p(saddr((p)), v)
|
||||
#define stq_raw(p, v) stq_p(saddr((p)), v)
|
||||
#define stfl_raw(p, v) stfl_p(saddr((p)), v)
|
||||
#define stfq_raw(p, v) stfq_p(saddr((p)), v)
|
||||
|
||||
|
||||
#if defined(CONFIG_USER_ONLY)
|
||||
|
||||
/* if user mode, no other memory access functions */
|
||||
#define ldub(p) ldub_raw(p)
|
||||
#define ldsb(p) ldsb_raw(p)
|
||||
#define lduw(p) lduw_raw(p)
|
||||
#define ldsw(p) ldsw_raw(p)
|
||||
#define ldl(p) ldl_raw(p)
|
||||
#define ldq(p) ldq_raw(p)
|
||||
#define ldfl(p) ldfl_raw(p)
|
||||
#define ldfq(p) ldfq_raw(p)
|
||||
#define stb(p, v) stb_raw(p, v)
|
||||
#define stw(p, v) stw_raw(p, v)
|
||||
#define stl(p, v) stl_raw(p, v)
|
||||
#define stq(p, v) stq_raw(p, v)
|
||||
#define stfl(p, v) stfl_raw(p, v)
|
||||
#define stfq(p, v) stfq_raw(p, v)
|
||||
|
||||
#define cpu_ldub_code(env1, p) ldub_raw(p)
|
||||
#define cpu_ldsb_code(env1, p) ldsb_raw(p)
|
||||
#define cpu_lduw_code(env1, p) lduw_raw(p)
|
||||
#define cpu_ldsw_code(env1, p) ldsw_raw(p)
|
||||
#define cpu_ldl_code(env1, p) ldl_raw(p)
|
||||
#define cpu_ldq_code(env1, p) ldq_raw(p)
|
||||
|
||||
#define cpu_ldub_data(env, addr) ldub_raw(addr)
|
||||
#define cpu_lduw_data(env, addr) lduw_raw(addr)
|
||||
#define cpu_ldsw_data(env, addr) ldsw_raw(addr)
|
||||
#define cpu_ldl_data(env, addr) ldl_raw(addr)
|
||||
#define cpu_ldq_data(env, addr) ldq_raw(addr)
|
||||
|
||||
#define cpu_stb_data(env, addr, data) stb_raw(addr, data)
|
||||
#define cpu_stw_data(env, addr, data) stw_raw(addr, data)
|
||||
#define cpu_stl_data(env, addr, data) stl_raw(addr, data)
|
||||
#define cpu_stq_data(env, addr, data) stq_raw(addr, data)
|
||||
|
||||
#define cpu_ldub_kernel(env, addr) ldub_raw(addr)
|
||||
#define cpu_lduw_kernel(env, addr) lduw_raw(addr)
|
||||
#define cpu_ldsw_kernel(env, addr) ldsw_raw(addr)
|
||||
#define cpu_ldl_kernel(env, addr) ldl_raw(addr)
|
||||
#define cpu_ldq_kernel(env, addr) ldq_raw(addr)
|
||||
|
||||
#define cpu_stb_kernel(env, addr, data) stb_raw(addr, data)
|
||||
#define cpu_stw_kernel(env, addr, data) stw_raw(addr, data)
|
||||
#define cpu_stl_kernel(env, addr, data) stl_raw(addr, data)
|
||||
#define cpu_stq_kernel(env, addr, data) stq_raw(addr, data)
|
||||
|
||||
#define ldub_kernel(p) ldub_raw(p)
|
||||
#define ldsb_kernel(p) ldsb_raw(p)
|
||||
#define lduw_kernel(p) lduw_raw(p)
|
||||
#define ldsw_kernel(p) ldsw_raw(p)
|
||||
#define ldl_kernel(p) ldl_raw(p)
|
||||
#define ldq_kernel(p) ldq_raw(p)
|
||||
#define ldfl_kernel(p) ldfl_raw(p)
|
||||
#define ldfq_kernel(p) ldfq_raw(p)
|
||||
#define stb_kernel(p, v) stb_raw(p, v)
|
||||
#define stw_kernel(p, v) stw_raw(p, v)
|
||||
#define stl_kernel(p, v) stl_raw(p, v)
|
||||
#define stq_kernel(p, v) stq_raw(p, v)
|
||||
#define stfl_kernel(p, v) stfl_raw(p, v)
|
||||
#define stfq_kernel(p, vt) stfq_raw(p, v)
|
||||
|
||||
#define cpu_ldub_data(env, addr) ldub_raw(addr)
|
||||
#define cpu_lduw_data(env, addr) lduw_raw(addr)
|
||||
#define cpu_ldl_data(env, addr) ldl_raw(addr)
|
||||
|
||||
#define cpu_stb_data(env, addr, data) stb_raw(addr, data)
|
||||
#define cpu_stw_data(env, addr, data) stw_raw(addr, data)
|
||||
#define cpu_stl_data(env, addr, data) stl_raw(addr, data)
|
||||
#endif /* defined(CONFIG_USER_ONLY) */
|
||||
|
||||
/* page related stuff */
|
||||
|
||||
#define TARGET_PAGE_SIZE (1 << TARGET_PAGE_BITS)
|
||||
|
||||
@@ -0,0 +1,400 @@
|
||||
/*
|
||||
* Software MMU support
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Generate inline load/store functions for all MMU modes (typically
|
||||
* at least _user and _kernel) as well as _data versions, for all data
|
||||
* sizes.
|
||||
*
|
||||
* Used by target op helpers.
|
||||
*
|
||||
* MMU mode suffixes are defined in target cpu.h.
|
||||
*/
|
||||
#ifndef CPU_LDST_H
|
||||
#define CPU_LDST_H
|
||||
|
||||
#if defined(CONFIG_USER_ONLY)
|
||||
/* All direct uses of g2h and h2g need to go away for usermode softmmu. */
|
||||
#define g2h(x) ((void *)((unsigned long)(target_ulong)(x) + GUEST_BASE))
|
||||
|
||||
#if HOST_LONG_BITS <= TARGET_VIRT_ADDR_SPACE_BITS
|
||||
#define h2g_valid(x) 1
|
||||
#else
|
||||
#define h2g_valid(x) ({ \
|
||||
unsigned long __guest = (unsigned long)(x) - GUEST_BASE; \
|
||||
(__guest < (1ul << TARGET_VIRT_ADDR_SPACE_BITS)) && \
|
||||
(!RESERVED_VA || (__guest < RESERVED_VA)); \
|
||||
})
|
||||
#endif
|
||||
|
||||
#define h2g_nocheck(x) ({ \
|
||||
unsigned long __ret = (unsigned long)(x) - GUEST_BASE; \
|
||||
(abi_ulong)__ret; \
|
||||
})
|
||||
|
||||
#define h2g(x) ({ \
|
||||
/* Check if given address fits target address space */ \
|
||||
assert(h2g_valid(x)); \
|
||||
h2g_nocheck(x); \
|
||||
})
|
||||
|
||||
#define saddr(x) g2h(x)
|
||||
#define laddr(x) g2h(x)
|
||||
|
||||
#else /* !CONFIG_USER_ONLY */
|
||||
/* NOTE: we use double casts if pointers and target_ulong have
|
||||
different sizes */
|
||||
#define saddr(x) (uint8_t *)(intptr_t)(x)
|
||||
#define laddr(x) (uint8_t *)(intptr_t)(x)
|
||||
#endif
|
||||
|
||||
#define ldub_raw(p) ldub_p(laddr((p)))
|
||||
#define ldsb_raw(p) ldsb_p(laddr((p)))
|
||||
#define lduw_raw(p) lduw_p(laddr((p)))
|
||||
#define ldsw_raw(p) ldsw_p(laddr((p)))
|
||||
#define ldl_raw(p) ldl_p(laddr((p)))
|
||||
#define ldq_raw(p) ldq_p(laddr((p)))
|
||||
#define ldfl_raw(p) ldfl_p(laddr((p)))
|
||||
#define ldfq_raw(p) ldfq_p(laddr((p)))
|
||||
#define stb_raw(p, v) stb_p(saddr((p)), v)
|
||||
#define stw_raw(p, v) stw_p(saddr((p)), v)
|
||||
#define stl_raw(p, v) stl_p(saddr((p)), v)
|
||||
#define stq_raw(p, v) stq_p(saddr((p)), v)
|
||||
#define stfl_raw(p, v) stfl_p(saddr((p)), v)
|
||||
#define stfq_raw(p, v) stfq_p(saddr((p)), v)
|
||||
|
||||
|
||||
#if defined(CONFIG_USER_ONLY)
|
||||
|
||||
/* if user mode, no other memory access functions */
|
||||
#define ldub(p) ldub_raw(p)
|
||||
#define ldsb(p) ldsb_raw(p)
|
||||
#define lduw(p) lduw_raw(p)
|
||||
#define ldsw(p) ldsw_raw(p)
|
||||
#define ldl(p) ldl_raw(p)
|
||||
#define ldq(p) ldq_raw(p)
|
||||
#define ldfl(p) ldfl_raw(p)
|
||||
#define ldfq(p) ldfq_raw(p)
|
||||
#define stb(p, v) stb_raw(p, v)
|
||||
#define stw(p, v) stw_raw(p, v)
|
||||
#define stl(p, v) stl_raw(p, v)
|
||||
#define stq(p, v) stq_raw(p, v)
|
||||
#define stfl(p, v) stfl_raw(p, v)
|
||||
#define stfq(p, v) stfq_raw(p, v)
|
||||
|
||||
#define cpu_ldub_code(env1, p) ldub_raw(p)
|
||||
#define cpu_ldsb_code(env1, p) ldsb_raw(p)
|
||||
#define cpu_lduw_code(env1, p) lduw_raw(p)
|
||||
#define cpu_ldsw_code(env1, p) ldsw_raw(p)
|
||||
#define cpu_ldl_code(env1, p) ldl_raw(p)
|
||||
#define cpu_ldq_code(env1, p) ldq_raw(p)
|
||||
|
||||
#define cpu_ldub_data(env, addr) ldub_raw(addr)
|
||||
#define cpu_lduw_data(env, addr) lduw_raw(addr)
|
||||
#define cpu_ldsw_data(env, addr) ldsw_raw(addr)
|
||||
#define cpu_ldl_data(env, addr) ldl_raw(addr)
|
||||
#define cpu_ldq_data(env, addr) ldq_raw(addr)
|
||||
|
||||
#define cpu_stb_data(env, addr, data) stb_raw(addr, data)
|
||||
#define cpu_stw_data(env, addr, data) stw_raw(addr, data)
|
||||
#define cpu_stl_data(env, addr, data) stl_raw(addr, data)
|
||||
#define cpu_stq_data(env, addr, data) stq_raw(addr, data)
|
||||
|
||||
#define cpu_ldub_kernel(env, addr) ldub_raw(addr)
|
||||
#define cpu_lduw_kernel(env, addr) lduw_raw(addr)
|
||||
#define cpu_ldsw_kernel(env, addr) ldsw_raw(addr)
|
||||
#define cpu_ldl_kernel(env, addr) ldl_raw(addr)
|
||||
#define cpu_ldq_kernel(env, addr) ldq_raw(addr)
|
||||
|
||||
#define cpu_stb_kernel(env, addr, data) stb_raw(addr, data)
|
||||
#define cpu_stw_kernel(env, addr, data) stw_raw(addr, data)
|
||||
#define cpu_stl_kernel(env, addr, data) stl_raw(addr, data)
|
||||
#define cpu_stq_kernel(env, addr, data) stq_raw(addr, data)
|
||||
|
||||
#define ldub_kernel(p) ldub_raw(p)
|
||||
#define ldsb_kernel(p) ldsb_raw(p)
|
||||
#define lduw_kernel(p) lduw_raw(p)
|
||||
#define ldsw_kernel(p) ldsw_raw(p)
|
||||
#define ldl_kernel(p) ldl_raw(p)
|
||||
#define ldq_kernel(p) ldq_raw(p)
|
||||
#define ldfl_kernel(p) ldfl_raw(p)
|
||||
#define ldfq_kernel(p) ldfq_raw(p)
|
||||
#define stb_kernel(p, v) stb_raw(p, v)
|
||||
#define stw_kernel(p, v) stw_raw(p, v)
|
||||
#define stl_kernel(p, v) stl_raw(p, v)
|
||||
#define stq_kernel(p, v) stq_raw(p, v)
|
||||
#define stfl_kernel(p, v) stfl_raw(p, v)
|
||||
#define stfq_kernel(p, vt) stfq_raw(p, v)
|
||||
|
||||
#define cpu_ldub_data(env, addr) ldub_raw(addr)
|
||||
#define cpu_lduw_data(env, addr) lduw_raw(addr)
|
||||
#define cpu_ldl_data(env, addr) ldl_raw(addr)
|
||||
|
||||
#define cpu_stb_data(env, addr, data) stb_raw(addr, data)
|
||||
#define cpu_stw_data(env, addr, data) stw_raw(addr, data)
|
||||
#define cpu_stl_data(env, addr, data) stl_raw(addr, data)
|
||||
|
||||
#else
|
||||
|
||||
/* XXX: find something cleaner.
|
||||
* Furthermore, this is false for 64 bits targets
|
||||
*/
|
||||
#define ldul_user ldl_user
|
||||
#define ldul_kernel ldl_kernel
|
||||
#define ldul_hypv ldl_hypv
|
||||
#define ldul_executive ldl_executive
|
||||
#define ldul_supervisor ldl_supervisor
|
||||
|
||||
/* The memory helpers for tcg-generated code need tcg_target_long etc. */
|
||||
#include "tcg.h"
|
||||
|
||||
uint8_t helper_ldb_mmu(CPUArchState *env, target_ulong addr, int mmu_idx);
|
||||
uint16_t helper_ldw_mmu(CPUArchState *env, target_ulong addr, int mmu_idx);
|
||||
uint32_t helper_ldl_mmu(CPUArchState *env, target_ulong addr, int mmu_idx);
|
||||
uint64_t helper_ldq_mmu(CPUArchState *env, target_ulong addr, int mmu_idx);
|
||||
|
||||
void helper_stb_mmu(CPUArchState *env, target_ulong addr,
|
||||
uint8_t val, int mmu_idx);
|
||||
void helper_stw_mmu(CPUArchState *env, target_ulong addr,
|
||||
uint16_t val, int mmu_idx);
|
||||
void helper_stl_mmu(CPUArchState *env, target_ulong addr,
|
||||
uint32_t val, int mmu_idx);
|
||||
void helper_stq_mmu(CPUArchState *env, target_ulong addr,
|
||||
uint64_t val, int mmu_idx);
|
||||
|
||||
uint8_t helper_ldb_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx);
|
||||
uint16_t helper_ldw_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx);
|
||||
uint32_t helper_ldl_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx);
|
||||
uint64_t helper_ldq_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx);
|
||||
|
||||
#define CPU_MMU_INDEX 0
|
||||
#define MEMSUFFIX MMU_MODE0_SUFFIX
|
||||
#define DATA_SIZE 1
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#define DATA_SIZE 2
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#define DATA_SIZE 4
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#define DATA_SIZE 8
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
#undef CPU_MMU_INDEX
|
||||
#undef MEMSUFFIX
|
||||
|
||||
#define CPU_MMU_INDEX 1
|
||||
#define MEMSUFFIX MMU_MODE1_SUFFIX
|
||||
#define DATA_SIZE 1
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#define DATA_SIZE 2
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#define DATA_SIZE 4
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#define DATA_SIZE 8
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
#undef CPU_MMU_INDEX
|
||||
#undef MEMSUFFIX
|
||||
|
||||
#if (NB_MMU_MODES >= 3)
|
||||
|
||||
#define CPU_MMU_INDEX 2
|
||||
#define MEMSUFFIX MMU_MODE2_SUFFIX
|
||||
#define DATA_SIZE 1
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#define DATA_SIZE 2
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#define DATA_SIZE 4
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#define DATA_SIZE 8
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
#undef CPU_MMU_INDEX
|
||||
#undef MEMSUFFIX
|
||||
#endif /* (NB_MMU_MODES >= 3) */
|
||||
|
||||
#if (NB_MMU_MODES >= 4)
|
||||
|
||||
#define CPU_MMU_INDEX 3
|
||||
#define MEMSUFFIX MMU_MODE3_SUFFIX
|
||||
#define DATA_SIZE 1
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#define DATA_SIZE 2
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#define DATA_SIZE 4
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#define DATA_SIZE 8
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
#undef CPU_MMU_INDEX
|
||||
#undef MEMSUFFIX
|
||||
#endif /* (NB_MMU_MODES >= 4) */
|
||||
|
||||
#if (NB_MMU_MODES >= 5)
|
||||
|
||||
#define CPU_MMU_INDEX 4
|
||||
#define MEMSUFFIX MMU_MODE4_SUFFIX
|
||||
#define DATA_SIZE 1
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#define DATA_SIZE 2
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#define DATA_SIZE 4
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#define DATA_SIZE 8
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
#undef CPU_MMU_INDEX
|
||||
#undef MEMSUFFIX
|
||||
#endif /* (NB_MMU_MODES >= 5) */
|
||||
|
||||
#if (NB_MMU_MODES >= 6)
|
||||
|
||||
#define CPU_MMU_INDEX 5
|
||||
#define MEMSUFFIX MMU_MODE5_SUFFIX
|
||||
#define DATA_SIZE 1
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#define DATA_SIZE 2
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#define DATA_SIZE 4
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#define DATA_SIZE 8
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
#undef CPU_MMU_INDEX
|
||||
#undef MEMSUFFIX
|
||||
#endif /* (NB_MMU_MODES >= 6) */
|
||||
|
||||
#if (NB_MMU_MODES > 6)
|
||||
#error "NB_MMU_MODES > 6 is not supported for now"
|
||||
#endif /* (NB_MMU_MODES > 6) */
|
||||
|
||||
/* these access are slower, they must be as rare as possible */
|
||||
#define CPU_MMU_INDEX (cpu_mmu_index(env))
|
||||
#define MEMSUFFIX _data
|
||||
#define DATA_SIZE 1
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#define DATA_SIZE 2
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#define DATA_SIZE 4
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#define DATA_SIZE 8
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
#undef CPU_MMU_INDEX
|
||||
#undef MEMSUFFIX
|
||||
|
||||
#define ldub(p) ldub_data(p)
|
||||
#define ldsb(p) ldsb_data(p)
|
||||
#define lduw(p) lduw_data(p)
|
||||
#define ldsw(p) ldsw_data(p)
|
||||
#define ldl(p) ldl_data(p)
|
||||
#define ldq(p) ldq_data(p)
|
||||
|
||||
#define stb(p, v) stb_data(p, v)
|
||||
#define stw(p, v) stw_data(p, v)
|
||||
#define stl(p, v) stl_data(p, v)
|
||||
#define stq(p, v) stq_data(p, v)
|
||||
|
||||
#define CPU_MMU_INDEX (cpu_mmu_index(env))
|
||||
#define MEMSUFFIX _code
|
||||
#define SOFTMMU_CODE_ACCESS
|
||||
|
||||
#define DATA_SIZE 1
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#define DATA_SIZE 2
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#define DATA_SIZE 4
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#define DATA_SIZE 8
|
||||
#include "exec/cpu_ldst_template.h"
|
||||
|
||||
#undef CPU_MMU_INDEX
|
||||
#undef MEMSUFFIX
|
||||
#undef SOFTMMU_CODE_ACCESS
|
||||
|
||||
/**
|
||||
* tlb_vaddr_to_host:
|
||||
* @env: CPUArchState
|
||||
* @addr: guest virtual address to look up
|
||||
* @access_type: 0 for read, 1 for write, 2 for execute
|
||||
* @mmu_idx: MMU index to use for lookup
|
||||
*
|
||||
* Look up the specified guest virtual index in the TCG softmmu TLB.
|
||||
* If the TLB contains a host virtual address suitable for direct RAM
|
||||
* access, then return it. Otherwise (TLB miss, TLB entry is for an
|
||||
* I/O access, etc) return NULL.
|
||||
*
|
||||
* This is the equivalent of the initial fast-path code used by
|
||||
* TCG backends for guest load and store accesses.
|
||||
*/
|
||||
static inline void *tlb_vaddr_to_host(CPUArchState *env, target_ulong addr,
|
||||
int access_type, int mmu_idx)
|
||||
{
|
||||
int index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
|
||||
CPUTLBEntry *tlbentry = &env->tlb_table[mmu_idx][index];
|
||||
target_ulong tlb_addr;
|
||||
uintptr_t haddr;
|
||||
|
||||
switch (access_type) {
|
||||
case 0:
|
||||
tlb_addr = tlbentry->addr_read;
|
||||
break;
|
||||
case 1:
|
||||
tlb_addr = tlbentry->addr_write;
|
||||
break;
|
||||
case 2:
|
||||
tlb_addr = tlbentry->addr_code;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
if ((addr & TARGET_PAGE_MASK)
|
||||
!= (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) {
|
||||
/* TLB entry is for a different page */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (tlb_addr & ~TARGET_PAGE_MASK) {
|
||||
/* IO access */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
haddr = addr + env->tlb_table[mmu_idx][index].addend;
|
||||
return (void *)haddr;
|
||||
}
|
||||
|
||||
#endif /* defined(CONFIG_USER_ONLY) */
|
||||
|
||||
#endif /* CPU_LDST_H */
|
||||
@@ -8,7 +8,7 @@
|
||||
* 32 and 64 bit cases, also generate floating point functions with
|
||||
* the same size.
|
||||
*
|
||||
* Not used directly but included from softmmu_exec.h and exec-all.h.
|
||||
* Not used directly but included from cpu_ldst.h.
|
||||
*
|
||||
* Copyright (c) 2003 Fabrice Bellard
|
||||
*
|
||||
@@ -47,35 +47,18 @@
|
||||
#error unsupported data size
|
||||
#endif
|
||||
|
||||
#if ACCESS_TYPE < (NB_MMU_MODES)
|
||||
|
||||
#define CPU_MMU_INDEX ACCESS_TYPE
|
||||
#define MMUSUFFIX _mmu
|
||||
|
||||
#elif ACCESS_TYPE == (NB_MMU_MODES)
|
||||
|
||||
#define CPU_MMU_INDEX (cpu_mmu_index(env))
|
||||
#define MMUSUFFIX _mmu
|
||||
|
||||
#elif ACCESS_TYPE == (NB_MMU_MODES + 1)
|
||||
|
||||
#define CPU_MMU_INDEX (cpu_mmu_index(env))
|
||||
#define MMUSUFFIX _cmmu
|
||||
|
||||
#else
|
||||
#error invalid ACCESS_TYPE
|
||||
#endif
|
||||
|
||||
#if DATA_SIZE == 8
|
||||
#define RES_TYPE uint64_t
|
||||
#else
|
||||
#define RES_TYPE uint32_t
|
||||
#endif
|
||||
|
||||
#if ACCESS_TYPE == (NB_MMU_MODES + 1)
|
||||
#ifdef SOFTMMU_CODE_ACCESS
|
||||
#define ADDR_READ addr_code
|
||||
#define MMUSUFFIX _cmmu
|
||||
#else
|
||||
#define ADDR_READ addr_read
|
||||
#define MMUSUFFIX _mmu
|
||||
#endif
|
||||
|
||||
/* generic load/store macros */
|
||||
@@ -124,7 +107,7 @@ glue(glue(cpu_lds, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ACCESS_TYPE != (NB_MMU_MODES + 1)
|
||||
#ifndef SOFTMMU_CODE_ACCESS
|
||||
|
||||
/* generic store macro */
|
||||
|
||||
@@ -148,9 +131,7 @@ glue(glue(cpu_st, SUFFIX), MEMSUFFIX)(CPUArchState *env, target_ulong ptr,
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* ACCESS_TYPE != (NB_MMU_MODES + 1) */
|
||||
|
||||
#if ACCESS_TYPE != (NB_MMU_MODES + 1)
|
||||
|
||||
#if DATA_SIZE == 8
|
||||
static inline float64 glue(cpu_ldfq, MEMSUFFIX)(CPUArchState *env,
|
||||
@@ -200,7 +181,7 @@ static inline void glue(cpu_stfl, MEMSUFFIX)(CPUArchState *env,
|
||||
}
|
||||
#endif /* DATA_SIZE == 4 */
|
||||
|
||||
#endif /* ACCESS_TYPE != (NB_MMU_MODES + 1) */
|
||||
#endif /* !SOFTMMU_CODE_ACCESS */
|
||||
|
||||
#undef RES_TYPE
|
||||
#undef DATA_TYPE
|
||||
@@ -208,6 +189,5 @@ static inline void glue(cpu_stfl, MEMSUFFIX)(CPUArchState *env,
|
||||
#undef SUFFIX
|
||||
#undef USUFFIX
|
||||
#undef DATA_SIZE
|
||||
#undef CPU_MMU_INDEX
|
||||
#undef MMUSUFFIX
|
||||
#undef ADDR_READ
|
||||
@@ -344,29 +344,6 @@ bool io_mem_write(struct MemoryRegion *mr, hwaddr addr,
|
||||
void tlb_fill(CPUState *cpu, target_ulong addr, int is_write, int mmu_idx,
|
||||
uintptr_t retaddr);
|
||||
|
||||
uint8_t helper_ldb_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx);
|
||||
uint16_t helper_ldw_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx);
|
||||
uint32_t helper_ldl_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx);
|
||||
uint64_t helper_ldq_cmmu(CPUArchState *env, target_ulong addr, int mmu_idx);
|
||||
|
||||
#define ACCESS_TYPE (NB_MMU_MODES + 1)
|
||||
#define MEMSUFFIX _code
|
||||
|
||||
#define DATA_SIZE 1
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#define DATA_SIZE 2
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#define DATA_SIZE 4
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#define DATA_SIZE 8
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#undef ACCESS_TYPE
|
||||
#undef MEMSUFFIX
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_USER_ONLY)
|
||||
|
||||
@@ -1,216 +0,0 @@
|
||||
/*
|
||||
* Software MMU support
|
||||
*
|
||||
* Generate inline load/store functions for all MMU modes (typically
|
||||
* at least _user and _kernel) as well as _data versions, for all data
|
||||
* sizes.
|
||||
*
|
||||
* Used by target op helpers.
|
||||
*
|
||||
* MMU mode suffixes are defined in target cpu.h.
|
||||
*/
|
||||
|
||||
/* XXX: find something cleaner.
|
||||
* Furthermore, this is false for 64 bits targets
|
||||
*/
|
||||
#define ldul_user ldl_user
|
||||
#define ldul_kernel ldl_kernel
|
||||
#define ldul_hypv ldl_hypv
|
||||
#define ldul_executive ldl_executive
|
||||
#define ldul_supervisor ldl_supervisor
|
||||
|
||||
/* The memory helpers for tcg-generated code need tcg_target_long etc. */
|
||||
#include "tcg.h"
|
||||
|
||||
#define ACCESS_TYPE 0
|
||||
#define MEMSUFFIX MMU_MODE0_SUFFIX
|
||||
#define DATA_SIZE 1
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#define DATA_SIZE 2
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#define DATA_SIZE 4
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#define DATA_SIZE 8
|
||||
#include "exec/softmmu_header.h"
|
||||
#undef ACCESS_TYPE
|
||||
#undef MEMSUFFIX
|
||||
|
||||
#define ACCESS_TYPE 1
|
||||
#define MEMSUFFIX MMU_MODE1_SUFFIX
|
||||
#define DATA_SIZE 1
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#define DATA_SIZE 2
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#define DATA_SIZE 4
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#define DATA_SIZE 8
|
||||
#include "exec/softmmu_header.h"
|
||||
#undef ACCESS_TYPE
|
||||
#undef MEMSUFFIX
|
||||
|
||||
#if (NB_MMU_MODES >= 3)
|
||||
|
||||
#define ACCESS_TYPE 2
|
||||
#define MEMSUFFIX MMU_MODE2_SUFFIX
|
||||
#define DATA_SIZE 1
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#define DATA_SIZE 2
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#define DATA_SIZE 4
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#define DATA_SIZE 8
|
||||
#include "exec/softmmu_header.h"
|
||||
#undef ACCESS_TYPE
|
||||
#undef MEMSUFFIX
|
||||
#endif /* (NB_MMU_MODES >= 3) */
|
||||
|
||||
#if (NB_MMU_MODES >= 4)
|
||||
|
||||
#define ACCESS_TYPE 3
|
||||
#define MEMSUFFIX MMU_MODE3_SUFFIX
|
||||
#define DATA_SIZE 1
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#define DATA_SIZE 2
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#define DATA_SIZE 4
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#define DATA_SIZE 8
|
||||
#include "exec/softmmu_header.h"
|
||||
#undef ACCESS_TYPE
|
||||
#undef MEMSUFFIX
|
||||
#endif /* (NB_MMU_MODES >= 4) */
|
||||
|
||||
#if (NB_MMU_MODES >= 5)
|
||||
|
||||
#define ACCESS_TYPE 4
|
||||
#define MEMSUFFIX MMU_MODE4_SUFFIX
|
||||
#define DATA_SIZE 1
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#define DATA_SIZE 2
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#define DATA_SIZE 4
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#define DATA_SIZE 8
|
||||
#include "exec/softmmu_header.h"
|
||||
#undef ACCESS_TYPE
|
||||
#undef MEMSUFFIX
|
||||
#endif /* (NB_MMU_MODES >= 5) */
|
||||
|
||||
#if (NB_MMU_MODES >= 6)
|
||||
|
||||
#define ACCESS_TYPE 5
|
||||
#define MEMSUFFIX MMU_MODE5_SUFFIX
|
||||
#define DATA_SIZE 1
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#define DATA_SIZE 2
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#define DATA_SIZE 4
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#define DATA_SIZE 8
|
||||
#include "exec/softmmu_header.h"
|
||||
#undef ACCESS_TYPE
|
||||
#undef MEMSUFFIX
|
||||
#endif /* (NB_MMU_MODES >= 6) */
|
||||
|
||||
#if (NB_MMU_MODES > 6)
|
||||
#error "NB_MMU_MODES > 6 is not supported for now"
|
||||
#endif /* (NB_MMU_MODES > 6) */
|
||||
|
||||
/* these access are slower, they must be as rare as possible */
|
||||
#define ACCESS_TYPE (NB_MMU_MODES)
|
||||
#define MEMSUFFIX _data
|
||||
#define DATA_SIZE 1
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#define DATA_SIZE 2
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#define DATA_SIZE 4
|
||||
#include "exec/softmmu_header.h"
|
||||
|
||||
#define DATA_SIZE 8
|
||||
#include "exec/softmmu_header.h"
|
||||
#undef ACCESS_TYPE
|
||||
#undef MEMSUFFIX
|
||||
|
||||
#define ldub(p) ldub_data(p)
|
||||
#define ldsb(p) ldsb_data(p)
|
||||
#define lduw(p) lduw_data(p)
|
||||
#define ldsw(p) ldsw_data(p)
|
||||
#define ldl(p) ldl_data(p)
|
||||
#define ldq(p) ldq_data(p)
|
||||
|
||||
#define stb(p, v) stb_data(p, v)
|
||||
#define stw(p, v) stw_data(p, v)
|
||||
#define stl(p, v) stl_data(p, v)
|
||||
#define stq(p, v) stq_data(p, v)
|
||||
|
||||
/**
|
||||
* tlb_vaddr_to_host:
|
||||
* @env: CPUArchState
|
||||
* @addr: guest virtual address to look up
|
||||
* @access_type: 0 for read, 1 for write, 2 for execute
|
||||
* @mmu_idx: MMU index to use for lookup
|
||||
*
|
||||
* Look up the specified guest virtual index in the TCG softmmu TLB.
|
||||
* If the TLB contains a host virtual address suitable for direct RAM
|
||||
* access, then return it. Otherwise (TLB miss, TLB entry is for an
|
||||
* I/O access, etc) return NULL.
|
||||
*
|
||||
* This is the equivalent of the initial fast-path code used by
|
||||
* TCG backends for guest load and store accesses.
|
||||
*/
|
||||
static inline void *tlb_vaddr_to_host(CPUArchState *env, target_ulong addr,
|
||||
int access_type, int mmu_idx)
|
||||
{
|
||||
int index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1);
|
||||
CPUTLBEntry *tlbentry = &env->tlb_table[mmu_idx][index];
|
||||
target_ulong tlb_addr;
|
||||
uintptr_t haddr;
|
||||
|
||||
switch (access_type) {
|
||||
case 0:
|
||||
tlb_addr = tlbentry->addr_read;
|
||||
break;
|
||||
case 1:
|
||||
tlb_addr = tlbentry->addr_write;
|
||||
break;
|
||||
case 2:
|
||||
tlb_addr = tlbentry->addr_code;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
if ((addr & TARGET_PAGE_MASK)
|
||||
!= (tlb_addr & (TARGET_PAGE_MASK | TLB_INVALID_MASK))) {
|
||||
/* TLB entry is for a different page */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (tlb_addr & ~TARGET_PAGE_MASK) {
|
||||
/* IO access */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
haddr = addr + env->tlb_table[mmu_idx][index].addend;
|
||||
return (void *)haddr;
|
||||
}
|
||||
+13
-2
@@ -80,6 +80,8 @@ struct TranslationBlock;
|
||||
* @has_work: Callback for checking if there is work to do.
|
||||
* @do_interrupt: Callback for interrupt handling.
|
||||
* @do_unassigned_access: Callback for unassigned access handling.
|
||||
* @do_unaligned_access: Callback for unaligned access handling, if
|
||||
* the target defines #ALIGNED_ONLY.
|
||||
* @memory_rw_debug: Callback for GDB memory access.
|
||||
* @dump_state: Callback for dumping state.
|
||||
* @dump_statistics: Callback for dumping statistics.
|
||||
@@ -112,6 +114,8 @@ typedef struct CPUClass {
|
||||
bool (*has_work)(CPUState *cpu);
|
||||
void (*do_interrupt)(CPUState *cpu);
|
||||
CPUUnassignedAccess do_unassigned_access;
|
||||
void (*do_unaligned_access)(CPUState *cpu, vaddr addr,
|
||||
int is_write, int is_user, uintptr_t retaddr);
|
||||
int (*memory_rw_debug)(CPUState *cpu, vaddr addr,
|
||||
uint8_t *buf, int len, bool is_write);
|
||||
void (*dump_state)(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf,
|
||||
@@ -544,8 +548,7 @@ void cpu_interrupt(CPUState *cpu, int mask);
|
||||
|
||||
#endif /* USER_ONLY */
|
||||
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
|
||||
#ifdef CONFIG_SOFTMMU
|
||||
static inline void cpu_unassigned_access(CPUState *cpu, hwaddr addr,
|
||||
bool is_write, bool is_exec,
|
||||
int opaque, unsigned size)
|
||||
@@ -557,6 +560,14 @@ static inline void cpu_unassigned_access(CPUState *cpu, hwaddr addr,
|
||||
}
|
||||
}
|
||||
|
||||
static inline void cpu_unaligned_access(CPUState *cpu, vaddr addr,
|
||||
int is_write, int is_user,
|
||||
uintptr_t retaddr)
|
||||
{
|
||||
CPUClass *cc = CPU_GET_CLASS(cpu);
|
||||
|
||||
return cc->do_unaligned_access(cpu, addr, is_write, is_user, retaddr);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "cpu.h"
|
||||
#include "exec/cpu_ldst.h"
|
||||
|
||||
#undef DEBUG_REMAP
|
||||
#ifdef DEBUG_REMAP
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
#include "trace/simple.h"
|
||||
#endif
|
||||
#include "exec/memory.h"
|
||||
#include "exec/cpu_ldst.h"
|
||||
#include "qmp-commands.h"
|
||||
#include "hmp.h"
|
||||
#include "qemu/thread.h"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user