aarch32-linux-nat.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* Copyright (C) 1999-2022 Free Software Foundation, Inc.
  2. This file is part of GDB.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. #include "defs.h"
  14. #include "regcache.h"
  15. #include "arm-tdep.h"
  16. #include "arm-linux-tdep.h"
  17. #include "arch/arm-linux.h"
  18. #include "aarch32-linux-nat.h"
  19. /* Supply GP registers contents, stored in REGS, to REGCACHE. ARM_APCS_32
  20. is true if the 32-bit mode is in use, otherwise, it is false. */
  21. void
  22. aarch32_gp_regcache_supply (struct regcache *regcache, uint32_t *regs,
  23. int arm_apcs_32)
  24. {
  25. int regno;
  26. for (regno = ARM_A1_REGNUM; regno < ARM_PC_REGNUM; regno++)
  27. regcache->raw_supply (regno, &regs[regno]);
  28. if (arm_apcs_32)
  29. {
  30. /* Clear reserved bits bit 20 to bit 23. */
  31. regs[ARM_CPSR_GREGNUM] &= 0xff0fffff;
  32. regcache->raw_supply (ARM_PS_REGNUM, &regs[ARM_CPSR_GREGNUM]);
  33. }
  34. else
  35. regcache->raw_supply (ARM_PS_REGNUM, &regs[ARM_PC_REGNUM]);
  36. regs[ARM_PC_REGNUM] = gdbarch_addr_bits_remove
  37. (regcache->arch (), regs[ARM_PC_REGNUM]);
  38. regcache->raw_supply (ARM_PC_REGNUM, &regs[ARM_PC_REGNUM]);
  39. }
  40. /* Collect GP registers from REGCACHE to buffer REGS. ARM_APCS_32 is
  41. true if the 32-bit mode is in use, otherwise, it is false. */
  42. void
  43. aarch32_gp_regcache_collect (const struct regcache *regcache, uint32_t *regs,
  44. int arm_apcs_32)
  45. {
  46. int regno;
  47. for (regno = ARM_A1_REGNUM; regno <= ARM_PC_REGNUM; regno++)
  48. {
  49. if (REG_VALID == regcache->get_register_status (regno))
  50. regcache->raw_collect (regno, &regs[regno]);
  51. }
  52. if (arm_apcs_32
  53. && REG_VALID == regcache->get_register_status (ARM_PS_REGNUM))
  54. {
  55. uint32_t cpsr = regs[ARM_CPSR_GREGNUM];
  56. regcache->raw_collect (ARM_PS_REGNUM, &regs[ARM_CPSR_GREGNUM]);
  57. /* Keep reserved bits bit 20 to bit 23. */
  58. regs[ARM_CPSR_GREGNUM] = ((regs[ARM_CPSR_GREGNUM] & 0xff0fffff)
  59. | (cpsr & 0x00f00000));
  60. }
  61. }
  62. /* Supply VFP registers contents, stored in REGS, to REGCACHE.
  63. VFP_REGISTER_COUNT is the number of VFP registers. */
  64. void
  65. aarch32_vfp_regcache_supply (struct regcache *regcache, gdb_byte *regs,
  66. const int vfp_register_count)
  67. {
  68. int regno;
  69. for (regno = 0; regno < vfp_register_count; regno++)
  70. regcache->raw_supply (regno + ARM_D0_REGNUM, regs + regno * 8);
  71. regcache->raw_supply (ARM_FPSCR_REGNUM, regs + 32 * 8);
  72. }
  73. /* Collect VFP registers from REGCACHE to buffer REGS.
  74. VFP_REGISTER_COUNT is the number VFP registers. */
  75. void
  76. aarch32_vfp_regcache_collect (const struct regcache *regcache, gdb_byte *regs,
  77. const int vfp_register_count)
  78. {
  79. int regno;
  80. for (regno = 0; regno < vfp_register_count; regno++)
  81. regcache->raw_collect (regno + ARM_D0_REGNUM, regs + regno * 8);
  82. regcache->raw_collect (ARM_FPSCR_REGNUM, regs + 32 * 8);
  83. }