xref: /qemu/target/s390x/helper.c (revision 10c339a07d42fcccbccd3f8a5e9c94ccb51fe3e4)
110ec5117SAlexander Graf /*
210ec5117SAlexander Graf  *  S/390 helpers
310ec5117SAlexander Graf  *
410ec5117SAlexander Graf  *  Copyright (c) 2009 Ulrich Hecht
510ec5117SAlexander Graf  *
610ec5117SAlexander Graf  * This library is free software; you can redistribute it and/or
710ec5117SAlexander Graf  * modify it under the terms of the GNU Lesser General Public
810ec5117SAlexander Graf  * License as published by the Free Software Foundation; either
910ec5117SAlexander Graf  * version 2 of the License, or (at your option) any later version.
1010ec5117SAlexander Graf  *
1110ec5117SAlexander Graf  * This library is distributed in the hope that it will be useful,
1210ec5117SAlexander Graf  * but WITHOUT ANY WARRANTY; without even the implied warranty of
1310ec5117SAlexander Graf  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1410ec5117SAlexander Graf  * Lesser General Public License for more details.
1510ec5117SAlexander Graf  *
1610ec5117SAlexander Graf  * You should have received a copy of the GNU Lesser General Public
1710ec5117SAlexander Graf  * License along with this library; if not, write to the Free Software
1810ec5117SAlexander Graf  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA  02110-1301 USA
1910ec5117SAlexander Graf  */
2010ec5117SAlexander Graf 
2110ec5117SAlexander Graf #include <stdio.h>
2210ec5117SAlexander Graf #include <stdlib.h>
2310ec5117SAlexander Graf #include <string.h>
2410ec5117SAlexander Graf 
2510ec5117SAlexander Graf #include "cpu.h"
2610ec5117SAlexander Graf #include "exec-all.h"
2710ec5117SAlexander Graf #include "gdbstub.h"
2810ec5117SAlexander Graf #include "qemu-common.h"
2910ec5117SAlexander Graf 
3010c339a0SAlexander Graf #include <linux/kvm.h>
3110c339a0SAlexander Graf #include "kvm.h"
3210c339a0SAlexander Graf 
3310ec5117SAlexander Graf CPUS390XState *cpu_s390x_init(const char *cpu_model)
3410ec5117SAlexander Graf {
3510ec5117SAlexander Graf     CPUS390XState *env;
3610ec5117SAlexander Graf     static int inited = 0;
3710ec5117SAlexander Graf 
3810ec5117SAlexander Graf     env = qemu_mallocz(sizeof(CPUS390XState));
3910ec5117SAlexander Graf     cpu_exec_init(env);
4010ec5117SAlexander Graf     if (!inited) {
4110ec5117SAlexander Graf         inited = 1;
4210ec5117SAlexander Graf     }
4310ec5117SAlexander Graf 
4410ec5117SAlexander Graf     env->cpu_model_str = cpu_model;
4510ec5117SAlexander Graf     cpu_reset(env);
4610ec5117SAlexander Graf     qemu_init_vcpu(env);
4710ec5117SAlexander Graf     return env;
4810ec5117SAlexander Graf }
4910ec5117SAlexander Graf 
5010ec5117SAlexander Graf target_phys_addr_t cpu_get_phys_page_debug(CPUState *env, target_ulong addr)
5110ec5117SAlexander Graf {
5210ec5117SAlexander Graf     return addr;
5310ec5117SAlexander Graf }
5410ec5117SAlexander Graf 
5510ec5117SAlexander Graf void cpu_reset(CPUS390XState *env)
5610ec5117SAlexander Graf {
5710ec5117SAlexander Graf     if (qemu_loglevel_mask(CPU_LOG_RESET)) {
5810ec5117SAlexander Graf         qemu_log("CPU Reset (CPU %d)\n", env->cpu_index);
5910ec5117SAlexander Graf         log_cpu_state(env, 0);
6010ec5117SAlexander Graf     }
6110ec5117SAlexander Graf 
6210ec5117SAlexander Graf     memset(env, 0, offsetof(CPUS390XState, breakpoints));
6310ec5117SAlexander Graf     /* FIXME: reset vector? */
6410ec5117SAlexander Graf     tlb_flush(env, 1);
6510ec5117SAlexander Graf }
6610c339a0SAlexander Graf 
6710c339a0SAlexander Graf #ifndef CONFIG_USER_ONLY
6810c339a0SAlexander Graf 
6910c339a0SAlexander Graf int cpu_s390x_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
7010c339a0SAlexander Graf                                 int mmu_idx, int is_softmmu)
7110c339a0SAlexander Graf {
7210c339a0SAlexander Graf     target_ulong phys;
7310c339a0SAlexander Graf     int prot;
7410c339a0SAlexander Graf 
7510c339a0SAlexander Graf     /* XXX: implement mmu */
7610c339a0SAlexander Graf 
7710c339a0SAlexander Graf     phys = address;
7810c339a0SAlexander Graf     prot = PAGE_READ | PAGE_WRITE;
7910c339a0SAlexander Graf 
8010c339a0SAlexander Graf     return tlb_set_page(env, address & TARGET_PAGE_MASK,
8110c339a0SAlexander Graf                         phys & TARGET_PAGE_MASK, prot,
8210c339a0SAlexander Graf                         mmu_idx, is_softmmu);
8310c339a0SAlexander Graf }
8410c339a0SAlexander Graf #endif /* CONFIG_USER_ONLY */
85