]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/gdbserver/win32-arm-low.c
Update Copyright year range in all files maintained by GDB.
[thirdparty/binutils-gdb.git] / gdb / gdbserver / win32-arm-low.c
CommitLineData
ecd75fc8 1/* Copyright (C) 2007-2014 Free Software Foundation, Inc.
68070c10
PA
2
3 This file is part of GDB.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
a9762ec7 7 the Free Software Foundation; either version 3 of the License, or
68070c10
PA
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
a9762ec7 16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
68070c10
PA
17
18#include "server.h"
19#include "win32-low.h"
20
34b34921
PA
21#ifndef CONTEXT_FLOATING_POINT
22#define CONTEXT_FLOATING_POINT 0
23#endif
24
d05b4ac3
UW
25/* Defined in auto-generated file reg-arm.c. */
26void init_registers_arm (void);
3aee8918 27extern const struct target_desc *tdesc_arm;
d05b4ac3 28
68070c10 29static void
34b34921 30arm_get_thread_context (win32_thread_info *th, DEBUG_EVENT* current_event)
68070c10 31{
34b34921
PA
32 th->context.ContextFlags = \
33 CONTEXT_FULL | \
34 CONTEXT_FLOATING_POINT;
35
36 GetThreadContext (th->h, &th->context);
37}
38
39static void
40arm_set_thread_context (win32_thread_info *th, DEBUG_EVENT* current_event)
41{
42 SetThreadContext (th->h, &th->context);
68070c10
PA
43}
44
45#define context_offset(x) ((int)&(((CONTEXT *)NULL)->x))
46static const int mappings[] = {
47 context_offset (R0),
48 context_offset (R1),
49 context_offset (R2),
50 context_offset (R3),
51 context_offset (R4),
52 context_offset (R5),
53 context_offset (R6),
54 context_offset (R7),
55 context_offset (R8),
56 context_offset (R9),
57 context_offset (R10),
58 context_offset (R11),
59 context_offset (R12),
60 context_offset (Sp),
61 context_offset (Lr),
62 context_offset (Pc),
63 -1, /* f0 */
64 -1, /* f1 */
65 -1, /* f2 */
66 -1, /* f3 */
67 -1, /* f4 */
68 -1, /* f5 */
69 -1, /* f6 */
70 -1, /* f7 */
71 -1, /* fps */
72 context_offset (Psr),
73};
74#undef context_offset
75
34b34921
PA
76/* Return a pointer into a CONTEXT field indexed by gdb register number.
77 Return a pointer to an dummy register holding zero if there is no
78 corresponding CONTEXT field for the given register number. */
79static char *
80regptr (CONTEXT* c, int r)
81{
82 if (mappings[r] < 0)
83 {
84 static ULONG zero;
85 /* Always force value to zero, in case the user tried to write
86 to this register before. */
87 zero = 0;
88 return (char *) &zero;
89 }
90 else
91 return (char *) c + mappings[r];
92}
93
94/* Fetch register from gdbserver regcache data. */
95static void
442ea881
PA
96arm_fetch_inferior_register (struct regcache *regcache,
97 win32_thread_info *th, int r)
34b34921
PA
98{
99 char *context_offset = regptr (&th->context, r);
442ea881 100 supply_register (regcache, r, context_offset);
34b34921
PA
101}
102
103/* Store a new register value into the thread context of TH. */
104static void
442ea881
PA
105arm_store_inferior_register (struct regcache *regcache,
106 win32_thread_info *th, int r)
34b34921 107{
442ea881 108 collect_register (regcache, r, regptr (&th->context, r));
34b34921
PA
109}
110
3aee8918
PA
111static void
112arm_arch_setup (void)
113{
114 init_registers_arm ();
115 win32_tdesc = tdesc_arm;
116}
117
34b34921 118/* Correct in either endianness. We do not support Thumb yet. */
c5674cf1 119static const unsigned long arm_wince_breakpoint = 0xe6000010;
34b34921 120#define arm_wince_breakpoint_len 4
68070c10
PA
121
122struct win32_target_ops the_low_target = {
3aee8918 123 arm_arch_setup,
68070c10
PA
124 sizeof (mappings) / sizeof (mappings[0]),
125 NULL, /* initial_stuff */
34b34921
PA
126 arm_get_thread_context,
127 arm_set_thread_context,
128 NULL, /* thread_added */
129 arm_fetch_inferior_register,
130 arm_store_inferior_register,
68070c10 131 NULL, /* single_step */
34b34921
PA
132 (const unsigned char *) &arm_wince_breakpoint,
133 arm_wince_breakpoint_len,
aa5ca48f
DE
134 /* Watchpoint related functions. See target.h for comments. */
135 NULL, /* insert_point */
136 NULL, /* remove_point */
137 NULL, /* stopped_by_watchpoint */
138 NULL /* stopped_data_address */
68070c10 139};