## root / target-ppc / exec.h @ 17348a7f

History | View | Annotate | Download (3.7 kB)

1 | 79aceca5 | bellard | ```
/*
``` |
---|---|---|---|

2 | 79aceca5 | bellard | ```
* PPC emulation definitions for qemu.
``` |

3 | 79aceca5 | bellard | ```
*
``` |

4 | 79aceca5 | bellard | ```
* Copyright (c) 2003 Jocelyn Mayer
``` |

5 | 79aceca5 | bellard | ```
*
``` |

6 | 79aceca5 | bellard | ```
* This library is free software; you can redistribute it and/or
``` |

7 | 79aceca5 | bellard | ```
* modify it under the terms of the GNU Lesser General Public
``` |

8 | 79aceca5 | bellard | ```
* License as published by the Free Software Foundation; either
``` |

9 | 79aceca5 | bellard | ```
* version 2 of the License, or (at your option) any later version.
``` |

10 | 79aceca5 | bellard | ```
*
``` |

11 | 79aceca5 | bellard | ```
* This library is distributed in the hope that it will be useful,
``` |

12 | 79aceca5 | bellard | ```
* but WITHOUT ANY WARRANTY; without even the implied warranty of
``` |

13 | 79aceca5 | bellard | ```
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
``` |

14 | 79aceca5 | bellard | ```
* Lesser General Public License for more details.
``` |

15 | 79aceca5 | bellard | ```
*
``` |

16 | 79aceca5 | bellard | ```
* You should have received a copy of the GNU Lesser General Public
``` |

17 | 79aceca5 | bellard | ```
* License along with this library; if not, write to the Free Software
``` |

18 | 79aceca5 | bellard | ```
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
``` |

19 | 79aceca5 | bellard | ```
*/
``` |

20 | 79aceca5 | bellard | ```
#if !defined (__PPC_H__)
``` |

21 | 79aceca5 | bellard | ```
#define __PPC_H__
``` |

22 | 79aceca5 | bellard | |

23 | 79aceca5 | bellard | #include "dyngen-exec.h" |

24 | 79aceca5 | bellard | |

25 | 79aceca5 | bellard | register struct CPUPPCState *env asm(AREG0); |

26 | 79aceca5 | bellard | register uint32_t T0 asm(AREG1); |

27 | 79aceca5 | bellard | register uint32_t T1 asm(AREG2); |

28 | 79aceca5 | bellard | register uint32_t T2 asm(AREG3); |

29 | 79aceca5 | bellard | |

30 | 79aceca5 | bellard | #define PARAM(n) ((uint32_t)PARAM##n) |

31 | 79aceca5 | bellard | #define SPARAM(n) ((int32_t)PARAM##n) |

32 | fb0eaffc | bellard | ```
#define FT0 (env->ft0)
``` |

33 | fb0eaffc | bellard | ```
#define FT1 (env->ft1)
``` |

34 | fb0eaffc | bellard | ```
#define FT2 (env->ft2)
``` |

35 | fb0eaffc | bellard | #define FTS0 ((float)env->ft0) |

36 | fb0eaffc | bellard | #define FTS1 ((float)env->ft1) |

37 | fb0eaffc | bellard | #define FTS2 ((float)env->ft2) |

38 | 79aceca5 | bellard | |

39 | 79aceca5 | bellard | #define RETURN() __asm__ __volatile__(""); |

40 | 79aceca5 | bellard | |

41 | 79aceca5 | bellard | #include "cpu.h" |

42 | 79aceca5 | bellard | #include "exec-all.h" |

43 | 79aceca5 | bellard | |

44 | 79aceca5 | bellard | static inline uint8_t ld8 (uint32_t EA) |

45 | 79aceca5 | bellard | { |

46 | 79aceca5 | bellard | ```
return *((uint8_t *)EA);
``` |

47 | 79aceca5 | bellard | } |

48 | 79aceca5 | bellard | |

49 | 79aceca5 | bellard | static inline uint16_t ld16 (uint32_t EA) |

50 | 79aceca5 | bellard | { |

51 | 79aceca5 | bellard | ```
return __be16_to_cpu(*((uint16_t *)EA));
``` |

52 | 79aceca5 | bellard | } |

53 | 79aceca5 | bellard | |

54 | 79aceca5 | bellard | static inline uint16_t ld16r (uint32_t EA) |

55 | 79aceca5 | bellard | { |

56 | 79aceca5 | bellard | ```
return __le16_to_cpu(*((uint16_t *)EA));
``` |

57 | 79aceca5 | bellard | } |

58 | 79aceca5 | bellard | |

59 | 79aceca5 | bellard | static inline uint32_t ld32 (uint32_t EA) |

60 | 79aceca5 | bellard | { |

61 | 79aceca5 | bellard | ```
return __be32_to_cpu(*((uint32_t *)EA));
``` |

62 | 79aceca5 | bellard | } |

63 | 79aceca5 | bellard | |

64 | 79aceca5 | bellard | static inline uint32_t ld32r (uint32_t EA) |

65 | 79aceca5 | bellard | { |

66 | 79aceca5 | bellard | ```
return __le32_to_cpu(*((uint32_t *)EA));
``` |

67 | 79aceca5 | bellard | } |

68 | 79aceca5 | bellard | |

69 | 79aceca5 | bellard | static inline uint64_t ld64 (uint32_t EA) |

70 | 79aceca5 | bellard | { |

71 | 79aceca5 | bellard | ```
return __be64_to_cpu(*((uint64_t *)EA));
``` |

72 | 79aceca5 | bellard | } |

73 | 79aceca5 | bellard | |

74 | 79aceca5 | bellard | static inline uint64_t ld64r (uint32_t EA) |

75 | 79aceca5 | bellard | { |

76 | 79aceca5 | bellard | ```
return __le64_to_cpu(*((uint64_t *)EA));
``` |

77 | 79aceca5 | bellard | } |

78 | 79aceca5 | bellard | |

79 | 79aceca5 | bellard | static inline void st8 (uint32_t EA, uint8_t data) |

80 | 79aceca5 | bellard | { |

81 | 79aceca5 | bellard | *((uint8_t *)EA) = data; |

82 | 79aceca5 | bellard | } |

83 | 79aceca5 | bellard | |

84 | 79aceca5 | bellard | static inline void st16 (uint32_t EA, uint16_t data) |

85 | 79aceca5 | bellard | { |

86 | 79aceca5 | bellard | *((uint16_t *)EA) = __cpu_to_be16(data); |

87 | 79aceca5 | bellard | } |

88 | 79aceca5 | bellard | |

89 | 79aceca5 | bellard | static inline void st16r (uint32_t EA, uint16_t data) |

90 | 79aceca5 | bellard | { |

91 | 79aceca5 | bellard | *((uint16_t *)EA) = __cpu_to_le16(data); |

92 | 79aceca5 | bellard | } |

93 | 79aceca5 | bellard | |

94 | 79aceca5 | bellard | static inline void st32 (uint32_t EA, uint32_t data) |

95 | 79aceca5 | bellard | { |

96 | 79aceca5 | bellard | *((uint32_t *)EA) = __cpu_to_be32(data); |

97 | 79aceca5 | bellard | } |

98 | 79aceca5 | bellard | |

99 | 79aceca5 | bellard | static inline void st32r (uint32_t EA, uint32_t data) |

100 | 79aceca5 | bellard | { |

101 | 79aceca5 | bellard | *((uint32_t *)EA) = __cpu_to_le32(data); |

102 | 79aceca5 | bellard | } |

103 | 79aceca5 | bellard | |

104 | 79aceca5 | bellard | static inline void st64 (uint32_t EA, uint64_t data) |

105 | 79aceca5 | bellard | { |

106 | 79aceca5 | bellard | *((uint64_t *)EA) = __cpu_to_be64(data); |

107 | 79aceca5 | bellard | } |

108 | 79aceca5 | bellard | |

109 | 79aceca5 | bellard | static inline void st64r (uint32_t EA, uint64_t data) |

110 | 79aceca5 | bellard | { |

111 | 79aceca5 | bellard | *((uint64_t *)EA) = __cpu_to_le64(data); |

112 | 79aceca5 | bellard | } |

113 | 79aceca5 | bellard | |

114 | 79aceca5 | bellard | static inline void set_CRn(int n, uint8_t value) |

115 | 79aceca5 | bellard | { |

116 | 79aceca5 | bellard | env->crf[n] = value; |

117 | 79aceca5 | bellard | } |

118 | 79aceca5 | bellard | |

119 | 79aceca5 | bellard | static inline void set_carry (void) |

120 | 79aceca5 | bellard | { |

121 | 79aceca5 | bellard | ```
xer_ca = 1;
``` |

122 | 79aceca5 | bellard | } |

123 | 79aceca5 | bellard | |

124 | 79aceca5 | bellard | static inline void reset_carry (void) |

125 | 79aceca5 | bellard | { |

126 | 79aceca5 | bellard | ```
xer_ca = 0;
``` |

127 | 79aceca5 | bellard | } |

128 | 79aceca5 | bellard | |

129 | 79aceca5 | bellard | static inline void set_overflow (void) |

130 | 79aceca5 | bellard | { |

131 | 79aceca5 | bellard | ```
xer_so = 1;
``` |

132 | 79aceca5 | bellard | ```
xer_ov = 1;
``` |

133 | 79aceca5 | bellard | } |

134 | 79aceca5 | bellard | |

135 | 79aceca5 | bellard | static inline void reset_overflow (void) |

136 | 79aceca5 | bellard | { |

137 | 79aceca5 | bellard | ```
xer_ov = 0;
``` |

138 | 79aceca5 | bellard | } |

139 | 79aceca5 | bellard | |

140 | 79aceca5 | bellard | static inline uint32_t rotl (uint32_t i, int n) |

141 | 79aceca5 | bellard | { |

142 | 79aceca5 | bellard | return ((i << n) | (i >> (32 - n))); |

143 | 79aceca5 | bellard | } |

144 | 79aceca5 | bellard | |

145 | 79aceca5 | bellard | void raise_exception (int exception_index); |

146 | 79aceca5 | bellard | void raise_exception_err (int exception_index, int error_code); |

147 | 79aceca5 | bellard | |

148 | 79aceca5 | bellard | ```
uint32_t do_load_cr (void);
``` |

149 | 79aceca5 | bellard | ```
void do_store_cr (uint32_t crn, uint32_t value);
``` |

150 | 79aceca5 | bellard | ```
uint32_t do_load_xer (void);
``` |

151 | 79aceca5 | bellard | ```
void do_store_xer (uint32_t value);
``` |

152 | 79aceca5 | bellard | ```
uint32_t do_load_msr (void);
``` |

153 | 79aceca5 | bellard | ```
void do_store_msr (uint32_t msr_value);
``` |

154 | fb0eaffc | bellard | void do_load_fpscr (void); |

155 | fb0eaffc | bellard | ```
void do_store_fpscr (uint32_t mask);
``` |

156 | 79aceca5 | bellard | |

157 | 79aceca5 | bellard | int32_t do_sraw(int32_t Ta, uint32_t Tb); |

158 | 79aceca5 | bellard | void do_lmw (int reg, uint32_t src); |

159 | 79aceca5 | bellard | void do_stmw (int reg, uint32_t dest); |

160 | 79aceca5 | bellard | void do_lsw (uint32_t reg, int count, uint32_t src); |

161 | 79aceca5 | bellard | void do_stsw (uint32_t reg, int count, uint32_t dest); |

162 | 79aceca5 | bellard | |

163 | fb0eaffc | bellard | void do_dcbz (void); |

164 | fb0eaffc | bellard | void do_icbi (void); |

165 | fb0eaffc | bellard | |

166 | 79aceca5 | bellard | #endif /* !defined (__PPC_H__) */ |