helper.c
来自「xen虚拟机源代码安装包」· C语言 代码 · 共 1,349 行 · 第 1/3 页
C
1,349 行
.mmu_cxr_mask = 0x000000ff, .mmu_sfsr_mask = 0x00016fff, .mmu_trcr_mask = 0x00ffffff, .features = CPU_DEFAULT_FEATURES, }, { .name = "Fujitsu MB86907", .iu_version = 0x05 << 24, /* Impl 0, ver 5 */ .fpu_version = 4 << 17, /* FPU version 4 (Meiko) */ .mmu_version = 0x05 << 24, /* Impl 0, ver 5 */ .mmu_bm = 0x00004000, .mmu_ctpr_mask = 0xffffffc0, .mmu_cxr_mask = 0x000000ff, .mmu_sfsr_mask = 0x00016fff, .mmu_trcr_mask = 0xffffffff, .features = CPU_DEFAULT_FEATURES, }, { .name = "LSI L64811", .iu_version = 0x10 << 24, /* Impl 1, ver 0 */ .fpu_version = 1 << 17, /* FPU version 1 (LSI L64814) */ .mmu_version = 0x10 << 24, .mmu_bm = 0x00004000, .mmu_ctpr_mask = 0x007ffff0, .mmu_cxr_mask = 0x0000003f, .mmu_sfsr_mask = 0xffffffff, .mmu_trcr_mask = 0xffffffff, .features = CPU_FEATURE_FLOAT | CPU_FEATURE_SWAP | CPU_FEATURE_FSQRT, }, { .name = "Cypress CY7C601", .iu_version = 0x11 << 24, /* Impl 1, ver 1 */ .fpu_version = 3 << 17, /* FPU version 3 (Cypress CY7C602) */ .mmu_version = 0x10 << 24, .mmu_bm = 0x00004000, .mmu_ctpr_mask = 0x007ffff0, .mmu_cxr_mask = 0x0000003f, .mmu_sfsr_mask = 0xffffffff, .mmu_trcr_mask = 0xffffffff, .features = CPU_FEATURE_FLOAT | CPU_FEATURE_SWAP | CPU_FEATURE_FSQRT, }, { .name = "Cypress CY7C611", .iu_version = 0x13 << 24, /* Impl 1, ver 3 */ .fpu_version = 3 << 17, /* FPU version 3 (Cypress CY7C602) */ .mmu_version = 0x10 << 24, .mmu_bm = 0x00004000, .mmu_ctpr_mask = 0x007ffff0, .mmu_cxr_mask = 0x0000003f, .mmu_sfsr_mask = 0xffffffff, .mmu_trcr_mask = 0xffffffff, .features = CPU_FEATURE_FLOAT | CPU_FEATURE_SWAP | CPU_FEATURE_FSQRT, }, { .name = "TI SuperSparc II", .iu_version = 0x40000000, .fpu_version = 0 << 17, .mmu_version = 0x04000000, .mmu_bm = 0x00002000, .mmu_ctpr_mask = 0xffffffc0, .mmu_cxr_mask = 0x0000ffff, .mmu_sfsr_mask = 0xffffffff, .mmu_trcr_mask = 0xffffffff, .features = CPU_DEFAULT_FEATURES, }, { .name = "TI MicroSparc I", .iu_version = 0x41000000, .fpu_version = 4 << 17, .mmu_version = 0x41000000, .mmu_bm = 0x00004000, .mmu_ctpr_mask = 0x007ffff0, .mmu_cxr_mask = 0x0000003f, .mmu_sfsr_mask = 0x00016fff, .mmu_trcr_mask = 0x0000003f, .features = CPU_DEFAULT_FEATURES, }, { .name = "TI MicroSparc II", .iu_version = 0x42000000, .fpu_version = 4 << 17, .mmu_version = 0x02000000, .mmu_bm = 0x00004000, .mmu_ctpr_mask = 0x00ffffc0, .mmu_cxr_mask = 0x000000ff, .mmu_sfsr_mask = 0x00016fff, .mmu_trcr_mask = 0x00ffffff, .features = CPU_DEFAULT_FEATURES, }, { .name = "TI MicroSparc IIep", .iu_version = 0x42000000, .fpu_version = 4 << 17, .mmu_version = 0x04000000, .mmu_bm = 0x00004000, .mmu_ctpr_mask = 0x00ffffc0, .mmu_cxr_mask = 0x000000ff, .mmu_sfsr_mask = 0x00016bff, .mmu_trcr_mask = 0x00ffffff, .features = CPU_DEFAULT_FEATURES, }, { .name = "TI SuperSparc 51", .iu_version = 0x43000000, .fpu_version = 0 << 17, .mmu_version = 0x04000000, .mmu_bm = 0x00002000, .mmu_ctpr_mask = 0xffffffc0, .mmu_cxr_mask = 0x0000ffff, .mmu_sfsr_mask = 0xffffffff, .mmu_trcr_mask = 0xffffffff, .features = CPU_DEFAULT_FEATURES, }, { .name = "TI SuperSparc 61", .iu_version = 0x44000000, .fpu_version = 0 << 17, .mmu_version = 0x04000000, .mmu_bm = 0x00002000, .mmu_ctpr_mask = 0xffffffc0, .mmu_cxr_mask = 0x0000ffff, .mmu_sfsr_mask = 0xffffffff, .mmu_trcr_mask = 0xffffffff, .features = CPU_DEFAULT_FEATURES, }, { .name = "Ross RT625", .iu_version = 0x1e000000, .fpu_version = 1 << 17, .mmu_version = 0x1e000000, .mmu_bm = 0x00004000, .mmu_ctpr_mask = 0x007ffff0, .mmu_cxr_mask = 0x0000003f, .mmu_sfsr_mask = 0xffffffff, .mmu_trcr_mask = 0xffffffff, .features = CPU_DEFAULT_FEATURES, }, { .name = "Ross RT620", .iu_version = 0x1f000000, .fpu_version = 1 << 17, .mmu_version = 0x1f000000, .mmu_bm = 0x00004000, .mmu_ctpr_mask = 0x007ffff0, .mmu_cxr_mask = 0x0000003f, .mmu_sfsr_mask = 0xffffffff, .mmu_trcr_mask = 0xffffffff, .features = CPU_DEFAULT_FEATURES, }, { .name = "BIT B5010", .iu_version = 0x20000000, .fpu_version = 0 << 17, /* B5010/B5110/B5120/B5210 */ .mmu_version = 0x20000000, .mmu_bm = 0x00004000, .mmu_ctpr_mask = 0x007ffff0, .mmu_cxr_mask = 0x0000003f, .mmu_sfsr_mask = 0xffffffff, .mmu_trcr_mask = 0xffffffff, .features = CPU_FEATURE_FLOAT | CPU_FEATURE_SWAP | CPU_FEATURE_FSQRT, }, { .name = "Matsushita MN10501", .iu_version = 0x50000000, .fpu_version = 0 << 17, .mmu_version = 0x50000000, .mmu_bm = 0x00004000, .mmu_ctpr_mask = 0x007ffff0, .mmu_cxr_mask = 0x0000003f, .mmu_sfsr_mask = 0xffffffff, .mmu_trcr_mask = 0xffffffff, .features = CPU_FEATURE_FLOAT | CPU_FEATURE_MUL | CPU_FEATURE_FSQRT, }, { .name = "Weitek W8601", .iu_version = 0x90 << 24, /* Impl 9, ver 0 */ .fpu_version = 3 << 17, /* FPU version 3 (Weitek WTL3170/2) */ .mmu_version = 0x10 << 24, .mmu_bm = 0x00004000, .mmu_ctpr_mask = 0x007ffff0, .mmu_cxr_mask = 0x0000003f, .mmu_sfsr_mask = 0xffffffff, .mmu_trcr_mask = 0xffffffff, .features = CPU_DEFAULT_FEATURES, }, { .name = "LEON2", .iu_version = 0xf2000000, .fpu_version = 4 << 17, /* FPU version 4 (Meiko) */ .mmu_version = 0xf2000000, .mmu_bm = 0x00004000, .mmu_ctpr_mask = 0x007ffff0, .mmu_cxr_mask = 0x0000003f, .mmu_sfsr_mask = 0xffffffff, .mmu_trcr_mask = 0xffffffff, .features = CPU_DEFAULT_FEATURES, }, { .name = "LEON3", .iu_version = 0xf3000000, .fpu_version = 4 << 17, /* FPU version 4 (Meiko) */ .mmu_version = 0xf3000000, .mmu_bm = 0x00004000, .mmu_ctpr_mask = 0x007ffff0, .mmu_cxr_mask = 0x0000003f, .mmu_sfsr_mask = 0xffffffff, .mmu_trcr_mask = 0xffffffff, .features = CPU_DEFAULT_FEATURES, },#endif};static const char * const feature_name[] = { "float", "float128", "swap", "mul", "div", "flush", "fsqrt", "fmul", "vis1", "vis2",};static void print_features(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...), uint32_t features, const char *prefix){ unsigned int i; for (i = 0; i < ARRAY_SIZE(feature_name); i++) if (feature_name[i] && (features & (1 << i))) { if (prefix) (*cpu_fprintf)(f, "%s", prefix); (*cpu_fprintf)(f, "%s ", feature_name[i]); }}static void add_flagname_to_bitmaps(const char *flagname, uint32_t *features){ unsigned int i; for (i = 0; i < ARRAY_SIZE(feature_name); i++) if (feature_name[i] && !strcmp(flagname, feature_name[i])) { *features |= 1 << i; return; } fprintf(stderr, "CPU feature %s not found\n", flagname);}static int cpu_sparc_find_by_name(sparc_def_t *cpu_def, const char *cpu_model){ unsigned int i; const sparc_def_t *def = NULL; char *s = strdup(cpu_model); char *featurestr, *name = strtok(s, ","); uint32_t plus_features = 0; uint32_t minus_features = 0; long long iu_version; uint32_t fpu_version, mmu_version; for (i = 0; i < sizeof(sparc_defs) / sizeof(sparc_def_t); i++) { if (strcasecmp(name, sparc_defs[i].name) == 0) { def = &sparc_defs[i]; } } if (!def) goto error; memcpy(cpu_def, def, sizeof(*def)); featurestr = strtok(NULL, ","); while (featurestr) { char *val; if (featurestr[0] == '+') { add_flagname_to_bitmaps(featurestr + 1, &plus_features); } else if (featurestr[0] == '-') { add_flagname_to_bitmaps(featurestr + 1, &minus_features); } else if ((val = strchr(featurestr, '='))) { *val = 0; val++; if (!strcmp(featurestr, "iu_version")) { char *err; iu_version = strtoll(val, &err, 0); if (!*val || *err) { fprintf(stderr, "bad numerical value %s\n", val); goto error; } cpu_def->iu_version = iu_version;#ifdef DEBUG_FEATURES fprintf(stderr, "iu_version %llx\n", iu_version);#endif } else if (!strcmp(featurestr, "fpu_version")) { char *err; fpu_version = strtol(val, &err, 0); if (!*val || *err) { fprintf(stderr, "bad numerical value %s\n", val); goto error; } cpu_def->fpu_version = fpu_version;#ifdef DEBUG_FEATURES fprintf(stderr, "fpu_version %llx\n", fpu_version);#endif } else if (!strcmp(featurestr, "mmu_version")) { char *err; mmu_version = strtol(val, &err, 0); if (!*val || *err) { fprintf(stderr, "bad numerical value %s\n", val); goto error; } cpu_def->mmu_version = mmu_version;#ifdef DEBUG_FEATURES fprintf(stderr, "mmu_version %llx\n", mmu_version);#endif } else { fprintf(stderr, "unrecognized feature %s\n", featurestr); goto error; } } else { fprintf(stderr, "feature string `%s' not in format " "(+feature|-feature|feature=xyz)\n", featurestr); goto error; } featurestr = strtok(NULL, ","); } cpu_def->features |= plus_features; cpu_def->features &= ~minus_features;#ifdef DEBUG_FEATURES print_features(stderr, fprintf, cpu_def->features, NULL);#endif free(s); return 0; error: free(s); return -1;}void sparc_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)){ unsigned int i; for (i = 0; i < sizeof(sparc_defs) / sizeof(sparc_def_t); i++) { (*cpu_fprintf)(f, "Sparc %16s IU " TARGET_FMT_lx " FPU %08x MMU %08x ", sparc_defs[i].name, sparc_defs[i].iu_version, sparc_defs[i].fpu_version, sparc_defs[i].mmu_version); print_features(f, cpu_fprintf, CPU_DEFAULT_FEATURES & ~sparc_defs[i].features, "-"); print_features(f, cpu_fprintf, ~CPU_DEFAULT_FEATURES & sparc_defs[i].features, "+"); (*cpu_fprintf)(f, "\n"); } (*cpu_fprintf)(f, "CPU feature flags (+/-): "); print_features(f, cpu_fprintf, -1, NULL); (*cpu_fprintf)(f, "\n"); (*cpu_fprintf)(f, "Numerical features (=): iu_version fpu_version " "mmu_version\n");}#define GET_FLAG(a,b) ((env->psr & a)?b:'-')void cpu_dump_state(CPUState *env, FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...), int flags){ int i, x; cpu_fprintf(f, "pc: " TARGET_FMT_lx " npc: " TARGET_FMT_lx "\n", env->pc, env->npc); cpu_fprintf(f, "General Registers:\n"); for (i = 0; i < 4; i++) cpu_fprintf(f, "%%g%c: " TARGET_FMT_lx "\t", i + '0', env->gregs[i]); cpu_fprintf(f, "\n"); for (; i < 8; i++) cpu_fprintf(f, "%%g%c: " TARGET_FMT_lx "\t", i + '0', env->gregs[i]); cpu_fprintf(f, "\nCurrent Register Window:\n"); for (x = 0; x < 3; x++) { for (i = 0; i < 4; i++) cpu_fprintf(f, "%%%c%d: " TARGET_FMT_lx "\t", (x == 0 ? 'o' : (x == 1 ? 'l' : 'i')), i, env->regwptr[i + x * 8]); cpu_fprintf(f, "\n"); for (; i < 8; i++) cpu_fprintf(f, "%%%c%d: " TARGET_FMT_lx "\t", (x == 0 ? 'o' : x == 1 ? 'l' : 'i'), i, env->regwptr[i + x * 8]); cpu_fprintf(f, "\n"); } cpu_fprintf(f, "\nFloating Point Registers:\n"); for (i = 0; i < 32; i++) { if ((i & 3) == 0) cpu_fprintf(f, "%%f%02d:", i); cpu_fprintf(f, " %016lf", env->fpr[i]); if ((i & 3) == 3) cpu_fprintf(f, "\n"); }#ifdef TARGET_SPARC64 cpu_fprintf(f, "pstate: 0x%08x ccr: 0x%02x asi: 0x%02x tl: %d fprs: %d\n", env->pstate, GET_CCR(env), env->asi, env->tl, env->fprs); cpu_fprintf(f, "cansave: %d canrestore: %d otherwin: %d wstate %d " "cleanwin %d cwp %d\n", env->cansave, env->canrestore, env->otherwin, env->wstate, env->cleanwin, NWINDOWS - 1 - env->cwp);#else cpu_fprintf(f, "psr: 0x%08x -> %c%c%c%c %c%c%c wim: 0x%08x\n", GET_PSR(env), GET_FLAG(PSR_ZERO, 'Z'), GET_FLAG(PSR_OVF, 'V'), GET_FLAG(PSR_NEG, 'N'), GET_FLAG(PSR_CARRY, 'C'), env->psrs?'S':'-', env->psrps?'P':'-', env->psret?'E':'-', env->wim);#endif cpu_fprintf(f, "fsr: 0x%08x\n", GET_FSR32(env));}#ifdef TARGET_SPARC64#if !defined(CONFIG_USER_ONLY)#include "qemu-common.h"#include "hw/irq.h"#include "qemu-timer.h"#endifvoid helper_tick_set_count(void *opaque, uint64_t count){#if !defined(CONFIG_USER_ONLY) ptimer_set_count(opaque, -count);#endif}uint64_t helper_tick_get_count(void *opaque){#if !defined(CONFIG_USER_ONLY) return -ptimer_get_count(opaque);#else return 0;#endif}void helper_tick_set_limit(void *opaque, uint64_t limit){#if !defined(CONFIG_USER_ONLY) ptimer_set_limit(opaque, -limit, 0);#endif}#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?