1 |
/* |
/* |
2 |
* Copyright (C) 2004-2005 Anders Gavare. All rights reserved. |
* Copyright (C) 2004-2006 Anders Gavare. All rights reserved. |
3 |
* |
* |
4 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
5 |
* modification, are permitted provided that the following conditions are met: |
* modification, are permitted provided that the following conditions are met: |
25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: useremul.c,v 1.62 2005/08/16 06:49:26 debug Exp $ |
* $Id: useremul.c,v 1.70 2006/01/14 12:51:59 debug Exp $ |
29 |
* |
* |
30 |
* Userland (syscall) emulation. |
* Userland (syscall) emulation. |
31 |
* |
* |
32 |
* TODO: |
* TODO: |
33 |
* |
* |
34 |
* NetBSD/pmax: |
* environment passing for most emulation modes |
35 |
* environment passing |
* |
36 |
* more syscalls |
* implement more syscalls |
37 |
* |
* |
38 |
* 32-bit vs 64-bit problems? MIPS n32, o32, n64? |
* 32-bit vs 64-bit problems? MIPS n32, o32, n64? |
39 |
* |
* |
232 |
} |
} |
233 |
break; |
break; |
234 |
|
|
235 |
|
case ARCH_ALPHA: |
236 |
|
debug("useremul__netbsd_setup(): ALPHA: TODO\n"); |
237 |
|
break; |
238 |
|
|
239 |
case ARCH_ARM: |
case ARCH_ARM: |
240 |
debug("useremul__netbsd_setup(): ARM: TODO\n"); |
debug("useremul__netbsd_setup(): ARM: TODO\n"); |
241 |
break; |
break; |
364 |
uint64_t baseaddr, uint64_t len) |
uint64_t baseaddr, uint64_t len) |
365 |
{ |
{ |
366 |
unsigned char *charbuf; |
unsigned char *charbuf; |
367 |
ssize_t i; |
size_t i; |
368 |
|
|
369 |
charbuf = malloc(len); |
charbuf = malloc(len); |
370 |
if (charbuf == NULL) { |
if (charbuf == NULL) { |
699 |
case 58:res = useremul_readlink(cpu, &err, arg0, arg1, arg2); |
case 58:res = useremul_readlink(cpu, &err, arg0, arg1, arg2); |
700 |
break; |
break; |
701 |
|
|
702 |
|
case 73:/* munmap. TODO */ |
703 |
|
res = 1; |
704 |
|
break; |
705 |
|
|
706 |
case 117:res = useremul_getrusage(cpu, &err, arg0, arg1); |
case 117:res = useremul_getrusage(cpu, &err, arg0, arg1); |
707 |
break; |
break; |
708 |
|
|
836 |
arg3 = cpu->cd.ppc.gpr[6]; |
arg3 = cpu->cd.ppc.gpr[6]; |
837 |
/* TODO: More arguments? Stack arguments? */ |
/* TODO: More arguments? Stack arguments? */ |
838 |
break; |
break; |
839 |
|
|
840 |
|
case ARCH_ARM: |
841 |
|
sysnr = code & 0xfffff; |
842 |
|
arg0 = cpu->cd.arm.r[0]; |
843 |
|
arg1 = cpu->cd.arm.r[1]; |
844 |
|
arg2 = cpu->cd.arm.r[2]; |
845 |
|
arg3 = cpu->cd.arm.r[3]; |
846 |
|
/* TODO: More arguments? Stack arguments? */ |
847 |
|
break; |
848 |
|
|
849 |
|
default:fatal("netbsd syscall for this arch: TODO\n"); |
850 |
|
exit(1); |
851 |
} |
} |
852 |
|
|
853 |
/* |
/* |
854 |
* NOTE: The following code should not be CPU arch dependant! |
* NOTE/TODO: The following code should not be CPU arch dependent! |
|
* (TODO) |
|
855 |
*/ |
*/ |
856 |
|
|
857 |
switch (sysnr) { |
switch (sysnr) { |
1206 |
|
|
1207 |
|
|
1208 |
switch (cpu->machine->arch) { |
switch (cpu->machine->arch) { |
1209 |
|
case ARCH_ARM: |
1210 |
|
/* NetBSD/arm return values: */ |
1211 |
|
cpu->cd.arm.r[0] = result_low; |
1212 |
|
cpu->cd.arm.cpsr &= ~ARM_FLAG_C; |
1213 |
|
if (error_flag) { |
1214 |
|
cpu->cd.arm.cpsr |= ARM_FLAG_C; |
1215 |
|
cpu->cd.arm.r[0] = error_code; |
1216 |
|
} |
1217 |
|
if (result_high_set) |
1218 |
|
cpu->cd.arm.r[1] = result_high; |
1219 |
|
cpu->cd.arm.flags = cpu->cd.arm.cpsr >> 28; |
1220 |
|
break; |
1221 |
case ARCH_MIPS: |
case ARCH_MIPS: |
1222 |
/* |
/* |
1223 |
* NetBSD/mips return values: |
* NetBSD/mips return values: |
1716 |
void useremul_list_emuls(void) |
void useremul_list_emuls(void) |
1717 |
{ |
{ |
1718 |
struct syscall_emul *sep; |
struct syscall_emul *sep; |
1719 |
int iadd = 8; |
int iadd = DEBUG_INDENTATION * 2; |
1720 |
|
|
1721 |
sep = first_syscall_emul; |
sep = first_syscall_emul; |
1722 |
|
|
1760 |
add_useremul("NetBSD/pmax", ARCH_MIPS, "R3000", |
add_useremul("NetBSD/pmax", ARCH_MIPS, "R3000", |
1761 |
useremul__netbsd, useremul__netbsd_setup); |
useremul__netbsd, useremul__netbsd_setup); |
1762 |
|
|
1763 |
add_useremul("NetBSD/arm", ARCH_ARM, "ARM", |
add_useremul("NetBSD/arm", ARCH_ARM, "SA1110", |
1764 |
useremul__netbsd, useremul__netbsd_setup); |
useremul__netbsd, useremul__netbsd_setup); |
1765 |
|
|
1766 |
add_useremul("NetBSD/amd64", ARCH_X86, "AMD64", |
add_useremul("NetBSD/amd64", ARCH_X86, "AMD64", |
1767 |
useremul__netbsd, useremul__netbsd_setup); |
useremul__netbsd, useremul__netbsd_setup); |
1768 |
|
|
1769 |
|
add_useremul("NetBSD/alpha", ARCH_ALPHA, "Alpha", |
1770 |
|
useremul__netbsd, useremul__netbsd_setup); |
1771 |
|
|
1772 |
add_useremul("Linux/PPC64", ARCH_PPC, "PPC970", |
add_useremul("Linux/PPC64", ARCH_PPC, "PPC970", |
1773 |
useremul__linux, useremul__linux_setup); |
useremul__linux, useremul__linux_setup); |
1774 |
|
|