psim.h 3.8 KB

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