root / target-alpha / op_mem.h @ f36672ae
History | View | Annotate | Download (4.3 kB)
1 | 4c9649a9 | j_mayer | /*
|
---|---|---|---|
2 | 4c9649a9 | j_mayer | * Alpha emulation cpu micro-operations for memory accesses for qemu.
|
3 | 5fafdf24 | ths | *
|
4 | 4c9649a9 | j_mayer | * Copyright (c) 2007 Jocelyn Mayer
|
5 | 4c9649a9 | j_mayer | *
|
6 | 4c9649a9 | j_mayer | * This library is free software; you can redistribute it and/or
|
7 | 4c9649a9 | j_mayer | * modify it under the terms of the GNU Lesser General Public
|
8 | 4c9649a9 | j_mayer | * License as published by the Free Software Foundation; either
|
9 | 4c9649a9 | j_mayer | * version 2 of the License, or (at your option) any later version.
|
10 | 4c9649a9 | j_mayer | *
|
11 | 4c9649a9 | j_mayer | * This library is distributed in the hope that it will be useful,
|
12 | 4c9649a9 | j_mayer | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 4c9649a9 | j_mayer | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | 4c9649a9 | j_mayer | * Lesser General Public License for more details.
|
15 | 4c9649a9 | j_mayer | *
|
16 | 4c9649a9 | j_mayer | * You should have received a copy of the GNU Lesser General Public
|
17 | 4c9649a9 | j_mayer | * License along with this library; if not, write to the Free Software
|
18 | 4c9649a9 | j_mayer | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19 | 4c9649a9 | j_mayer | */
|
20 | 4c9649a9 | j_mayer | |
21 | 87518e0c | bellard | //#define DEBUG_MEM_ACCESSES
|
22 | 4c9649a9 | j_mayer | #if defined (DEBUG_MEM_ACCESSES)
|
23 | 4c9649a9 | j_mayer | void helper_print_mem_EA (target_ulong EA);
|
24 | 4c9649a9 | j_mayer | #define print_mem_EA(EA) do { helper_print_mem_EA(EA); } while (0) |
25 | 4c9649a9 | j_mayer | #else
|
26 | 4c9649a9 | j_mayer | #define print_mem_EA(EA) do { } while (0) |
27 | 4c9649a9 | j_mayer | #endif
|
28 | 4c9649a9 | j_mayer | |
29 | f071b4d3 | j_mayer | static always_inline uint32_t glue(ldl_l, MEMSUFFIX) (target_ulong EA)
|
30 | 4c9649a9 | j_mayer | { |
31 | 4c9649a9 | j_mayer | env->lock = EA; |
32 | 4c9649a9 | j_mayer | |
33 | 4c9649a9 | j_mayer | return glue(ldl, MEMSUFFIX)(EA);
|
34 | 4c9649a9 | j_mayer | } |
35 | 4c9649a9 | j_mayer | |
36 | f071b4d3 | j_mayer | static always_inline uint32_t glue(ldq_l, MEMSUFFIX) (target_ulong EA)
|
37 | 4c9649a9 | j_mayer | { |
38 | 4c9649a9 | j_mayer | env->lock = EA; |
39 | 4c9649a9 | j_mayer | |
40 | 4c9649a9 | j_mayer | return glue(ldq, MEMSUFFIX)(EA);
|
41 | 4c9649a9 | j_mayer | } |
42 | 4c9649a9 | j_mayer | |
43 | f071b4d3 | j_mayer | static always_inline void glue(stl_c, MEMSUFFIX) (target_ulong EA, |
44 | f071b4d3 | j_mayer | uint32_t data) |
45 | 4c9649a9 | j_mayer | { |
46 | 4c9649a9 | j_mayer | if (EA == env->lock) {
|
47 | 4c9649a9 | j_mayer | glue(stl, MEMSUFFIX)(EA, data); |
48 | 4c9649a9 | j_mayer | T0 = 0;
|
49 | 4c9649a9 | j_mayer | } else {
|
50 | 4c9649a9 | j_mayer | T0 = 1;
|
51 | 4c9649a9 | j_mayer | } |
52 | 4c9649a9 | j_mayer | env->lock = -1;
|
53 | 4c9649a9 | j_mayer | } |
54 | 4c9649a9 | j_mayer | |
55 | f071b4d3 | j_mayer | static always_inline void glue(stq_c, MEMSUFFIX) (target_ulong EA, |
56 | f071b4d3 | j_mayer | uint64_t data) |
57 | 4c9649a9 | j_mayer | { |
58 | 4c9649a9 | j_mayer | if (EA == env->lock) {
|
59 | 4c9649a9 | j_mayer | glue(stq, MEMSUFFIX)(EA, data); |
60 | 4c9649a9 | j_mayer | T0 = 0;
|
61 | 4c9649a9 | j_mayer | } else {
|
62 | 4c9649a9 | j_mayer | T0 = 1;
|
63 | 4c9649a9 | j_mayer | } |
64 | 4c9649a9 | j_mayer | env->lock = -1;
|
65 | 4c9649a9 | j_mayer | } |
66 | 4c9649a9 | j_mayer | |
67 | 4c9649a9 | j_mayer | #define ALPHA_LD_OP(name, op) \
|
68 | 4c9649a9 | j_mayer | void OPPROTO glue(glue(op_ld, name), MEMSUFFIX) (void) \ |
69 | 4c9649a9 | j_mayer | { \ |
70 | 4c9649a9 | j_mayer | print_mem_EA(T0); \ |
71 | 4c9649a9 | j_mayer | T1 = glue(op, MEMSUFFIX)(T0); \ |
72 | 4c9649a9 | j_mayer | RETURN(); \ |
73 | 4c9649a9 | j_mayer | } |
74 | 4c9649a9 | j_mayer | |
75 | 4c9649a9 | j_mayer | #define ALPHA_ST_OP(name, op) \
|
76 | 4c9649a9 | j_mayer | void OPPROTO glue(glue(op_st, name), MEMSUFFIX) (void) \ |
77 | 4c9649a9 | j_mayer | { \ |
78 | 4c9649a9 | j_mayer | print_mem_EA(T0); \ |
79 | 4c9649a9 | j_mayer | glue(op, MEMSUFFIX)(T0, T1); \ |
80 | 4c9649a9 | j_mayer | RETURN(); \ |
81 | 4c9649a9 | j_mayer | } |
82 | 4c9649a9 | j_mayer | |
83 | 4c9649a9 | j_mayer | ALPHA_LD_OP(bu, ldub); |
84 | 4c9649a9 | j_mayer | ALPHA_ST_OP(b, stb); |
85 | 4c9649a9 | j_mayer | ALPHA_LD_OP(wu, lduw); |
86 | 4c9649a9 | j_mayer | ALPHA_ST_OP(w, stw); |
87 | 4c9649a9 | j_mayer | ALPHA_LD_OP(l, ldl); |
88 | 4c9649a9 | j_mayer | ALPHA_ST_OP(l, stl); |
89 | 4c9649a9 | j_mayer | ALPHA_LD_OP(q, ldq); |
90 | 4c9649a9 | j_mayer | ALPHA_ST_OP(q, stq); |
91 | 4c9649a9 | j_mayer | |
92 | 4c9649a9 | j_mayer | ALPHA_LD_OP(q_u, ldq); |
93 | 4c9649a9 | j_mayer | ALPHA_ST_OP(q_u, stq); |
94 | 4c9649a9 | j_mayer | |
95 | 4c9649a9 | j_mayer | ALPHA_LD_OP(l_l, ldl_l); |
96 | 4c9649a9 | j_mayer | ALPHA_LD_OP(q_l, ldq_l); |
97 | 4c9649a9 | j_mayer | ALPHA_ST_OP(l_c, stl_c); |
98 | 4c9649a9 | j_mayer | ALPHA_ST_OP(q_c, stq_c); |
99 | 4c9649a9 | j_mayer | |
100 | 4c9649a9 | j_mayer | #define ALPHA_LDF_OP(name, op) \
|
101 | 4c9649a9 | j_mayer | void OPPROTO glue(glue(op_ld, name), MEMSUFFIX) (void) \ |
102 | 4c9649a9 | j_mayer | { \ |
103 | 4c9649a9 | j_mayer | print_mem_EA(T0); \ |
104 | 4c9649a9 | j_mayer | FT1 = glue(op, MEMSUFFIX)(T0); \ |
105 | 4c9649a9 | j_mayer | RETURN(); \ |
106 | 4c9649a9 | j_mayer | } |
107 | 4c9649a9 | j_mayer | |
108 | 4c9649a9 | j_mayer | #define ALPHA_STF_OP(name, op) \
|
109 | 4c9649a9 | j_mayer | void OPPROTO glue(glue(op_st, name), MEMSUFFIX) (void) \ |
110 | 4c9649a9 | j_mayer | { \ |
111 | 4c9649a9 | j_mayer | print_mem_EA(T0); \ |
112 | 4c9649a9 | j_mayer | glue(op, MEMSUFFIX)(T0, FT1); \ |
113 | 4c9649a9 | j_mayer | RETURN(); \ |
114 | 4c9649a9 | j_mayer | } |
115 | 4c9649a9 | j_mayer | |
116 | 4c9649a9 | j_mayer | ALPHA_LDF_OP(t, ldfq); |
117 | 4c9649a9 | j_mayer | ALPHA_STF_OP(t, stfq); |
118 | 4c9649a9 | j_mayer | ALPHA_LDF_OP(s, ldfl); |
119 | 4c9649a9 | j_mayer | ALPHA_STF_OP(s, stfl); |
120 | 4c9649a9 | j_mayer | |
121 | 4c9649a9 | j_mayer | /* VAX floating point */
|
122 | 4c9649a9 | j_mayer | ALPHA_LDF_OP(f, helper_ldff); |
123 | 4c9649a9 | j_mayer | ALPHA_STF_OP(f, helper_stff); |
124 | 4c9649a9 | j_mayer | ALPHA_LDF_OP(g, helper_ldfg); |
125 | 4c9649a9 | j_mayer | ALPHA_STF_OP(g, helper_stfg); |
126 | 4c9649a9 | j_mayer | |
127 | 4c9649a9 | j_mayer | #undef MEMSUFFIX |