2 * PPC emulation definitions for qemu.
4 * Copyright (c) 2003 Jocelyn Mayer
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.
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.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #if !defined (__PPC_H__)
23 #include "dyngen-exec.h"
25 register struct CPUPPCState *env asm(AREG0);
26 register uint32_t T0 asm(AREG1);
27 register uint32_t T1 asm(AREG2);
28 register uint32_t T2 asm(AREG3);
30 #define PARAM(n) ((uint32_t)PARAM##n)
31 #define SPARAM(n) ((int32_t)PARAM##n)
32 #define FT0 (env->ft0)
33 #define FT1 (env->ft1)
34 #define FT2 (env->ft2)
35 #define FTS0 ((float)env->ft0)
36 #define FTS1 ((float)env->ft1)
37 #define FTS2 ((float)env->ft2)
39 #define RETURN() __asm__ __volatile__("");
44 static inline uint8_t ld8 (uint32_t EA)
46 return *((uint8_t *)EA);
49 static inline uint16_t ld16 (uint32_t EA)
51 return __be16_to_cpu(*((uint16_t *)EA));
54 static inline uint16_t ld16r (uint32_t EA)
56 return __le16_to_cpu(*((uint16_t *)EA));
59 static inline uint32_t ld32 (uint32_t EA)
61 return __be32_to_cpu(*((uint32_t *)EA));
64 static inline uint32_t ld32r (uint32_t EA)
66 return __le32_to_cpu(*((uint32_t *)EA));
69 static inline uint64_t ld64 (uint32_t EA)
71 return __be64_to_cpu(*((uint64_t *)EA));
74 static inline uint64_t ld64r (uint32_t EA)
76 return __le64_to_cpu(*((uint64_t *)EA));
79 static inline void st8 (uint32_t EA, uint8_t data)
81 *((uint8_t *)EA) = data;
84 static inline void st16 (uint32_t EA, uint16_t data)
86 *((uint16_t *)EA) = __cpu_to_be16(data);
89 static inline void st16r (uint32_t EA, uint16_t data)
91 *((uint16_t *)EA) = __cpu_to_le16(data);
94 static inline void st32 (uint32_t EA, uint32_t data)
96 *((uint32_t *)EA) = __cpu_to_be32(data);
99 static inline void st32r (uint32_t EA, uint32_t data)
101 *((uint32_t *)EA) = __cpu_to_le32(data);
104 static inline void st64 (uint32_t EA, uint64_t data)
106 *((uint64_t *)EA) = __cpu_to_be64(data);
109 static inline void st64r (uint32_t EA, uint64_t data)
111 *((uint64_t *)EA) = __cpu_to_le64(data);
114 static inline void set_CRn(int n, uint8_t value)
119 static inline void set_carry (void)
124 static inline void reset_carry (void)
129 static inline void set_overflow (void)
135 static inline void reset_overflow (void)
140 static inline uint32_t rotl (uint32_t i, int n)
142 return ((i << n) | (i >> (32 - n)));
145 void raise_exception (int exception_index);
146 void raise_exception_err (int exception_index, int error_code);
148 uint32_t do_load_cr (void);
149 void do_store_cr (uint32_t crn, uint32_t value);
150 uint32_t do_load_xer (void);
151 void do_store_xer (uint32_t value);
152 uint32_t do_load_msr (void);
153 void do_store_msr (uint32_t msr_value);
154 void do_load_fpscr (void);
155 void do_store_fpscr (uint32_t mask);
157 int32_t do_sraw(int32_t Ta, uint32_t Tb);
158 void do_lmw (int reg, uint32_t src);
159 void do_stmw (int reg, uint32_t dest);
160 void do_lsw (uint32_t reg, int count, uint32_t src);
161 void do_stsw (uint32_t reg, int count, uint32_t dest);
166 #endif /* !defined (__PPC_H__) */