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)
33 #define RETURN() __asm__ __volatile__("");
38 static inline uint8_t ld8 (uint32_t EA)
40 return *((uint8_t *)EA);
43 static inline uint16_t ld16 (uint32_t EA)
45 return __be16_to_cpu(*((uint16_t *)EA));
48 static inline uint16_t ld16r (uint32_t EA)
50 return __le16_to_cpu(*((uint16_t *)EA));
53 static inline uint32_t ld32 (uint32_t EA)
55 return __be32_to_cpu(*((uint32_t *)EA));
58 static inline uint32_t ld32r (uint32_t EA)
60 return __le32_to_cpu(*((uint32_t *)EA));
63 static inline uint64_t ld64 (uint32_t EA)
65 return __be64_to_cpu(*((uint64_t *)EA));
68 static inline uint64_t ld64r (uint32_t EA)
70 return __le64_to_cpu(*((uint64_t *)EA));
73 static inline void st8 (uint32_t EA, uint8_t data)
75 *((uint8_t *)EA) = data;
78 static inline void st16 (uint32_t EA, uint16_t data)
80 *((uint16_t *)EA) = __cpu_to_be16(data);
83 static inline void st16r (uint32_t EA, uint16_t data)
85 *((uint16_t *)EA) = __cpu_to_le16(data);
88 static inline void st32 (uint32_t EA, uint32_t data)
90 *((uint32_t *)EA) = __cpu_to_be32(data);
93 static inline void st32r (uint32_t EA, uint32_t data)
95 *((uint32_t *)EA) = __cpu_to_le32(data);
98 static inline void st64 (uint32_t EA, uint64_t data)
100 *((uint64_t *)EA) = __cpu_to_be64(data);
103 static inline void st64r (uint32_t EA, uint64_t data)
105 *((uint64_t *)EA) = __cpu_to_le64(data);
108 static inline void set_CRn(int n, uint8_t value)
113 static inline void set_carry (void)
118 static inline void reset_carry (void)
123 static inline void set_overflow (void)
129 static inline void reset_overflow (void)
134 static inline uint32_t rotl (uint32_t i, int n)
136 return ((i << n) | (i >> (32 - n)));
139 void raise_exception (int exception_index);
140 void raise_exception_err (int exception_index, int error_code);
142 uint32_t do_load_cr (void);
143 void do_store_cr (uint32_t crn, uint32_t value);
144 uint32_t do_load_xer (void);
145 void do_store_xer (uint32_t value);
146 uint32_t do_load_msr (void);
147 void do_store_msr (uint32_t msr_value);
148 uint32_t do_load_fpscr (void);
149 void do_store_fpscr (uint8_t mask, uint32_t fp);
151 int32_t do_sraw(int32_t Ta, uint32_t Tb);
152 void do_lmw (int reg, uint32_t src);
153 void do_stmw (int reg, uint32_t dest);
154 void do_lsw (uint32_t reg, int count, uint32_t src);
155 void do_stsw (uint32_t reg, int count, uint32_t dest);
157 #endif /* !defined (__PPC_H__) */