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