root / darwin-user / commpage.c @ 44e4c0ba
History | View | Annotate | Download (12.8 kB)
1 | 831b7825 | ths | /*
|
---|---|---|---|
2 | 831b7825 | ths | * Commpage syscalls
|
3 | 831b7825 | ths | *
|
4 | 831b7825 | ths | * Copyright (c) 2006 Pierre d'Herbemont
|
5 | 831b7825 | ths | *
|
6 | 831b7825 | ths | * This program is free software; you can redistribute it and/or modify
|
7 | 831b7825 | ths | * it under the terms of the GNU General Public License as published by
|
8 | 831b7825 | ths | * the Free Software Foundation; either version 2 of the License, or
|
9 | 831b7825 | ths | * (at your option) any later version.
|
10 | 831b7825 | ths | *
|
11 | 831b7825 | ths | * This program is distributed in the hope that it will be useful,
|
12 | 831b7825 | ths | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 831b7825 | ths | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 | 831b7825 | ths | * GNU General Public License for more details.
|
15 | 831b7825 | ths | *
|
16 | 831b7825 | ths | * You should have received a copy of the GNU General Public License
|
17 | 8167ee88 | Blue Swirl | * along with this program; if not, see <http://www.gnu.org/licenses/>.
|
18 | 831b7825 | ths | */
|
19 | 831b7825 | ths | #include <fcntl.h> |
20 | 831b7825 | ths | #include <stdio.h> |
21 | 831b7825 | ths | #include <stdlib.h> |
22 | 831b7825 | ths | #include <errno.h> |
23 | 831b7825 | ths | |
24 | 831b7825 | ths | #include <mach/message.h> |
25 | 831b7825 | ths | #include <mach/mach.h> |
26 | 831b7825 | ths | #include <mach/mach_time.h> |
27 | 831b7825 | ths | #include <sys/time.h> |
28 | 831b7825 | ths | #include <sys/mman.h> |
29 | 831b7825 | ths | #include <libkern/OSAtomic.h> |
30 | 831b7825 | ths | |
31 | 831b7825 | ths | #include "qemu.h" |
32 | 831b7825 | ths | |
33 | 831b7825 | ths | //#define DEBUG_COMMPAGE
|
34 | 831b7825 | ths | |
35 | 831b7825 | ths | #ifdef DEBUG_COMMPAGE
|
36 | 93fcfe39 | aliguori | # define DPRINTF(...) do { qemu_log(__VA_ARGS__); printf(__VA_ARGS__); } while(0) |
37 | 831b7825 | ths | #else
|
38 | 93fcfe39 | aliguori | # define DPRINTF(...) do { qemu_log(__VA_ARGS__); } while(0) |
39 | 831b7825 | ths | #endif
|
40 | 831b7825 | ths | |
41 | 831b7825 | ths | /********************************************************************
|
42 | 831b7825 | ths | * Commpage definitions
|
43 | 831b7825 | ths | */
|
44 | 831b7825 | ths | #ifdef TARGET_I386
|
45 | 831b7825 | ths | /* Reserve space for the commpage see xnu/osfmk/i386/cpu_capabilities.h */
|
46 | 831b7825 | ths | # define COMMPAGE_START (-16 * 4096) /* base address is -20 * 4096 */ |
47 | 831b7825 | ths | # define COMMPAGE_SIZE (0x1240) /* _COMM_PAGE_AREA_LENGTH is 19 * 4096 */ |
48 | 831b7825 | ths | #elif defined(TARGET_PPC)
|
49 | 831b7825 | ths | /* Reserve space for the commpage see xnu/osfmk/ppc/cpu_capabilities.h */
|
50 | 831b7825 | ths | # define COMMPAGE_START (-8*4096) |
51 | 831b7825 | ths | # define COMMPAGE_SIZE (2*4096) /* its _COMM_PAGE_AREA_USED but _COMM_PAGE_AREA_LENGTH is 7*4096 */ |
52 | 831b7825 | ths | #endif
|
53 | 831b7825 | ths | |
54 | 831b7825 | ths | void do_compare_and_swap32(void *cpu_env, int num); |
55 | 831b7825 | ths | void do_compare_and_swap64(void *cpu_env, int num); |
56 | 831b7825 | ths | void do_add_atomic_word32(void *cpu_env, int num); |
57 | 831b7825 | ths | void do_cgettimeofday(void *cpu_env, int num, uint32_t arg1); |
58 | 831b7825 | ths | void do_nanotime(void *cpu_env, int num); |
59 | 831b7825 | ths | |
60 | 831b7825 | ths | void unimpl_commpage(void *cpu_env, int num); |
61 | 831b7825 | ths | |
62 | 831b7825 | ths | typedef void (*commpage_8args_function_t)(uint32_t arg1, uint32_t arg2, uint32_t arg3, |
63 | 831b7825 | ths | uint32_t arg4, uint32_t arg5, uint32_t arg6, uint32_t arg7, |
64 | 831b7825 | ths | uint32_t arg8); |
65 | 831b7825 | ths | typedef void (*commpage_indirect_function_t)(void *cpu_env, int num, uint32_t arg1, |
66 | 831b7825 | ths | uint32_t arg2, uint32_t arg3, uint32_t arg4, uint32_t arg5, |
67 | 831b7825 | ths | uint32_t arg6, uint32_t arg7, uint32_t arg8); |
68 | 831b7825 | ths | |
69 | 831b7825 | ths | #define HAS_PTR 0x10 |
70 | 831b7825 | ths | #define NO_PTR 0x20 |
71 | 831b7825 | ths | #define CALL_DIRECT 0x1 |
72 | 831b7825 | ths | #define CALL_INDIRECT 0x2 |
73 | 831b7825 | ths | |
74 | 831b7825 | ths | #define COMMPAGE_ENTRY(name, nargs, offset, func, options) \
|
75 | 831b7825 | ths | { #name, offset, nargs, options, (commpage_8args_function_t)func }
|
76 | 831b7825 | ths | |
77 | 831b7825 | ths | struct commpage_entry {
|
78 | 831b7825 | ths | char * name;
|
79 | 831b7825 | ths | int offset;
|
80 | 831b7825 | ths | int nargs;
|
81 | 831b7825 | ths | char options;
|
82 | 831b7825 | ths | commpage_8args_function_t function; |
83 | 831b7825 | ths | }; |
84 | 831b7825 | ths | |
85 | 831b7825 | ths | static inline int commpage_code_num(struct commpage_entry *entry) |
86 | 831b7825 | ths | { |
87 | 831b7825 | ths | if((entry->options & HAS_PTR))
|
88 | 831b7825 | ths | return entry->offset + 4; |
89 | 831b7825 | ths | else
|
90 | 831b7825 | ths | return entry->offset;
|
91 | 831b7825 | ths | } |
92 | 831b7825 | ths | |
93 | 831b7825 | ths | static inline int commpage_is_indirect(struct commpage_entry *entry) |
94 | 831b7825 | ths | { |
95 | 831b7825 | ths | return !(entry->options & CALL_DIRECT);
|
96 | 831b7825 | ths | } |
97 | 831b7825 | ths | |
98 | 831b7825 | ths | /********************************************************************
|
99 | 831b7825 | ths | * Commpage entry
|
100 | 831b7825 | ths | */
|
101 | 831b7825 | ths | static struct commpage_entry commpage_entries[] = |
102 | 831b7825 | ths | { |
103 | 831b7825 | ths | COMMPAGE_ENTRY(compare_and_swap32, 0, 0x080, do_compare_and_swap32, CALL_INDIRECT | HAS_PTR), |
104 | 831b7825 | ths | COMMPAGE_ENTRY(compare_and_swap64, 0, 0x0c0, do_compare_and_swap64, CALL_INDIRECT | HAS_PTR), |
105 | 831b7825 | ths | COMMPAGE_ENTRY(enqueue, 0, 0x100, unimpl_commpage, CALL_INDIRECT), |
106 | 831b7825 | ths | COMMPAGE_ENTRY(dequeue, 0, 0x140, unimpl_commpage, CALL_INDIRECT), |
107 | 831b7825 | ths | COMMPAGE_ENTRY(memory_barrier, 0, 0x180, unimpl_commpage, CALL_INDIRECT), |
108 | 831b7825 | ths | COMMPAGE_ENTRY(add_atomic_word32, 0, 0x1a0, do_add_atomic_word32, CALL_INDIRECT | HAS_PTR), |
109 | 831b7825 | ths | COMMPAGE_ENTRY(add_atomic_word64, 0, 0x1c0, unimpl_commpage, CALL_INDIRECT | HAS_PTR), |
110 | 831b7825 | ths | |
111 | 831b7825 | ths | COMMPAGE_ENTRY(mach_absolute_time, 0, 0x200, unimpl_commpage, CALL_INDIRECT), |
112 | c227f099 | Anthony Liguori | COMMPAGE_ENTRY(spinlock_try, 1, 0x220, unimpl_commpage, CALL_INDIRECT), |
113 | 831b7825 | ths | COMMPAGE_ENTRY(spinlock_lock, 1, 0x260, OSSpinLockLock, CALL_DIRECT), |
114 | 831b7825 | ths | COMMPAGE_ENTRY(spinlock_unlock, 1, 0x2a0, OSSpinLockUnlock, CALL_DIRECT), |
115 | 831b7825 | ths | COMMPAGE_ENTRY(pthread_getspecific, 0, 0x2c0, unimpl_commpage, CALL_INDIRECT), |
116 | 2a252826 | bellard | COMMPAGE_ENTRY(gettimeofday, 1, 0x2e0, do_cgettimeofday, CALL_INDIRECT), |
117 | 2a252826 | bellard | COMMPAGE_ENTRY(sys_dcache_flush, 0, 0x4e0, unimpl_commpage, CALL_INDIRECT), |
118 | 2a252826 | bellard | COMMPAGE_ENTRY(sys_icache_invalidate, 0, 0x520, unimpl_commpage, CALL_INDIRECT), |
119 | 2a252826 | bellard | COMMPAGE_ENTRY(pthread_self, 0, 0x580, unimpl_commpage, CALL_INDIRECT), |
120 | 831b7825 | ths | |
121 | 831b7825 | ths | COMMPAGE_ENTRY(relinquish, 0, 0x5c0, unimpl_commpage, CALL_INDIRECT), |
122 | 831b7825 | ths | |
123 | 831b7825 | ths | #ifdef TARGET_I386
|
124 | 831b7825 | ths | COMMPAGE_ENTRY(bts, 0, 0x5e0, unimpl_commpage, CALL_INDIRECT), |
125 | 831b7825 | ths | COMMPAGE_ENTRY(btc, 0, 0x5f0, unimpl_commpage, CALL_INDIRECT), |
126 | 831b7825 | ths | #endif
|
127 | 831b7825 | ths | |
128 | 831b7825 | ths | COMMPAGE_ENTRY(bzero, 2, 0x600, bzero, CALL_DIRECT), |
129 | 831b7825 | ths | COMMPAGE_ENTRY(bcopy, 3, 0x780, bcopy, CALL_DIRECT), |
130 | 831b7825 | ths | COMMPAGE_ENTRY(memcpy, 3, 0x7a0, memcpy, CALL_DIRECT), |
131 | 831b7825 | ths | |
132 | 831b7825 | ths | #ifdef TARGET_I386
|
133 | 831b7825 | ths | COMMPAGE_ENTRY(old_nanotime, 0, 0xf80, do_nanotime, CALL_INDIRECT), |
134 | 831b7825 | ths | COMMPAGE_ENTRY(memset_pattern, 0, 0xf80, unimpl_commpage, CALL_INDIRECT), |
135 | 831b7825 | ths | COMMPAGE_ENTRY(long_copy, 0, 0x1200, unimpl_commpage, CALL_INDIRECT), |
136 | 831b7825 | ths | |
137 | 831b7825 | ths | COMMPAGE_ENTRY(sysintegrity, 0, 0x1600, unimpl_commpage, CALL_INDIRECT), |
138 | 831b7825 | ths | |
139 | 831b7825 | ths | COMMPAGE_ENTRY(nanotime, 0, 0x1700, do_nanotime, CALL_INDIRECT), |
140 | 831b7825 | ths | #elif TARGET_PPC
|
141 | 831b7825 | ths | COMMPAGE_ENTRY(compare_and_swap32b, 0, 0xf80, unimpl_commpage, CALL_INDIRECT), |
142 | 831b7825 | ths | COMMPAGE_ENTRY(compare_and_swap64b, 0, 0xfc0, unimpl_commpage, CALL_INDIRECT), |
143 | 831b7825 | ths | COMMPAGE_ENTRY(memset_pattern, 0, 0x1000, unimpl_commpage, CALL_INDIRECT), |
144 | 831b7825 | ths | COMMPAGE_ENTRY(bigcopy, 0, 0x1140, unimpl_commpage, CALL_INDIRECT), |
145 | 831b7825 | ths | #endif
|
146 | 831b7825 | ths | }; |
147 | 831b7825 | ths | |
148 | 831b7825 | ths | |
149 | 831b7825 | ths | /********************************************************************
|
150 | 831b7825 | ths | * Commpage backdoor
|
151 | 831b7825 | ths | */
|
152 | 831b7825 | ths | static inline void print_commpage_entry(struct commpage_entry entry) |
153 | 831b7825 | ths | { |
154 | 831b7825 | ths | printf("@0x%x %s\n", entry.offset, entry.name);
|
155 | 831b7825 | ths | } |
156 | 831b7825 | ths | |
157 | 831b7825 | ths | static inline void install_commpage_backdoor_for_entry(struct commpage_entry entry) |
158 | 831b7825 | ths | { |
159 | 831b7825 | ths | #ifdef TARGET_I386
|
160 | 831b7825 | ths | char * commpage = (char*)(COMMPAGE_START+entry.offset); |
161 | 831b7825 | ths | int c = 0; |
162 | 831b7825 | ths | if(entry.options & HAS_PTR)
|
163 | 831b7825 | ths | { |
164 | 831b7825 | ths | commpage[c++] = (COMMPAGE_START+entry.offset+4) & 0xff; |
165 | 831b7825 | ths | commpage[c++] = ((COMMPAGE_START+entry.offset+4) >> 8) & 0xff; |
166 | 831b7825 | ths | commpage[c++] = ((COMMPAGE_START+entry.offset+4) >> 16) & 0xff; |
167 | 831b7825 | ths | commpage[c++] = ((COMMPAGE_START+entry.offset+4) >> 24) & 0xff; |
168 | 831b7825 | ths | } |
169 | 831b7825 | ths | commpage[c++] = 0xcd;
|
170 | 831b7825 | ths | commpage[c++] = 0x79; /* int 0x79 */ |
171 | 831b7825 | ths | commpage[c++] = 0xc3; /* ret */ |
172 | 831b7825 | ths | #else
|
173 | 831b7825 | ths | qerror("can't install the commpage on this arch\n");
|
174 | 831b7825 | ths | #endif
|
175 | 831b7825 | ths | } |
176 | 831b7825 | ths | |
177 | 831b7825 | ths | /********************************************************************
|
178 | 831b7825 | ths | * Commpage initialization
|
179 | 831b7825 | ths | */
|
180 | 831b7825 | ths | void commpage_init(void) |
181 | 831b7825 | ths | { |
182 | e58ffeb3 | malc | #if (defined(__i386__) ^ defined(TARGET_I386)) || (defined(_ARCH_PPC) ^ defined(TARGET_PPC))
|
183 | 831b7825 | ths | int i;
|
184 | 831b7825 | ths | void * commpage = (void *)target_mmap( COMMPAGE_START, COMMPAGE_SIZE, |
185 | 831b7825 | ths | PROT_WRITE | PROT_READ, MAP_ANONYMOUS | MAP_FIXED, -1, 0); |
186 | 831b7825 | ths | if((int)commpage != COMMPAGE_START) |
187 | 831b7825 | ths | qerror("can't allocate the commpage\n");
|
188 | 831b7825 | ths | |
189 | 831b7825 | ths | bzero(commpage, COMMPAGE_SIZE); |
190 | 831b7825 | ths | |
191 | 831b7825 | ths | /* XXX: commpage data not handled */
|
192 | 831b7825 | ths | |
193 | b1503cda | malc | for(i = 0; i < ARRAY_SIZE(commpage_entries); i++) |
194 | 831b7825 | ths | install_commpage_backdoor_for_entry(commpage_entries[i]); |
195 | 831b7825 | ths | #else
|
196 | 831b7825 | ths | /* simply map our pages so they can be executed
|
197 | 831b7825 | ths | XXX: we don't really want to do that since in the ppc on ppc situation we may
|
198 | 831b7825 | ths | not able to run commpages host optimized instructions (like G5's on a G5),
|
199 | 831b7825 | ths | hence this is sometimes a broken fix. */
|
200 | 831b7825 | ths | page_set_flags(COMMPAGE_START, COMMPAGE_START+COMMPAGE_SIZE, PROT_EXEC | PROT_READ | PAGE_VALID); |
201 | 831b7825 | ths | #endif
|
202 | 831b7825 | ths | } |
203 | 831b7825 | ths | |
204 | 831b7825 | ths | /********************************************************************
|
205 | 831b7825 | ths | * Commpage implementation
|
206 | 831b7825 | ths | */
|
207 | 831b7825 | ths | void do_compare_and_swap32(void *cpu_env, int num) |
208 | 831b7825 | ths | { |
209 | 831b7825 | ths | #ifdef TARGET_I386
|
210 | 831b7825 | ths | uint32_t old = ((CPUX86State*)cpu_env)->regs[R_EAX]; |
211 | 831b7825 | ths | uint32_t *value = (uint32_t*)((CPUX86State*)cpu_env)->regs[R_ECX]; |
212 | 831b7825 | ths | DPRINTF("commpage: compare_and_swap32(%x,new,%p)\n", old, value);
|
213 | 831b7825 | ths | |
214 | 831b7825 | ths | if(value && old == tswap32(*value))
|
215 | 831b7825 | ths | { |
216 | 831b7825 | ths | uint32_t new = ((CPUX86State*)cpu_env)->regs[R_EDX]; |
217 | 831b7825 | ths | *value = tswap32(new); |
218 | 831b7825 | ths | /* set zf flag */
|
219 | 831b7825 | ths | ((CPUX86State*)cpu_env)->eflags |= 0x40;
|
220 | 831b7825 | ths | } |
221 | 831b7825 | ths | else
|
222 | 831b7825 | ths | { |
223 | 831b7825 | ths | ((CPUX86State*)cpu_env)->regs[R_EAX] = tswap32(*value); |
224 | 831b7825 | ths | /* unset zf flag */
|
225 | 831b7825 | ths | ((CPUX86State*)cpu_env)->eflags &= ~0x40;
|
226 | 831b7825 | ths | } |
227 | 831b7825 | ths | #else
|
228 | 831b7825 | ths | qerror("do_compare_and_swap32 unimplemented");
|
229 | 831b7825 | ths | #endif
|
230 | 831b7825 | ths | } |
231 | 831b7825 | ths | |
232 | 831b7825 | ths | void do_compare_and_swap64(void *cpu_env, int num) |
233 | 831b7825 | ths | { |
234 | 831b7825 | ths | #ifdef TARGET_I386
|
235 | 831b7825 | ths | /* OSAtomicCompareAndSwap64 is not available on non 64 bits ppc, here is a raw implementation */
|
236 | 831b7825 | ths | uint64_t old, new, swapped_val; |
237 | 831b7825 | ths | uint64_t *value = (uint64_t*)((CPUX86State*)cpu_env)->regs[R_ESI]; |
238 | 831b7825 | ths | old = (uint64_t)((uint64_t)((CPUX86State*)cpu_env)->regs[R_EDX]) << 32 | (uint64_t)((CPUX86State*)cpu_env)->regs[R_EAX];
|
239 | 831b7825 | ths | |
240 | 831b7825 | ths | DPRINTF("commpage: compare_and_swap64(%llx,new,%p)\n", old, value);
|
241 | 831b7825 | ths | swapped_val = tswap64(*value); |
242 | 831b7825 | ths | |
243 | 831b7825 | ths | if(old == swapped_val)
|
244 | 831b7825 | ths | { |
245 | 831b7825 | ths | new = (uint64_t)((uint64_t)((CPUX86State*)cpu_env)->regs[R_ECX]) << 32 | (uint64_t)((CPUX86State*)cpu_env)->regs[R_EBX];
|
246 | 831b7825 | ths | *value = tswap64(new); |
247 | 831b7825 | ths | /* set zf flag */
|
248 | 831b7825 | ths | ((CPUX86State*)cpu_env)->eflags |= 0x40;
|
249 | 831b7825 | ths | } |
250 | 831b7825 | ths | else
|
251 | 831b7825 | ths | { |
252 | 831b7825 | ths | ((CPUX86State*)cpu_env)->regs[R_EAX] = (uint32_t)(swapped_val); |
253 | 831b7825 | ths | ((CPUX86State*)cpu_env)->regs[R_EDX] = (uint32_t)(swapped_val >> 32);
|
254 | 831b7825 | ths | /* unset zf flag */
|
255 | 831b7825 | ths | ((CPUX86State*)cpu_env)->eflags &= ~0x40;
|
256 | 831b7825 | ths | } |
257 | 831b7825 | ths | #else
|
258 | 831b7825 | ths | qerror("do_compare_and_swap64 unimplemented");
|
259 | 831b7825 | ths | #endif
|
260 | 831b7825 | ths | } |
261 | 831b7825 | ths | |
262 | 831b7825 | ths | void do_add_atomic_word32(void *cpu_env, int num) |
263 | 831b7825 | ths | { |
264 | 831b7825 | ths | #ifdef TARGET_I386
|
265 | 831b7825 | ths | uint32_t amt = ((CPUX86State*)cpu_env)->regs[R_EAX]; |
266 | 831b7825 | ths | uint32_t *value = (uint32_t*)((CPUX86State*)cpu_env)->regs[R_EDX]; |
267 | 831b7825 | ths | uint32_t swapped_value = tswap32(*value); |
268 | 831b7825 | ths | |
269 | 831b7825 | ths | DPRINTF("commpage: add_atomic_word32(%x,%p)\n", amt, value);
|
270 | 831b7825 | ths | |
271 | 831b7825 | ths | /* old value in EAX */
|
272 | 831b7825 | ths | ((CPUX86State*)cpu_env)->regs[R_EAX] = swapped_value; |
273 | 831b7825 | ths | *value = tswap32(swapped_value + amt); |
274 | 831b7825 | ths | #else
|
275 | 831b7825 | ths | qerror("do_add_atomic_word32 unimplemented");
|
276 | 831b7825 | ths | #endif
|
277 | 831b7825 | ths | } |
278 | 831b7825 | ths | |
279 | 831b7825 | ths | void do_cgettimeofday(void *cpu_env, int num, uint32_t arg1) |
280 | 831b7825 | ths | { |
281 | 831b7825 | ths | #ifdef TARGET_I386
|
282 | 831b7825 | ths | extern int __commpage_gettimeofday(struct timeval *); |
283 | 831b7825 | ths | DPRINTF("commpage: gettimeofday(0x%x)\n", arg1);
|
284 | 831b7825 | ths | struct timeval *time = (struct timeval *)arg1; |
285 | 831b7825 | ths | int ret = __commpage_gettimeofday(time);
|
286 | 831b7825 | ths | tswap32s((uint32_t*)&time->tv_sec); |
287 | 831b7825 | ths | tswap32s((uint32_t*)&time->tv_usec); |
288 | 831b7825 | ths | ((CPUX86State*)cpu_env)->regs[R_EAX] = ret; /* Success */
|
289 | 831b7825 | ths | #else
|
290 | 831b7825 | ths | qerror("do_gettimeofday unimplemented");
|
291 | 831b7825 | ths | #endif
|
292 | 831b7825 | ths | } |
293 | 831b7825 | ths | |
294 | 831b7825 | ths | void do_nanotime(void *cpu_env, int num) |
295 | 831b7825 | ths | { |
296 | 831b7825 | ths | #ifdef TARGET_I386
|
297 | 831b7825 | ths | uint64_t t = mach_absolute_time(); |
298 | 831b7825 | ths | ((CPUX86State*)cpu_env)->regs[R_EAX] = (int)(t & 0xffffffff); |
299 | 831b7825 | ths | ((CPUX86State*)cpu_env)->regs[R_EDX] = (int)((t >> 32) & 0xffffffff); |
300 | 831b7825 | ths | #else
|
301 | 831b7825 | ths | qerror("do_nanotime unimplemented");
|
302 | 831b7825 | ths | #endif
|
303 | 831b7825 | ths | } |
304 | 831b7825 | ths | |
305 | 831b7825 | ths | void unimpl_commpage(void *cpu_env, int num) |
306 | 831b7825 | ths | { |
307 | 2a252826 | bellard | qerror("qemu: commpage function 0x%x not implemented\n", num);
|
308 | 831b7825 | ths | } |
309 | 831b7825 | ths | |
310 | 831b7825 | ths | /********************************************************************
|
311 | 831b7825 | ths | * do_commpage - called by the main cpu loop
|
312 | 831b7825 | ths | */
|
313 | 831b7825 | ths | void
|
314 | 831b7825 | ths | do_commpage(void *cpu_env, int num, uint32_t arg1, uint32_t arg2, uint32_t arg3, |
315 | 831b7825 | ths | uint32_t arg4, uint32_t arg5, uint32_t arg6, uint32_t arg7, |
316 | 831b7825 | ths | uint32_t arg8) |
317 | 831b7825 | ths | { |
318 | 831b7825 | ths | int i, found = 0; |
319 | 831b7825 | ths | |
320 | 831b7825 | ths | arg1 = tswap32(arg1); |
321 | 831b7825 | ths | arg2 = tswap32(arg2); |
322 | 831b7825 | ths | arg3 = tswap32(arg3); |
323 | 831b7825 | ths | arg4 = tswap32(arg4); |
324 | 831b7825 | ths | arg5 = tswap32(arg5); |
325 | 831b7825 | ths | arg6 = tswap32(arg6); |
326 | 831b7825 | ths | arg7 = tswap32(arg7); |
327 | 831b7825 | ths | arg8 = tswap32(arg8); |
328 | 831b7825 | ths | |
329 | 831b7825 | ths | num = num-COMMPAGE_START-2;
|
330 | 831b7825 | ths | |
331 | b1503cda | malc | for(i = 0; i < ARRAY_SIZE(commpage_entries); i++) { |
332 | 831b7825 | ths | if( num == commpage_code_num(&commpage_entries[i]) )
|
333 | 831b7825 | ths | { |
334 | 831b7825 | ths | DPRINTF("commpage: %s %s\n", commpage_entries[i].name, commpage_is_indirect(&commpage_entries[i]) ? "[indirect]" : "[direct]"); |
335 | 831b7825 | ths | found = 1;
|
336 | 831b7825 | ths | if(commpage_is_indirect(&commpage_entries[i]))
|
337 | 831b7825 | ths | { |
338 | 831b7825 | ths | commpage_indirect_function_t function = (commpage_indirect_function_t)commpage_entries[i].function; |
339 | 831b7825 | ths | function(cpu_env, num, arg1, arg2, arg3, |
340 | 831b7825 | ths | arg4, arg5, arg6, arg7, arg8); |
341 | 831b7825 | ths | } |
342 | 831b7825 | ths | else
|
343 | 831b7825 | ths | { |
344 | 831b7825 | ths | commpage_entries[i].function(arg1, arg2, arg3, |
345 | 831b7825 | ths | arg4, arg5, arg6, arg7, arg8); |
346 | 831b7825 | ths | } |
347 | 831b7825 | ths | break;
|
348 | 831b7825 | ths | } |
349 | 831b7825 | ths | } |
350 | 831b7825 | ths | |
351 | 831b7825 | ths | if(!found)
|
352 | 831b7825 | ths | { |
353 | 831b7825 | ths | gemu_log("qemu: commpage function 0x%x not defined\n", num);
|
354 | 831b7825 | ths | gdb_handlesig (cpu_env, SIGTRAP); |
355 | 831b7825 | ths | exit(-1);
|
356 | 831b7825 | ths | } |
357 | 831b7825 | ths | } |