| 1 | /* Host-dependent code for Apollo-68ks for GDB, the GNU debugger. |
| 2 | Copyright 1986, 1987, 1989, 1991 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., 59 Temple Place - Suite 330, |
| 19 | Boston, MA 02111-1307, USA. */ |
| 20 | |
| 21 | #include "defs.h" |
| 22 | #include "inferior.h" |
| 23 | |
| 24 | #ifndef _ISP__M68K |
| 25 | #define _ISP__M68K 1 |
| 26 | #endif |
| 27 | |
| 28 | #include <ptrace.h> |
| 29 | |
| 30 | extern int errno; |
| 31 | |
| 32 | void |
| 33 | fetch_inferior_registers (int ignored) |
| 34 | { |
| 35 | struct ptrace_$data_regs_m68k inferior_registers; |
| 36 | struct ptrace_$floating_regs_m68k inferior_fp_registers; |
| 37 | struct ptrace_$control_regs_m68k inferior_control_registers; |
| 38 | |
| 39 | ptrace_$init_control (&inferior_control_registers); |
| 40 | inferior_fp_registers.size = sizeof (inferior_fp_registers); |
| 41 | |
| 42 | registers_fetched (); |
| 43 | |
| 44 | ptrace (PTRACE_GETREGS, inferior_pid, |
| 45 | (PTRACE_ARG3_TYPE) & inferior_registers, |
| 46 | ptrace_$data_set, |
| 47 | (PTRACE_ARG3_TYPE) & inferior_registers, |
| 48 | ptrace_$data_set); |
| 49 | |
| 50 | ptrace (PTRACE_GETREGS, inferior_pid, |
| 51 | (PTRACE_ARG3_TYPE) & inferior_fp_registers, |
| 52 | ptrace_$floating_set_m68k, |
| 53 | (PTRACE_ARG3_TYPE) & inferior_fp_registers, |
| 54 | ptrace_$floating_set_m68k); |
| 55 | |
| 56 | ptrace (PTRACE_GETREGS, inferior_pid, |
| 57 | (PTRACE_ARG3_TYPE) & inferior_control_registers, |
| 58 | ptrace_$control_set_m68k, |
| 59 | (PTRACE_ARG3_TYPE) & inferior_control_registers, |
| 60 | ptrace_$control_set_m68k); |
| 61 | |
| 62 | bcopy (&inferior_registers, registers, 16 * 4); |
| 63 | bcopy (&inferior_fp_registers, ®isters[REGISTER_BYTE (FP0_REGNUM)], |
| 64 | sizeof inferior_fp_registers.regs); |
| 65 | *(int *) ®isters[REGISTER_BYTE (PS_REGNUM)] = inferior_control_registers.sr; |
| 66 | *(int *) ®isters[REGISTER_BYTE (PC_REGNUM)] = inferior_control_registers.pc; |
| 67 | } |
| 68 | |
| 69 | /* Store our register values back into the inferior. |
| 70 | If REGNO is -1, do this for all registers. |
| 71 | Otherwise, REGNO specifies which register (so we can save time). */ |
| 72 | |
| 73 | void |
| 74 | store_inferior_registers (int regno) |
| 75 | { |
| 76 | struct ptrace_$data_regs_m68k inferior_registers; |
| 77 | struct ptrace_$floating_regs_m68k inferior_fp_registers; |
| 78 | struct ptrace_$control_regs_m68k inferior_control_registers; |
| 79 | |
| 80 | ptrace_$init_control (&inferior_control_registers); |
| 81 | inferior_fp_registers.size = sizeof (inferior_fp_registers); |
| 82 | |
| 83 | ptrace (PTRACE_GETREGS, inferior_pid, |
| 84 | (PTRACE_ARG3_TYPE) & inferior_fp_registers, |
| 85 | ptrace_$floating_set_m68k, |
| 86 | (PTRACE_ARG3_TYPE) & inferior_fp_registers, |
| 87 | ptrace_$floating_set_m68k); |
| 88 | |
| 89 | ptrace (PTRACE_GETREGS, inferior_pid, |
| 90 | (PTRACE_ARG3_TYPE) & inferior_control_registers, |
| 91 | ptrace_$control_set_m68k, |
| 92 | (PTRACE_ARG3_TYPE) & inferior_control_registers, |
| 93 | ptrace_$control_set_m68k); |
| 94 | |
| 95 | bcopy (registers, &inferior_registers, sizeof (inferior_registers)); |
| 96 | |
| 97 | bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)], inferior_fp_registers.regs, |
| 98 | sizeof inferior_fp_registers.regs); |
| 99 | |
| 100 | inferior_control_registers.sr = *(int *) ®isters[REGISTER_BYTE (PS_REGNUM)]; |
| 101 | inferior_control_registers.pc = *(int *) ®isters[REGISTER_BYTE (PC_REGNUM)]; |
| 102 | |
| 103 | ptrace (PTRACE_SETREGS, inferior_pid, |
| 104 | (PTRACE_ARG3_TYPE) & inferior_registers, |
| 105 | ptrace_$data_set_m68k, |
| 106 | (PTRACE_ARG3_TYPE) & inferior_registers, |
| 107 | ptrace_$data_set_m68k); |
| 108 | |
| 109 | ptrace (PTRACE_SETREGS, inferior_pid, |
| 110 | (PTRACE_ARG3_TYPE) & inferior_fp_registers, |
| 111 | ptrace_$floating_set_m68k, |
| 112 | (PTRACE_ARG3_TYPE) & inferior_fp_registers, |
| 113 | ptrace_$floating_set_m68k); |
| 114 | |
| 115 | ptrace (PTRACE_SETREGS, inferior_pid, |
| 116 | (PTRACE_ARG3_TYPE) & inferior_control_registers, |
| 117 | ptrace_$control_set_m68k, |
| 118 | (PTRACE_ARG3_TYPE) & inferior_control_registers, |
| 119 | ptrace_$control_set_m68k); |
| 120 | } |