mem.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /* Hey EMACS -*- linux-c -*- */
  2. /* $Id: mem.c 2268 2006-11-06 17:18:51Z roms $ */
  3. /* TiEmu - Tiemu Is an EMUlator
  4. *
  5. * Copyright (c) 2000-2001, Thomas Corvazier, Romain Liévin
  6. * Copyright (c) 2001-2003, Romain Liévin
  7. * Copyright (c) 2003, Julien Blache
  8. * Copyright (c) 2004, Romain Liévin
  9. * Copyright (c) 2005, Romain Liévin, Kevin Kofler
  10. * Copyright (c) 2007, Kevin Kofler
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
  25. */
  26. /*
  27. Memory management: RAM, PROM/FLASH, I/O ports and bkpts
  28. */
  29. #include <stdlib.h>
  30. #include <stdio.h>
  31. #include <string.h>
  32. #include <math.h>
  33. #include "main.h"
  34. #include "mem.h"
  35. #include "ti68k_def.h"
  36. #include "mem89.h"
  37. #include "mem92.h"
  38. #include "mem92p.h"
  39. #include "mem89tm.h"
  40. #include "memv2.h"
  41. // 000000-0fffff : RAM (128 or 256 KB)
  42. // 100000-1fffff :
  43. // 200000-2fffff : internal ROM (TI92, TI89, V200) or unused
  44. // 300000-3fffff : idem
  45. // 400000-4fffff : external ROM (TI92, TI92-II, TI92+) or unused
  46. // 500000-5fffff : idem
  47. // 600000-6fffff : memory mapped I/O (all HW)
  48. // 700000-7fffff : memory mapped I/O (HW2, HW3)
  49. // 800000-8fffff : ROM (TI89 Titanium) or unused
  50. // 900000-9fffff : idem
  51. // a00000-afffff : idem
  52. // b00000-bfffff : idem
  53. // c00000-cfffff : unused
  54. // d00000-dfffff : ...
  55. // e00000-efffff : ...
  56. // d00000-ffffff : unused
  57. static GETBYTE_FUNC get_byte_ptr; // set on memXX.c or hwprot.c
  58. static GETWORD_FUNC get_word_ptr;
  59. static GETLONG_FUNC get_long_ptr;
  60. GETBYTE_FUNC mem_get_byte_ptr; // set by memXX.c:tiXX_mem_init
  61. GETWORD_FUNC mem_get_word_ptr;
  62. GETLONG_FUNC mem_get_long_ptr;
  63. REALADR_FUNC mem_get_real_addr_ptr;
  64. /* Mem init/exit */
  65. int hw_mem_init(void)
  66. {
  67. // set banks and mappers on per calc basis
  68. switch(calc_type)
  69. {
  70. case TI92: ti92_mem_init(); break;
  71. case TI92p: ti92p_mem_init(); break;
  72. case TI89: ti89_mem_init(); break;
  73. case V200: v200_mem_init(); break;
  74. case TI89t: ti89t_mem_init(); break;
  75. default: break;
  76. }
  77. get_byte_ptr = mem_get_byte_ptr;
  78. get_word_ptr = mem_get_word_ptr;
  79. get_long_ptr = mem_get_long_ptr;
  80. return 0;
  81. }
  82. uint8_t* hw_get_real_address(uint32_t adr)
  83. {
  84. return mem_get_real_addr_ptr(adr);
  85. }
  86. uint32_t hw_get_long(uint32_t adr)
  87. {
  88. adr &= 0xFFFFFF;
  89. return get_long_ptr(adr);
  90. }
  91. uint16_t hw_get_word(uint32_t adr)
  92. {
  93. adr &= 0xFFFFFF;
  94. return get_word_ptr(adr);
  95. }
  96. uint8_t hw_get_byte(uint32_t adr)
  97. {
  98. adr &= 0xFFFFFF;
  99. return get_byte_ptr(adr);
  100. }
  101. uint8_t hw_get_byte_noexcept(uint32_t adr)
  102. {
  103. adr &= 0xFFFFFF;
  104. return get_byte_ptr(adr);
  105. }