psim.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /* This file is part of the program psim.
  2. Copyright (C) 1994-1996, Andrew Cagney <cagney@highland.com.au>
  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. */
  14. #ifndef _PSIM_H_
  15. #define _PSIM_H_
  16. #include "basics.h"
  17. #include "sim/sim.h"
  18. /* the system object */
  19. /* typedef struct _psim psim; */
  20. /* typedef struct _device device; */
  21. /* when the `system' stops, find out why. FIXME - at this point this
  22. is really a bit puzzling. After all, how can there be a status
  23. when there several processors involved */
  24. typedef struct _psim_status {
  25. int cpu_nr;
  26. stop_reason reason;
  27. int signal;
  28. unsigned_word program_counter;
  29. } psim_status;
  30. /* create an initial device tree and then populate it using
  31. information obtained from either the command line or a file */
  32. extern device *psim_tree
  33. (void);
  34. extern char * const *psim_options
  35. (device *root,
  36. char * const *argv,
  37. SIM_OPEN_KIND kind);
  38. extern void psim_command
  39. (device *root,
  40. char * const *argv);
  41. extern void psim_merge_device_file
  42. (device *root,
  43. const char *file_name);
  44. extern void psim_usage
  45. (int verbose, int help, SIM_OPEN_KIND kind);
  46. /* create a new simulator from the device tree */
  47. extern psim *psim_create
  48. (const char *file_name,
  49. device *root);
  50. /* Given the created simulator (re) initialize it */
  51. extern void psim_init
  52. (psim *system);
  53. extern void psim_stack
  54. (psim *system,
  55. char * const *argv,
  56. char * const *envp);
  57. /* Run/stop the system */
  58. extern void psim_step
  59. (psim *system);
  60. extern void psim_run
  61. (psim *system);
  62. extern void psim_restart
  63. (psim *system,
  64. int cpu_nr);
  65. extern void psim_set_halt_and_restart
  66. (psim *system,
  67. void *halt_jmp_buf,
  68. void *restart_jmp_buf);
  69. extern void psim_clear_halt_and_restart
  70. (psim *system);
  71. extern void psim_stop
  72. (psim *system);
  73. extern void psim_halt
  74. (psim *system,
  75. int cpu_nr,
  76. stop_reason reason,
  77. int signal);
  78. extern int psim_last_cpu
  79. (psim *system);
  80. extern int psim_nr_cpus
  81. (psim *system);
  82. extern psim_status psim_get_status
  83. (psim *system);
  84. /* reveal the internals of the simulation. Grant access to the
  85. processor (cpu) device tree (device) and events (event_queue). */
  86. extern cpu *psim_cpu
  87. (psim *system,
  88. int cpu_nr);
  89. extern device *psim_device
  90. (psim *system,
  91. const char *path);
  92. extern event_queue *psim_event_queue
  93. (psim *system);
  94. /* Manipulate the state (registers or memory) of a processor within
  95. the system. In the case of memory, the read/write is performed
  96. using the specified processors address translation tables.
  97. Where applicable, WHICH_CPU == -1 indicates all processors and
  98. WHICH_CPU == <nr_cpus> indicates the `current' processor.
  99. The register functions return the size of the register, or 0 if the
  100. register's name is not recognized. */
  101. extern int psim_read_register
  102. (psim *system,
  103. int which_cpu,
  104. void *host_ordered_buf,
  105. const char reg[],
  106. transfer_mode mode);
  107. extern int psim_write_register
  108. (psim *system,
  109. int which_cpu,
  110. const void *buf,
  111. const char reg[],
  112. transfer_mode mode);
  113. extern unsigned psim_read_memory
  114. (psim *system,
  115. int which_cpu,
  116. void *buf,
  117. unsigned_word vaddr,
  118. unsigned len);
  119. extern unsigned psim_write_memory
  120. (psim *system,
  121. int which_cpu,
  122. const void *buf,
  123. unsigned_word vaddr,
  124. unsigned len,
  125. int violate_read_only_section);
  126. extern void psim_print_info
  127. (psim *system,
  128. int verbose);
  129. #endif /* _PSIM_H_ */