netbsd-aarch64-low.cc 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /* Copyright (C) 2020-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 <sys/types.h>
  14. #include <sys/ptrace.h>
  15. #include <limits.h>
  16. #include "server.h"
  17. #include "netbsd-low.h"
  18. #include "arch/aarch64.h"
  19. #include "arch/aarch64-insn.h"
  20. #include "tdesc.h"
  21. /* The fill_function for the general-purpose register set. */
  22. static void
  23. netbsd_aarch64_fill_gregset (struct regcache *regcache, char *buf)
  24. {
  25. struct reg *r = (struct reg *) buf;
  26. #define netbsd_aarch64_collect_gp(regnum, fld) do { \
  27. collect_register (regcache, regnum, &r->fld); \
  28. } while (0)
  29. for (size_t i = 0; i < ARRAY_SIZE (r->r_reg); i++)
  30. netbsd_aarch64_collect_gp (AARCH64_X0_REGNUM + i, r_reg[i]);
  31. netbsd_aarch64_collect_gp (AARCH64_SP_REGNUM, r_sp);
  32. netbsd_aarch64_collect_gp (AARCH64_PC_REGNUM, r_pc);
  33. }
  34. /* The store_function for the general-purpose register set. */
  35. static void
  36. netbsd_aarch64_store_gregset (struct regcache *regcache, const char *buf)
  37. {
  38. struct reg *r = (struct reg *) buf;
  39. #define netbsd_aarch64_supply_gp(regnum, fld) do { \
  40. supply_register (regcache, regnum, &r->fld); \
  41. } while(0)
  42. for (size_t i = 0; i < ARRAY_SIZE (r->r_reg); i++)
  43. netbsd_aarch64_supply_gp (AARCH64_X0_REGNUM + i, r_reg[i]);
  44. netbsd_aarch64_supply_gp (AARCH64_SP_REGNUM, r_sp);
  45. netbsd_aarch64_supply_gp (AARCH64_PC_REGNUM, r_pc);
  46. }
  47. /* Description of all the aarch64-netbsd register sets. */
  48. static const struct netbsd_regset_info netbsd_target_regsets[] =
  49. {
  50. /* General Purpose Registers. */
  51. {PT_GETREGS, PT_SETREGS, sizeof (struct reg),
  52. netbsd_aarch64_fill_gregset, netbsd_aarch64_store_gregset},
  53. /* End of list marker. */
  54. {0, 0, -1, NULL, NULL }
  55. };
  56. /* NetBSD target op definitions for the aarch64 architecture. */
  57. class netbsd_aarch64_target : public netbsd_process_target
  58. {
  59. protected:
  60. const netbsd_regset_info *get_regs_info () override;
  61. void low_arch_setup () override;
  62. };
  63. /* Return the information to access registers. */
  64. const netbsd_regset_info *
  65. netbsd_aarch64_target::get_regs_info ()
  66. {
  67. return netbsd_target_regsets;
  68. }
  69. /* Architecture-specific setup for the current process. */
  70. void
  71. netbsd_aarch64_target::low_arch_setup ()
  72. {
  73. target_desc *tdesc
  74. = aarch64_create_target_description (0, false);
  75. static const char *expedite_regs_aarch64[] = { "x29", "sp", "pc", NULL };
  76. init_target_desc (tdesc, expedite_regs_aarch64);
  77. current_process ()->tdesc = tdesc;
  78. }
  79. /* The singleton target ops object. */
  80. static netbsd_aarch64_target the_netbsd_aarch64_target;
  81. /* The NetBSD target ops object. */
  82. netbsd_process_target *the_netbsd_target = &the_netbsd_aarch64_target;