Commit | Line | Data |
---|---|---|
c906108c SS |
1 | /* Motorola m68k native support for Linux |
2 | Copyright (C) 1996,1998 Free Software Foundation, Inc. | |
3 | ||
c5aa993b | 4 | This file is part of GDB. |
c906108c | 5 | |
c5aa993b JM |
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. | |
c906108c | 10 | |
c5aa993b JM |
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. | |
c906108c | 15 | |
c5aa993b JM |
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. */ | |
c906108c SS |
20 | |
21 | #include "defs.h" | |
22 | #include "frame.h" | |
23 | #include "inferior.h" | |
24 | #include "language.h" | |
25 | #include "gdbcore.h" | |
26 | ||
27 | #ifdef USG | |
28 | #include <sys/types.h> | |
29 | #endif | |
30 | ||
31 | #include <sys/param.h> | |
32 | #include <sys/dir.h> | |
33 | #include <signal.h> | |
34 | #include <sys/user.h> | |
35 | #include <sys/ioctl.h> | |
36 | #include <fcntl.h> | |
37 | #include <sys/procfs.h> | |
38 | ||
39 | #include <sys/file.h> | |
40 | #include "gdb_stat.h" | |
41 | ||
42 | #include "floatformat.h" | |
43 | ||
44 | #include "target.h" | |
c906108c | 45 | \f |
c5aa993b | 46 | |
c906108c | 47 | /* This table must line up with REGISTER_NAMES in tm-m68k.h */ |
c5aa993b | 48 | static const int regmap[] = |
c906108c SS |
49 | { |
50 | PT_D0, PT_D1, PT_D2, PT_D3, PT_D4, PT_D5, PT_D6, PT_D7, | |
51 | PT_A0, PT_A1, PT_A2, PT_A3, PT_A4, PT_A5, PT_A6, PT_USP, | |
52 | PT_SR, PT_PC, | |
53 | /* PT_FP0, ..., PT_FP7 */ | |
54 | 21, 24, 27, 30, 33, 36, 39, 42, | |
55 | /* PT_FPCR, PT_FPSR, PT_FPIAR */ | |
56 | 45, 46, 47 | |
57 | }; | |
58 | ||
59 | /* BLOCKEND is the value of u.u_ar0, and points to the place where GS | |
60 | is stored. */ | |
61 | ||
62 | int | |
fba45db2 | 63 | m68k_linux_register_u_addr (int blockend, int regnum) |
c906108c | 64 | { |
c5aa993b | 65 | return (blockend + 4 * regmap[regnum]); |
c906108c SS |
66 | } |
67 | ||
68 | /* Given a pointer to a general register set in /proc format (gregset_t *), | |
c5aa993b JM |
69 | unpack the register contents and supply them as gdb's idea of the current |
70 | register values. */ | |
c906108c SS |
71 | |
72 | ||
73 | /* Note both m68k-tdep.c and m68klinux-nat.c contain definitions | |
74 | for supply_gregset and supply_fpregset. The definitions | |
75 | in m68k-tdep.c are valid if USE_PROC_FS is defined. Otherwise, | |
76 | the definitions in m68klinux-nat.c will be used. This is a | |
77 | bit of a hack. The supply_* routines do not belong in | |
78 | *_tdep.c files. But, there are several lynx ports that currently | |
c5aa993b | 79 | depend on these definitions. */ |
c906108c SS |
80 | |
81 | #ifndef USE_PROC_FS | |
82 | ||
c60c0f5f MS |
83 | /* Prototypes for supply_gregset etc. */ |
84 | #include "gregset.h" | |
85 | ||
c906108c | 86 | void |
fba45db2 | 87 | supply_gregset (gregset_t *gregsetp) |
c906108c SS |
88 | { |
89 | int regi; | |
90 | ||
c5aa993b | 91 | for (regi = D0_REGNUM; regi <= SP_REGNUM; regi++) |
c906108c SS |
92 | supply_register (regi, (char *) (*gregsetp + regmap[regi])); |
93 | supply_register (PS_REGNUM, (char *) (*gregsetp + PT_SR)); | |
94 | supply_register (PC_REGNUM, (char *) (*gregsetp + PT_PC)); | |
95 | } | |
96 | ||
97 | /* Given a pointer to a floating point register set in /proc format | |
c5aa993b JM |
98 | (fpregset_t *), unpack the register contents and supply them as gdb's |
99 | idea of the current floating point register values. */ | |
c906108c | 100 | |
c5aa993b | 101 | void |
fba45db2 | 102 | supply_fpregset (fpregset_t *fpregsetp) |
c906108c SS |
103 | { |
104 | int regi; | |
105 | ||
c5aa993b | 106 | for (regi = FP0_REGNUM; regi < FPC_REGNUM; regi++) |
c906108c SS |
107 | supply_register (regi, (char *) &fpregsetp->fpregs[(regi - FP0_REGNUM) * 3]); |
108 | supply_register (FPC_REGNUM, (char *) &fpregsetp->fpcntl[0]); | |
109 | supply_register (FPS_REGNUM, (char *) &fpregsetp->fpcntl[1]); | |
110 | supply_register (FPI_REGNUM, (char *) &fpregsetp->fpcntl[2]); | |
111 | } | |
112 | ||
113 | #endif | |
c906108c | 114 | \f |
c5aa993b | 115 | |
c906108c | 116 | int |
fba45db2 | 117 | kernel_u_size (void) |
c906108c SS |
118 | { |
119 | return (sizeof (struct user)); | |
120 | } | |
121 | \f | |
122 | /* Return non-zero if PC points into the signal trampoline. */ | |
123 | ||
124 | int | |
fba45db2 | 125 | in_sigtramp (CORE_ADDR pc) |
c906108c SS |
126 | { |
127 | CORE_ADDR sp; | |
128 | char buf[TARGET_SHORT_BIT / TARGET_CHAR_BIT]; | |
129 | int insn; | |
130 | ||
131 | sp = read_register (SP_REGNUM); | |
132 | if (pc - 2 < sp) | |
133 | return 0; | |
134 | ||
135 | if (read_memory_nobpt (pc, buf, sizeof (buf))) | |
136 | return 0; | |
137 | insn = extract_unsigned_integer (buf, sizeof (buf)); | |
c5aa993b JM |
138 | if (insn == 0xdefc /* addaw #,sp */ |
139 | || insn == 0x7077 /* moveq #119,d0 */ | |
140 | || insn == 0x4e40 /* trap #0 */ | |
141 | || insn == 0x203c /* movel #,d0 */ ) | |
c906108c SS |
142 | return 1; |
143 | ||
144 | if (read_memory_nobpt (pc - 2, buf, sizeof (buf))) | |
145 | return 0; | |
146 | insn = extract_unsigned_integer (buf, sizeof (buf)); | |
c5aa993b JM |
147 | if (insn == 0xdefc /* addaw #,sp */ |
148 | || insn == 0x7077 /* moveq #119,d0 */ | |
149 | || insn == 0x4e40 /* trap #0 */ | |
150 | || insn == 0x203c /* movel #,d0 */ ) | |
c906108c SS |
151 | return 1; |
152 | ||
153 | return 0; | |
154 | } |