Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

word-wise dma copy #175

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/memory/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ extern void (*writememd[0x10000])(void);

#endif

#ifdef __arm__
void __aeabi_memcpy4(void*, void*, uint32_t); //this is present in libc6 on Raspberry PI
#define MEMCPY4(...) __aeabi_memcpy4(__VA_ARGS__)
#else
#define MEMCPY4(...) memcpy(__VA_ARGS__)
#endif


static void masked_write(uint32_t* dst, uint32_t value, uint32_t mask)
{
*dst = (*dst & ~mask) | (value & mask);
Expand Down
15 changes: 11 additions & 4 deletions src/pi/pi_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,17 @@ static void dma_pi_write(struct pi_controller* pi)
dram = (uint8_t*)pi->ri->rdram.dram;
rom = pi->cart_rom.rom;

for(i = 0; i < longueur; ++i)
{
dram[(dram_address+i)^S8] = rom[(rom_address+i)^S8];
}
if (((dram_address | rom_address | longueur) & 3) != 0)
Copy link
Member

@Narann Narann Aug 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest a tiny comment after the if statement non aligned word (or maybe it's obvious).

{
for(i = 0; i < longueur; ++i)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I suggest to add a tab in from of the for loop to keep code readable?

{
dram[(dram_address+i)^S8] = rom[(rom_address+i)^S8];
}
}
else
{
MEMCPY4(&dram[dram_address], &rom[rom_address], longueur);
}

invalidate_r4300_cached_code(0x80000000 + dram_address, longueur);
invalidate_r4300_cached_code(0xa0000000 + dram_address, longueur);
Expand Down
54 changes: 38 additions & 16 deletions src/rsp/rsp_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,25 @@ static void dma_sp_write(struct rsp_core* sp)
unsigned char *spmem = (unsigned char*)sp->mem + (sp->regs[SP_MEM_ADDR_REG] & 0x1000);
unsigned char *dram = (unsigned char*)sp->ri->rdram.dram;

for(j=0; j<count; j++) {
for(i=0; i<length; i++) {
spmem[memaddr^S8] = dram[dramaddr^S8];
memaddr++;
dramaddr++;
}
dramaddr+=skip;
}
if (((memaddr | dramaddr | length | skip) & 3) != 0)
Copy link
Member

@Narann Narann Aug 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non aligned word comment?

{
for(j=0; j<count; j++) {
for(i=0; i<length; i++) {
spmem[memaddr^S8] = dram[dramaddr^S8];
memaddr++;
dramaddr++;
}
dramaddr+=skip;
}
}
else
{
for(j=0; j<count; j++) {
MEMCPY4(&spmem[memaddr], &dram[dramaddr], length);
memaddr += length;
dramaddr += skip + length;
}
}
}

static void dma_sp_read(struct rsp_core* sp)
Expand All @@ -73,14 +84,25 @@ static void dma_sp_read(struct rsp_core* sp)
unsigned char *spmem = (unsigned char*)sp->mem + (sp->regs[SP_MEM_ADDR_REG] & 0x1000);
unsigned char *dram = (unsigned char*)sp->ri->rdram.dram;

for(j=0; j<count; j++) {
for(i=0; i<length; i++) {
dram[dramaddr^S8] = spmem[memaddr^S8];
memaddr++;
dramaddr++;
}
dramaddr+=skip;
}
if (((dramaddr | memaddr | skip | length) & 3) != 0)
Copy link
Member

@Narann Narann Aug 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non aligned word comment?

{
for(j=0; j<count; j++) {
for(i=0; i<length; i++) {
dram[dramaddr^S8] = spmem[memaddr^S8];
memaddr++;
dramaddr++;
}
dramaddr+=skip;
}
}
else
{
for(j=0; j<count; j++) {
MEMCPY4(&dram[dramaddr], &spmem[memaddr], length);
memaddr += length;
dramaddr += length + skip;
}
}
}

static void update_sp_status(struct rsp_core* sp, uint32_t w)
Expand Down