vm.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /* This file is part of the program psim.
  2. Copyright (C) 1994-1997, 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 _VM_H_
  15. #define _VM_H_
  16. typedef struct _vm vm;
  17. typedef struct _vm_data_map vm_data_map;
  18. typedef struct _vm_instruction_map vm_instruction_map;
  19. /* each PowerPC requires two virtual memory maps */
  20. INLINE_VM\
  21. (vm *) vm_create
  22. (core *memory);
  23. INLINE_VM\
  24. (vm_data_map *) vm_create_data_map
  25. (vm *memory);
  26. INLINE_VM\
  27. (vm_instruction_map *) vm_create_instruction_map
  28. (vm *memory);
  29. /* address translation, if the translation is invalid
  30. these will not return */
  31. INLINE_VM\
  32. (unsigned_word) vm_real_data_addr
  33. (vm_data_map *data_map,
  34. unsigned_word ea,
  35. int is_read,
  36. cpu *processor,
  37. unsigned_word cia);
  38. INLINE_VM\
  39. (unsigned_word) vm_real_instruction_addr
  40. (vm_instruction_map *instruction_map,
  41. cpu *processor,
  42. unsigned_word cia);
  43. /* generic block transfers. Dependant on the presence of the
  44. PROCESSOR arg, either returns the number of bytes transfered or (if
  45. PROCESSOR is non NULL) aborts the simulation */
  46. INLINE_VM\
  47. (int) vm_data_map_read_buffer
  48. (vm_data_map *map,
  49. void *target,
  50. unsigned_word addr,
  51. unsigned len,
  52. cpu *processor,
  53. unsigned_word cia);
  54. INLINE_VM\
  55. (int) vm_data_map_write_buffer
  56. (vm_data_map *map,
  57. const void *source,
  58. unsigned_word addr,
  59. unsigned len,
  60. int violate_read_only_section,
  61. cpu *processor,
  62. unsigned_word cia);
  63. /* fetch the next instruction from memory */
  64. INLINE_VM\
  65. (instruction_word) vm_instruction_map_read
  66. (vm_instruction_map *instruction_map,
  67. cpu *processor,
  68. unsigned_word cia);
  69. /* read data from memory */
  70. #define DECLARE_VM_DATA_MAP_READ_N(N) \
  71. INLINE_VM\
  72. (unsigned_##N) vm_data_map_read_##N \
  73. (vm_data_map *map, \
  74. unsigned_word ea, \
  75. cpu *processor, \
  76. unsigned_word cia);
  77. DECLARE_VM_DATA_MAP_READ_N(1)
  78. DECLARE_VM_DATA_MAP_READ_N(2)
  79. DECLARE_VM_DATA_MAP_READ_N(4)
  80. DECLARE_VM_DATA_MAP_READ_N(8)
  81. DECLARE_VM_DATA_MAP_READ_N(word)
  82. /* write data to memory */
  83. #define DECLARE_VM_DATA_MAP_WRITE_N(N) \
  84. INLINE_VM\
  85. (void) vm_data_map_write_##N \
  86. (vm_data_map *map, \
  87. unsigned_word addr, \
  88. unsigned_##N val, \
  89. cpu *processor, \
  90. unsigned_word cia);
  91. DECLARE_VM_DATA_MAP_WRITE_N(1)
  92. DECLARE_VM_DATA_MAP_WRITE_N(2)
  93. DECLARE_VM_DATA_MAP_WRITE_N(4)
  94. DECLARE_VM_DATA_MAP_WRITE_N(8)
  95. DECLARE_VM_DATA_MAP_WRITE_N(word)
  96. /* update vm data structures due to a synchronization point */
  97. INLINE_VM\
  98. (void) vm_synchronize_context
  99. (vm *memory,
  100. spreg *sprs,
  101. sreg *srs,
  102. msreg msr,
  103. /**/
  104. cpu *processor,
  105. unsigned_word cia);
  106. /* update vm data structures due to a TLB operation */
  107. INLINE_VM\
  108. (void) vm_page_tlb_invalidate_entry
  109. (vm *memory,
  110. unsigned_word ea);
  111. INLINE_VM\
  112. (void) vm_page_tlb_invalidate_all
  113. (vm *memory);
  114. #endif