Statistics
| Branch: | Revision:

root / target-s390x / helper.c @ bb4ea393

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 70539e18 Blue Swirl
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 10ec5117 Alexander Graf
 */
19 10ec5117 Alexander Graf
20 10ec5117 Alexander Graf
#include <stdio.h>
21 10ec5117 Alexander Graf
#include <stdlib.h>
22 10ec5117 Alexander Graf
#include <string.h>
23 10ec5117 Alexander Graf
24 10ec5117 Alexander Graf
#include "cpu.h"
25 10ec5117 Alexander Graf
#include "exec-all.h"
26 10ec5117 Alexander Graf
#include "gdbstub.h"
27 10ec5117 Alexander Graf
#include "qemu-common.h"
28 10ec5117 Alexander Graf
29 10c339a0 Alexander Graf
#include <linux/kvm.h>
30 10c339a0 Alexander Graf
#include "kvm.h"
31 10c339a0 Alexander Graf
32 10ec5117 Alexander Graf
CPUS390XState *cpu_s390x_init(const char *cpu_model)
33 10ec5117 Alexander Graf
{
34 10ec5117 Alexander Graf
    CPUS390XState *env;
35 10ec5117 Alexander Graf
    static int inited = 0;
36 10ec5117 Alexander Graf
37 10ec5117 Alexander Graf
    env = qemu_mallocz(sizeof(CPUS390XState));
38 10ec5117 Alexander Graf
    cpu_exec_init(env);
39 10ec5117 Alexander Graf
    if (!inited) {
40 10ec5117 Alexander Graf
        inited = 1;
41 10ec5117 Alexander Graf
    }
42 10ec5117 Alexander Graf
43 10ec5117 Alexander Graf
    env->cpu_model_str = cpu_model;
44 10ec5117 Alexander Graf
    cpu_reset(env);
45 10ec5117 Alexander Graf
    qemu_init_vcpu(env);
46 10ec5117 Alexander Graf
    return env;
47 10ec5117 Alexander Graf
}
48 10ec5117 Alexander Graf
49 10ec5117 Alexander Graf
void cpu_reset(CPUS390XState *env)
50 10ec5117 Alexander Graf
{
51 10ec5117 Alexander Graf
    if (qemu_loglevel_mask(CPU_LOG_RESET)) {
52 10ec5117 Alexander Graf
        qemu_log("CPU Reset (CPU %d)\n", env->cpu_index);
53 10ec5117 Alexander Graf
        log_cpu_state(env, 0);
54 10ec5117 Alexander Graf
    }
55 10ec5117 Alexander Graf
56 10ec5117 Alexander Graf
    memset(env, 0, offsetof(CPUS390XState, breakpoints));
57 10ec5117 Alexander Graf
    /* FIXME: reset vector? */
58 10ec5117 Alexander Graf
    tlb_flush(env, 1);
59 10ec5117 Alexander Graf
}
60 10c339a0 Alexander Graf
61 c92114b1 Alexander Graf
target_phys_addr_t cpu_get_phys_page_debug(CPUState *env, target_ulong addr)
62 c92114b1 Alexander Graf
{
63 c92114b1 Alexander Graf
    return 0;
64 c92114b1 Alexander Graf
}
65 c92114b1 Alexander Graf
66 10c339a0 Alexander Graf
#ifndef CONFIG_USER_ONLY
67 10c339a0 Alexander Graf
68 10c339a0 Alexander Graf
int cpu_s390x_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
69 10c339a0 Alexander Graf
                                int mmu_idx, int is_softmmu)
70 10c339a0 Alexander Graf
{
71 10c339a0 Alexander Graf
    target_ulong phys;
72 10c339a0 Alexander Graf
    int prot;
73 10c339a0 Alexander Graf
74 10c339a0 Alexander Graf
    /* XXX: implement mmu */
75 10c339a0 Alexander Graf
76 10c339a0 Alexander Graf
    phys = address;
77 d4c430a8 Paul Brook
    prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
78 10c339a0 Alexander Graf
79 d4c430a8 Paul Brook
    tlb_set_page(env, address & TARGET_PAGE_MASK,
80 d4c430a8 Paul Brook
                 phys & TARGET_PAGE_MASK, prot,
81 d4c430a8 Paul Brook
                 mmu_idx, TARGET_PAGE_SIZE);
82 d4c430a8 Paul Brook
    return 0;
83 10c339a0 Alexander Graf
}
84 10c339a0 Alexander Graf
#endif /* CONFIG_USER_ONLY */