1 /* This file is part of the program psim.
3 Copyright (C) 1996, Andrew Cagney <cagney@highland.com.au>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 /* Note: this module is called via a table. There is no benefit in
29 #include "emul_generic.h"
30 #include "emul_unix.h"
40 #ifdef HAVE_SYS_TYPES_H
41 #include <sys/types.h>
44 #ifdef HAVE_SYS_TYPES_H
60 #ifdef HAVE_SYS_PARAM_H
61 #include <sys/param.h>
64 #ifdef HAVE_SYS_TIME_H
68 #ifdef HAVE_SYS_TERMIOS_H
69 #include <sys/termios.h>
72 #ifdef HAVE_SYS_TERMIO_H
73 #include <sys/termio.h>
77 #ifndef HAVE_SYS_RESOURCE_H
83 #include <sys/resource.h>
88 #include <sys/ioctl.h>
92 #include <sys/mount.h>
97 # define NAMLEN(dirent) strlen((dirent)->d_name)
99 # define dirent direct
100 # define NAMLEN(dirent) (dirent)->d_namlen
102 # include <sys/ndir.h>
105 # include <sys/dir.h>
113 #undef MAXPATHLEN /* sys/param.h might define this also */
121 #if defined(BSD) && !defined(errno) && (BSD < 199306) /* here BSD as just a bug */
125 #ifndef STATIC_INLINE_EMUL_UNIX
126 #define STATIC_INLINE_EMUL_UNIX STATIC_INLINE
130 #define PATH_MAX 1024
137 /* UNIX's idea of what is needed to implement emulations */
139 struct _os_emul_data
{
141 emul_syscall
*syscalls
;
145 /* Emulation of simple UNIX system calls that are common on all systems. */
147 do_unix_exit(os_emul_data
*emul
,
153 int status
= (int)cpu_registers(processor
)->gpr
[arg0
];
154 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
155 printf_filtered ("%d)\n", status
);
157 cpu_halt(processor
, cia
, was_exited
, status
);
162 do_unix_read(os_emul_data
*emul
,
168 void *scratch_buffer
;
169 int d
= (int)cpu_registers(processor
)->gpr
[arg0
];
170 unsigned_word buf
= cpu_registers(processor
)->gpr
[arg0
+1];
171 int nbytes
= cpu_registers(processor
)->gpr
[arg0
+2];
174 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
175 printf_filtered ("%d, 0x%lx, %d", d
, (long)buf
, nbytes
);
177 /* get a tempoary bufer */
178 scratch_buffer
= zalloc(nbytes
);
180 /* check if buffer exists by reading it */
181 emul_read_buffer(scratch_buffer
, buf
, nbytes
, processor
, cia
);
184 status
= read (d
, scratch_buffer
, nbytes
);
186 emul_write_status(processor
, status
, errno
);
188 emul_write_buffer(scratch_buffer
, buf
, status
, processor
, cia
);
190 zfree(scratch_buffer
);
195 do_unix_write(os_emul_data
*emul
,
201 void *scratch_buffer
= NULL
;
203 int d
= (int)cpu_registers(processor
)->gpr
[arg0
];
204 unsigned_word buf
= cpu_registers(processor
)->gpr
[arg0
+1];
205 int nbytes
= cpu_registers(processor
)->gpr
[arg0
+2];
208 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
209 printf_filtered ("%d, 0x%lx, %d", d
, (long)buf
, nbytes
);
211 /* get a tempoary bufer */
212 scratch_buffer
= zalloc(nbytes
); /* FIXME - nbytes == 0 */
215 nr_moved
= vm_data_map_read_buffer(cpu_data_map(processor
),
219 if (nr_moved
!= nbytes
) {
220 /* FIXME - should handle better */
221 error("system_call()write copy failed (nr_moved=%d != nbytes=%d)\n",
226 status
= write(d
, scratch_buffer
, nbytes
);
227 emul_write_status(processor
, status
, errno
);
228 zfree(scratch_buffer
);
235 do_unix_open(os_emul_data
*emul
,
241 unsigned_word path_addr
= cpu_registers(processor
)->gpr
[arg0
];
242 char path_buf
[PATH_MAX
];
243 char *path
= emul_read_string(path_buf
, path_addr
, PATH_MAX
, processor
, cia
);
244 int flags
= (int)cpu_registers(processor
)->gpr
[arg0
+1];
245 int mode
= (int)cpu_registers(processor
)->gpr
[arg0
+2];
248 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
249 printf_filtered ("0x%lx [%s], 0x%x, 0x%x", (long)path_addr
, path
, flags
, mode
);
251 status
= open(path
, flags
, mode
);
252 emul_write_status(processor
, status
, errno
);
257 do_unix_close(os_emul_data
*emul
,
263 int d
= (int)cpu_registers(processor
)->gpr
[arg0
];
266 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
267 printf_filtered ("%d", d
);
270 emul_write_status(processor
, status
, errno
);
275 do_unix_break(os_emul_data
*emul
,
281 /* just pass this onto the `vm' device */
282 psim
*system
= cpu_system(processor
);
283 unsigned_word new_break
= cpu_registers(processor
)->gpr
[arg0
];
286 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
287 printf_filtered ("0x%lx", (long)cpu_registers(processor
)->gpr
[arg0
]);
289 status
= device_ioctl(emul
->vm
,
293 new_break
); /*ioctl-data*/
295 emul_write_status(processor
, 0, status
);
299 #define do_unix_getpid 0
302 do_unix_getpid(os_emul_data
*emul
,
308 int status
= (int)getpid();
309 emul_write_status(processor
, status
, errno
);
314 #define do_unix_getppid 0
317 do_unix_getppid(os_emul_data
*emul
,
323 int status
= (int)getppid();
324 emul_write_status(processor
, status
, errno
);
328 #if !defined(HAVE_GETPID) || !defined(HAVE_GETPPID)
329 #define do_unix_getpid2 0
332 do_unix_getpid2(os_emul_data
*emul
,
338 int pid
= (int)getpid();
339 int ppid
= (int)getppid();
340 emul_write2_status(processor
, pid
, ppid
, errno
);
344 #if !defined(HAVE_GETUID) || !defined(HAVE_GETEUID)
345 #define do_unix_getuid2 0
348 do_unix_getuid2(os_emul_data
*emul
,
354 int uid
= (int)getuid();
355 int euid
= (int)geteuid();
356 emul_write2_status(processor
, uid
, euid
, errno
);
361 #define do_unix_getuid 0
364 do_unix_getuid(os_emul_data
*emul
,
370 int status
= (int)getuid();
371 emul_write_status(processor
, status
, errno
);
376 #define do_unix_geteuid 0
379 do_unix_geteuid(os_emul_data
*emul
,
385 int status
= (int)geteuid();
386 emul_write_status(processor
, status
, errno
);
392 #define do_unix_kill 0
395 do_unix_kill(os_emul_data
*emul
,
401 pid_t pid
= cpu_registers(processor
)->gpr
[arg0
];
402 int sig
= cpu_registers(processor
)->gpr
[arg0
+1];
404 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
405 printf_filtered ("%d, %d", (int)pid
, sig
);
407 printf_filtered("SYS_kill at 0x%lx - more to this than just being killed\n",
410 cpu_halt(processor
, cia
, was_signalled
, sig
);
416 #define do_unix_dup 0
419 do_unix_dup(os_emul_data
*emul
,
425 int oldd
= cpu_registers(processor
)->gpr
[arg0
];
426 int status
= dup(oldd
);
429 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
430 printf_filtered ("%d", oldd
);
432 emul_write_status(processor
, status
, err
);
437 #define do_unix_dup2 0
440 do_unix_dup2(os_emul_data
*emul
,
446 int oldd
= cpu_registers(processor
)->gpr
[arg0
];
447 int newd
= cpu_registers(processor
)->gpr
[arg0
+1];
448 int status
= dup2(oldd
, newd
);
451 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
452 printf_filtered ("%d, %d", oldd
, newd
);
454 emul_write_status(processor
, status
, err
);
459 #define do_unix_lseek 0
462 do_unix_lseek(os_emul_data
*emul
,
468 int fildes
= cpu_registers(processor
)->gpr
[arg0
];
469 off_t offset
= emul_read_gpr64(processor
, arg0
+2);
470 int whence
= cpu_registers(processor
)->gpr
[arg0
+4];
473 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
474 printf_filtered ("%d %ld %d", fildes
, (long)offset
, whence
);
476 status
= lseek(fildes
, offset
, whence
);
478 emul_write_status(processor
, -1, errno
);
480 emul_write_status(processor
, 0, 0); /* success */
481 emul_write_gpr64(processor
, 3, status
);
487 #if !defined(HAVE_GETGID) || !defined(HAVE_GETEGID)
488 #define do_unix_getgid2 0
491 do_unix_getgid2(os_emul_data
*emul
,
497 int gid
= (int)getgid();
498 int egid
= (int)getegid();
499 emul_write2_status(processor
, gid
, egid
, errno
);
504 #define do_unix_getgid 0
507 do_unix_getgid(os_emul_data
*emul
,
513 int status
= (int)getgid();
514 emul_write_status(processor
, status
, 0);
519 #define do_unix_getegid 0
522 do_unix_getegid(os_emul_data
*emul
,
528 int status
= (int)getegid();
529 emul_write_status(processor
, status
, errno
);
534 #define do_unix_umask 0
537 do_unix_umask(os_emul_data
*emul
,
543 int mask
= cpu_registers(processor
)->gpr
[arg0
];
544 int status
= umask(mask
);
546 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
547 printf_filtered ("0%o", mask
);
549 emul_write_status(processor
, status
, errno
);
554 #define do_unix_chdir 0
557 do_unix_chdir(os_emul_data
*emul
,
563 unsigned_word path_addr
= cpu_registers(processor
)->gpr
[arg0
];
564 char path_buf
[PATH_MAX
];
565 char *path
= emul_read_string(path_buf
, path_addr
, PATH_MAX
, processor
, cia
);
568 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
569 printf_filtered ("0x%lx [%s]", (long)path_addr
, path
);
571 status
= chdir(path
);
572 emul_write_status(processor
, status
, errno
);
577 #define do_unix_link 0
580 do_unix_link(os_emul_data
*emul
,
586 unsigned_word path1_addr
= cpu_registers(processor
)->gpr
[arg0
];
587 char path1_buf
[PATH_MAX
];
588 char *path1
= emul_read_string(path1_buf
, path1_addr
, PATH_MAX
, processor
, cia
);
589 unsigned_word path2_addr
= cpu_registers(processor
)->gpr
[arg0
+1];
590 char path2_buf
[PATH_MAX
];
591 char *path2
= emul_read_string(path2_buf
, path2_addr
, PATH_MAX
, processor
, cia
);
594 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
595 printf_filtered ("0x%lx [%s], 0x%lx [%s]", (long)path1_addr
, path1
, (long)path2_addr
, path2
);
597 status
= link(path1
, path2
);
598 emul_write_status(processor
, status
, errno
);
603 #define do_unix_symlink 0
606 do_unix_symlink(os_emul_data
*emul
,
612 unsigned_word path1_addr
= cpu_registers(processor
)->gpr
[arg0
];
613 char path1_buf
[PATH_MAX
];
614 char *path1
= emul_read_string(path1_buf
, path1_addr
, PATH_MAX
, processor
, cia
);
615 unsigned_word path2_addr
= cpu_registers(processor
)->gpr
[arg0
+1];
616 char path2_buf
[PATH_MAX
];
617 char *path2
= emul_read_string(path2_buf
, path2_addr
, PATH_MAX
, processor
, cia
);
620 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
621 printf_filtered ("0x%lx [%s], 0x%lx [%s]", (long)path1_addr
, path1
, (long)path2_addr
, path2
);
623 status
= symlink(path1
, path2
);
624 emul_write_status(processor
, status
, errno
);
629 #define do_unix_unlink 0
632 do_unix_unlink(os_emul_data
*emul
,
638 unsigned_word path_addr
= cpu_registers(processor
)->gpr
[arg0
];
639 char path_buf
[PATH_MAX
];
640 char *path
= emul_read_string(path_buf
, path_addr
, PATH_MAX
, processor
, cia
);
643 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
644 printf_filtered ("0x%lx [%s]", (long)path_addr
, path
);
646 status
= unlink(path
);
647 emul_write_status(processor
, status
, errno
);
652 #define do_unix_mkdir 0
655 do_unix_mkdir(os_emul_data
*emul
,
661 unsigned_word path_addr
= cpu_registers(processor
)->gpr
[arg0
];
662 char path_buf
[PATH_MAX
];
663 char *path
= emul_read_string(path_buf
, path_addr
, PATH_MAX
, processor
, cia
);
664 int mode
= (int)cpu_registers(processor
)->gpr
[arg0
+1];
667 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
668 printf_filtered ("0x%lx [%s], 0%3o", (long)path_addr
, path
, mode
);
670 status
= mkdir(path
, mode
);
671 emul_write_status(processor
, status
, errno
);
676 #define do_unix_rmdir 0
679 do_unix_rmdir(os_emul_data
*emul
,
685 unsigned_word path_addr
= cpu_registers(processor
)->gpr
[arg0
];
686 char path_buf
[PATH_MAX
];
687 char *path
= emul_read_string(path_buf
, path_addr
, PATH_MAX
, processor
, cia
);
690 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
691 printf_filtered ("0x%lx [%s]", (long)path_addr
, path
);
693 status
= rmdir(path
);
694 emul_write_status(processor
, status
, errno
);
699 /* Common code for initializing the system call stuff */
701 static os_emul_data
*
702 emul_unix_create(device
*root
,
705 emul_syscall
*syscall
)
707 unsigned_word top_of_stack
;
713 /* merge any emulation specific entries into the device tree */
715 /* establish a few defaults */
716 if (image
->xvec
->flavour
== bfd_target_elf_flavour
) {
718 top_of_stack
= 0xe0000000;
719 stack_size
= 0x00100000;
723 top_of_stack
= 0x20000000;
724 stack_size
= 0x00100000;
728 emul_add_tree_options(root
, image
, name
,
729 (WITH_ENVIRONMENT
== USER_ENVIRONMENT
730 ? "user" : "virtual"),
731 0 /*oea-interrupt-prefix*/);
733 /* virtual memory - handles growth of stack/heap */
734 vm
= device_tree_add_parsed(root
, "/openprom/vm@0x%lx",
735 (unsigned long)(top_of_stack
- stack_size
));
736 device_tree_add_parsed(vm
, "./stack-base 0x%lx",
737 (unsigned long)(top_of_stack
- stack_size
));
738 device_tree_add_parsed(vm
, "./nr-bytes 0x%x", stack_size
);
740 device_tree_add_parsed(root
, "/openprom/vm/map-binary/file-name %s",
741 bfd_get_filename(image
));
743 /* finish the init */
744 device_tree_add_parsed(root
, "/openprom/init/register/pc 0x%lx",
745 (unsigned long)bfd_get_start_address(image
));
746 device_tree_add_parsed(root
, "/openprom/init/register/sp 0x%lx",
747 (unsigned long)top_of_stack
);
748 device_tree_add_parsed(root
, "/openprom/init/register/msr 0x%x", msr_little_endian_mode
);
749 device_tree_add_parsed(root
, "/openprom/init/stack/stack-type %s",
750 (elf_binary
? "elf" : "xcoff"));
752 /* finally our emulation data */
753 data
= ZALLOC(os_emul_data
);
755 data
->syscalls
= syscall
;
760 /* Solaris specific implementation */
762 typedef signed32 solaris_uid_t
;
763 typedef signed32 solaris_gid_t
;
764 typedef signed32 solaris_off_t
;
765 typedef signed32 solaris_pid_t
;
766 typedef signed32 solaris_time_t
;
767 typedef unsigned32 solaris_dev_t
;
768 typedef unsigned32 solaris_ino_t
;
769 typedef unsigned32 solaris_mode_t
;
770 typedef unsigned32 solaris_nlink_t
;
772 #ifdef HAVE_SYS_STAT_H
773 #define SOLARIS_ST_FSTYPSZ 16 /* array size for file system type name */
776 solaris_time_t tv_sec
;
778 } solaris_timestruc_t
;
780 struct solaris_stat
{
781 solaris_dev_t st_dev
;
782 signed32 st_pad1
[3]; /* reserved for network id */
783 solaris_ino_t st_ino
;
784 solaris_mode_t st_mode
;
785 solaris_nlink_t st_nlink
;
786 solaris_uid_t st_uid
;
787 solaris_gid_t st_gid
;
788 solaris_dev_t st_rdev
;
790 solaris_off_t st_size
;
791 signed32 st_pad3
; /* future off_t expansion */
792 solaris_timestruc_t st_atim
;
793 solaris_timestruc_t st_mtim
;
794 solaris_timestruc_t st_ctim
;
797 char st_fstype
[SOLARIS_ST_FSTYPSZ
];
798 signed32 st_pad4
[8]; /* expansion area */
801 /* Convert from host stat structure to solaris stat structure */
802 STATIC_INLINE_EMUL_UNIX
void
803 convert_to_solaris_stat(unsigned_word addr
,
808 struct solaris_stat target
;
811 target
.st_dev
= H2T_4(host
->st_dev
);
812 target
.st_ino
= H2T_4(host
->st_ino
);
813 target
.st_mode
= H2T_4(host
->st_mode
);
814 target
.st_nlink
= H2T_4(host
->st_nlink
);
815 target
.st_uid
= H2T_4(host
->st_uid
);
816 target
.st_gid
= H2T_4(host
->st_gid
);
817 target
.st_size
= H2T_4(host
->st_size
);
820 target
.st_rdev
= H2T_4(host
->st_rdev
);
825 #ifdef HAVE_ST_BLKSIZE
826 target
.st_blksize
= H2T_4(host
->st_blksize
);
828 target
.st_blksize
= 0;
831 #ifdef HAVE_ST_BLOCKS
832 target
.st_blocks
= H2T_4(host
->st_blocks
);
834 target
.st_blocks
= 0;
837 target
.st_atim
.tv_sec
= H2T_4(host
->st_atime
);
838 target
.st_atim
.tv_usec
= 0;
840 target
.st_ctim
.tv_sec
= H2T_4(host
->st_ctime
);
841 target
.st_ctim
.tv_usec
= 0;
843 target
.st_mtim
.tv_sec
= H2T_4(host
->st_mtime
);
844 target
.st_mtim
.tv_usec
= 0;
846 for (i
= 0; i
< sizeof (target
.st_pad1
) / sizeof (target
.st_pad1
[0]); i
++)
847 target
.st_pad1
[i
] = 0;
849 for (i
= 0; i
< sizeof (target
.st_pad2
) / sizeof (target
.st_pad2
[0]); i
++)
850 target
.st_pad2
[i
] = 0;
854 for (i
= 0; i
< sizeof (target
.st_pad4
) / sizeof (target
.st_pad4
[0]); i
++)
855 target
.st_pad4
[i
] = 0;
857 /* For now, just punt and always say it is a ufs file */
858 strcpy (target
.st_fstype
, "ufs");
860 emul_write_buffer(&target
, addr
, sizeof(target
), processor
, cia
);
862 #endif /* HAVE_SYS_STAT_H */
865 #define do_solaris_stat 0
868 do_solaris_stat(os_emul_data
*emul
,
874 unsigned_word path_addr
= cpu_registers(processor
)->gpr
[arg0
];
875 unsigned_word stat_pkt
= cpu_registers(processor
)->gpr
[arg0
+1];
876 char path_buf
[PATH_MAX
];
878 char *path
= emul_read_string(path_buf
, path_addr
, PATH_MAX
, processor
, cia
);
881 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
882 printf_filtered ("0x%lx [%s], 0x%lx", (long)path_addr
, path
, (long)stat_pkt
);
884 status
= stat (path
, &buf
);
886 convert_to_solaris_stat (stat_pkt
, &buf
, processor
, cia
);
888 emul_write_status(processor
, status
, errno
);
893 #define do_solaris_lstat 0
896 do_solaris_lstat(os_emul_data
*emul
,
902 unsigned_word path_addr
= cpu_registers(processor
)->gpr
[arg0
];
903 unsigned_word stat_pkt
= cpu_registers(processor
)->gpr
[arg0
+1];
904 char path_buf
[PATH_MAX
];
906 char *path
= emul_read_string(path_buf
, path_addr
, PATH_MAX
, processor
, cia
);
909 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
910 printf_filtered ("0x%lx [%s], 0x%lx", (long)path_addr
, path
, (long)stat_pkt
);
912 status
= lstat (path
, &buf
);
914 convert_to_solaris_stat (stat_pkt
, &buf
, processor
, cia
);
916 emul_write_status(processor
, status
, errno
);
921 #define do_solaris_fstat 0
924 do_solaris_fstat(os_emul_data
*emul
,
930 int fildes
= (int)cpu_registers(processor
)->gpr
[arg0
];
931 unsigned_word stat_pkt
= cpu_registers(processor
)->gpr
[arg0
+1];
935 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
936 printf_filtered ("%d, 0x%lx", fildes
, (long)stat_pkt
);
938 status
= fstat (fildes
, &buf
);
940 convert_to_solaris_stat (stat_pkt
, &buf
, processor
, cia
);
942 emul_write_status(processor
, status
, errno
);
946 #if defined(HAVE_SYS_TERMIO_H) || defined(HAVE_SYS_TERMIOS_H)
947 #define SOLARIS_TIOC ('T'<<8)
948 #define SOLARIS_NCC 8
949 #define SOLARIS_NCCS 19
951 #define SOLARIS_VINTR 0
952 #define SOLARIS_VQUIT 1
953 #define SOLARIS_VERASE 2
954 #define SOLARIS_VKILL 3
955 #define SOLARIS_VEOF 4
956 #define SOLARIS_VEOL 5
957 #define SOLARIS_VEOL2 6
958 #define SOLARIS_VSWTCH 7
959 #define SOLARIS_VSTART 8
960 #define SOLARIS_VSTOP 9
961 #define SOLARIS_VSUSP 10
962 #define SOLARIS_VDSUSP 11
963 #define SOLARIS_VREPRINT 12
964 #define SOLARIS_VDISCARD 13
965 #define SOLARIS_VWERASE 14
966 #define SOLARIS_VLNEXT 15
969 #ifdef HAVE_SYS_TERMIO_H
970 /* Convert to/from host termio structure */
972 struct solaris_termio
{
973 unsigned16 c_iflag
; /* input modes */
974 unsigned16 c_oflag
; /* output modes */
975 unsigned16 c_cflag
; /* control modes */
976 unsigned16 c_lflag
; /* line discipline modes */
977 unsigned8 c_line
; /* line discipline */
978 unsigned8 c_cc
[SOLARIS_NCC
]; /* control chars */
981 STATIC_INLINE_EMUL_UNIX
void
982 convert_to_solaris_termio(unsigned_word addr
,
987 struct solaris_termio target
;
990 target
.c_iflag
= H2T_2 (host
->c_iflag
);
991 target
.c_oflag
= H2T_2 (host
->c_oflag
);
992 target
.c_cflag
= H2T_2 (host
->c_cflag
);
993 target
.c_lflag
= H2T_2 (host
->c_lflag
);
994 target
.c_line
= host
->c_line
;
996 for (i
= 0; i
< SOLARIS_NCC
; i
++)
1000 target
.c_cc
[SOLARIS_VINTR
] = host
->c_cc
[VINTR
];
1004 target
.c_cc
[SOLARIS_VQUIT
] = host
->c_cc
[VQUIT
];
1008 target
.c_cc
[SOLARIS_VERASE
] = host
->c_cc
[VERASE
];
1012 target
.c_cc
[SOLARIS_VKILL
] = host
->c_cc
[VKILL
];
1016 target
.c_cc
[SOLARIS_VEOF
] = host
->c_cc
[VEOF
];
1020 target
.c_cc
[SOLARIS_VEOL
] = host
->c_cc
[VEOL
];
1024 target
.c_cc
[SOLARIS_VEOL2
] = host
->c_cc
[VEOL2
];
1028 target
.c_cc
[SOLARIS_VSWTCH
] = host
->c_cc
[VSWTCH
];
1032 target
.c_cc
[SOLARIS_VSWTCH
] = host
->c_cc
[VSWTC
];
1036 emul_write_buffer(&target
, addr
, sizeof(target
), processor
, cia
);
1038 #endif /* HAVE_SYS_TERMIO_H */
1040 #ifdef HAVE_SYS_TERMIOS_H
1041 /* Convert to/from host termios structure */
1043 typedef unsigned32 solaris_tcflag_t
;
1044 typedef unsigned8 solaris_cc_t
;
1045 typedef unsigned32 solaris_speed_t
;
1047 struct solaris_termios
{
1048 solaris_tcflag_t c_iflag
;
1049 solaris_tcflag_t c_oflag
;
1050 solaris_tcflag_t c_cflag
;
1051 solaris_tcflag_t c_lflag
;
1052 solaris_cc_t c_cc
[SOLARIS_NCCS
];
1055 STATIC_INLINE_EMUL_UNIX
void
1056 convert_to_solaris_termios(unsigned_word addr
,
1057 struct termios
*host
,
1061 struct solaris_termios target
;
1064 target
.c_iflag
= H2T_4 (host
->c_iflag
);
1065 target
.c_oflag
= H2T_4 (host
->c_oflag
);
1066 target
.c_cflag
= H2T_4 (host
->c_cflag
);
1067 target
.c_lflag
= H2T_4 (host
->c_lflag
);
1069 for (i
= 0; i
< SOLARIS_NCCS
; i
++)
1073 target
.c_cc
[SOLARIS_VINTR
] = host
->c_cc
[VINTR
];
1077 target
.c_cc
[SOLARIS_VQUIT
] = host
->c_cc
[VQUIT
];
1081 target
.c_cc
[SOLARIS_VERASE
] = host
->c_cc
[VERASE
];
1085 target
.c_cc
[SOLARIS_VKILL
] = host
->c_cc
[VKILL
];
1089 target
.c_cc
[SOLARIS_VEOF
] = host
->c_cc
[VEOF
];
1093 target
.c_cc
[SOLARIS_VEOL
] = host
->c_cc
[VEOL
];
1097 target
.c_cc
[SOLARIS_VEOL2
] = host
->c_cc
[VEOL2
];
1101 target
.c_cc
[SOLARIS_VSWTCH
] = host
->c_cc
[VSWTCH
];
1105 target
.c_cc
[SOLARIS_VSWTCH
] = host
->c_cc
[VSWTC
];
1110 target
.c_cc
[SOLARIS_VSTART
] = host
->c_cc
[VSTART
];
1114 target
.c_cc
[SOLARIS_VSTOP
] = host
->c_cc
[VSTOP
];
1118 target
.c_cc
[SOLARIS_VSUSP
] = host
->c_cc
[VSUSP
];
1122 target
.c_cc
[SOLARIS_VDSUSP
] = host
->c_cc
[VDSUSP
];
1126 target
.c_cc
[SOLARIS_VREPRINT
] = host
->c_cc
[VREPRINT
];
1130 target
.c_cc
[SOLARIS_VDISCARD
] = host
->c_cc
[VDISCARD
];
1134 target
.c_cc
[SOLARIS_VWERASE
] = host
->c_cc
[VWERASE
];
1138 target
.c_cc
[SOLARIS_VLNEXT
] = host
->c_cc
[VLNEXT
];
1141 emul_write_buffer(&target
, addr
, sizeof(target
), processor
, cia
);
1143 #endif /* HAVE_SYS_TERMIOS_H */
1146 #define do_solaris_ioctl 0
1149 do_solaris_ioctl(os_emul_data
*emul
,
1155 int fildes
= cpu_registers(processor
)->gpr
[arg0
];
1156 unsigned request
= cpu_registers(processor
)->gpr
[arg0
+1];
1157 unsigned_word argp_addr
= cpu_registers(processor
)->gpr
[arg0
+2];
1159 const char *name
= "<unknown>";
1161 #ifdef HAVE_SYS_TERMIO_H
1162 struct termio host_termio
;
1165 #ifdef HAVE_SYS_TERMIOS_H
1166 struct termios host_termios
;
1171 case 0: /* make sure we have at least one case */
1177 #ifdef HAVE_SYS_TERMIO_H
1179 case SOLARIS_TIOC
| 1: /* TCGETA */
1181 status
= ioctl (fildes
, TCGETA
, &host_termio
);
1183 convert_to_solaris_termio (argp_addr
, &host_termio
, processor
, cia
);
1186 #endif /* HAVE_SYS_TERMIO_H */
1188 #ifdef HAVE_SYS_TERMIOS_H
1189 #if defined(TCGETS) || defined(HAVE_TCGETATTR)
1190 case SOLARIS_TIOC
| 13: /* TCGETS */
1192 #ifdef HAVE_TCGETATTR
1193 status
= tcgetattr(fildes
, &host_termios
);
1195 status
= ioctl (fildes
, TCGETS
, &host_termios
);
1198 convert_to_solaris_termios (argp_addr
, &host_termios
, processor
, cia
);
1201 #endif /* HAVE_SYS_TERMIOS_H */
1204 emul_write_status(processor
, status
, errno
);
1206 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
1207 printf_filtered ("%d, 0x%x [%s], 0x%lx", fildes
, request
, name
, (long)argp_addr
);
1209 #endif /* HAVE_IOCTL */
1211 static emul_syscall_descriptor solaris_descriptors
[] = {
1212 /* 0 */ { 0, "syscall" },
1213 /* 1 */ { do_unix_exit
, "exit" },
1214 /* 2 */ { 0, "fork" },
1215 /* 3 */ { do_unix_read
, "read" },
1216 /* 4 */ { do_unix_write
, "write" },
1217 /* 5 */ { do_unix_open
, "open" },
1218 /* 6 */ { do_unix_close
, "close" },
1219 /* 7 */ { 0, "wait" },
1220 /* 8 */ { 0, "creat" },
1221 /* 9 */ { do_unix_link
, "link" },
1222 /* 10 */ { do_unix_unlink
, "unlink" },
1223 /* 11 */ { 0, "exec" },
1224 /* 12 */ { do_unix_chdir
, "chdir" },
1225 /* 13 */ { 0, "time" },
1226 /* 14 */ { 0, "mknod" },
1227 /* 15 */ { 0, "chmod" },
1228 /* 16 */ { 0, "chown" },
1229 /* 17 */ { do_unix_break
, "brk" },
1230 /* 18 */ { do_solaris_stat
, "stat" },
1231 /* 19 */ { do_unix_lseek
, "lseek" },
1232 /* 20 */ { do_unix_getpid2
, "getpid" },
1233 /* 21 */ { 0, "mount" },
1234 /* 22 */ { 0, "umount" },
1235 /* 23 */ { 0, "setuid" },
1236 /* 24 */ { do_unix_getuid2
, "getuid" },
1237 /* 25 */ { 0, "stime" },
1238 /* 26 */ { 0, "ptrace" },
1239 /* 27 */ { 0, "alarm" },
1240 /* 28 */ { do_solaris_fstat
, "fstat" },
1241 /* 29 */ { 0, "pause" },
1242 /* 30 */ { 0, "utime" },
1243 /* 31 */ { 0, "stty" },
1244 /* 32 */ { 0, "gtty" },
1245 /* 33 */ { 0, "access" },
1246 /* 34 */ { 0, "nice" },
1247 /* 35 */ { 0, "statfs" },
1248 /* 36 */ { 0, "sync" },
1249 /* 37 */ { 0, "kill" },
1250 /* 38 */ { 0, "fstatfs" },
1251 /* 39 */ { 0, "pgrpsys" },
1252 /* 40 */ { 0, "xenix" },
1253 /* 41 */ { do_unix_dup
, "dup" },
1254 /* 42 */ { 0, "pipe" },
1255 /* 43 */ { 0, "times" },
1256 /* 44 */ { 0, "profil" },
1257 /* 45 */ { 0, "plock" },
1258 /* 46 */ { 0, "setgid" },
1259 /* 47 */ { do_unix_getgid2
, "getgid" },
1260 /* 48 */ { 0, "signal" },
1261 /* 49 */ { 0, "msgsys" },
1262 /* 50 */ { 0, "syssun" },
1263 /* 51 */ { 0, "acct" },
1264 /* 52 */ { 0, "shmsys" },
1265 /* 53 */ { 0, "semsys" },
1266 /* 54 */ { do_solaris_ioctl
, "ioctl" },
1267 /* 55 */ { 0, "uadmin" },
1268 /* 56 */ { 0, 0 /* reserved for exch */ },
1269 /* 57 */ { 0, "utssys" },
1270 /* 58 */ { 0, "fdsync" },
1271 /* 59 */ { 0, "execve" },
1272 /* 60 */ { do_unix_umask
, "umask" },
1273 /* 61 */ { 0, "chroot" },
1274 /* 62 */ { 0, "fcntl" },
1275 /* 63 */ { 0, "ulimit" },
1276 /* 64 */ { 0, 0 /* reserved for UNIX PC */ },
1277 /* 64 */ { 0, 0 /* reserved for UNIX PC */ },
1278 /* 65 */ { 0, 0 /* reserved for UNIX PC */ },
1279 /* 66 */ { 0, 0 /* reserved for UNIX PC */ },
1280 /* 67 */ { 0, 0 /* reserved for UNIX PC */ },
1281 /* 68 */ { 0, 0 /* reserved for UNIX PC */ },
1282 /* 69 */ { 0, 0 /* reserved for UNIX PC */ },
1283 /* 70 */ { 0, 0 /* was advfs */ },
1284 /* 71 */ { 0, 0 /* was unadvfs */ },
1285 /* 72 */ { 0, 0 /* was rmount */ },
1286 /* 73 */ { 0, 0 /* was rumount */ },
1287 /* 74 */ { 0, 0 /* was rfstart */ },
1288 /* 75 */ { 0, 0 /* was sigret */ },
1289 /* 76 */ { 0, 0 /* was rdebug */ },
1290 /* 77 */ { 0, 0 /* was rfstop */ },
1291 /* 78 */ { 0, 0 /* was rfsys */ },
1292 /* 79 */ { do_unix_rmdir
, "rmdir" },
1293 /* 80 */ { do_unix_mkdir
, "mkdir" },
1294 /* 81 */ { 0, "getdents" },
1295 /* 82 */ { 0, 0 /* was libattach */ },
1296 /* 83 */ { 0, 0 /* was libdetach */ },
1297 /* 84 */ { 0, "sysfs" },
1298 /* 85 */ { 0, "getmsg" },
1299 /* 86 */ { 0, "putmsg" },
1300 /* 87 */ { 0, "poll" },
1301 /* 88 */ { do_solaris_lstat
, "lstat" },
1302 /* 89 */ { do_unix_symlink
, "symlink" },
1303 /* 90 */ { 0, "readlink" },
1304 /* 91 */ { 0, "setgroups" },
1305 /* 92 */ { 0, "getgroups" },
1306 /* 93 */ { 0, "fchmod" },
1307 /* 94 */ { 0, "fchown" },
1308 /* 95 */ { 0, "sigprocmask" },
1309 /* 96 */ { 0, "sigsuspend" },
1310 /* 97 */ { 0, "sigaltstack" },
1311 /* 98 */ { 0, "sigaction" },
1312 /* 99 */ { 0, "sigpending" },
1313 /* 100 */ { 0, "context" },
1314 /* 101 */ { 0, "evsys" },
1315 /* 102 */ { 0, "evtrapret" },
1316 /* 103 */ { 0, "statvfs" },
1317 /* 104 */ { 0, "fstatvfs" },
1318 /* 105 */ { 0, 0 /* reserved */ },
1319 /* 106 */ { 0, "nfssys" },
1320 /* 107 */ { 0, "waitsys" },
1321 /* 108 */ { 0, "sigsendsys" },
1322 /* 109 */ { 0, "hrtsys" },
1323 /* 110 */ { 0, "acancel" },
1324 /* 111 */ { 0, "async" },
1325 /* 112 */ { 0, "priocntlsys" },
1326 /* 113 */ { 0, "pathconf" },
1327 /* 114 */ { 0, "mincore" },
1328 /* 115 */ { 0, "mmap" },
1329 /* 116 */ { 0, "mprotect" },
1330 /* 117 */ { 0, "munmap" },
1331 /* 118 */ { 0, "fpathconf" },
1332 /* 119 */ { 0, "vfork" },
1333 /* 120 */ { 0, "fchdir" },
1334 /* 121 */ { 0, "readv" },
1335 /* 122 */ { 0, "writev" },
1336 /* 123 */ { 0, "xstat" },
1337 /* 124 */ { 0, "lxstat" },
1338 /* 125 */ { 0, "fxstat" },
1339 /* 126 */ { 0, "xmknod" },
1340 /* 127 */ { 0, "clocal" },
1341 /* 128 */ { 0, "setrlimit" },
1342 /* 129 */ { 0, "getrlimit" },
1343 /* 130 */ { 0, "lchown" },
1344 /* 131 */ { 0, "memcntl" },
1345 /* 132 */ { 0, "getpmsg" },
1346 /* 133 */ { 0, "putpmsg" },
1347 /* 134 */ { 0, "rename" },
1348 /* 135 */ { 0, "uname" },
1349 /* 136 */ { 0, "setegid" },
1350 /* 137 */ { 0, "sysconfig" },
1351 /* 138 */ { 0, "adjtime" },
1352 /* 139 */ { 0, "systeminfo" },
1353 /* 140 */ { 0, 0 /* reserved */ },
1354 /* 141 */ { 0, "seteuid" },
1355 /* 142 */ { 0, "vtrace" },
1356 /* 143 */ { 0, "fork1" },
1357 /* 144 */ { 0, "sigtimedwait" },
1358 /* 145 */ { 0, "lwp_info" },
1359 /* 146 */ { 0, "yield" },
1360 /* 147 */ { 0, "lwp_sema_wait" },
1361 /* 148 */ { 0, "lwp_sema_post" },
1362 /* 149 */ { 0, 0 /* reserved */ },
1363 /* 150 */ { 0, 0 /* reserved */ },
1364 /* 151 */ { 0, 0 /* reserved */ },
1365 /* 152 */ { 0, "modctl" },
1366 /* 153 */ { 0, "fchroot" },
1367 /* 154 */ { 0, "utimes" },
1368 /* 155 */ { 0, "vhangup" },
1369 /* 156 */ { 0, "gettimeofday" },
1370 /* 157 */ { 0, "getitimer" },
1371 /* 158 */ { 0, "setitimer" },
1372 /* 159 */ { 0, "lwp_create" },
1373 /* 160 */ { 0, "lwp_exit" },
1374 /* 161 */ { 0, "lwp_suspend" },
1375 /* 162 */ { 0, "lwp_continue" },
1376 /* 163 */ { 0, "lwp_kill" },
1377 /* 164 */ { 0, "lwp_self" },
1378 /* 165 */ { 0, "lwp_setprivate" },
1379 /* 166 */ { 0, "lwp_getprivate" },
1380 /* 167 */ { 0, "lwp_wait" },
1381 /* 168 */ { 0, "lwp_mutex_unlock" },
1382 /* 169 */ { 0, "lwp_mutex_lock" },
1383 /* 170 */ { 0, "lwp_cond_wait" },
1384 /* 171 */ { 0, "lwp_cond_signal" },
1385 /* 172 */ { 0, "lwp_cond_broadcast" },
1386 /* 173 */ { 0, "pread" },
1387 /* 174 */ { 0, "pwrite" },
1388 /* 175 */ { 0, "llseek" },
1389 /* 176 */ { 0, "inst_sync" },
1390 /* 177 */ { 0, 0 /* reserved */ },
1391 /* 178 */ { 0, "kaio" },
1392 /* 179 */ { 0, 0 /* reserved */ },
1393 /* 180 */ { 0, 0 /* reserved */ },
1394 /* 181 */ { 0, 0 /* reserved */ },
1395 /* 182 */ { 0, 0 /* reserved */ },
1396 /* 183 */ { 0, 0 /* reserved */ },
1397 /* 184 */ { 0, "tsolsys" },
1398 /* 185 */ { 0, "acl" },
1399 /* 186 */ { 0, "auditsys" },
1400 /* 187 */ { 0, "processor_bind" },
1401 /* 188 */ { 0, "processor_info" },
1402 /* 189 */ { 0, "p_online" },
1403 /* 190 */ { 0, "sigqueue" },
1404 /* 191 */ { 0, "clock_gettime" },
1405 /* 192 */ { 0, "clock_settime" },
1406 /* 193 */ { 0, "clock_getres" },
1407 /* 194 */ { 0, "timer_create" },
1408 /* 195 */ { 0, "timer_delete" },
1409 /* 196 */ { 0, "timer_settime" },
1410 /* 197 */ { 0, "timer_gettime" },
1411 /* 198 */ { 0, "timer_getoverrun" },
1412 /* 199 */ { 0, "nanosleep" },
1413 /* 200 */ { 0, "facl" },
1414 /* 201 */ { 0, "door" },
1415 /* 202 */ { 0, "setreuid" },
1416 /* 203 */ { 0, "setregid" },
1417 /* 204 */ { 0, "install_utrap" },
1418 /* 205 */ { 0, 0 /* reserved */ },
1419 /* 206 */ { 0, 0 /* reserved */ },
1420 /* 207 */ { 0, 0 /* reserved */ },
1421 /* 208 */ { 0, 0 /* reserved */ },
1422 /* 209 */ { 0, 0 /* reserved */ },
1423 /* 210 */ { 0, "signotifywait" },
1424 /* 211 */ { 0, "lwp_sigredirect" },
1425 /* 212 */ { 0, "lwp_alarm" },
1428 static char *(solaris_error_names
[]) = {
1467 /* 38 */ "EL2NSYNC",
1476 /* 47 */ "ECANCELED",
1485 /* 56 */ "EDEADLOCK",
1487 /* 58 */ "Error code 58",
1488 /* 59 */ "Error code 59",
1501 /* 72 */ "Error code 72",
1502 /* 73 */ "Error code 73",
1503 /* 74 */ "EMULTIHOP",
1504 /* 75 */ "Error code 75",
1505 /* 76 */ "Error code 76",
1507 /* 78 */ "ENAMETOOLONG",
1508 /* 79 */ "EOVERFLOW",
1509 /* 80 */ "ENOTUNIQ",
1516 /* 87 */ "ELIBEXEC",
1520 /* 91 */ "ERESTART",
1521 /* 92 */ "ESTRPIPE",
1522 /* 93 */ "ENOTEMPTY",
1524 /* 95 */ "ENOTSOCK",
1525 /* 96 */ "EDESTADDRREQ",
1526 /* 97 */ "EMSGSIZE",
1527 /* 98 */ "EPROTOTYPE",
1528 /* 99 */ "ENOPROTOOPT",
1529 /* 100 */ "Error code 100",
1530 /* 101 */ "Error code 101",
1531 /* 102 */ "Error code 102",
1532 /* 103 */ "Error code 103",
1533 /* 104 */ "Error code 104",
1534 /* 105 */ "Error code 105",
1535 /* 106 */ "Error code 106",
1536 /* 107 */ "Error code 107",
1537 /* 108 */ "Error code 108",
1538 /* 109 */ "Error code 109",
1539 /* 110 */ "Error code 110",
1540 /* 111 */ "Error code 111",
1541 /* 112 */ "Error code 112",
1542 /* 113 */ "Error code 113",
1543 /* 114 */ "Error code 114",
1544 /* 115 */ "Error code 115",
1545 /* 116 */ "Error code 116",
1546 /* 117 */ "Error code 117",
1547 /* 118 */ "Error code 118",
1548 /* 119 */ "Error code 119",
1549 /* 120 */ "EPROTONOSUPPORT",
1550 /* 121 */ "ESOCKTNOSUPPORT",
1551 /* 122 */ "EOPNOTSUPP",
1552 /* 123 */ "EPFNOSUPPORT",
1553 /* 124 */ "EAFNOSUPPORT",
1554 /* 125 */ "EADDRINUSE",
1555 /* 126 */ "EADDRNOTAVAIL",
1556 /* 127 */ "ENETDOWN",
1557 /* 128 */ "ENETUNREACH",
1558 /* 129 */ "ENETRESET",
1559 /* 130 */ "ECONNABORTED",
1560 /* 131 */ "ECONNRESET",
1561 /* 132 */ "ENOBUFS",
1562 /* 133 */ "EISCONN",
1563 /* 134 */ "ENOTCONN",
1564 /* 135 */ "Error code 135", /* XENIX has 135 - 142 */
1565 /* 136 */ "Error code 136",
1566 /* 137 */ "Error code 137",
1567 /* 138 */ "Error code 138",
1568 /* 139 */ "Error code 139",
1569 /* 140 */ "Error code 140",
1570 /* 141 */ "Error code 141",
1571 /* 142 */ "Error code 142",
1572 /* 143 */ "ESHUTDOWN",
1573 /* 144 */ "ETOOMANYREFS",
1574 /* 145 */ "ETIMEDOUT",
1575 /* 146 */ "ECONNREFUSED",
1576 /* 147 */ "EHOSTDOWN",
1577 /* 148 */ "EHOSTUNREACH",
1578 /* 149 */ "EALREADY",
1579 /* 150 */ "EINPROGRESS",
1583 static char *(solaris_signal_names
[]) = {
1604 /* 20 */ "SIGWINCH",
1612 /* 28 */ "SIGVTALRM",
1616 /* 32 */ "SIGWAITING",
1618 /* 34 */ "SIGFREEZE",
1620 /* 36 */ "SIGCANCEL",
1623 static emul_syscall emul_solaris_syscalls
= {
1624 solaris_descriptors
,
1625 sizeof(solaris_descriptors
) / sizeof(solaris_descriptors
[0]),
1626 solaris_error_names
,
1627 sizeof(solaris_error_names
) / sizeof(solaris_error_names
[0]),
1628 solaris_signal_names
,
1629 sizeof(solaris_signal_names
) / sizeof(solaris_signal_names
[0]),
1633 /* Solaris's os_emul interface, most are just passed on to the generic
1636 static os_emul_data
*
1637 emul_solaris_create(device
*root
,
1641 /* check that this emulation is really for us */
1642 if (name
!= NULL
&& strcmp(name
, "solaris") != 0)
1648 return emul_unix_create(root
, image
, "solaris", &emul_solaris_syscalls
);
1652 emul_solaris_init(os_emul_data
*emul_data
,
1659 emul_solaris_system_call(cpu
*processor
,
1661 os_emul_data
*emul_data
)
1663 emul_do_system_call(emul_data
,
1664 emul_data
->syscalls
,
1665 cpu_registers(processor
)->gpr
[0],
1666 3, /*r3 contains arg0*/
1671 const os_emul emul_solaris
= {
1673 emul_solaris_create
,
1675 emul_solaris_system_call
,
1676 0, /*instruction_call*/
1681 /* Linux specific implementation */
1683 typedef unsigned32 linux_dev_t
;
1684 typedef unsigned32 linux_ino_t
;
1685 typedef unsigned32 linux_mode_t
;
1686 typedef unsigned16 linux_nlink_t
;
1687 typedef signed32 linux_off_t
;
1688 typedef signed32 linux_pid_t
;
1689 typedef unsigned32 linux_uid_t
;
1690 typedef unsigned32 linux_gid_t
;
1691 typedef unsigned32 linux_size_t
;
1692 typedef signed32 linux_ssize_t
;
1693 typedef signed32 linux_ptrdiff_t
;
1694 typedef signed32 linux_time_t
;
1695 typedef signed32 linux_clock_t
;
1696 typedef signed32 linux_daddr_t
;
1698 #ifdef HAVE_SYS_STAT_H
1699 /* For the PowerPC, don't both with the 'old' stat structure, since there
1700 should be no extant binaries with that structure. */
1705 linux_mode_t st_mode
;
1706 linux_nlink_t st_nlink
;
1709 linux_dev_t st_rdev
;
1710 linux_off_t st_size
;
1711 unsigned32 st_blksize
;
1712 unsigned32 st_blocks
;
1713 unsigned32 st_atimx
; /* don't use st_{a,c,m}time, that might a macro */
1714 unsigned32 __unused1
; /* defined by the host's stat.h */
1715 unsigned32 st_mtimx
;
1716 unsigned32 __unused2
;
1717 unsigned32 st_ctimx
;
1718 unsigned32 __unused3
;
1719 unsigned32 __unused4
;
1720 unsigned32 __unused5
;
1723 /* Convert from host stat structure to solaris stat structure */
1724 STATIC_INLINE_EMUL_UNIX
void
1725 convert_to_linux_stat(unsigned_word addr
,
1730 struct linux_stat target
;
1732 target
.st_dev
= H2T_4(host
->st_dev
);
1733 target
.st_ino
= H2T_4(host
->st_ino
);
1734 target
.st_mode
= H2T_4(host
->st_mode
);
1735 target
.st_nlink
= H2T_2(host
->st_nlink
);
1736 target
.st_uid
= H2T_4(host
->st_uid
);
1737 target
.st_gid
= H2T_4(host
->st_gid
);
1738 target
.st_size
= H2T_4(host
->st_size
);
1741 target
.st_rdev
= H2T_4(host
->st_rdev
);
1746 #ifdef HAVE_ST_BLKSIZE
1747 target
.st_blksize
= H2T_4(host
->st_blksize
);
1749 target
.st_blksize
= 0;
1752 #ifdef HAVE_ST_BLOCKS
1753 target
.st_blocks
= H2T_4(host
->st_blocks
);
1755 target
.st_blocks
= 0;
1758 target
.st_atimx
= H2T_4(host
->st_atime
);
1759 target
.st_ctimx
= H2T_4(host
->st_ctime
);
1760 target
.st_mtimx
= H2T_4(host
->st_mtime
);
1761 target
.__unused1
= 0;
1762 target
.__unused2
= 0;
1763 target
.__unused3
= 0;
1764 target
.__unused4
= 0;
1765 target
.__unused5
= 0;
1767 emul_write_buffer(&target
, addr
, sizeof(target
), processor
, cia
);
1769 #endif /* HAVE_SYS_STAT_H */
1772 #define do_linux_stat 0
1775 do_linux_stat(os_emul_data
*emul
,
1781 unsigned_word path_addr
= cpu_registers(processor
)->gpr
[arg0
];
1782 unsigned_word stat_pkt
= cpu_registers(processor
)->gpr
[arg0
+1];
1783 char path_buf
[PATH_MAX
];
1785 char *path
= emul_read_string(path_buf
, path_addr
, PATH_MAX
, processor
, cia
);
1788 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
1789 printf_filtered ("0x%lx [%s], 0x%lx", (long)path_addr
, path
, (long)stat_pkt
);
1791 status
= stat (path
, &buf
);
1793 convert_to_linux_stat (stat_pkt
, &buf
, processor
, cia
);
1795 emul_write_status(processor
, status
, errno
);
1800 #define do_linux_lstat 0
1803 do_linux_lstat(os_emul_data
*emul
,
1809 unsigned_word path_addr
= cpu_registers(processor
)->gpr
[arg0
];
1810 unsigned_word stat_pkt
= cpu_registers(processor
)->gpr
[arg0
+1];
1811 char path_buf
[PATH_MAX
];
1813 char *path
= emul_read_string(path_buf
, path_addr
, PATH_MAX
, processor
, cia
);
1816 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
1817 printf_filtered ("0x%lx [%s], 0x%lx", (long)path_addr
, path
, (long)stat_pkt
);
1819 status
= lstat (path
, &buf
);
1821 convert_to_linux_stat (stat_pkt
, &buf
, processor
, cia
);
1823 emul_write_status(processor
, status
, errno
);
1828 #define do_linux_fstat 0
1831 do_linux_fstat(os_emul_data
*emul
,
1837 int fildes
= (int)cpu_registers(processor
)->gpr
[arg0
];
1838 unsigned_word stat_pkt
= cpu_registers(processor
)->gpr
[arg0
+1];
1842 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
1843 printf_filtered ("%d, 0x%lx", fildes
, (long)stat_pkt
);
1845 status
= fstat (fildes
, &buf
);
1847 convert_to_linux_stat (stat_pkt
, &buf
, processor
, cia
);
1849 emul_write_status(processor
, status
, errno
);
1853 #if defined(HAVE_SYS_TERMIO_H) || defined(HAVE_SYS_TERMIOS_H)
1854 #define LINUX_NCC 10
1855 #define LINUX_NCCS 19
1857 #define LINUX_VINTR 0
1858 #define LINUX_VQUIT 1
1859 #define LINUX_VERASE 2
1860 #define LINUX_VKILL 3
1861 #define LINUX_VEOF 4
1862 #define LINUX_VMIN 5
1863 #define LINUX_VEOL 6
1864 #define LINUX_VTIME 7
1865 #define LINUX_VEOL2 8
1866 #define LINUX_VSWTC 9
1867 #define LINUX_VWERASE 10
1868 #define LINUX_VREPRINT 11
1869 #define LINUX_VSUSP 12
1870 #define LINUX_VSTART 13
1871 #define LINUX_VSTOP 14
1872 #define LINUX_VLNEXT 15
1873 #define LINUX_VDISCARD 16
1875 #define LINUX_IOC_NRBITS 8
1876 #define LINUX_IOC_TYPEBITS 8
1877 #define LINUX_IOC_SIZEBITS 13
1878 #define LINUX_IOC_DIRBITS 3
1880 #define LINUX_IOC_NRMASK ((1 << LINUX_IOC_NRBITS)-1)
1881 #define LINUX_IOC_TYPEMASK ((1 << LINUX_IOC_TYPEBITS)-1)
1882 #define LINUX_IOC_SIZEMASK ((1 << LINUX_IOC_SIZEBITS)-1)
1883 #define LINUX_IOC_DIRMASK ((1 << LINUX_IOC_DIRBITS)-1)
1885 #define LINUX_IOC_NRSHIFT 0
1886 #define LINUX_IOC_TYPESHIFT (LINUX_IOC_NRSHIFT+LINUX_IOC_NRBITS)
1887 #define LINUX_IOC_SIZESHIFT (LINUX_IOC_TYPESHIFT+LINUX_IOC_TYPEBITS)
1888 #define LINUX_IOC_DIRSHIFT (LINUX_IOC_SIZESHIFT+LINUX_IOC_SIZEBITS)
1891 * Direction bits _IOC_NONE could be 0, but OSF/1 gives it a bit.
1892 * And this turns out useful to catch old ioctl numbers in header
1895 #define LINUX_IOC_NONE 1U
1896 #define LINUX_IOC_READ 2U
1897 #define LINUX_IOC_WRITE 4U
1899 #define LINUX_IOC(dir,type,nr,size) \
1900 (((dir) << LINUX_IOC_DIRSHIFT) | \
1901 ((type) << LINUX_IOC_TYPESHIFT) | \
1902 ((nr) << LINUX_IOC_NRSHIFT) | \
1903 ((size) << LINUX_IOC_SIZESHIFT))
1905 /* used to create numbers */
1906 #define LINUX_IO(type,nr) LINUX_IOC(LINUX_IOC_NONE,(type),(nr),0)
1907 #define LINUX_IOR(type,nr,size) LINUX_IOC(LINUX_IOC_READ,(type),(nr),sizeof(size))
1908 #define LINUX_IOW(type,nr,size) LINUX_IOC(LINUX_IOC_WRITE,(type),(nr),sizeof(size))
1909 #define LINUX_IOWR(type,nr,size) LINUX_IOC(LINUX_IOC_READ|LINUX_IOC_WRITE,(type),(nr),sizeof(size))
1912 #ifdef HAVE_SYS_TERMIO_H
1913 /* Convert to/from host termio structure */
1915 struct linux_termio
{
1916 unsigned16 c_iflag
; /* input modes */
1917 unsigned16 c_oflag
; /* output modes */
1918 unsigned16 c_cflag
; /* control modes */
1919 unsigned16 c_lflag
; /* line discipline modes */
1920 unsigned8 c_line
; /* line discipline */
1921 unsigned8 c_cc
[LINUX_NCC
]; /* control chars */
1924 STATIC_INLINE_EMUL_UNIX
void
1925 convert_to_linux_termio(unsigned_word addr
,
1926 struct termio
*host
,
1930 struct linux_termio target
;
1933 target
.c_iflag
= H2T_2 (host
->c_iflag
);
1934 target
.c_oflag
= H2T_2 (host
->c_oflag
);
1935 target
.c_cflag
= H2T_2 (host
->c_cflag
);
1936 target
.c_lflag
= H2T_2 (host
->c_lflag
);
1937 target
.c_line
= host
->c_line
;
1939 for (i
= 0; i
< LINUX_NCC
; i
++)
1943 target
.c_cc
[LINUX_VINTR
] = host
->c_cc
[VINTR
];
1947 target
.c_cc
[LINUX_VQUIT
] = host
->c_cc
[VQUIT
];
1951 target
.c_cc
[LINUX_VERASE
] = host
->c_cc
[VERASE
];
1955 target
.c_cc
[LINUX_VKILL
] = host
->c_cc
[VKILL
];
1959 target
.c_cc
[LINUX_VEOF
] = host
->c_cc
[VEOF
];
1963 target
.c_cc
[LINUX_VMIN
] = host
->c_cc
[VMIN
];
1967 target
.c_cc
[LINUX_VEOL
] = host
->c_cc
[VEOL
];
1971 target
.c_cc
[LINUX_VTIME
] = host
->c_cc
[VTIME
];
1975 target
.c_cc
[LINUX_VEOL2
] = host
->c_cc
[VEOL2
];
1979 target
.c_cc
[LINUX_VSWTC
] = host
->c_cc
[VSWTC
];
1983 target
.c_cc
[LINUX_VSWTC
] = host
->c_cc
[VSWTCH
];
1986 emul_write_buffer(&target
, addr
, sizeof(target
), processor
, cia
);
1988 #endif /* HAVE_SYS_TERMIO_H */
1990 #ifdef HAVE_SYS_TERMIOS_H
1991 /* Convert to/from host termios structure */
1993 typedef unsigned32 linux_tcflag_t
;
1994 typedef unsigned8 linux_cc_t
;
1995 typedef unsigned32 linux_speed_t
;
1997 struct linux_termios
{
1998 linux_tcflag_t c_iflag
;
1999 linux_tcflag_t c_oflag
;
2000 linux_tcflag_t c_cflag
;
2001 linux_tcflag_t c_lflag
;
2002 linux_cc_t c_cc
[LINUX_NCCS
];
2008 STATIC_INLINE_EMUL_UNIX
void
2009 convert_to_linux_termios(unsigned_word addr
,
2010 struct termios
*host
,
2014 struct linux_termios target
;
2017 target
.c_iflag
= H2T_4 (host
->c_iflag
);
2018 target
.c_oflag
= H2T_4 (host
->c_oflag
);
2019 target
.c_cflag
= H2T_4 (host
->c_cflag
);
2020 target
.c_lflag
= H2T_4 (host
->c_lflag
);
2022 for (i
= 0; i
< LINUX_NCCS
; i
++)
2026 target
.c_cc
[LINUX_VINTR
] = host
->c_cc
[VINTR
];
2030 target
.c_cc
[LINUX_VQUIT
] = host
->c_cc
[VQUIT
];
2034 target
.c_cc
[LINUX_VERASE
] = host
->c_cc
[VERASE
];
2038 target
.c_cc
[LINUX_VKILL
] = host
->c_cc
[VKILL
];
2042 target
.c_cc
[LINUX_VEOF
] = host
->c_cc
[VEOF
];
2046 target
.c_cc
[LINUX_VEOL
] = host
->c_cc
[VEOL
];
2050 target
.c_cc
[LINUX_VEOL2
] = host
->c_cc
[VEOL2
];
2054 target
.c_cc
[LINUX_VSWTCH
] = host
->c_cc
[VSWTCH
];
2059 #ifdef HAVE_CFGETISPEED
2060 target
.c_ispeed
= cfgetispeed (host
);
2062 target
.c_ispeed
= 0;
2065 #ifdef HAVE_CFGETOSPEED
2066 target
.c_ospeed
= cfgetospeed (host
);
2068 target
.c_ospeed
= 0;
2071 emul_write_buffer(&target
, addr
, sizeof(target
), processor
, cia
);
2073 #endif /* HAVE_SYS_TERMIOS_H */
2076 #define do_linux_ioctl 0
2079 do_linux_ioctl(os_emul_data
*emul
,
2085 int fildes
= cpu_registers(processor
)->gpr
[arg0
];
2086 unsigned request
= cpu_registers(processor
)->gpr
[arg0
+1];
2087 unsigned_word argp_addr
= cpu_registers(processor
)->gpr
[arg0
+2];
2089 const char *name
= "<unknown>";
2091 #ifdef HAVE_SYS_TERMIO_H
2092 struct termio host_termio
;
2095 #ifdef HAVE_SYS_TERMIOS_H
2096 struct termios host_termios
;
2101 case 0: /* make sure we have at least one case */
2107 #ifdef HAVE_SYS_TERMIO_H
2109 case LINUX_IOR('t', 23, struct linux_termio
): /* TCGETA */
2111 status
= ioctl (fildes
, TCGETA
, &host_termio
);
2113 convert_to_linux_termio (argp_addr
, &host_termio
, processor
, cia
);
2116 #endif /* HAVE_SYS_TERMIO_H */
2118 #ifdef HAVE_SYS_TERMIOS_H
2119 #if defined(TCGETS) || defined(HAVE_TCGETATTR)
2120 case LINUX_IOR('t', 19, struct linux_termios
): /* TCGETS */
2122 #ifdef HAVE_TCGETATTR
2123 status
= tcgetattr(fildes
, &host_termios
);
2125 status
= ioctl (fildes
, TCGETS
, &host_termios
);
2128 convert_to_linux_termios (argp_addr
, &host_termios
, processor
, cia
);
2131 #endif /* HAVE_SYS_TERMIOS_H */
2134 emul_write_status(processor
, status
, errno
);
2136 if (WITH_TRACE
&& ppc_trace
[trace_os_emul
])
2137 printf_filtered ("%d, 0x%x [%s], 0x%lx", fildes
, request
, name
, (long)argp_addr
);
2139 #endif /* HAVE_IOCTL */
2141 static emul_syscall_descriptor linux_descriptors
[] = {
2142 /* 0 */ { 0, "setup" },
2143 /* 1 */ { do_unix_exit
, "exit" },
2144 /* 2 */ { 0, "fork" },
2145 /* 3 */ { do_unix_read
, "read" },
2146 /* 4 */ { do_unix_write
, "write" },
2147 /* 5 */ { do_unix_open
, "open" },
2148 /* 6 */ { do_unix_close
, "close" },
2149 /* 7 */ { 0, "waitpid" },
2150 /* 8 */ { 0, "creat" },
2151 /* 9 */ { do_unix_link
, "link" },
2152 /* 10 */ { do_unix_unlink
, "unlink" },
2153 /* 11 */ { 0, "execve" },
2154 /* 12 */ { do_unix_chdir
, "chdir" },
2155 /* 13 */ { 0, "time" },
2156 /* 14 */ { 0, "mknod" },
2157 /* 15 */ { 0, "chmod" },
2158 /* 16 */ { 0, "chown" },
2159 /* 17 */ { 0, "break" },
2160 /* 18 */ { 0, "stat" },
2161 /* 19 */ { do_unix_lseek
, "lseek" },
2162 /* 20 */ { do_unix_getpid
, "getpid" },
2163 /* 21 */ { 0, "mount" },
2164 /* 22 */ { 0, "umount" },
2165 /* 23 */ { 0, "setuid" },
2166 /* 24 */ { do_unix_getuid
, "getuid" },
2167 /* 25 */ { 0, "stime" },
2168 /* 26 */ { 0, "ptrace" },
2169 /* 27 */ { 0, "alarm" },
2170 /* 28 */ { 0, "fstat" },
2171 /* 29 */ { 0, "pause" },
2172 /* 30 */ { 0, "utime" },
2173 /* 31 */ { 0, "stty" },
2174 /* 32 */ { 0, "gtty" },
2175 /* 33 */ { 0, "access" },
2176 /* 34 */ { 0, "nice" },
2177 /* 35 */ { 0, "ftime" },
2178 /* 36 */ { 0, "sync" },
2179 /* 37 */ { 0, "kill" },
2180 /* 38 */ { 0, "rename" },
2181 /* 39 */ { do_unix_mkdir
, "mkdir" },
2182 /* 40 */ { do_unix_rmdir
, "rmdir" },
2183 /* 41 */ { do_unix_dup
, "dup" },
2184 /* 42 */ { 0, "pipe" },
2185 /* 43 */ { 0, "times" },
2186 /* 44 */ { 0, "prof" },
2187 /* 45 */ { do_unix_break
, "brk" },
2188 /* 46 */ { 0, "setgid" },
2189 /* 47 */ { do_unix_getgid
, "getgid" },
2190 /* 48 */ { 0, "signal" },
2191 /* 49 */ { do_unix_geteuid
, "geteuid" },
2192 /* 50 */ { do_unix_getegid
, "getegid" },
2193 /* 51 */ { 0, "acct" },
2194 /* 52 */ { 0, "phys" },
2195 /* 53 */ { 0, "lock" },
2196 /* 54 */ { do_linux_ioctl
, "ioctl" },
2197 /* 55 */ { 0, "fcntl" },
2198 /* 56 */ { 0, "mpx" },
2199 /* 57 */ { 0, "setpgid" },
2200 /* 58 */ { 0, "ulimit" },
2201 /* 59 */ { 0, "olduname" },
2202 /* 60 */ { do_unix_umask
, "umask" },
2203 /* 61 */ { 0, "chroot" },
2204 /* 62 */ { 0, "ustat" },
2205 /* 63 */ { do_unix_dup2
, "dup2" },
2206 /* 64 */ { do_unix_getppid
, "getppid" },
2207 /* 65 */ { 0, "getpgrp" },
2208 /* 66 */ { 0, "setsid" },
2209 /* 67 */ { 0, "sigaction" },
2210 /* 68 */ { 0, "sgetmask" },
2211 /* 69 */ { 0, "ssetmask" },
2212 /* 70 */ { 0, "setreuid" },
2213 /* 71 */ { 0, "setregid" },
2214 /* 72 */ { 0, "sigsuspend" },
2215 /* 73 */ { 0, "sigpending" },
2216 /* 74 */ { 0, "sethostname" },
2217 /* 75 */ { 0, "setrlimit" },
2218 /* 76 */ { 0, "getrlimit" },
2219 /* 77 */ { 0, "getrusage" },
2220 /* 78 */ { 0, "gettimeofday" },
2221 /* 79 */ { 0, "settimeofday" },
2222 /* 80 */ { 0, "getgroups" },
2223 /* 81 */ { 0, "setgroups" },
2224 /* 82 */ { 0, "select" },
2225 /* 83 */ { do_unix_symlink
, "symlink" },
2226 /* 84 */ { 0, "lstat" },
2227 /* 85 */ { 0, "readlink" },
2228 /* 86 */ { 0, "uselib" },
2229 /* 87 */ { 0, "swapon" },
2230 /* 88 */ { 0, "reboot" },
2231 /* 89 */ { 0, "readdir" },
2232 /* 90 */ { 0, "mmap" },
2233 /* 91 */ { 0, "munmap" },
2234 /* 92 */ { 0, "truncate" },
2235 /* 93 */ { 0, "ftruncate" },
2236 /* 94 */ { 0, "fchmod" },
2237 /* 95 */ { 0, "fchown" },
2238 /* 96 */ { 0, "getpriority" },
2239 /* 97 */ { 0, "setpriority" },
2240 /* 98 */ { 0, "profil" },
2241 /* 99 */ { 0, "statfs" },
2242 /* 100 */ { 0, "fstatfs" },
2243 /* 101 */ { 0, "ioperm" },
2244 /* 102 */ { 0, "socketcall" },
2245 /* 103 */ { 0, "syslog" },
2246 /* 104 */ { 0, "setitimer" },
2247 /* 105 */ { 0, "getitimer" },
2248 /* 106 */ { do_linux_stat
, "newstat" },
2249 /* 107 */ { do_linux_lstat
, "newlstat" },
2250 /* 108 */ { do_linux_fstat
, "newfstat" },
2251 /* 109 */ { 0, "uname" },
2252 /* 110 */ { 0, "iopl" },
2253 /* 111 */ { 0, "vhangup" },
2254 /* 112 */ { 0, "idle" },
2255 /* 113 */ { 0, "vm86" },
2256 /* 114 */ { 0, "wait4" },
2257 /* 115 */ { 0, "swapoff" },
2258 /* 116 */ { 0, "sysinfo" },
2259 /* 117 */ { 0, "ipc" },
2260 /* 118 */ { 0, "fsync" },
2261 /* 119 */ { 0, "sigreturn" },
2262 /* 120 */ { 0, "clone" },
2263 /* 121 */ { 0, "setdomainname" },
2264 /* 122 */ { 0, "newuname" },
2265 /* 123 */ { 0, "modify_ldt" },
2266 /* 124 */ { 0, "adjtimex" },
2267 /* 125 */ { 0, "mprotect" },
2268 /* 126 */ { 0, "sigprocmask" },
2269 /* 127 */ { 0, "create_module" },
2270 /* 128 */ { 0, "init_module" },
2271 /* 129 */ { 0, "delete_module" },
2272 /* 130 */ { 0, "get_kernel_syms" },
2273 /* 131 */ { 0, "quotactl" },
2274 /* 132 */ { 0, "getpgid" },
2275 /* 133 */ { 0, "fchdir" },
2276 /* 134 */ { 0, "bdflush" },
2277 /* 135 */ { 0, "sysfs" },
2278 /* 136 */ { 0, "personality" },
2279 /* 137 */ { 0, "afs_syscall" },
2280 /* 138 */ { 0, "setfsuid" },
2281 /* 139 */ { 0, "setfsgid" },
2282 /* 140 */ { 0, "llseek" },
2283 /* 141 */ { 0, "getdents" },
2284 /* 142 */ { 0, "newselect" },
2285 /* 143 */ { 0, "flock" },
2286 /* 144 */ { 0, "msync" },
2287 /* 145 */ { 0, "readv" },
2288 /* 146 */ { 0, "writev" },
2289 /* 147 */ { 0, "getsid" },
2290 /* 148 */ { 0, "fdatasync" },
2291 /* 149 */ { 0, "sysctl" },
2292 /* 150 */ { 0, "mlock" },
2293 /* 151 */ { 0, "munlock" },
2294 /* 152 */ { 0, "mlockall" },
2295 /* 153 */ { 0, "munlockall" },
2296 /* 154 */ { 0, "sched_setparam" },
2297 /* 155 */ { 0, "sched_getparam" },
2298 /* 156 */ { 0, "sched_setscheduler" },
2299 /* 157 */ { 0, "sched_getscheduler" },
2300 /* 158 */ { 0, "sched_yield" },
2301 /* 159 */ { 0, "sched_get_priority_max" },
2302 /* 160 */ { 0, "sched_get_priority_min" },
2303 /* 161 */ { 0, "sched_rr_get_interval" },
2306 static char *(linux_error_names
[]) = {
2343 /* 36 */ "ENAMETOOLONG",
2346 /* 39 */ "ENOTEMPTY",
2352 /* 45 */ "EL2NSYNC",
2365 /* 58 */ "EDEADLOCK",
2379 /* 72 */ "EMULTIHOP",
2382 /* 75 */ "EOVERFLOW",
2383 /* 76 */ "ENOTUNIQ",
2390 /* 83 */ "ELIBEXEC",
2392 /* 85 */ "ERESTART",
2393 /* 86 */ "ESTRPIPE",
2395 /* 88 */ "ENOTSOCK",
2396 /* 89 */ "EDESTADDRREQ",
2397 /* 90 */ "EMSGSIZE",
2398 /* 91 */ "EPROTOTYPE",
2399 /* 92 */ "ENOPROTOOPT",
2400 /* 93 */ "EPROTONOSUPPORT",
2401 /* 94 */ "ESOCKTNOSUPPORT",
2402 /* 95 */ "EOPNOTSUPP",
2403 /* 96 */ "EPFNOSUPPORT",
2404 /* 97 */ "EAFNOSUPPORT",
2405 /* 98 */ "EADDRINUSE",
2406 /* 99 */ "EADDRNOTAVAIL",
2407 /* 100 */ "ENETDOWN",
2408 /* 101 */ "ENETUNREACH",
2409 /* 102 */ "ENETRESET",
2410 /* 103 */ "ECONNABORTED",
2411 /* 104 */ "ECONNRESET",
2412 /* 105 */ "ENOBUFS",
2413 /* 106 */ "EISCONN",
2414 /* 107 */ "ENOTCONN",
2415 /* 108 */ "ESHUTDOWN",
2416 /* 109 */ "ETOOMANYREFS",
2417 /* 110 */ "ETIMEDOUT",
2418 /* 111 */ "ECONNREFUSED",
2419 /* 112 */ "EHOSTDOWN",
2420 /* 113 */ "EHOSTUNREACH",
2421 /* 114 */ "EALREADY",
2422 /* 115 */ "EINPROGRESS",
2424 /* 117 */ "EUCLEAN",
2425 /* 118 */ "ENOTNAM",
2426 /* 119 */ "ENAVAIL",
2428 /* 121 */ "EREMOTEIO",
2432 static char *(linux_signal_names
[]) = {
2450 /* 16 */ "SIGSTKFLT",
2460 /* 26 */ "SIGVTALRM",
2462 /* 28 */ "SIGWINCH",
2465 /* 31 */ "SIGUNUSED",
2468 static emul_syscall emul_linux_syscalls
= {
2470 sizeof(linux_descriptors
) / sizeof(linux_descriptors
[0]),
2472 sizeof(linux_error_names
) / sizeof(linux_error_names
[0]),
2474 sizeof(linux_signal_names
) / sizeof(linux_signal_names
[0]),
2478 /* Linux's os_emul interface, most are just passed on to the generic
2481 static os_emul_data
*
2482 emul_linux_create(device
*root
,
2486 /* check that this emulation is really for us */
2487 if (name
!= NULL
&& strcmp(name
, "linux") != 0)
2493 return emul_unix_create(root
, image
, "linux", &emul_linux_syscalls
);
2497 emul_linux_init(os_emul_data
*emul_data
,
2504 emul_linux_system_call(cpu
*processor
,
2506 os_emul_data
*emul_data
)
2508 emul_do_system_call(emul_data
,
2509 emul_data
->syscalls
,
2510 cpu_registers(processor
)->gpr
[0],
2511 3, /*r3 contains arg0*/
2516 const os_emul emul_linux
= {
2520 emul_linux_system_call
,
2521 0, /*instruction_call*/
2525 #endif /* _EMUL_UNIX_C_ */