sim_callbacks.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* This file is part of the program psim.
  2. Copyright (C) 1994-1995,1998, 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 _SIM_CALLBACKS_H_
  15. #define _SIM_CALLBACKS_H_
  16. /* Simulator output:
  17. Functions to report diagnostic information to the user. */
  18. #define printf_filtered sim_io_printf_filtered
  19. void sim_io_printf_filtered
  20. (const char *msg, ...) __attribute__ ((format (printf, 1, 2)));
  21. void NORETURN error
  22. (const char *msg, ...);
  23. /* External environment:
  24. Some HOST OS's require regular polling so that external events such
  25. as GUI io can be handled. */
  26. void sim_io_poll_quit
  27. (void);
  28. /* Model I/O:
  29. These functions provide the interface between the modeled targets
  30. standard input and output streams and the hosts external
  31. environment.
  32. The underlying model is responsible for co-ordinating I/O
  33. interactions such as:
  34. main()
  35. {
  36. const char mess[] = "Hello World\r\n";
  37. int out;
  38. out = dup(1);
  39. close(1);
  40. write(out, mess, sizeof(mess))
  41. }
  42. That is to say, the underlying model would, in implementing dup()
  43. recorded the fact that any output directed at fid-OUT should be
  44. displayed using sim_io_write_stdout(). While for the code stub:
  45. main()
  46. {
  47. const char mess[] = "Hello World\r\n";
  48. int out;
  49. close(1);
  50. out = open("output", 0x0001|0x0200, 0); // write+create
  51. out = dup(1);
  52. write(out, mess, sizeof(mess))
  53. }
  54. would result in output to fid-1 being directed towards the file
  55. "output". */
  56. int
  57. sim_io_write_stdout
  58. (const char *buf,
  59. int sizeof_buf);
  60. int
  61. sim_io_write_stderr
  62. (const char *buf,
  63. int sizeof_buf);
  64. /* read results */
  65. enum { sim_io_eof = -1, sim_io_not_ready = -2, }; /* See: IEEE 1275 */
  66. int
  67. sim_io_read_stdin
  68. (char *buf,
  69. int sizeof_buf);
  70. #define flush_stdoutput sim_io_flush_stdoutput
  71. void sim_io_flush_stdoutput
  72. (void);
  73. /* Simulator instance. */
  74. extern psim *simulator;
  75. /* Memory management with an allocator that clears memory before use. */
  76. void *zalloc
  77. (long size);
  78. #define ZALLOC(TYPE) (TYPE*)zalloc(sizeof (TYPE))
  79. #endif