| 1 | /* Definitions to make GDB run on an Altos 3068 (m68k running SVR2) |
| 2 | Copyright (C) 1987,1989 Free Software Foundation, Inc. |
| 3 | |
| 4 | This file is part of GDB. |
| 5 | |
| 6 | This program is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 2 of the License, or |
| 9 | (at your option) any later version. |
| 10 | |
| 11 | This program is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with this program; if not, write to the Free Software |
| 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
| 19 | |
| 20 | #define HOST_BYTE_ORDER BIG_ENDIAN |
| 21 | |
| 22 | /* The altos support would make a good base for a port to other USGR2 systems |
| 23 | (like the 3b1 and the Convergent miniframe). */ |
| 24 | |
| 25 | /* This is only needed in one file, but it's cleaner to put it here than |
| 26 | putting in more #ifdef's. */ |
| 27 | #include <sys/page.h> |
| 28 | #include <sys/net.h> |
| 29 | |
| 30 | #define USG |
| 31 | |
| 32 | #define HAVE_TERMIO |
| 33 | |
| 34 | #define CBREAK XTABS /* It takes all kinds... */ |
| 35 | |
| 36 | #ifndef R_OK |
| 37 | #define R_OK 4 |
| 38 | #define W_OK 2 |
| 39 | #define X_OK 1 |
| 40 | #define F_OK 0 |
| 41 | #endif |
| 42 | |
| 43 | /* Get sys/wait.h ie. from a Sun and edit it a little (mc68000 to m68k) */ |
| 44 | /* Why bother? */ |
| 45 | #if 0 |
| 46 | #define HAVE_WAIT_STRUCT |
| 47 | #endif |
| 48 | |
| 49 | /* This is the amount to subtract from u.u_ar0 |
| 50 | to get the offset in the core file of the register values. */ |
| 51 | |
| 52 | #define KERNEL_U_ADDR 0x1fbf000 |
| 53 | |
| 54 | #define REGISTER_U_ADDR(addr, blockend, regno) \ |
| 55 | { if (regno <= SP_REGNUM) \ |
| 56 | addr = blockend + regno * 4; \ |
| 57 | else if (regno == PS_REGNUM) \ |
| 58 | addr = blockend + regno * 4 + 4; \ |
| 59 | else if (regno == PC_REGNUM) \ |
| 60 | addr = blockend + regno * 4 + 2; \ |
| 61 | } |
| 62 | |
| 63 | #define REGISTER_ADDR(u_ar0, regno) \ |
| 64 | (((regno) < PS_REGNUM) \ |
| 65 | ? (&((struct exception_stack *) (u_ar0))->e_regs[(regno + R0)]) \ |
| 66 | : (((regno) == PS_REGNUM) \ |
| 67 | ? ((int *) (&((struct exception_stack *) (u_ar0))->e_PS)) \ |
| 68 | : (&((struct exception_stack *) (u_ar0))->e_PC))) |
| 69 | |
| 70 | #define FP_REGISTER_ADDR(u, regno) \ |
| 71 | (((char *) \ |
| 72 | (((regno) < FPC_REGNUM) \ |
| 73 | ? (&u.u_pcb.pcb_mc68881[FMC68881_R0 + (((regno) - FP0_REGNUM) * 3)]) \ |
| 74 | : (&u.u_pcb.pcb_mc68881[FMC68881_C + ((regno) - FPC_REGNUM)]))) \ |
| 75 | - ((char *) (& u))) |
| 76 | |
| 77 | \f |
| 78 | #ifndef __GNUC__ |
| 79 | #undef USE_GAS |
| 80 | #define ALTOS_AS |
| 81 | #else |
| 82 | #define USE_GAS |
| 83 | #endif |
| 84 | |
| 85 | /* Motorola assembly format */ |
| 86 | #if !defined(USE_GAS) && !defined(ALTOS) |
| 87 | #define MOTOROLA |
| 88 | #endif |
| 89 | |
| 90 | /* Interface definitions for kernel debugger KDB. */ |
| 91 | |
| 92 | /* Map machine fault codes into signal numbers. |
| 93 | First subtract 0, divide by 4, then index in a table. |
| 94 | Faults for which the entry in this table is 0 |
| 95 | are not handled by KDB; the program's own trap handler |
| 96 | gets to handle then. */ |
| 97 | |
| 98 | #define FAULT_CODE_ORIGIN 0 |
| 99 | #define FAULT_CODE_UNITS 4 |
| 100 | #define FAULT_TABLE \ |
| 101 | { 0, 0, 0, 0, SIGTRAP, 0, 0, 0, \ |
| 102 | 0, SIGTRAP, 0, 0, 0, 0, 0, SIGKILL, \ |
| 103 | 0, 0, 0, 0, 0, 0, 0, 0, \ |
| 104 | SIGILL } |
| 105 | |
| 106 | /* Start running with a stack stretching from BEG to END. |
| 107 | BEG and END should be symbols meaningful to the assembler. |
| 108 | This is used only for kdb. */ |
| 109 | |
| 110 | #ifdef MOTOROLA |
| 111 | #define INIT_STACK(beg, end) \ |
| 112 | { asm (".globl end"); \ |
| 113 | asm ("move.l $ end, sp"); \ |
| 114 | asm ("clr.l fp"); } |
| 115 | #else |
| 116 | #ifdef ALTOS_AS |
| 117 | #define INIT_STACK(beg, end) \ |
| 118 | { asm ("global end"); \ |
| 119 | asm ("mov.l &end,%sp"); \ |
| 120 | asm ("clr.l %fp"); } |
| 121 | #else |
| 122 | #define INIT_STACK(beg, end) \ |
| 123 | { asm (".globl end"); \ |
| 124 | asm ("movel $ end, sp"); \ |
| 125 | asm ("clrl fp"); } |
| 126 | #endif |
| 127 | #endif |
| 128 | |
| 129 | /* Push the frame pointer register on the stack. */ |
| 130 | #ifdef MOTOROLA |
| 131 | #define PUSH_FRAME_PTR \ |
| 132 | asm ("move.l fp, -(sp)"); |
| 133 | #else |
| 134 | #ifdef ALTOS_AS |
| 135 | #define PUSH_FRAME_PTR \ |
| 136 | asm ("mov.l %fp, -(%sp)"); |
| 137 | #else |
| 138 | #define PUSH_FRAME_PTR \ |
| 139 | asm ("movel fp, -(sp)"); |
| 140 | #endif |
| 141 | #endif |
| 142 | |
| 143 | /* Copy the top-of-stack to the frame pointer register. */ |
| 144 | #ifdef MOTOROLA |
| 145 | #define POP_FRAME_PTR \ |
| 146 | asm ("move.l (sp), fp"); |
| 147 | #else |
| 148 | #ifdef ALTOS_AS |
| 149 | #define POP_FRAME_PTR \ |
| 150 | asm ("mov.l (%sp), %fp"); |
| 151 | #else |
| 152 | #define POP_FRAME_PTR \ |
| 153 | asm ("movl (sp), fp"); |
| 154 | #endif |
| 155 | #endif |
| 156 | |
| 157 | /* After KDB is entered by a fault, push all registers |
| 158 | that GDB thinks about (all NUM_REGS of them), |
| 159 | so that they appear in order of ascending GDB register number. |
| 160 | The fault code will be on the stack beyond the last register. */ |
| 161 | |
| 162 | #ifdef MOTOROLA |
| 163 | #define PUSH_REGISTERS \ |
| 164 | { asm ("clr.w -(sp)"); \ |
| 165 | asm ("pea (10,sp)"); \ |
| 166 | asm ("movem $ 0xfffe,-(sp)"); } |
| 167 | #else |
| 168 | #ifdef ALTOS_AS |
| 169 | #define PUSH_REGISTERS \ |
| 170 | { asm ("clr.w -(%sp)"); \ |
| 171 | asm ("pea (10,%sp)"); \ |
| 172 | asm ("movm.l &0xfffe,-(%sp)"); } |
| 173 | #else |
| 174 | #define PUSH_REGISTERS \ |
| 175 | { asm ("clrw -(sp)"); \ |
| 176 | asm ("pea 10(sp)"); \ |
| 177 | asm ("movem $ 0xfffe,-(sp)"); } |
| 178 | #endif |
| 179 | #endif |
| 180 | |
| 181 | /* Assuming the registers (including processor status) have been |
| 182 | pushed on the stack in order of ascending GDB register number, |
| 183 | restore them and return to the address in the saved PC register. */ |
| 184 | |
| 185 | #ifdef MOTOROLA |
| 186 | #define POP_REGISTERS \ |
| 187 | { asm ("subi.l $8,28(sp)"); \ |
| 188 | asm ("movem (sp),$ 0xffff"); \ |
| 189 | asm ("rte"); } |
| 190 | #else |
| 191 | #ifdef ALTOS_AS |
| 192 | #define POP_REGISTERS \ |
| 193 | { asm ("sub.l &8,28(%sp)"); \ |
| 194 | asm ("movem (%sp),&0xffff"); \ |
| 195 | asm ("rte"); } |
| 196 | #else |
| 197 | #define POP_REGISTERS \ |
| 198 | { asm ("subil $8,28(sp)"); \ |
| 199 | asm ("movem (sp),$ 0xffff"); \ |
| 200 | asm ("rte"); } |
| 201 | #endif |
| 202 | #endif |