]>
Commit | Line | Data |
---|---|---|
901c4eaf BS |
1 | /* |
2 | * Miscellaneous PowerPC emulation helpers for QEMU. | |
3 | * | |
4 | * Copyright (c) 2003-2007 Jocelyn Mayer | |
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 | #include "cpu.h" | |
20 | #include "dyngen-exec.h" | |
21 | #include "helper.h" | |
22 | ||
23 | #include "helper_regs.h" | |
24 | ||
25 | /*****************************************************************************/ | |
26 | /* SPR accesses */ | |
27 | void helper_load_dump_spr(uint32_t sprn) | |
28 | { | |
29 | qemu_log("Read SPR %d %03x => " TARGET_FMT_lx "\n", sprn, sprn, | |
30 | env->spr[sprn]); | |
31 | } | |
32 | ||
33 | void helper_store_dump_spr(uint32_t sprn) | |
34 | { | |
35 | qemu_log("Write SPR %d %03x <= " TARGET_FMT_lx "\n", sprn, sprn, | |
36 | env->spr[sprn]); | |
37 | } | |
38 | #if !defined(CONFIG_USER_ONLY) | |
39 | #if defined(TARGET_PPC64) | |
40 | void helper_store_asr(target_ulong val) | |
41 | { | |
42 | ppc_store_asr(env, val); | |
43 | } | |
44 | #endif | |
45 | ||
46 | void helper_store_sdr1(target_ulong val) | |
47 | { | |
48 | ppc_store_sdr1(env, val); | |
49 | } | |
50 | ||
51 | void helper_store_hid0_601(target_ulong val) | |
52 | { | |
53 | target_ulong hid0; | |
54 | ||
55 | hid0 = env->spr[SPR_HID0]; | |
56 | if ((val ^ hid0) & 0x00000008) { | |
57 | /* Change current endianness */ | |
58 | env->hflags &= ~(1 << MSR_LE); | |
59 | env->hflags_nmsr &= ~(1 << MSR_LE); | |
60 | env->hflags_nmsr |= (1 << MSR_LE) & (((val >> 3) & 1) << MSR_LE); | |
61 | env->hflags |= env->hflags_nmsr; | |
62 | qemu_log("%s: set endianness to %c => " TARGET_FMT_lx "\n", __func__, | |
63 | val & 0x8 ? 'l' : 'b', env->hflags); | |
64 | } | |
65 | env->spr[SPR_HID0] = (uint32_t)val; | |
66 | } | |
67 | ||
68 | void helper_store_403_pbr(uint32_t num, target_ulong value) | |
69 | { | |
70 | if (likely(env->pb[num] != value)) { | |
71 | env->pb[num] = value; | |
72 | /* Should be optimized */ | |
73 | tlb_flush(env, 1); | |
74 | } | |
75 | } | |
76 | ||
77 | void helper_store_40x_dbcr0(target_ulong val) | |
78 | { | |
79 | store_40x_dbcr0(env, val); | |
80 | } | |
81 | ||
82 | void helper_store_40x_sler(target_ulong val) | |
83 | { | |
84 | store_40x_sler(env, val); | |
85 | } | |
86 | #endif | |
87 | /*****************************************************************************/ | |
88 | /* PowerPC 601 specific instructions (POWER bridge) */ | |
89 | ||
90 | target_ulong helper_clcs(uint32_t arg) | |
91 | { | |
92 | switch (arg) { | |
93 | case 0x0CUL: | |
94 | /* Instruction cache line size */ | |
95 | return env->icache_line_size; | |
96 | break; | |
97 | case 0x0DUL: | |
98 | /* Data cache line size */ | |
99 | return env->dcache_line_size; | |
100 | break; | |
101 | case 0x0EUL: | |
102 | /* Minimum cache line size */ | |
103 | return (env->icache_line_size < env->dcache_line_size) ? | |
104 | env->icache_line_size : env->dcache_line_size; | |
105 | break; | |
106 | case 0x0FUL: | |
107 | /* Maximum cache line size */ | |
108 | return (env->icache_line_size > env->dcache_line_size) ? | |
109 | env->icache_line_size : env->dcache_line_size; | |
110 | break; | |
111 | default: | |
112 | /* Undefined */ | |
113 | return 0; | |
114 | break; | |
115 | } | |
116 | } |