gdb/
[deliverable/binutils-gdb.git] / gdb / armbsd-tdep.c
... / ...
CommitLineData
1/* Target-dependent code for ARM BSD's.
2
3 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
4 Free Software Foundation, Inc.
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 3 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, see <http://www.gnu.org/licenses/>. */
20
21#include "defs.h"
22#include "osabi.h"
23#include "regcache.h"
24#include "regset.h"
25
26#include "gdb_assert.h"
27#include "gdb_string.h"
28
29#include "arm-tdep.h"
30
31/* Core file support. */
32
33/* Sizeof `struct reg' in <machine/reg.h>. */
34#define ARMBSD_SIZEOF_GREGS (17 * 4)
35
36/* Sizeof `struct fpreg' in <machine/reg.h. */
37#define ARMBSD_SIZEOF_FPREGS ((1 + (8 * 3)) * 4)
38
39static int
40armbsd_fpreg_offset (int regnum)
41{
42 if (regnum == ARM_FPS_REGNUM)
43 return 0;
44
45 return 4 + (regnum - ARM_F0_REGNUM) * 12;
46}
47
48/* Supply register REGNUM from the buffer specified by FPREGS and LEN
49 in the floating-point register set REGSET to register cache
50 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
51
52static void
53armbsd_supply_fpregset (const struct regset *regset,
54 struct regcache *regcache,
55 int regnum, const void *fpregs, size_t len)
56{
57 const gdb_byte *regs = fpregs;
58 int i;
59
60 gdb_assert (len >= ARMBSD_SIZEOF_FPREGS);
61
62 for (i = ARM_F0_REGNUM; i <= ARM_FPS_REGNUM; i++)
63 {
64 if (regnum == i || regnum == -1)
65 regcache_raw_supply (regcache, i, regs + armbsd_fpreg_offset (i));
66 }
67}
68
69/* Supply register REGNUM from the buffer specified by GREGS and LEN
70 in the general-purpose register set REGSET to register cache
71 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
72
73static void
74armbsd_supply_gregset (const struct regset *regset,
75 struct regcache *regcache,
76 int regnum, const void *gregs, size_t len)
77{
78 const gdb_byte *regs = gregs;
79 int i;
80
81 gdb_assert (len >= ARMBSD_SIZEOF_GREGS);
82
83 for (i = ARM_A1_REGNUM; i <= ARM_PC_REGNUM; i++)
84 {
85 if (regnum == i || regnum == -1)
86 regcache_raw_supply (regcache, i, regs + i * 4);
87 }
88
89 if (regnum == ARM_PS_REGNUM || regnum == -1)
90 regcache_raw_supply (regcache, i, regs + 16 * 4);
91
92 if (len >= ARMBSD_SIZEOF_GREGS + ARMBSD_SIZEOF_FPREGS)
93 {
94 regs += ARMBSD_SIZEOF_GREGS;
95 len -= ARMBSD_SIZEOF_GREGS;
96 armbsd_supply_fpregset (regset, regcache, regnum, regs, len);
97 }
98}
99
100/* ARM register sets. */
101
102static struct regset armbsd_gregset =
103{
104 NULL,
105 armbsd_supply_gregset
106};
107
108static struct regset armbsd_fpregset =
109{
110 NULL,
111 armbsd_supply_fpregset
112};
113
114/* Return the appropriate register set for the core section identified
115 by SECT_NAME and SECT_SIZE. */
116
117const struct regset *
118armbsd_regset_from_core_section (struct gdbarch *gdbarch,
119 const char *sect_name, size_t sect_size)
120{
121 if (strcmp (sect_name, ".reg") == 0 && sect_size >= ARMBSD_SIZEOF_GREGS)
122 return &armbsd_gregset;
123
124 if (strcmp (sect_name, ".reg2") == 0 && sect_size >= ARMBSD_SIZEOF_FPREGS)
125 return &armbsd_fpregset;
126
127 return NULL;
128}
This page took 0.022696 seconds and 4 git commands to generate.