memory.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* sd2snes - SD card based universal cartridge for the SNES
  2. Copyright (C) 2009-2010 Maximilian Rehkopf <otakon@gmx.net>
  3. AVR firmware portion
  4. Inspired by and based on code from sd2iec, written by Ingo Korb et al.
  5. See sdcard.c|h, config.h.
  6. FAT file system access based on code by ChaN, Jim Brain, Ingo Korb,
  7. see ff.c|h.
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; version 2 of the License only.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. memory.h: RAM operations
  19. */
  20. #ifndef MEMORY_H
  21. #define MEMORY_H
  22. #include <arm/NXP/LPC17xx/LPC17xx.h>
  23. #include "smc.h"
  24. #define SRAM_ROM_ADDR (0x000000L)
  25. #define SRAM_SAVE_ADDR (0xE00000L)
  26. #define SRAM_MENU_ADDR (0xE00000L)
  27. #define SRAM_DB_ADDR (0xE20000L)
  28. #define SRAM_DIR_ADDR (0xE10000L)
  29. #define SRAM_CMD_ADDR (0xFF1000L)
  30. #define SRAM_PARAM_ADDR (0xFF1004L)
  31. #define SRAM_STATUS_ADDR (0xFF1100L)
  32. #define SRAM_MENU_SAVE_ADDR (0xFF0000L)
  33. #define SRAM_SCRATCHPAD (0xFFFF00L)
  34. #define SRAM_DIRID (0xFFFFF0L)
  35. #define SRAM_RELIABILITY_SCORE (0x100)
  36. #define LOADROM_WITH_SRAM (1)
  37. #define LOADROM_WITH_RESET (2)
  38. uint32_t load_rom(uint8_t* filename, uint32_t base_addr, uint8_t flags);
  39. uint32_t load_sram(uint8_t* filename, uint32_t base_addr);
  40. uint32_t load_sram_offload(uint8_t* filename, uint32_t base_addr);
  41. uint32_t load_sram_rle(uint8_t* filename, uint32_t base_addr);
  42. uint32_t load_bootrle(uint32_t base_addr);
  43. void load_dspx(const uint8_t* filename, uint8_t st0010);
  44. void sram_hexdump(uint32_t addr, uint32_t len);
  45. uint8_t sram_readbyte(uint32_t addr);
  46. uint16_t sram_readshort(uint32_t addr);
  47. uint32_t sram_readlong(uint32_t addr);
  48. void sram_writebyte(uint8_t val, uint32_t addr);
  49. void sram_writeshort(uint16_t val, uint32_t addr);
  50. void sram_writelong(uint32_t val, uint32_t addr);
  51. void sram_readblock(void* buf, uint32_t addr, uint16_t size);
  52. void sram_readlongblock(uint32_t* buf, uint32_t addr, uint16_t count);
  53. void sram_writeblock(void* buf, uint32_t addr, uint16_t size);
  54. void save_sram(uint8_t* filename, uint32_t sram_size, uint32_t base_addr);
  55. uint32_t calc_sram_crc(uint32_t base_addr, uint32_t size);
  56. uint8_t sram_reliable(void);
  57. void sram_memset(uint32_t base_addr, uint32_t len, uint8_t val);
  58. uint64_t sram_gettime(uint32_t base_addr);
  59. #endif