|
|
@ -63,13 +63,6 @@ void mem_write8(uint32_t address, uint8_t value) |
|
|
|
io = io->next; |
|
|
|
io = io->next; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Check if we are inside of physical memory
|
|
|
|
|
|
|
|
if(address + 1 > memory_size) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fprintf(stderr, "MEMORY: Invalid write of size 1 outside of physical memory at address 0x%x\n", address); |
|
|
|
|
|
|
|
exit(EXIT_FAILURE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Proceed with memory write
|
|
|
|
// Proceed with memory write
|
|
|
|
pthread_mutex_lock(&memory_mutex); |
|
|
|
pthread_mutex_lock(&memory_mutex); |
|
|
|
memory[address] = value; |
|
|
|
memory[address] = value; |
|
|
@ -101,13 +94,6 @@ void mem_write16(uint32_t address, uint16_t value) |
|
|
|
io = io->next; |
|
|
|
io = io->next; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Check if we are inside of physical memory
|
|
|
|
|
|
|
|
if(address + 2 > memory_size) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fprintf(stderr, "MEMORY: Invalid write of size 2 outside of physical memory at address 0x%x\n", address); |
|
|
|
|
|
|
|
exit(EXIT_FAILURE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Proceed with memory write
|
|
|
|
// Proceed with memory write
|
|
|
|
pthread_mutex_lock(&memory_mutex); |
|
|
|
pthread_mutex_lock(&memory_mutex); |
|
|
|
*((uint16_t*) &memory[address]) = value; |
|
|
|
*((uint16_t*) &memory[address]) = value; |
|
|
@ -139,13 +125,6 @@ void mem_write32(uint32_t address, uint32_t value) |
|
|
|
io = io->next; |
|
|
|
io = io->next; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Check if we are inside of physical memory
|
|
|
|
|
|
|
|
if(address + 4 > memory_size) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fprintf(stderr, "MEMORY: Invalid write of size 1 outside of physical memory at address 0x%x\n", address); |
|
|
|
|
|
|
|
exit(EXIT_FAILURE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Proceed with memory write
|
|
|
|
// Proceed with memory write
|
|
|
|
pthread_mutex_lock(&memory_mutex); |
|
|
|
pthread_mutex_lock(&memory_mutex); |
|
|
|
*((uint32_t*) &memory[address]) = value; |
|
|
|
*((uint32_t*) &memory[address]) = value; |
|
|
@ -176,13 +155,6 @@ uint8_t mem_read8(uint32_t address) |
|
|
|
io = io->next; |
|
|
|
io = io->next; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Check if we are inside of physical memory
|
|
|
|
|
|
|
|
if(address + 1 > memory_size) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fprintf(stderr, "MEMORY: Invalid read of size 1 outside of physical memory at address 0x%x\n", address); |
|
|
|
|
|
|
|
exit(EXIT_FAILURE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Proceed with memory read
|
|
|
|
// Proceed with memory read
|
|
|
|
pthread_mutex_lock(&memory_mutex); |
|
|
|
pthread_mutex_lock(&memory_mutex); |
|
|
|
uint8_t tr = memory[address]; |
|
|
|
uint8_t tr = memory[address]; |
|
|
@ -214,13 +186,6 @@ uint16_t mem_read16(uint32_t address) |
|
|
|
io = io->next; |
|
|
|
io = io->next; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Check if we are inside of physical memory
|
|
|
|
|
|
|
|
if(address + 2 > memory_size) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fprintf(stderr, "MEMORY: Invalid read of size 2 outside of physical memory at address 0x%x\n", address); |
|
|
|
|
|
|
|
exit(EXIT_FAILURE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Proceed with memory read
|
|
|
|
// Proceed with memory read
|
|
|
|
pthread_mutex_lock(&memory_mutex); |
|
|
|
pthread_mutex_lock(&memory_mutex); |
|
|
|
uint16_t tr = *((uint16_t*) &memory[address]); |
|
|
|
uint16_t tr = *((uint16_t*) &memory[address]); |
|
|
@ -252,13 +217,6 @@ uint32_t mem_read32(uint32_t address) |
|
|
|
io = io->next; |
|
|
|
io = io->next; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Check if we are inside of physical memory
|
|
|
|
|
|
|
|
if(address + 4 > memory_size) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fprintf(stderr, "MEMORY: Invalid read of size 4 outside of physical memory at address 0x%x\n", address); |
|
|
|
|
|
|
|
exit(EXIT_FAILURE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Proceed with memory read
|
|
|
|
// Proceed with memory read
|
|
|
|
pthread_mutex_lock(&memory_mutex); |
|
|
|
pthread_mutex_lock(&memory_mutex); |
|
|
|
uint32_t tr = *((uint32_t*) &memory[address]); |
|
|
|
uint32_t tr = *((uint32_t*) &memory[address]); |
|
|
@ -282,13 +240,6 @@ uint32_t mem_fetch(uint32_t address) |
|
|
|
io = io->next; |
|
|
|
io = io->next; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Check if we are inside of physical memory
|
|
|
|
|
|
|
|
if(address + 4 > memory_size) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
fprintf(stderr, "MEMORY: Invalid fetch outside of physical memory at address 0x%x\n", address); |
|
|
|
|
|
|
|
exit(EXIT_FAILURE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Proceed with memory read
|
|
|
|
// Proceed with memory read
|
|
|
|
pthread_mutex_lock(&memory_mutex); |
|
|
|
pthread_mutex_lock(&memory_mutex); |
|
|
|
uint32_t tr = *((uint32_t*) &memory[address]); |
|
|
|
uint32_t tr = *((uint32_t*) &memory[address]); |
|
|
|