sim-reg.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* Generic register read/write.
  2. Copyright (C) 1998-2015 Free Software Foundation, Inc.
  3. Contributed by Cygnus Solutions.
  4. This file is part of GDB, the GNU debugger.
  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
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. #include "sim-main.h"
  16. #include "sim-assert.h"
  17. /* Generic implementation of sim_fetch_register for simulators using
  18. CPU_REG_FETCH.
  19. The contents of BUF are in target byte order. */
  20. /* ??? Obviously the interface needs to be extended to handle multiple
  21. cpus. */
  22. int
  23. sim_fetch_register (SIM_DESC sd, int rn, unsigned char *buf, int length)
  24. {
  25. SIM_CPU *cpu = STATE_CPU (sd, 0);
  26. SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
  27. return (* CPU_REG_FETCH (cpu)) (cpu, rn, buf, length);
  28. }
  29. /* Generic implementation of sim_store_register for simulators using
  30. CPU_REG_STORE.
  31. The contents of BUF are in target byte order. */
  32. /* ??? Obviously the interface needs to be extended to handle multiple
  33. cpus. */
  34. int
  35. sim_store_register (SIM_DESC sd, int rn, unsigned char *buf, int length)
  36. {
  37. SIM_CPU *cpu = STATE_CPU (sd, 0);
  38. SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
  39. return (* CPU_REG_STORE (cpu)) (cpu, rn, buf, length);
  40. }