/*- * Copyright (c) 1994-1996 Søren Schmidt * Copyright (c) 2013 Dmitry Chagin * Copyright (c) 2018 Turing Robotic Industries Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef _POWERPC_LINUX_H_ #define _POWERPC_LINUX_H_ #include #include #include #include #define LINUX_LEGACY_SYSCALLS #define LINUX_DTRACE linuxulator /* Provide a separate set of types for the Linux types */ typedef int32_t l_int; typedef int64_t l_long; typedef int16_t l_short; typedef uint32_t l_uint; typedef uint64_t l_ulong; typedef uint16_t l_ushort; typedef l_ulong l_uintptr_t; typedef l_long l_clock_t; typedef l_int l_daddr_t; typedef l_uint l_gid_t; typedef l_ushort l_gid16_t; /* XXX */ typedef l_uint l_uid_t; typedef l_ushort l_uid16_t; /* XXX */ typedef l_ulong l_ino_t; typedef l_int l_key_t; typedef l_long l_loff_t; typedef l_uint l_mode_t; typedef l_long l_off_t; typedef l_int l_pid_t; typedef l_ulong l_size_t; typedef l_long l_suseconds_t; typedef l_long l_time_t; typedef l_int l_timer_t; /* XXX */ typedef l_int l_mqd_t; typedef l_ulong l_fd_mask; #include typedef struct { l_int val[2]; } l_fsid_t; typedef struct { l_time_t tv_sec; l_suseconds_t tv_usec; } l_timeval; #define l_fd_set fd_set /* Miscellaneous */ #define LINUX_AT_COUNT 22 /* Count of used aux entry types. * Keep this synchronized with * linux_copyout_auxargs() code. */ struct l___sysctl_args { l_uintptr_t name; l_int nlen; l_uintptr_t oldval; l_uintptr_t oldlenp; l_uintptr_t newval; l_uintptr_t newlen; l_ulong __spare[4]; }; /* Resource limits */ #define LINUX_RLIMIT_CPU 0 #define LINUX_RLIMIT_FSIZE 1 #define LINUX_RLIMIT_DATA 2 #define LINUX_RLIMIT_STACK 3 #define LINUX_RLIMIT_CORE 4 #define LINUX_RLIMIT_RSS 5 #define LINUX_RLIMIT_NPROC 6 #define LINUX_RLIMIT_NOFILE 7 #define LINUX_RLIMIT_MEMLOCK 8 #define LINUX_RLIMIT_AS 9 /* Address space limit */ #define LINUX_RLIM_NLIMITS 10 struct l_rlimit { l_ulong rlim_cur; l_ulong rlim_max; }; /* stat family of syscalls */ struct l_timespec { l_ulong tv_sec; l_ulong tv_nsec; }; #define LINUX_O_DIRECTORY 040000 /* must be a directory */ #define LINUX_O_NOFOLLOW 0100000 /* don't follow links */ #define LINUX_O_LARGEFILE 0200000 #define LINUX_O_DIRECT 0400000 /* direct disk access hint */ /* Definitions for syscalls */ #define LINUX_FIRSTARG 3 /* first arg in reg 3 */ #define LINUX_NARGREG 8 /* 8 args in regs */ struct l_newstat { l_dev_t st_dev; l_ino_t st_ino; l_ulong st_nlink; l_uint st_mode; l_uid_t st_uid; l_gid_t st_gid; l_dev_t st_rdev; l_long st_size; l_ulong st_blksize; l_ulong st_blocks; struct l_timespec st_atim; struct l_timespec st_mtim; struct l_timespec st_ctim; l_ulong __unused1; l_ulong __unused2; l_ulong __unused3; }; struct l_statfs64 { l_int f_type; l_int f_bsize; uint64_t f_blocks; uint64_t f_bfree; uint64_t f_bavail; uint64_t f_files; uint64_t f_ffree; l_fsid_t f_fsid; l_int f_namelen; l_int f_frsize; l_int f_flags; l_int f_spare[4]; }; /* sigaction flags */ #define LINUX_SA_NOCLDSTOP 0x00000001 #define LINUX_SA_NOCLDWAIT 0x00000002 #define LINUX_SA_SIGINFO 0x00000004 #define LINUX_SA_UNSUPPORTED 0x00000400 #define LINUX_SA_EXPOSE_TAGBITS 0x00000800 #define LINUX_SA_RESTORER 0x04000000 #define LINUX_SA_ONSTACK 0x08000000 #define LINUX_SA_RESTART 0x10000000 #define LINUX_SA_INTERRUPT 0x20000000 /* XXX */ #define LINUX_SA_NOMASK 0x40000000 /* SA_NODEFER */ #define LINUX_SA_ONESHOT 0x80000000 /* SA_RESETHAND */ /* sigaltstack */ #define LINUX_MINSIGSTKSZ 8192 #define LINUX_SIGSTKSZ 32768 typedef void (*l_handler_t)(l_int); typedef struct { l_handler_t lsa_handler; l_ulong lsa_flags; l_uintptr_t lsa_restorer; l_sigset_t lsa_mask; } l_sigaction_t; /* XXX */ typedef struct { l_uintptr_t ss_sp; l_int ss_flags; l_size_t ss_size; } l_stack_t; union l_semun { l_int val; l_uintptr_t buf; l_uintptr_t array; l_uintptr_t __buf; l_uintptr_t __pad; }; #define linux_copyout_rusage(r, u) copyout(r, u, sizeof(*r)) struct reg; struct syscall_info; /* * Mirrors Linux ppc64's struct pt_regs (arch/powerpc/include/uapi/asm/ptrace.h): * 32 GPRs followed by NIP/MSR/... plus DSCR and a small pad to reach the * ELF gregset size (LINUX_ELF_NGREG = 48 unsigned longs). */ struct linux_pt_regset { l_ulong gpr[32]; /* PT_R0 .. PT_R31 (0..31) */ l_ulong nip; /* PT_NIP (32) */ l_ulong msr; /* PT_MSR (33) */ l_ulong orig_gpr3; /* PT_ORIG_R3 (34) */ l_ulong ctr; /* PT_CTR (35) */ l_ulong link; /* PT_LNK (36) */ l_ulong xer; /* PT_XER (37) */ l_ulong ccr; /* PT_CCR (38) */ l_ulong softe; /* PT_SOFTE (39, ppc64) */ l_ulong trap; /* PT_TRAP (40) */ l_ulong dar; /* PT_DAR (41) */ l_ulong dsisr; /* PT_DSISR (42) */ l_ulong result; /* PT_RESULT (43) */ l_ulong dscr; /* PT_DSCR (44) */ l_ulong _pad[3]; /* pad to LINUX_ELF_NGREG (48) */ }; #ifdef _KERNEL struct reg; struct syscall_info; void bsd_to_linux_regset(const struct reg *b_reg, struct linux_pt_regset *l_regset); void linux_to_bsd_regset(struct reg *b_reg, const struct linux_pt_regset *l_regset); void linux_ptrace_get_syscall_info_machdep(const struct reg *reg, struct syscall_info *si); int linux_ptrace_getregs_machdep(struct thread *td, pid_t pid, struct linux_pt_regset *l_regset); int linux_ptrace_peekuser(struct thread *td, pid_t pid, void *addr, void *data); int linux_ptrace_pokeuser(struct thread *td, pid_t pid, void *addr, void *data); #endif /* _KERNEL */ /* * termio * * The LINUX_IOC_* encoding lives in which is * pulled in by . The PowerPC-specific * TIOC ioctls below use the BSD-style _IO/_IOR/_IOW macros, which * matches how Linux ppc encodes them (see ). */ /* linux_tchars matches tchars (COMPAT_43TTY) */ struct linux_tchars { char t_intrc; char t_quitc; char t_startc; char t_stopc; char t_eofc; char t_brkc; }; struct linux_ltchars { char t_suspc; char t_dsuspc; char t_rprntc; char t_flushc; char t_werasc; char t_lnextc; }; #define LINUX_TCGETS_PPC _IOR('t', 19, struct linux_termios) #define LINUX_TCSETS_PPC _IOW('t', 20, struct linux_termios) #define LINUX_TCSETSW_PPC _IOW('t', 21, struct linux_termios) #define LINUX_TCSETSF_PPC _IOW('t', 22, struct linux_termios) #define LINUX_TCGETA_PPC _IOR('t', 23, struct linux_termio) #define LINUX_TCSETA_PPC _IOW('t', 24, struct linux_termio) #define LINUX_TCSETAW_PPC _IOW('t', 25, struct linux_termio) #define LINUX_TCSETAF_PPC _IOW('t', 28, struct linux_termio) #define LINUX_TCSBRK_PPC _IO('t', 29) #define LINUX_TCXONC_PPC _IO('t', 30) #define LINUX_TCFLSH_PPC _IO('t', 31) #define LINUX_TIOCSWINSZ_PPC _IOW('t', 103, struct linux_winsize) #define LINUX_TIOCGWINSZ_PPC _IOR('t', 104, struct linux_winsize) #define LINUX_TIOCSTART_PPC _IO('t', 110) #define LINUX_TIOCSTOP_PPC _IO('t', 111) #define LINUX_TIOCOUTQ_PPC _IOR('t', 115, int) #define LINUX_TIOCGLTC_PPC _IOR('t', 116, struct linux_ltchars) #define LINUX_TIOCSLTC_PPC _IOW('t', 117, struct linux_ltchars) #define LINUX_TIOCSPGRP_PPC _IOW('t', 118, int) #define LINUX_TIOCGPGRP_PPC _IOR('t', 119, int) #define LINUX_IOCTL_TERMIO_PPC_MIN LINUX_TCGETS_PPC #define LINUX_IOCTL_TERMIO_PPC_MAX LINUX_TIOCSPGRP_PPC struct l_func_desc { unsigned long addr; unsigned long toc; unsigned long env; }; #endif /* _POWERPC_LINUX_H_ */