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.64 2005/08/27 17:29:06 debug Exp $ |
* $Id: useremul.c,v 1.72 2006/09/30 05:57:07 debug Exp $ |
29 |
* |
* |
30 |
* Userland (syscall) emulation. |
* Userland (syscall) emulation. |
31 |
* |
* |
40 |
* Dynamic ELFs? |
* Dynamic ELFs? |
41 |
* |
* |
42 |
* Try to prefix "/emul/mips/" or similar to all filenames, |
* Try to prefix "/emul/mips/" or similar to all filenames, |
43 |
* and only if that fails, try the given filename |
* and only if that fails, try the given filename. |
44 |
|
* Read this setting from an environment variable, and only |
45 |
|
* if there is none, fall back to hardcoded string. |
46 |
* |
* |
47 |
* Automagic errno translation? |
* Automagic errno translation! |
48 |
* |
* |
49 |
* Memory allocation? mmap etc. |
* Memory allocation? mmap, munmap, mprotect, etc. |
50 |
|
* mprotect = unmap in dyntrans... |
51 |
* |
* |
52 |
* File descriptor (0,1,2) assumptions? |
* File descriptor (0,1,2) assumptions? Find and fix these? |
53 |
* |
* |
54 |
* |
* |
55 |
* This module needs more cleanup. |
* This module needs more cleanup. |
56 |
* ------------------------------- |
* ------------------------------- |
57 |
* |
* |
58 |
* |
* |
59 |
* NOTE: This module (useremul.c) is just a quick hack to see if |
* NOTE: This module (useremul.c) is just a quick hack so far, to see if |
60 |
* userland emulation works at all. |
* userland emulation works at all. It only works for Hello World- |
61 |
|
* style programs compiled for FreeBSD/alpha or NetBSD/mips. |
62 |
*/ |
*/ |
63 |
|
|
64 |
#include <errno.h> |
#include <errno.h> |
252 |
|
|
253 |
break; |
break; |
254 |
|
|
255 |
|
case ARCH_SH: |
256 |
|
debug("useremul__netbsd_setup(): SH: TODO\n"); |
257 |
|
break; |
258 |
|
|
259 |
case ARCH_X86: |
case ARCH_X86: |
260 |
debug("useremul__netbsd_setup(): X86: TODO\n"); |
debug("useremul__netbsd_setup(): X86: TODO\n"); |
261 |
|
|
372 |
uint64_t baseaddr, uint64_t len) |
uint64_t baseaddr, uint64_t len) |
373 |
{ |
{ |
374 |
unsigned char *charbuf; |
unsigned char *charbuf; |
375 |
ssize_t i; |
size_t i; |
376 |
|
|
377 |
charbuf = malloc(len); |
charbuf = malloc(len); |
378 |
if (charbuf == NULL) { |
if (charbuf == NULL) { |
707 |
case 58:res = useremul_readlink(cpu, &err, arg0, arg1, arg2); |
case 58:res = useremul_readlink(cpu, &err, arg0, arg1, arg2); |
708 |
break; |
break; |
709 |
|
|
710 |
|
case 73:/* munmap. TODO */ |
711 |
|
res = 1; |
712 |
|
break; |
713 |
|
|
714 |
case 117:res = useremul_getrusage(cpu, &err, arg0, arg1); |
case 117:res = useremul_getrusage(cpu, &err, arg0, arg1); |
715 |
break; |
break; |
716 |
|
|
859 |
} |
} |
860 |
|
|
861 |
/* |
/* |
862 |
* NOTE: The following code should not be CPU arch dependant! |
* NOTE/TODO: The following code should not be CPU arch dependent! |
|
* (TODO) |
|
863 |
*/ |
*/ |
864 |
|
|
865 |
switch (sysnr) { |
switch (sysnr) { |
1224 |
} |
} |
1225 |
if (result_high_set) |
if (result_high_set) |
1226 |
cpu->cd.arm.r[1] = result_high; |
cpu->cd.arm.r[1] = result_high; |
1227 |
|
cpu->cd.arm.flags = cpu->cd.arm.cpsr >> 28; |
1228 |
break; |
break; |
1229 |
case ARCH_MIPS: |
case ARCH_MIPS: |
1230 |
/* |
/* |
1724 |
void useremul_list_emuls(void) |
void useremul_list_emuls(void) |
1725 |
{ |
{ |
1726 |
struct syscall_emul *sep; |
struct syscall_emul *sep; |
1727 |
int iadd = 8; |
int iadd = DEBUG_INDENTATION * 2; |
1728 |
|
|
1729 |
sep = first_syscall_emul; |
sep = first_syscall_emul; |
1730 |
|
|
1762 |
add_useremul("Ultrix", ARCH_MIPS, "R3000", |
add_useremul("Ultrix", ARCH_MIPS, "R3000", |
1763 |
useremul__ultrix, useremul__ultrix_setup); |
useremul__ultrix, useremul__ultrix_setup); |
1764 |
|
|
1765 |
|
add_useremul("NetBSD/sh", ARCH_SH, "SH4", |
1766 |
|
useremul__netbsd, useremul__netbsd_setup); |
1767 |
|
|
1768 |
add_useremul("NetBSD/powerpc", ARCH_PPC, "PPC750", |
add_useremul("NetBSD/powerpc", ARCH_PPC, "PPC750", |
1769 |
useremul__netbsd, useremul__netbsd_setup); |
useremul__netbsd, useremul__netbsd_setup); |
1770 |
|
|