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