Skip to content

Commit 35bf313

Browse files
committed
cache: make sceSifWriteBackDCache share func impl
sceSifWriteBackDCache used Hit writeback invalidate ops, this makes it a good match to use SyncDCache now that it also does. This misses some loop unrolling that was there for large invalidations, not sure that particularly matters.
1 parent aec69ae commit 35bf313

File tree

3 files changed

+10
-64
lines changed

3 files changed

+10
-64
lines changed

ee/kernel/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ GLUE_OBJS += iEnableIntc.o iDisableIntc.o iEnableDmac.o iDisableDmac.o
8282

8383
### Cache
8484
CACHE_OBJS = SyncDCache.o iSyncDCache.o InvalidDCache.o iInvalidDCache.o
85+
CACHE_OBJS += sceSifWriteBackDCache.o
8586

8687
### SIO objects
8788

@@ -220,8 +221,8 @@ KERNEL_OBJS = ResetEE.o SetGsCrt.o $(EXEC_SYSCALLS) \
220221
SetPgifHandler.o SetVSyncFlag.o SetSyscall.o sceSifDmaStat.o isceSifDmaStat.o \
221222
sceSifSetDma.o isceSifSetDma.o sceSifSetDChain.o isceSifSetDChain.o sceSifSetReg.o \
222223
sceSifGetReg.o $(EXECOSD_SYSCALL) Deci2Call.o PSMode.o MachineType.o GetMemorySize.o _GetGsDxDyOffset.o \
223-
_InitTLB.o SetMemoryMode.o GetMemoryMode.o sceSifWriteBackDCache.o \
224-
__errno.o errno.o strncpy.o strlen.o memcpy.o memset.o __syscall.o GPfuncs.o _print.o
224+
_InitTLB.o SetMemoryMode.o GetMemoryMode.o __errno.o errno.o strncpy.o strlen.o memcpy.o \
225+
memset.o __syscall.o GPfuncs.o _print.o
225226

226227
EE_OBJS = $(KERNEL_OBJS) $(SIFCMD_OBJS) $(SIFRPC_OBJS) $(FILEIO_OBJS) \
227228
$(LOADFILE_OBJS) $(IOPHEAP_OBJS) $(IOPCONTROL_OBJS) $(ROM0_OBJS) $(CONFIG_OBJS) \

ee/kernel/src/cache.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ static inline void _InvalidDCache(u32 start, u32 end)
4242
}
4343
}
4444

45+
#ifdef F_sceSifWriteBackDCache
46+
void sceSifWriteBackDCache(void *ptr, int size)
47+
{
48+
_SyncDCache((u32)ptr & LINE_MASK, ((u32)(ptr) + size - 1) & LINE_MASK);
49+
}
50+
#endif
51+
4552
#ifdef F_SyncDCache
4653
void SyncDCache(void *start, void *end)
4754
{

ee/kernel/src/kernel.S

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -695,68 +695,6 @@ GetGP:
695695
.end GetGP
696696
#endif
697697

698-
#ifdef F_sceSifWriteBackDCache
699-
700-
.globl sceSifWriteBackDCache
701-
.ent sceSifWriteBackDCache
702-
.set push
703-
.set noreorder
704-
705-
sceSifWriteBackDCache: /* DHWBIN: Data cache Hit WriteBack INvalidate. */
706-
707-
lui $25, 0xffff
708-
ori $25, $25, 0xffc0
709-
blez $5, last
710-
addu $10, $4, $5
711-
and $8, $4, $25
712-
addiu $10, $10, -1
713-
and $9, $10, $25
714-
subu $10, $9, $8
715-
srl $11, $10, 0x6
716-
addiu $11, $11, 1
717-
andi $9, $11, 0x7
718-
beqz $9, eight
719-
srl $10, $11, 0x3
720-
loop1:
721-
sync
722-
cache 0x18, 0($8)
723-
sync
724-
addiu $9, $9, -1
725-
nop
726-
bgtz $9, loop1
727-
addiu $8, $8, 64
728-
729-
eight:
730-
beqz $10, last
731-
loop8:
732-
addiu $10, $10, -1
733-
sync
734-
cache 0x18, 0($8)
735-
sync
736-
cache 0x18, 64($8)
737-
sync
738-
cache 0x18, 128($8)
739-
sync
740-
cache 0x18, 192($8)
741-
sync
742-
cache 0x18, 256($8)
743-
sync
744-
cache 0x18, 320($8)
745-
sync
746-
cache 0x18, 384($8)
747-
sync
748-
cache 0x18, 448($8)
749-
sync
750-
bgtz $10, loop8
751-
addiu $8, $8, 512
752-
last:
753-
jr $31
754-
nop
755-
756-
.set pop
757-
.end sceSifWriteBackDCache
758-
#endif
759-
760698
#ifdef F___errno
761699
/* This is needed in case we are linked against libm (the math library) but
762700
not libc. */

0 commit comments

Comments
 (0)