2019-01-01 14:01:51 +08:00
|
|
|
/* Copyright (C) 1999-2019 Free Software Foundation, Inc.
|
2015-07-07 23:58:19 +08:00
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
|
2019-04-03 10:04:24 +08:00
|
|
|
#include "regcache.h"
|
2019-04-07 03:38:10 +08:00
|
|
|
#include "arm-tdep.h"
|
|
|
|
#include "arm-linux-tdep.h"
|
|
|
|
#include "arch/arm-linux.h"
|
|
|
|
|
|
|
|
#include "aarch32-linux-nat.h"
|
2015-07-07 23:58:19 +08:00
|
|
|
|
|
|
|
/* Supply GP registers contents, stored in REGS, to REGCACHE. ARM_APCS_32
|
|
|
|
is true if the 32-bit mode is in use, otherwise, it is false. */
|
|
|
|
|
|
|
|
void
|
|
|
|
aarch32_gp_regcache_supply (struct regcache *regcache, uint32_t *regs,
|
|
|
|
int arm_apcs_32)
|
|
|
|
{
|
|
|
|
int regno;
|
|
|
|
|
|
|
|
for (regno = ARM_A1_REGNUM; regno < ARM_PC_REGNUM; regno++)
|
2018-05-31 02:54:45 +08:00
|
|
|
regcache->raw_supply (regno, ®s[regno]);
|
2015-07-07 23:58:19 +08:00
|
|
|
|
|
|
|
if (arm_apcs_32)
|
2016-04-22 22:53:05 +08:00
|
|
|
{
|
|
|
|
/* Clear reserved bits bit 20 to bit 23. */
|
|
|
|
regs[ARM_CPSR_GREGNUM] &= 0xff0fffff;
|
2018-05-31 02:54:45 +08:00
|
|
|
regcache->raw_supply (ARM_PS_REGNUM, ®s[ARM_CPSR_GREGNUM]);
|
2016-04-22 22:53:05 +08:00
|
|
|
}
|
2015-07-07 23:58:19 +08:00
|
|
|
else
|
2018-05-31 02:54:45 +08:00
|
|
|
regcache->raw_supply (ARM_PS_REGNUM, ®s[ARM_PC_REGNUM]);
|
2015-07-07 23:58:19 +08:00
|
|
|
|
|
|
|
regs[ARM_PC_REGNUM] = gdbarch_addr_bits_remove
|
2017-10-25 23:37:03 +08:00
|
|
|
(regcache->arch (), regs[ARM_PC_REGNUM]);
|
2018-05-31 02:54:45 +08:00
|
|
|
regcache->raw_supply (ARM_PC_REGNUM, ®s[ARM_PC_REGNUM]);
|
2015-07-07 23:58:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Collect GP registers from REGCACHE to buffer REGS. ARM_APCS_32 is
|
|
|
|
true if the 32-bit mode is in use, otherwise, it is false. */
|
|
|
|
|
|
|
|
void
|
|
|
|
aarch32_gp_regcache_collect (const struct regcache *regcache, uint32_t *regs,
|
|
|
|
int arm_apcs_32)
|
|
|
|
{
|
|
|
|
int regno;
|
|
|
|
|
|
|
|
for (regno = ARM_A1_REGNUM; regno <= ARM_PC_REGNUM; regno++)
|
|
|
|
{
|
2018-05-31 02:54:35 +08:00
|
|
|
if (REG_VALID == regcache->get_register_status (regno))
|
2018-05-31 02:54:46 +08:00
|
|
|
regcache->raw_collect (regno, ®s[regno]);
|
2015-07-07 23:58:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (arm_apcs_32
|
2018-05-31 02:54:35 +08:00
|
|
|
&& REG_VALID == regcache->get_register_status (ARM_PS_REGNUM))
|
2016-09-16 21:58:31 +08:00
|
|
|
{
|
|
|
|
uint32_t cpsr = regs[ARM_CPSR_GREGNUM];
|
|
|
|
|
2018-05-31 02:54:46 +08:00
|
|
|
regcache->raw_collect (ARM_PS_REGNUM, ®s[ARM_CPSR_GREGNUM]);
|
2016-09-16 21:58:31 +08:00
|
|
|
/* Keep reserved bits bit 20 to bit 23. */
|
|
|
|
regs[ARM_CPSR_GREGNUM] = ((regs[ARM_CPSR_GREGNUM] & 0xff0fffff)
|
|
|
|
| (cpsr & 0x00f00000));
|
|
|
|
}
|
2015-07-07 23:58:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Supply VFP registers contents, stored in REGS, to REGCACHE.
|
|
|
|
VFP_REGISTER_COUNT is the number of VFP registers. */
|
|
|
|
|
|
|
|
void
|
|
|
|
aarch32_vfp_regcache_supply (struct regcache *regcache, gdb_byte *regs,
|
|
|
|
const int vfp_register_count)
|
|
|
|
{
|
|
|
|
int regno;
|
|
|
|
|
|
|
|
for (regno = 0; regno < vfp_register_count; regno++)
|
2018-05-31 02:54:45 +08:00
|
|
|
regcache->raw_supply (regno + ARM_D0_REGNUM, regs + regno * 8);
|
2015-07-07 23:58:19 +08:00
|
|
|
|
2018-05-31 02:54:45 +08:00
|
|
|
regcache->raw_supply (ARM_FPSCR_REGNUM, regs + 32 * 8);
|
2015-07-07 23:58:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Collect VFP registers from REGCACHE to buffer REGS.
|
|
|
|
VFP_REGISTER_COUNT is the number VFP registers. */
|
|
|
|
|
|
|
|
void
|
|
|
|
aarch32_vfp_regcache_collect (const struct regcache *regcache, gdb_byte *regs,
|
|
|
|
const int vfp_register_count)
|
|
|
|
{
|
|
|
|
int regno;
|
|
|
|
|
|
|
|
for (regno = 0; regno < vfp_register_count; regno++)
|
2018-05-31 02:54:46 +08:00
|
|
|
regcache->raw_collect (regno + ARM_D0_REGNUM, regs + regno * 8);
|
2015-07-07 23:58:19 +08:00
|
|
|
|
2018-05-31 02:54:46 +08:00
|
|
|
regcache->raw_collect (ARM_FPSCR_REGNUM, regs + 32 * 8);
|
2015-07-07 23:58:19 +08:00
|
|
|
}
|