| 1 | /* Definitions to make GDB hosted on a tahoe running 4.3-Reno |
| 2 | Copyright (C) 1986, 1987, 1989, 1991 Free Software Foundation, Inc. |
| 3 | Contributed by the State University of New York at Buffalo, by the |
| 4 | Distributed Computer Systems Lab, Department of Computer Science, 1991. |
| 5 | |
| 6 | This file is part of GDB. |
| 7 | |
| 8 | This program is free software; you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation; either version 2 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | This program is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with this program; if not, write to the Free Software |
| 20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
| 21 | |
| 22 | /* Make sure the system include files define BIG_ENDIAN, UINT_MAX, const, |
| 23 | etc, rather than GDB's files. */ |
| 24 | #include <stdio.h> |
| 25 | #include <sys/param.h> |
| 26 | |
| 27 | /* Host is big-endian */ |
| 28 | |
| 29 | #define HOST_BYTE_ORDER BIG_ENDIAN |
| 30 | |
| 31 | /* Get rid of any system-imposed stack limit if possible. */ |
| 32 | |
| 33 | #define SET_STACK_LIMIT_HUGE |
| 34 | |
| 35 | #define REGISTER_U_ADDR(addr, blockend, regno) \ |
| 36 | { addr = blockend - 100 + regno * 4; \ |
| 37 | if (regno == PC_REGNUM) addr = blockend - 8; \ |
| 38 | if (regno == PS_REGNUM) addr = blockend - 4; \ |
| 39 | if (regno == FP_REGNUM) addr = blockend - 40; \ |
| 40 | if (regno == SP_REGNUM) addr = blockend - 36; \ |
| 41 | if (regno == AL_REGNUM) addr = blockend - 20; \ |
| 42 | if (regno == AH_REGNUM) addr = blockend - 24;} |
| 43 | |
| 44 | /* Interface definitions for kernel debugger KDB. */ |
| 45 | |
| 46 | /* Map machine fault codes into signal numbers. |
| 47 | First subtract 0, divide by 4, then index in a table. |
| 48 | Faults for which the entry in this table is 0 |
| 49 | are not handled by KDB; the program's own trap handler |
| 50 | gets to handle then. */ |
| 51 | |
| 52 | #define FAULT_CODE_ORIGIN 0 |
| 53 | #define FAULT_CODE_UNITS 4 |
| 54 | #define FAULT_TABLE \ |
| 55 | { 0, SIGKILL, SIGSEGV, 0, 0, 0, 0, 0, \ |
| 56 | 0, 0, SIGTRAP, SIGTRAP, 0, 0, 0, 0, \ |
| 57 | 0, 0, 0, 0, 0, 0, 0, 0} |
| 58 | |
| 59 | /* Start running with a stack stretching from BEG to END. |
| 60 | BEG and END should be symbols meaningful to the assembler. |
| 61 | This is used only for kdb. */ |
| 62 | |
| 63 | #define INIT_STACK(beg, end) \ |
| 64 | { asm (".globl end"); \ |
| 65 | asm ("movl $ end, sp"); \ |
| 66 | asm ("clrl fp"); } |
| 67 | |
| 68 | /* Push the frame pointer register on the stack. */ |
| 69 | |
| 70 | #define PUSH_FRAME_PTR \ |
| 71 | asm ("pushl fp"); |
| 72 | |
| 73 | /* Copy the top-of-stack to the frame pointer register. */ |
| 74 | |
| 75 | #define POP_FRAME_PTR \ |
| 76 | asm ("movl (sp), fp"); |
| 77 | |
| 78 | /* After KDB is entered by a fault, push all registers |
| 79 | that GDB thinks about (all NUM_REGS of them), |
| 80 | so that they appear in order of ascending GDB register number. |
| 81 | The fault code will be on the stack beyond the last register. */ |
| 82 | |
| 83 | #define PUSH_REGISTERS \ |
| 84 | { asm ("pushl 8(sp)"); \ |
| 85 | asm ("pushl 8(sp)"); \ |
| 86 | asm ("pushal 0x41(sp)"); \ |
| 87 | asm ("pushl r0" ); \ |
| 88 | asm ("pushl r1" ); \ |
| 89 | asm ("pushl r2" ); \ |
| 90 | asm ("pushl r3" ); \ |
| 91 | asm ("pushl r4" ); \ |
| 92 | asm ("pushl r5" ); \ |
| 93 | asm ("pushl r6" ); \ |
| 94 | asm ("pushl r7" ); \ |
| 95 | asm ("pushl r8" ); \ |
| 96 | asm ("pushl r9" ); \ |
| 97 | asm ("pushl r10" ); \ |
| 98 | asm ("pushl r11" ); \ |
| 99 | asm ("pushl r12" ); \ |
| 100 | asm ("pushl fp" ); \ |
| 101 | asm ("pushl sp" ); \ |
| 102 | asm ("pushl pc" ); \ |
| 103 | asm ("pushl ps" ); \ |
| 104 | asm ("pushl aclo" ); \ |
| 105 | asm ("pushl achi" ); \ |
| 106 | } |
| 107 | |
| 108 | /* Assuming the registers (including processor status) have been |
| 109 | pushed on the stack in order of ascending GDB register number, |
| 110 | restore them and return to the address in the saved PC register. */ |
| 111 | |
| 112 | #define POP_REGISTERS \ |
| 113 | { \ |
| 114 | asm ("movl (sp)+, achi"); \ |
| 115 | asm ("movl (sp)+, aclo"); \ |
| 116 | asm ("movl (sp)+, ps"); \ |
| 117 | asm ("movl (sp)+, pc"); \ |
| 118 | asm ("movl (sp)+, sp"); \ |
| 119 | asm ("movl (sp)+, fp"); \ |
| 120 | asm ("movl (sp)+, r12"); \ |
| 121 | asm ("movl (sp)+, r11"); \ |
| 122 | asm ("movl (sp)+, r10"); \ |
| 123 | asm ("movl (sp)+, r9"); \ |
| 124 | asm ("movl (sp)+, r8"); \ |
| 125 | asm ("movl (sp)+, r7"); \ |
| 126 | asm ("movl (sp)+, r6"); \ |
| 127 | asm ("movl (sp)+, r5"); \ |
| 128 | asm ("movl (sp)+, r4"); \ |
| 129 | asm ("movl (sp)+, r3"); \ |
| 130 | asm ("movl (sp)+, r2"); \ |
| 131 | asm ("movl (sp)+, r1"); \ |
| 132 | asm ("movl (sp)+, r0"); \ |
| 133 | asm ("subl2 $8,(sp)"); \ |
| 134 | asm ("movl (sp),sp"); \ |
| 135 | asm ("rei"); } |