mem.c 3.2 KB

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