Skip to content

Commit 3db25da

Browse files
authored
Merge pull request #346 from F0bes/libgs-clobber-fix
Libgs: Treat EE->GIF data as volatile like (Fixes libgs)
2 parents 92b5f89 + f1a6ece commit 3db25da

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

ee/libgs/src/dma.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ void GsDmaSend(const void *addr, u32 qwords)
112112
chcr.tag =0;
113113
chcr.pad1 =0;
114114
chcr.pad2 =0;
115+
116+
// This prevents the compiler from assuming the values in addr are unused,
117+
// and that the writes to addr can be delayed until after this function call
118+
asm("":::"memory");
119+
115120
*((volatile DMA_CHCR *)(gif_chcr)) = chcr;
116121
}
117122

@@ -142,10 +147,16 @@ void GsDmaSend_tag(const void *addr, u32 qwords, const GS_GIF_DMACHAIN_TAG *tag)
142147
chcr.tag =0;
143148
chcr.pad1 =0;
144149
chcr.pad2 =0;
150+
151+
// This prevents the compiler from assuming the values in addr are unused,
152+
// and that the writes to addr can be delayed until after this function call
153+
asm("":::"memory");
154+
145155
*((volatile DMA_CHCR *)(gif_chcr)) = chcr;
146156
}
147157

148158
void GsDmaWait(void)
149159
{
150160
while(*((vu32 *)(0x1000a000)) & ((u32)1<<8));
161+
asm("":::"memory");
151162
}

0 commit comments

Comments
 (0)