]> git.proxmox.com Git - mirror_qemu.git/blame - target/hppa/helper.c
target/hppa: Skeleton support for hppa-softmmu
[mirror_qemu.git] / target / hppa / helper.c
CommitLineData
61766fe9
RH
1/*
2 * HPPA emulation cpu helpers for qemu.
3 *
4 * Copyright (c) 2016 Richard Henderson <rth@twiddle.net>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "qemu/osdep.h"
21
22#include "cpu.h"
23#include "exec/exec-all.h"
24#include "fpu/softfloat.h"
25#include "exec/helper-proto.h"
26
27target_ulong cpu_hppa_get_psw(CPUHPPAState *env)
28{
29 target_ulong psw;
30
31 /* Fold carry bits down to 8 consecutive bits. */
32 /* ??? Needs tweaking for hppa64. */
33 /* .......b...c...d...e...f...g...h */
34 psw = (env->psw_cb >> 4) & 0x01111111;
35 /* .......b..bc..cd..de..ef..fg..gh */
36 psw |= psw >> 3;
37 /* .............bcd............efgh */
38 psw |= (psw >> 6) & 0x000f000f;
39 /* .........................bcdefgh */
40 psw |= (psw >> 12) & 0xf;
41 psw |= env->psw_cb_msb << 7;
42 psw <<= 8;
43
44 psw |= env->psw_n << 21;
45 psw |= (env->psw_v < 0) << 17;
46
47 return psw;
48}
49
50void cpu_hppa_put_psw(CPUHPPAState *env, target_ulong psw)
51{
52 target_ulong cb = 0;
53
54 env->psw_n = (psw >> 21) & 1;
55 env->psw_v = -((psw >> 17) & 1);
56 env->psw_cb_msb = (psw >> 15) & 1;
57
58 cb |= ((psw >> 14) & 1) << 28;
59 cb |= ((psw >> 13) & 1) << 24;
60 cb |= ((psw >> 12) & 1) << 20;
61 cb |= ((psw >> 11) & 1) << 16;
62 cb |= ((psw >> 10) & 1) << 12;
63 cb |= ((psw >> 9) & 1) << 8;
64 cb |= ((psw >> 8) & 1) << 4;
65 env->psw_cb = cb;
66}
67
61766fe9
RH
68void hppa_cpu_do_interrupt(CPUState *cs)
69{
70 HPPACPU *cpu = HPPA_CPU(cs);
71 CPUHPPAState *env = &cpu->env;
72 int i = cs->exception_index;
73
74 if (qemu_loglevel_mask(CPU_LOG_INT)) {
75 static int count;
76 const char *name = "<unknown>";
77
78 switch (i) {
79 case EXCP_SYSCALL:
80 name = "syscall";
81 break;
82 case EXCP_SIGSEGV:
83 name = "sigsegv";
84 break;
85 case EXCP_SIGILL:
86 name = "sigill";
87 break;
88 case EXCP_SIGFPE:
89 name = "sigfpe";
90 break;
91 }
92 qemu_log("INT %6d: %s ia_f=" TARGET_FMT_lx "\n",
93 ++count, name, env->iaoq_f);
94 }
95 cs->exception_index = -1;
96}
97
98bool hppa_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
99{
100 abort();
101 return false;
102}
103
104void hppa_cpu_dump_state(CPUState *cs, FILE *f,
105 fprintf_function cpu_fprintf, int flags)
106{
107 HPPACPU *cpu = HPPA_CPU(cs);
108 CPUHPPAState *env = &cpu->env;
109 int i;
110
111 cpu_fprintf(f, "IA_F " TARGET_FMT_lx
112 " IA_B " TARGET_FMT_lx
113 " PSW " TARGET_FMT_lx
114 " [N:" TARGET_FMT_ld " V:%d"
115 " CB:" TARGET_FMT_lx "]\n ",
116 env->iaoq_f, env->iaoq_b, cpu_hppa_get_psw(env),
117 env->psw_n, env->psw_v < 0,
118 ((env->psw_cb >> 4) & 0x01111111) | (env->psw_cb_msb << 28));
119 for (i = 1; i < 32; i++) {
120 cpu_fprintf(f, "GR%02d " TARGET_FMT_lx " ", i, env->gr[i]);
121 if ((i % 4) == 3) {
122 cpu_fprintf(f, "\n");
123 }
124 }
125
126 /* ??? FR */
127}