Statistics
| Branch: | Revision:

root / target-s390x / helper.c @ 44e4c0ba

History | View | Annotate | Download (2.1 kB)

1 10ec5117 Alexander Graf
/*
2 10ec5117 Alexander Graf
 *  S/390 helpers
3 10ec5117 Alexander Graf
 *
4 10ec5117 Alexander Graf
 *  Copyright (c) 2009 Ulrich Hecht
5 10ec5117 Alexander Graf
 *
6 10ec5117 Alexander Graf
 * This library is free software; you can redistribute it and/or
7 10ec5117 Alexander Graf
 * modify it under the terms of the GNU Lesser General Public
8 10ec5117 Alexander Graf
 * License as published by the Free Software Foundation; either
9 10ec5117 Alexander Graf
 * version 2 of the License, or (at your option) any later version.
10 10ec5117 Alexander Graf
 *
11 10ec5117 Alexander Graf
 * This library is distributed in the hope that it will be useful,
12 10ec5117 Alexander Graf
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 10ec5117 Alexander Graf
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 10ec5117 Alexander Graf
 * Lesser General Public License for more details.
15 10ec5117 Alexander Graf
 *
16 10ec5117 Alexander Graf
 * You should have received a copy of the GNU Lesser General Public
17 10ec5117 Alexander Graf
 * License along with this library; if not, write to the Free Software
18 10ec5117 Alexander Graf
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA  02110-1301 USA
19 10ec5117 Alexander Graf
 */
20 10ec5117 Alexander Graf
21 10ec5117 Alexander Graf
#include <stdio.h>
22 10ec5117 Alexander Graf
#include <stdlib.h>
23 10ec5117 Alexander Graf
#include <string.h>
24 10ec5117 Alexander Graf
25 10ec5117 Alexander Graf
#include "cpu.h"
26 10ec5117 Alexander Graf
#include "exec-all.h"
27 10ec5117 Alexander Graf
#include "gdbstub.h"
28 10ec5117 Alexander Graf
#include "qemu-common.h"
29 10ec5117 Alexander Graf
30 10c339a0 Alexander Graf
#include <linux/kvm.h>
31 10c339a0 Alexander Graf
#include "kvm.h"
32 10c339a0 Alexander Graf
33 10ec5117 Alexander Graf
CPUS390XState *cpu_s390x_init(const char *cpu_model)
34 10ec5117 Alexander Graf
{
35 10ec5117 Alexander Graf
    CPUS390XState *env;
36 10ec5117 Alexander Graf
    static int inited = 0;
37 10ec5117 Alexander Graf
38 10ec5117 Alexander Graf
    env = qemu_mallocz(sizeof(CPUS390XState));
39 10ec5117 Alexander Graf
    cpu_exec_init(env);
40 10ec5117 Alexander Graf
    if (!inited) {
41 10ec5117 Alexander Graf
        inited = 1;
42 10ec5117 Alexander Graf
    }
43 10ec5117 Alexander Graf
44 10ec5117 Alexander Graf
    env->cpu_model_str = cpu_model;
45 10ec5117 Alexander Graf
    cpu_reset(env);
46 10ec5117 Alexander Graf
    qemu_init_vcpu(env);
47 10ec5117 Alexander Graf
    return env;
48 10ec5117 Alexander Graf
}
49 10ec5117 Alexander Graf
50 10ec5117 Alexander Graf
target_phys_addr_t cpu_get_phys_page_debug(CPUState *env, target_ulong addr)
51 10ec5117 Alexander Graf
{
52 10ec5117 Alexander Graf
    return addr;
53 10ec5117 Alexander Graf
}
54 10ec5117 Alexander Graf
55 10ec5117 Alexander Graf
void cpu_reset(CPUS390XState *env)
56 10ec5117 Alexander Graf
{
57 10ec5117 Alexander Graf
    if (qemu_loglevel_mask(CPU_LOG_RESET)) {
58 10ec5117 Alexander Graf
        qemu_log("CPU Reset (CPU %d)\n", env->cpu_index);
59 10ec5117 Alexander Graf
        log_cpu_state(env, 0);
60 10ec5117 Alexander Graf
    }
61 10ec5117 Alexander Graf
62 10ec5117 Alexander Graf
    memset(env, 0, offsetof(CPUS390XState, breakpoints));
63 10ec5117 Alexander Graf
    /* FIXME: reset vector? */
64 10ec5117 Alexander Graf
    tlb_flush(env, 1);
65 10ec5117 Alexander Graf
}
66 10c339a0 Alexander Graf
67 10c339a0 Alexander Graf
#ifndef CONFIG_USER_ONLY
68 10c339a0 Alexander Graf
69 10c339a0 Alexander Graf
int cpu_s390x_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
70 10c339a0 Alexander Graf
                                int mmu_idx, int is_softmmu)
71 10c339a0 Alexander Graf
{
72 10c339a0 Alexander Graf
    target_ulong phys;
73 10c339a0 Alexander Graf
    int prot;
74 10c339a0 Alexander Graf
75 10c339a0 Alexander Graf
    /* XXX: implement mmu */
76 10c339a0 Alexander Graf
77 10c339a0 Alexander Graf
    phys = address;
78 10c339a0 Alexander Graf
    prot = PAGE_READ | PAGE_WRITE;
79 10c339a0 Alexander Graf
80 10c339a0 Alexander Graf
    return tlb_set_page(env, address & TARGET_PAGE_MASK,
81 10c339a0 Alexander Graf
                        phys & TARGET_PAGE_MASK, prot,
82 10c339a0 Alexander Graf
                        mmu_idx, is_softmmu);
83 10c339a0 Alexander Graf
}
84 10c339a0 Alexander Graf
#endif /* CONFIG_USER_ONLY */