* alpha-tdep.c (alpha_register_to_value, alpha_value_to_register)
[deliverable/binutils-gdb.git] / gdb / armbsd-tdep.c
CommitLineData
47ccd048
MK
1/* Target-dependent code for ARM BSD's.
2
3 Copyright (C) 2006 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. */
21
22#include "defs.h"
23#include "osabi.h"
24#include "regcache.h"
25#include "regset.h"
26
27#include "gdb_assert.h"
28#include "gdb_string.h"
29
30#include "arm-tdep.h"
31
32/* Core file support. */
33
34/* Sizeof `struct reg' in <machine/reg.h>. */
35#define ARMBSD_SIZEOF_GREGS (17 * 4)
36
37/* Sizeof `struct fpreg' in <machine/reg.h. */
38#define ARMBSD_SIZEOF_FPREGS ((1 + (8 * 3)) * 4)
39
40int
41armbsd_fpreg_offset (int regnum)
42{
43 if (regnum == ARM_FPS_REGNUM)
44 return 0;
45
46 return 4 + (regnum - ARM_F0_REGNUM) * 12;
47}
48
49/* Supply register REGNUM from the buffer specified by FPREGS and LEN
50 in the floating-point register set REGSET to register cache
51 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
52
53static void
54armbsd_supply_fpregset (const struct regset *regset,
55 struct regcache *regcache,
56 int regnum, const void *fpregs, size_t len)
57{
58 const gdb_byte *regs = fpregs;
59 int i;
60
61 gdb_assert (len >= ARMBSD_SIZEOF_FPREGS);
62
63 for (i = ARM_F0_REGNUM; i <= ARM_FPS_REGNUM; i++)
64 {
65 if (regnum == i || regnum == -1)
66 regcache_raw_supply (regcache, i, regs + armbsd_fpreg_offset (i));
67 }
68}
69
70/* Supply register REGNUM from the buffer specified by GREGS and LEN
71 in the general-purpose register set REGSET to register cache
72 REGCACHE. If REGNUM is -1, do this for all registers in REGSET. */
73
74static void
75armbsd_supply_gregset (const struct regset *regset,
76 struct regcache *regcache,
77 int regnum, const void *gregs, size_t len)
78{
79 const gdb_byte *regs = gregs;
80 int i;
81
82 gdb_assert (len >= ARMBSD_SIZEOF_GREGS);
83
84 for (i = ARM_A1_REGNUM; i <= ARM_PC_REGNUM; i++)
85 {
86 if (regnum == i || regnum == -1)
87 regcache_raw_supply (regcache, i, regs + i * 4);
88 }
89
90 if (regnum == ARM_PS_REGNUM || regnum == -1)
91 regcache_raw_supply (regcache, i, regs + 16 * 4);
92
93 if (len >= ARMBSD_SIZEOF_GREGS + ARMBSD_SIZEOF_FPREGS)
94 {
95 regs += ARMBSD_SIZEOF_GREGS;
96 len -= ARMBSD_SIZEOF_GREGS;
97 armbsd_supply_fpregset (regset, regcache, regnum, regs, len);
98 }
99}
100
101/* ARM register sets. */
102
103static struct regset armbsd_gregset =
104{
105 NULL,
106 armbsd_supply_gregset
107};
108
109static struct regset armbsd_fpregset =
110{
111 NULL,
112 armbsd_supply_fpregset
113};
114
115/* Return the appropriate register set for the core section identified
116 by SECT_NAME and SECT_SIZE. */
117
118const struct regset *
119armbsd_regset_from_core_section (struct gdbarch *gdbarch,
120 const char *sect_name, size_t sect_size)
121{
122 if (strcmp (sect_name, ".reg") == 0 && sect_size >= ARMBSD_SIZEOF_GREGS)
123 return &armbsd_gregset;
124
125 if (strcmp (sect_name, ".reg2") == 0 && sect_size >= ARMBSD_SIZEOF_FPREGS)
126 return &armbsd_fpregset;
127
128 return NULL;
129}
This page took 0.028675 seconds and 4 git commands to generate.