Commit 2d7a3b9d7bf8959077ad19951d7f30dc87da9838
1 parent
7c206a75
qruncom compile fixes (initial patch by Even Rouault)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1722 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
32 additions
and
11 deletions
tests/Makefile
| @@ -71,7 +71,7 @@ runcom: runcom.c | @@ -71,7 +71,7 @@ runcom: runcom.c | ||
| 71 | 71 | ||
| 72 | # NOTE: -fomit-frame-pointer is currently needed : this is a bug in libqemu | 72 | # NOTE: -fomit-frame-pointer is currently needed : this is a bug in libqemu |
| 73 | qruncom: qruncom.c ../i386-user/libqemu.a | 73 | qruncom: qruncom.c ../i386-user/libqemu.a |
| 74 | - $(CC) $(CFLAGS) -fomit-frame-pointer $(LDFLAGS) -I../target-i386 -I.. -I../i386-user \ | 74 | + $(CC) $(CFLAGS) -fomit-frame-pointer $(LDFLAGS) -I../target-i386 -I.. -I../i386-user -I../fpu \ |
| 75 | -o $@ $< -L../i386-user -lqemu -lm | 75 | -o $@ $< -L../i386-user -lqemu -lm |
| 76 | 76 | ||
| 77 | # arm test | 77 | # arm test |
tests/qruncom.c
| @@ -10,6 +10,7 @@ | @@ -10,6 +10,7 @@ | ||
| 10 | #include <fcntl.h> | 10 | #include <fcntl.h> |
| 11 | #include <sys/mman.h> | 11 | #include <sys/mman.h> |
| 12 | #include <signal.h> | 12 | #include <signal.h> |
| 13 | +#include <malloc.h> | ||
| 13 | 14 | ||
| 14 | #include "cpu.h" | 15 | #include "cpu.h" |
| 15 | 16 | ||
| @@ -86,6 +87,26 @@ void *qemu_malloc(size_t size) | @@ -86,6 +87,26 @@ void *qemu_malloc(size_t size) | ||
| 86 | return malloc(size); | 87 | return malloc(size); |
| 87 | } | 88 | } |
| 88 | 89 | ||
| 90 | +void *qemu_mallocz(size_t size) | ||
| 91 | +{ | ||
| 92 | + void *ptr; | ||
| 93 | + ptr = qemu_malloc(size); | ||
| 94 | + if (!ptr) | ||
| 95 | + return NULL; | ||
| 96 | + memset(ptr, 0, size); | ||
| 97 | + return ptr; | ||
| 98 | +} | ||
| 99 | + | ||
| 100 | +void *qemu_vmalloc(size_t size) | ||
| 101 | +{ | ||
| 102 | + return memalign(4096, size); | ||
| 103 | +} | ||
| 104 | + | ||
| 105 | +void qemu_vfree(void *ptr) | ||
| 106 | +{ | ||
| 107 | + free(ptr); | ||
| 108 | +} | ||
| 109 | + | ||
| 89 | void qemu_printf(const char *fmt, ...) | 110 | void qemu_printf(const char *fmt, ...) |
| 90 | { | 111 | { |
| 91 | va_list ap; | 112 | va_list ap; |
| @@ -204,20 +225,20 @@ int main(int argc, char **argv) | @@ -204,20 +225,20 @@ int main(int argc, char **argv) | ||
| 204 | seg = (COM_BASE_ADDR - 0x100) >> 4; | 225 | seg = (COM_BASE_ADDR - 0x100) >> 4; |
| 205 | 226 | ||
| 206 | cpu_x86_load_seg_cache(env, R_CS, seg, | 227 | cpu_x86_load_seg_cache(env, R_CS, seg, |
| 207 | - (uint8_t *)(seg << 4), 0xffff, 0); | 228 | + (seg << 4), 0xffff, 0); |
| 208 | cpu_x86_load_seg_cache(env, R_SS, seg, | 229 | cpu_x86_load_seg_cache(env, R_SS, seg, |
| 209 | - (uint8_t *)(seg << 4), 0xffff, 0); | 230 | + (seg << 4), 0xffff, 0); |
| 210 | cpu_x86_load_seg_cache(env, R_DS, seg, | 231 | cpu_x86_load_seg_cache(env, R_DS, seg, |
| 211 | - (uint8_t *)(seg << 4), 0xffff, 0); | 232 | + (seg << 4), 0xffff, 0); |
| 212 | cpu_x86_load_seg_cache(env, R_ES, seg, | 233 | cpu_x86_load_seg_cache(env, R_ES, seg, |
| 213 | - (uint8_t *)(seg << 4), 0xffff, 0); | 234 | + (seg << 4), 0xffff, 0); |
| 214 | cpu_x86_load_seg_cache(env, R_FS, seg, | 235 | cpu_x86_load_seg_cache(env, R_FS, seg, |
| 215 | - (uint8_t *)(seg << 4), 0xffff, 0); | 236 | + (seg << 4), 0xffff, 0); |
| 216 | cpu_x86_load_seg_cache(env, R_GS, seg, | 237 | cpu_x86_load_seg_cache(env, R_GS, seg, |
| 217 | - (uint8_t *)(seg << 4), 0xffff, 0); | 238 | + (seg << 4), 0xffff, 0); |
| 218 | 239 | ||
| 219 | /* exception support */ | 240 | /* exception support */ |
| 220 | - env->idt.base = (void *)idt_table; | 241 | + env->idt.base = (unsigned long)idt_table; |
| 221 | env->idt.limit = sizeof(idt_table) - 1; | 242 | env->idt.limit = sizeof(idt_table) - 1; |
| 222 | set_idt(0, 0); | 243 | set_idt(0, 0); |
| 223 | set_idt(1, 0); | 244 | set_idt(1, 0); |
| @@ -263,7 +284,7 @@ int main(int argc, char **argv) | @@ -263,7 +284,7 @@ int main(int argc, char **argv) | ||
| 263 | case EXCP0D_GPF: | 284 | case EXCP0D_GPF: |
| 264 | { | 285 | { |
| 265 | int int_num, ah; | 286 | int int_num, ah; |
| 266 | - int_num = *(env->segs[R_CS].base + env->eip + 1); | 287 | + int_num = *(uint8_t *)(env->segs[R_CS].base + env->eip + 1); |
| 267 | if (int_num != 0x21) | 288 | if (int_num != 0x21) |
| 268 | goto unknown_int; | 289 | goto unknown_int; |
| 269 | ah = (env->regs[R_EAX] >> 8) & 0xff; | 290 | ah = (env->regs[R_EAX] >> 8) & 0xff; |
| @@ -291,7 +312,7 @@ int main(int argc, char **argv) | @@ -291,7 +312,7 @@ int main(int argc, char **argv) | ||
| 291 | default: | 312 | default: |
| 292 | unknown_int: | 313 | unknown_int: |
| 293 | fprintf(stderr, "unsupported int 0x%02x\n", int_num); | 314 | fprintf(stderr, "unsupported int 0x%02x\n", int_num); |
| 294 | - cpu_dump_state(env, stderr, 0); | 315 | + cpu_dump_state(env, stderr, fprintf, 0); |
| 295 | // exit(1); | 316 | // exit(1); |
| 296 | } | 317 | } |
| 297 | env->eip += 2; | 318 | env->eip += 2; |
| @@ -299,7 +320,7 @@ int main(int argc, char **argv) | @@ -299,7 +320,7 @@ int main(int argc, char **argv) | ||
| 299 | break; | 320 | break; |
| 300 | default: | 321 | default: |
| 301 | fprintf(stderr, "unhandled cpu_exec return code (0x%x)\n", ret); | 322 | fprintf(stderr, "unhandled cpu_exec return code (0x%x)\n", ret); |
| 302 | - cpu_dump_state(env, stderr, 0); | 323 | + cpu_dump_state(env, stderr, fprintf, 0); |
| 303 | exit(1); | 324 | exit(1); |
| 304 | } | 325 | } |
| 305 | } | 326 | } |