Xemu [doxygen]  hyppo 0a42be3a057156924bc1b626a687bd6e27349c45 @ Sat 19 Mar 02:15:11 CET 2022
Data Structures | Macros | Functions | Variables
memory_mapper.c File Reference
#include "xemu/emutools.h"
#include "memory_mapper.h"
#include "mega65.h"
#include "io_mapper.h"
#include "xemu/cpu65.h"
#include "hypervisor.h"
#include "vic4.h"
#include "dma65.h"
#include "ethernet65.h"
#include "audio65.h"
#include "sdcard.h"
#include <string.h>
#include "cpu_custom_functions.h"
Include dependency graph for memory_mapper.c:

Go to the source code of this file.

Data Structures

struct  m65_memory_map_st
 

Macros

#define ALLOW_CPU_CUSTOM_FUNCTIONS_INCLUDE
 
#define chip_ram   (main_ram + 0)
 
#define fast_ram   (main_ram + 0x20000)
 
#define extra_ram   (main_ram + 0x40000)
 
#define MEM_SLOT_C64_8KROM_A000   0x200
 
#define MEM_SLOT_C64_4KROM_D000   0x220
 
#define MEM_SLOT_OLD_4K_IO_D000   0x230
 
#define MEM_SLOT_C64_8KROM_E000   0x240
 
#define MEM_SLOT_C65_8KROM_8000   0x260
 
#define MEM_SLOT_C65_8KROM_A000   0x280
 
#define MEM_SLOT_C65_8KROM_E000   0x2A0
 
#define MEM_SLOT_C65_4KROM_C000   0x2C0
 
#define MEM_SLOT_DMA_RD_SRC   0x2D0
 
#define MEM_SLOT_DMA_WR_SRC   0x2D1
 
#define MEM_SLOT_DMA_RD_DST   0x2D2
 
#define MEM_SLOT_DMA_WR_DST   0x2D3
 
#define MEM_SLOT_DMA_RD_LST   0x2D4
 
#define MEM_SLOT_CPU_32BIT   0x2D5
 
#define MEM_SLOT_DEBUG_RESOLVER   0x2D6
 
#define MEM_SLOTS   0x2D7
 
#define VIC3_ROM_MASK_8000   0x08
 
#define VIC3_ROM_MASK_A000   0x10
 
#define VIC3_ROM_MASK_C000   0x20
 
#define VIC3_ROM_MASK_E000   0x80
 
#define MAP_MARKER_DUMMY_OFFSET   0x2000
 
#define DEFINE_READER(name)   static Uint8 name ( MEMORY_HANDLERS_ADDR_TYPE )
 
#define DEFINE_WRITER(name)   static void name ( MEMORY_HANDLERS_ADDR_TYPE, Uint8 data )
 
#define MEM_TABLE_COPY(to, from, pages)
 

Functions

 DEFINE_READER (zero_physical_page_reader)
 
 DEFINE_WRITER (zero_physical_page_writer)
 
 DEFINE_READER (opl3_reader)
 
 DEFINE_WRITER (opl3_writer)
 
 DEFINE_READER (chip_ram_from_page1_reader)
 
 DEFINE_WRITER (chip_ram_from_page1_writer)
 
 DEFINE_READER (fast_ram_reader)
 
 DEFINE_WRITER (fast_ram_writer)
 
 DEFINE_READER (extra_ram_reader)
 
 DEFINE_WRITER (extra_ram_writer)
 
 DEFINE_READER (colour_ram_reader)
 
 DEFINE_WRITER (colour_ram_writer)
 
 DEFINE_READER (dummy_reader)
 
 DEFINE_WRITER (dummy_writer)
 
 DEFINE_READER (hypervisor_ram_reader)
 
 DEFINE_WRITER (hypervisor_ram_writer)
 
 DEFINE_WRITER (char_wom_writer)
 
 DEFINE_READER (slow_ram_reader)
 
 DEFINE_WRITER (slow_ram_writer)
 
 DEFINE_READER (invalid_mem_reader)
 
 DEFINE_WRITER (invalid_mem_writer)
 
 DEFINE_READER (fatal_mem_reader)
 
 DEFINE_WRITER (fatal_mem_writer)
 
 DEFINE_READER (unreferenced_mem_reader)
 
 DEFINE_WRITER (unreferenced_mem_writer)
 
 DEFINE_READER (m65_io_reader)
 
 DEFINE_WRITER (m65_io_writer)
 
 DEFINE_READER (legacy_io_reader)
 
 DEFINE_WRITER (legacy_io_writer)
 
 DEFINE_READER (eth_buffer_reader)
 
 DEFINE_WRITER (eth_buffer_writer)
 
 DEFINE_READER (disk_buffers_reader)
 
 DEFINE_WRITER (disk_buffers_writer)
 
 DEFINE_READER (i2c_io_reader)
 
 DEFINE_WRITER (i2c_io_writer)
 
void memory_init (void)
 
void memory_set_vic3_rom_mapping (Uint8 value)
 
void memory_set_cpu_io_port (int addr, Uint8 value)
 
void memory_set_cpu_io_port_ddr_and_data (Uint8 p0, Uint8 p1)
 
Uint8 memory_get_cpu_io_port (int addr)
 
void memory_set_do_map (void)
 
void cpu65_do_aug_callback (void)
 
void cpu65_do_nop_callback (void)
 
Uint8 cpu65_read_linear_opcode_callback (void)
 
void cpu65_write_linear_opcode_callback (Uint8 data)
 
Uint32 cpu65_read_linear_long_opcode_callback (const Uint8 index)
 
void cpu65_write_linear_long_opcode_callback (const Uint8 index, Uint32 data)
 
Uint8 memory_dma_source_mreader (int addr)
 
void memory_dma_source_mwriter (int addr, Uint8 data)
 
Uint8 memory_dma_target_mreader (int addr)
 
void memory_dma_target_mwriter (int addr, Uint8 data)
 
Uint8 memory_dma_list_reader (int addr)
 
Uint8 memory_debug_read_phys_addr (int addr)
 
void memory_debug_write_phys_addr (int addr, Uint8 data)
 
int memory_cpurd2linear_xlat (Uint16 cpu_addr)
 
Uint8 memory_debug_read_cpu_addr (Uint16 addr)
 
void memory_debug_write_cpu_addr (Uint16 addr, Uint8 data)
 

Variables

Uint8 main_ram [512<< 10]
 
Uint8 colour_ram [0x8000]
 
Uint8 char_wom [0x2000]
 
Uint8 hypervisor_ram [0x4000]
 
Uint8 nvram [64]
 
Uint8 mega65_uuid [8]
 
Uint8 rtc_regs [6]
 
Uint8 slow_ram [SLOW_RAM_SIZE]
 
int cpu_rmw_old_data
 
int map_mask
 
int map_offset_low
 
int map_offset_high
 
int map_megabyte_low
 
int map_megabyte_high
 
int rom_protect
 
int skip_unhandled_mem = 0
 

Macro Definition Documentation

◆ ALLOW_CPU_CUSTOM_FUNCTIONS_INCLUDE

#define ALLOW_CPU_CUSTOM_FUNCTIONS_INCLUDE

Definition at line 40 of file memory_mapper.c.

◆ chip_ram

#define chip_ram   (main_ram + 0)

Definition at line 50 of file memory_mapper.c.

◆ DEFINE_READER

#define DEFINE_READER (   name)    static Uint8 name ( MEMORY_HANDLERS_ADDR_TYPE )

Definition at line 148 of file memory_mapper.c.

◆ DEFINE_WRITER

#define DEFINE_WRITER (   name)    static void name ( MEMORY_HANDLERS_ADDR_TYPE, Uint8 data )

Definition at line 149 of file memory_mapper.c.

◆ extra_ram

#define extra_ram   (main_ram + 0x40000)

Definition at line 52 of file memory_mapper.c.

◆ fast_ram

#define fast_ram   (main_ram + 0x20000)

Definition at line 51 of file memory_mapper.c.

◆ MAP_MARKER_DUMMY_OFFSET

#define MAP_MARKER_DUMMY_OFFSET   0x2000

Definition at line 114 of file memory_mapper.c.

◆ MEM_SLOT_C64_4KROM_D000

#define MEM_SLOT_C64_4KROM_D000   0x220

Definition at line 93 of file memory_mapper.c.

◆ MEM_SLOT_C64_8KROM_A000

#define MEM_SLOT_C64_8KROM_A000   0x200

Definition at line 92 of file memory_mapper.c.

◆ MEM_SLOT_C64_8KROM_E000

#define MEM_SLOT_C64_8KROM_E000   0x240

Definition at line 95 of file memory_mapper.c.

◆ MEM_SLOT_C65_4KROM_C000

#define MEM_SLOT_C65_4KROM_C000   0x2C0

Definition at line 99 of file memory_mapper.c.

◆ MEM_SLOT_C65_8KROM_8000

#define MEM_SLOT_C65_8KROM_8000   0x260

Definition at line 96 of file memory_mapper.c.

◆ MEM_SLOT_C65_8KROM_A000

#define MEM_SLOT_C65_8KROM_A000   0x280

Definition at line 97 of file memory_mapper.c.

◆ MEM_SLOT_C65_8KROM_E000

#define MEM_SLOT_C65_8KROM_E000   0x2A0

Definition at line 98 of file memory_mapper.c.

◆ MEM_SLOT_CPU_32BIT

#define MEM_SLOT_CPU_32BIT   0x2D5

Definition at line 105 of file memory_mapper.c.

◆ MEM_SLOT_DEBUG_RESOLVER

#define MEM_SLOT_DEBUG_RESOLVER   0x2D6

Definition at line 106 of file memory_mapper.c.

◆ MEM_SLOT_DMA_RD_DST

#define MEM_SLOT_DMA_RD_DST   0x2D2

Definition at line 102 of file memory_mapper.c.

◆ MEM_SLOT_DMA_RD_LST

#define MEM_SLOT_DMA_RD_LST   0x2D4

Definition at line 104 of file memory_mapper.c.

◆ MEM_SLOT_DMA_RD_SRC

#define MEM_SLOT_DMA_RD_SRC   0x2D0

Definition at line 100 of file memory_mapper.c.

◆ MEM_SLOT_DMA_WR_DST

#define MEM_SLOT_DMA_WR_DST   0x2D3

Definition at line 103 of file memory_mapper.c.

◆ MEM_SLOT_DMA_WR_SRC

#define MEM_SLOT_DMA_WR_SRC   0x2D1

Definition at line 101 of file memory_mapper.c.

◆ MEM_SLOT_OLD_4K_IO_D000

#define MEM_SLOT_OLD_4K_IO_D000   0x230

Definition at line 94 of file memory_mapper.c.

◆ MEM_SLOTS

#define MEM_SLOTS   0x2D7

Definition at line 107 of file memory_mapper.c.

◆ MEM_TABLE_COPY

#define MEM_TABLE_COPY (   to,
  from,
  pages 
)
Value:
do { \
memcpy(mem_page_rd_o + (to), mem_page_rd_o + (from), sizeof(int) * (pages)); \
memcpy(mem_page_wr_o + (to), mem_page_wr_o + (from), sizeof(int) * (pages)); \
memcpy(mem_page_rd_f + (to), mem_page_rd_f + (from), sizeof(mem_page_rd_f_type) * (pages)); \
memcpy(mem_page_wr_f + (to), mem_page_wr_f + (from), sizeof(mem_page_wr_f_type) * (pages)); \
memcpy(mem_page_refp + (to), mem_page_refp + (from), sizeof(const struct m65_memory_map_st*) * (pages)); \
memcpy(mem_page_phys + (to), mem_page_phys + (from), sizeof(int) * (pages)); \
} while (0)

Definition at line 439 of file memory_mapper.c.

◆ VIC3_ROM_MASK_8000

#define VIC3_ROM_MASK_8000   0x08

Definition at line 109 of file memory_mapper.c.

◆ VIC3_ROM_MASK_A000

#define VIC3_ROM_MASK_A000   0x10

Definition at line 110 of file memory_mapper.c.

◆ VIC3_ROM_MASK_C000

#define VIC3_ROM_MASK_C000   0x20

Definition at line 111 of file memory_mapper.c.

◆ VIC3_ROM_MASK_E000

#define VIC3_ROM_MASK_E000   0x80

Definition at line 112 of file memory_mapper.c.

Function Documentation

◆ cpu65_do_aug_callback()

void cpu65_do_aug_callback ( void  )

Definition at line 795 of file memory_mapper.c.

Here is the call graph for this function:

◆ cpu65_do_nop_callback()

void cpu65_do_nop_callback ( void  )

Definition at line 839 of file memory_mapper.c.

◆ cpu65_read_linear_long_opcode_callback()

Uint32 cpu65_read_linear_long_opcode_callback ( const Uint8  index)

Definition at line 885 of file memory_mapper.c.

◆ cpu65_read_linear_opcode_callback()

Uint8 cpu65_read_linear_opcode_callback ( void  )

Definition at line 869 of file memory_mapper.c.

◆ cpu65_write_linear_long_opcode_callback()

void cpu65_write_linear_long_opcode_callback ( const Uint8  index,
Uint32  data 
)

Definition at line 898 of file memory_mapper.c.

◆ cpu65_write_linear_opcode_callback()

void cpu65_write_linear_opcode_callback ( Uint8  data)

Definition at line 876 of file memory_mapper.c.

◆ DEFINE_READER() [1/17]

DEFINE_READER ( chip_ram_from_page1_reader  )

Definition at line 167 of file memory_mapper.c.

◆ DEFINE_READER() [2/17]

DEFINE_READER ( colour_ram_reader  )

Definition at line 186 of file memory_mapper.c.

◆ DEFINE_READER() [3/17]

DEFINE_READER ( disk_buffers_reader  )

Definition at line 282 of file memory_mapper.c.

◆ DEFINE_READER() [4/17]

DEFINE_READER ( dummy_reader  )

Definition at line 194 of file memory_mapper.c.

◆ DEFINE_READER() [5/17]

DEFINE_READER ( eth_buffer_reader  )

Definition at line 276 of file memory_mapper.c.

Here is the call graph for this function:

◆ DEFINE_READER() [6/17]

DEFINE_READER ( extra_ram_reader  )

Definition at line 180 of file memory_mapper.c.

◆ DEFINE_READER() [7/17]

DEFINE_READER ( fast_ram_reader  )

Definition at line 173 of file memory_mapper.c.

◆ DEFINE_READER() [8/17]

DEFINE_READER ( fatal_mem_reader  )

Definition at line 252 of file memory_mapper.c.

◆ DEFINE_READER() [9/17]

DEFINE_READER ( hypervisor_ram_reader  )

Definition at line 199 of file memory_mapper.c.

◆ DEFINE_READER() [10/17]

DEFINE_READER ( i2c_io_reader  )

Definition at line 296 of file memory_mapper.c.

◆ DEFINE_READER() [11/17]

DEFINE_READER ( invalid_mem_reader  )

Definition at line 215 of file memory_mapper.c.

◆ DEFINE_READER() [12/17]

DEFINE_READER ( legacy_io_reader  )

Definition at line 270 of file memory_mapper.c.

Here is the call graph for this function:

◆ DEFINE_READER() [13/17]

DEFINE_READER ( m65_io_reader  )

Definition at line 264 of file memory_mapper.c.

Here is the call graph for this function:

◆ DEFINE_READER() [14/17]

DEFINE_READER ( opl3_reader  )

Definition at line 161 of file memory_mapper.c.

◆ DEFINE_READER() [15/17]

DEFINE_READER ( slow_ram_reader  )

Definition at line 209 of file memory_mapper.c.

◆ DEFINE_READER() [16/17]

DEFINE_READER ( unreferenced_mem_reader  )

Definition at line 258 of file memory_mapper.c.

◆ DEFINE_READER() [17/17]

DEFINE_READER ( zero_physical_page_reader  )

Definition at line 151 of file memory_mapper.c.

◆ DEFINE_WRITER() [1/18]

DEFINE_WRITER ( char_wom_writer  )

Definition at line 206 of file memory_mapper.c.

◆ DEFINE_WRITER() [2/18]

DEFINE_WRITER ( chip_ram_from_page1_writer  )

Definition at line 170 of file memory_mapper.c.

◆ DEFINE_WRITER() [3/18]

DEFINE_WRITER ( colour_ram_writer  )

Definition at line 189 of file memory_mapper.c.

◆ DEFINE_WRITER() [4/18]

DEFINE_WRITER ( disk_buffers_writer  )

Definition at line 289 of file memory_mapper.c.

◆ DEFINE_WRITER() [5/18]

DEFINE_WRITER ( dummy_writer  )

Definition at line 197 of file memory_mapper.c.

◆ DEFINE_WRITER() [6/18]

DEFINE_WRITER ( eth_buffer_writer  )

Definition at line 279 of file memory_mapper.c.

Here is the call graph for this function:

◆ DEFINE_WRITER() [7/18]

DEFINE_WRITER ( extra_ram_writer  )

Definition at line 183 of file memory_mapper.c.

◆ DEFINE_WRITER() [8/18]

DEFINE_WRITER ( fast_ram_writer  )

Definition at line 176 of file memory_mapper.c.

◆ DEFINE_WRITER() [9/18]

DEFINE_WRITER ( fatal_mem_writer  )

Definition at line 255 of file memory_mapper.c.

◆ DEFINE_WRITER() [10/18]

DEFINE_WRITER ( hypervisor_ram_writer  )

Definition at line 202 of file memory_mapper.c.

◆ DEFINE_WRITER() [11/18]

DEFINE_WRITER ( i2c_io_writer  )

Definition at line 325 of file memory_mapper.c.

◆ DEFINE_WRITER() [12/18]

DEFINE_WRITER ( invalid_mem_writer  )

Definition at line 234 of file memory_mapper.c.

◆ DEFINE_WRITER() [13/18]

DEFINE_WRITER ( legacy_io_writer  )

Definition at line 273 of file memory_mapper.c.

Here is the call graph for this function:

◆ DEFINE_WRITER() [14/18]

DEFINE_WRITER ( m65_io_writer  )

Definition at line 267 of file memory_mapper.c.

Here is the call graph for this function:

◆ DEFINE_WRITER() [15/18]

DEFINE_WRITER ( opl3_writer  )

Definition at line 164 of file memory_mapper.c.

Here is the call graph for this function:

◆ DEFINE_WRITER() [16/18]

DEFINE_WRITER ( slow_ram_writer  )

Definition at line 212 of file memory_mapper.c.

◆ DEFINE_WRITER() [17/18]

DEFINE_WRITER ( unreferenced_mem_writer  )

Definition at line 261 of file memory_mapper.c.

◆ DEFINE_WRITER() [18/18]

DEFINE_WRITER ( zero_physical_page_writer  )

Definition at line 154 of file memory_mapper.c.

Here is the call graph for this function:

◆ memory_cpurd2linear_xlat()

int memory_cpurd2linear_xlat ( Uint16  cpu_addr)

Definition at line 966 of file memory_mapper.c.

◆ memory_debug_read_cpu_addr()

Uint8 memory_debug_read_cpu_addr ( Uint16  addr)

Definition at line 973 of file memory_mapper.c.

◆ memory_debug_read_phys_addr()

Uint8 memory_debug_read_phys_addr ( int  addr)

Definition at line 954 of file memory_mapper.c.

◆ memory_debug_write_cpu_addr()

void memory_debug_write_cpu_addr ( Uint16  addr,
Uint8  data 
)

Definition at line 978 of file memory_mapper.c.

◆ memory_debug_write_phys_addr()

void memory_debug_write_phys_addr ( int  addr,
Uint8  data 
)

Definition at line 960 of file memory_mapper.c.

◆ memory_dma_list_reader()

Uint8 memory_dma_list_reader ( int  addr)

Definition at line 947 of file memory_mapper.c.

◆ memory_dma_source_mreader()

Uint8 memory_dma_source_mreader ( int  addr)

Definition at line 923 of file memory_mapper.c.

◆ memory_dma_source_mwriter()

void memory_dma_source_mwriter ( int  addr,
Uint8  data 
)

Definition at line 929 of file memory_mapper.c.

◆ memory_dma_target_mreader()

Uint8 memory_dma_target_mreader ( int  addr)

Definition at line 935 of file memory_mapper.c.

◆ memory_dma_target_mwriter()

void memory_dma_target_mwriter ( int  addr,
Uint8  data 
)

Definition at line 941 of file memory_mapper.c.

◆ memory_get_cpu_io_port()

Uint8 memory_get_cpu_io_port ( int  addr)

Definition at line 763 of file memory_mapper.c.

◆ memory_init()

void memory_init ( void  )

Definition at line 479 of file memory_mapper.c.

◆ memory_set_cpu_io_port()

void memory_set_cpu_io_port ( int  addr,
Uint8  value 
)

Definition at line 737 of file memory_mapper.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ memory_set_cpu_io_port_ddr_and_data()

void memory_set_cpu_io_port_ddr_and_data ( Uint8  p0,
Uint8  p1 
)

Definition at line 755 of file memory_mapper.c.

Here is the caller graph for this function:

◆ memory_set_do_map()

void memory_set_do_map ( void  )

Definition at line 774 of file memory_mapper.c.

Here is the caller graph for this function:

◆ memory_set_vic3_rom_mapping()

void memory_set_vic3_rom_mapping ( Uint8  value)

Definition at line 689 of file memory_mapper.c.

Variable Documentation

◆ char_wom

Uint8 char_wom[0x2000]

Definition at line 67 of file memory_mapper.c.

◆ colour_ram

Uint8 colour_ram[0x8000]

Definition at line 65 of file memory_mapper.c.

◆ cpu_rmw_old_data

int cpu_rmw_old_data

Definition at line 123 of file memory_mapper.c.

◆ hypervisor_ram

Uint8 hypervisor_ram[0x4000]

Definition at line 69 of file memory_mapper.c.

◆ main_ram

Uint8 main_ram[512<< 10]

Definition at line 47 of file memory_mapper.c.

◆ map_mask

int map_mask

Definition at line 142 of file memory_mapper.c.

◆ map_megabyte_high

int map_megabyte_high

Definition at line 142 of file memory_mapper.c.

◆ map_megabyte_low

int map_megabyte_low

Definition at line 142 of file memory_mapper.c.

◆ map_offset_high

int map_offset_high

Definition at line 142 of file memory_mapper.c.

◆ map_offset_low

int map_offset_low

Definition at line 142 of file memory_mapper.c.

◆ mega65_uuid

Uint8 mega65_uuid[8]

Definition at line 73 of file memory_mapper.c.

◆ nvram

Uint8 nvram[64]

Definition at line 71 of file memory_mapper.c.

◆ rom_protect

int rom_protect

Definition at line 144 of file memory_mapper.c.

◆ rtc_regs

Uint8 rtc_regs[6]

Definition at line 75 of file memory_mapper.c.

◆ skip_unhandled_mem

int skip_unhandled_mem = 0

Definition at line 145 of file memory_mapper.c.

◆ slow_ram

Uint8 slow_ram[SLOW_RAM_SIZE]

Definition at line 77 of file memory_mapper.c.

mem_page_wr_f_type
void(* mem_page_wr_f_type)(MEMORY_HANDLERS_ADDR_TYPE, Uint8 data)
Definition: cpu_custom_functions.h:65
mem_page_rd_f_type
Uint8(* mem_page_rd_f_type)(MEMORY_HANDLERS_ADDR_TYPE)
Definition: cpu_custom_functions.h:64
mem_page_rd_o
int mem_page_rd_o[]
Definition: memory_mapper.c:117
mem_page_wr_f
mem_page_wr_f_type mem_page_wr_f[]
Definition: memory_mapper.c:120
mem_page_wr_o
int mem_page_wr_o[]
Definition: memory_mapper.c:118
mem_page_rd_f
mem_page_rd_f_type mem_page_rd_f[]
Definition: memory_mapper.c:119
m65_memory_map_st
Definition: memory_mapper.c:80