Home | History | Annotate | Line # | Download | only in powerpc
linux_machdep.h revision 1.6
      1 /*	$NetBSD: linux_machdep.h,v 1.6 2005/02/26 23:10:19 perry Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 1995, 2000, 2001 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Frank van der Linden and Emmanuel Dreyfus.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *	This product includes software developed by the NetBSD
     21  *	Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 #ifndef _POWERPC_LINUX_MACHDEP_H
     40 #define _POWERPC_LINUX_MACHDEP_H
     41 
     42 #include <compat/linux/common/linux_signal.h>
     43 
     44 /*
     45  * From Linux's include/asm-ppc/ptrace.h
     46  * Needed for sigcontext
     47  */
     48 struct linux_pt_regs {
     49 #define lpt_regs_fixreg_begin lgpr[0]
     50 	unsigned long lgpr[32];
     51 #define lpt_regs_fixreg_end lgpr[31]
     52 	unsigned long lnip;
     53 	unsigned long lmsr;
     54 	unsigned long lorig_gpr3;	/* Used for restarting system calls */
     55 	unsigned long lctr;
     56 	unsigned long llink;
     57 	unsigned long lxer;
     58 	unsigned long lccr;
     59 	unsigned long lmq;	 	/* 601 only (not used at present) */
     60 	/* Used on APUS to hold IPL value. */
     61 	unsigned long ltrap;	 	/* Reason for being here */
     62 	unsigned long ldar;	 	/* Fault registers */
     63 	unsigned long ldsisr;
     64 	unsigned long lresult;	/* Result of a system call */
     65 };
     66 
     67 /*
     68  * From Linux's include/asm-ppc/sigcontext.h
     69  * Linux/ppc calls that struct sigcontect_struct
     70  */
     71 struct linux_sigcontext {
     72 	unsigned long _unused[4];
     73 	int lsignal;
     74 	unsigned long lhandler;
     75 	unsigned long lmask;
     76 	struct linux_pt_regs	*lregs;
     77 };
     78 
     79 /*
     80  * From Linux's include/asm-ppc/elf.h
     81  */
     82 #define LINUX_ELF_NGREG 48		 	/* includes nip, msr, lr, etc. */
     83 #define LINUX_ELF_NFPREG 33		/* includes fpscr */
     84 typedef unsigned long linux_elf_greg_t;
     85 typedef linux_elf_greg_t linux_elf_gregset_t[LINUX_ELF_NGREG];
     86 
     87 /*
     88  * From Linux's include/asm-ppc/ptrace.h
     89  */
     90 #define LINUX__SIGNAL_FRAMESIZE 64
     91 
     92 /*
     93  * We make the stack look like Linux expects it when calling a signal
     94  * handler, but use the BSD way of calling the handler and sigreturn().
     95  * This means that we need to pass the pointer to the handler too.
     96  * It is appended to the frame to not interfere with the rest of it.
     97  *
     98  * The following is from Linux's arch/ppc/kern/signal.c:
     99  *
    100  * > When we have signals to deliver, we set up on the
    101  * > user stack, going down from the original stack pointer:
    102  * > a sigregs struct
    103  * > one or more sigcontext structs with
    104  * > a gap of LINUX__SIGNAL_FRAMESIZE bytes
    105  * >
    106  * > Each of these things must be a multiple of 16 bytes in size.
    107  *
    108  * linux_sigregs is a linux_sigframe on other Linux ports. Linux/PowerPC
    109  * defines a rt_sigframe struct, but it is only used for RT signals. for
    110  * non RT signals, struct sigregs is used instead.
    111  *
    112  * About the ltramp filed: that trampoline code is not used. Instead, the
    113  * sigcode (7 bytes long) trampoline code, copied by exec() on program startup
    114  * is used. However, Linux binaries might expect it to be here.
    115  */
    116 struct linux_sigregs {
    117 	linux_elf_gregset_t lgp_regs;
    118 	double lfp_regs[LINUX_ELF_NFPREG];
    119 	unsigned long ltramp[2];
    120 	/*
    121 	 * Programs using the rs6000/xcoff abi can save up to 19 gp regs
    122 	 * and 18 fp regs below sp before decrementing it.
    123 	 */
    124 	int labigap[56];
    125 };
    126 
    127 /*
    128  * The following is not from Linux, we define it for convenience. It is the
    129  * size of the abigap field of linux_sigregs.
    130  */
    131 #define LINUX_ABIGAP	(56*sizeof(int))
    132 
    133 /*
    134  * linux sigframe in a nutshell (however we don't use it):
    135  *
    136  * struct linux_sigframe {
    137  *		char _gap[LINUX__SIGNAL_FRAMESIZE];
    138  *		struct sigcontext lsc;
    139  *		struct linux_sigregs	lsg;
    140  * };
    141  */
    142 
    143 /*
    144  * From Linux's include/asm-ppc/ucontext.h
    145  */
    146 struct linux_ucontext {
    147 	unsigned long luc_flags;
    148 	struct linux_ucontext *luc_link;
    149 	linux_stack_t	luc_stack;
    150 	struct linux_sigcontext luc_context;
    151 	linux_sigset_t	luc_sigmask;  /* mask last for extensibility */
    152 };
    153 
    154 /*
    155  * From Linux's arch/ppc/kernel/signal.c, the real rt_sigframe
    156  */
    157 struct linux_rt_sigframe
    158 {
    159 	unsigned long  _unused[2];
    160 	struct linux_siginfo *lpinfo;
    161 	void *lpuc;
    162 	struct linux_siginfo linfo;
    163 	struct linux_ucontext luc;
    164 };
    165 
    166 /*
    167  * Major device numbers of VT device on both Linux and NetBSD. Used in
    168  * ugly patch to fake device numbers.
    169  *
    170  * LINUX_CONS_MAJOR is from Linux's include/linux/major.h
    171  */
    172 #define LINUX_CONS_MAJOR 4
    173 
    174 /*
    175  * Linux ioctl calls for the keyboard.
    176  *
    177  * From Linux's include/linux/kd.h
    178  */
    179 #define LINUX_KDGKBMODE	0x4b44
    180 #define LINUX_KDSKBMODE	0x4b45
    181 #define LINUX_KDMKTONE	0x4b30
    182 #define LINUX_KDSETMODE	0x4b3a
    183 #define LINUX_KDENABIO	0x4b36
    184 #define LINUX_KDDISABIO	0x4b37
    185 #define LINUX_KDGETLED	0x4b31
    186 #define LINUX_KDSETLED	0x4b32
    187 #define LINUX_KDGKBTYPE	0x4B33
    188 #define LINUX_KDGKBENT	0x4B46
    189 
    190 /*
    191  * Mode for KDSKBMODE which we don't have (we just use plain mode for this)
    192  *
    193  * From Linux's include/linux/kd.h
    194  */
    195 #define LINUX_K_MEDIUMRAW 2
    196 
    197 /*
    198  * VT ioctl calls in Linux (the ones that the pcvt emulation in
    199  * wscons can handle)
    200  *
    201  * From Linux's include/linux/vt.h
    202  */
    203 #define LINUX_VT_OPENQRY	0x5600
    204 #define LINUX_VT_GETMODE	0x5601
    205 #define LINUX_VT_SETMODE	0x5602
    206 #define LINUX_VT_GETSTATE	0x5603
    207 #define LINUX_VT_RELDISP	0x5605
    208 #define LINUX_VT_ACTIVATE	0x5606
    209 #define LINUX_VT_WAITACTIVE 	0x5607
    210 #define LINUX_VT_DISALLOCATE	0x5608
    211 
    212 /*
    213  * This range used by VMWare (XXX)
    214  *
    215  * From Linux's include/linux/vt.h
    216  * XXX It's not sure this s needed for powerpc
    217  */
    218 #define LINUX_VMWARE_NONE 200
    219 #define LINUX_VMWARE_LAST 237
    220 
    221 /*
    222  * Range of ioctls to just pass on, so that LKMs (like VMWare) can
    223  * handle them.
    224  *
    225  * From Linux's include/linux/vt.h
    226  */
    227 #define LINUX_IOCTL_MIN_PASS LINUX_VMWARE_NONE
    228 #define LINUX_IOCTL_MAX_PASS (LINUX_VMWARE_LAST+8)
    229 
    230 #ifdef _KERNEL
    231 __BEGIN_DECLS /* XXX from NetBSD/i386. Not arch dependent? */
    232 void linux_syscall_intern __P((struct proc *));
    233 __END_DECLS
    234 #endif /* !_KERNEL */
    235 
    236 
    237 #endif /* _POWERPC_LINUX_MACHDEP_H */
    238