From e2bbada9afb8710e91043b216a46ab4ec4fcb647 Mon Sep 17 00:00:00 2001 From: TheOfficialFloW Date: Sat, 17 Feb 2018 13:27:04 +0100 Subject: Added inline ksceKernelCpuUnrestrictedMemcpy because this doesn't exist in newer FWs --- include/kernel/kernel/cpu.h | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'include/kernel') diff --git a/include/kernel/kernel/cpu.h b/include/kernel/kernel/cpu.h index 09d144d..f6b60f7 100644 --- a/include/kernel/kernel/cpu.h +++ b/include/kernel/kernel/cpu.h @@ -64,6 +64,30 @@ static inline void sceKernelCpuRestoreContext(int context[3]) asm volatile ("cpsie i" ::: "memory"); } +/** + * @brief MMU permission bypassing memcpy + * + * This works by writing to the DACR before and after the memcpy. + * + * @param dst The destination + * @param[in] src The source + * @param[in] len The length + * + * @return Zero on success. + */ +static inline int sceKernelCpuUnrestrictedMemcpy(void *dst, const void *src, size_t len) +{ + int prev_dacr; + + asm ("mrc p15, 0, %0, c3, c0, 0" : "=r" (prev_dacr)); + asm ("mcr p15, 0, %0, c3, c0, 0" :: "r" (0xFFFF0000)); + + memcpy(dst, src, len); + + asm ("mcr p15, 0, %0, c3, c0, 0" :: "r" (prev_dacr)); + return 0; +} + /** * @brief Returns the CPU ID of the calling processor * @@ -195,19 +219,6 @@ int sceKernelCpuIcacheInvalidateAll(void); */ int sceKernelCpuIcacheAndL2WritebackInvalidateRange(const void *ptr, size_t len); -/** - * @brief MMU permission bypassing memcpy - * - * This works by writing to the DACR before and after the memcpy. - * - * @param dst The destination - * @param[in] src The source - * @param[in] len The length - * - * @return Zero on success. - */ -int sceKernelCpuUnrestrictedMemcpy(void *dst, const void *src, size_t len); - /** * @brief Suspend all interrupts (disables IRQs) * -- cgit v1.2.3