src/ssx/ppc405/ppc405_mmu.c
/// Perform a memcpy() without address translation (protection)
///
/// It sometimes arises that "read-only" data needs to be initialized at
/// run-time. This can be accomplished in general by temporarily disabling
/// translation (protection) while the "read-only" data is altered.  Another
/// option is to use the memcpy_real() API to copy an image of the data from
/// writable memory to memory marked read-only by the MMU.
///
/// The memcpy_real() function copies \a n bytes from memory area \a src to
/// memory area \a dest, with translation disabled. The memory areas should
/// not overlap. The memcpy_real() function returns a pointer to dest.
///
/// This is a general-purpose API that makes no assumption about the
/// cacheability of the data, and can also be used to move code from data
/// areas to text areas as the I-cache is always invalidated after the copy.
/// The algorithm is as follows:
///
/// - Flush the \a dest data from the D-cache
/// - Disable translation
/// - memcpy() the \a src to the \a dest
/// - Flush the \a dest data from the D-cache
/// - Invalidate the I-cache
/// - Re-enable translation (if it had been previously enabled)
///
/// \note Any synchronization access required for \a dest or \a src is the
/// responsibility of the caller.
Perform a memcpy() without address translation (protection)
It sometimes arises that "read-only" data needs to be initialized at
run-time. This can be accomplished in general by temporarily disabling
translation (protection) while the "read-only" data is altered.  Another
option is to use the memcpy_real() API to copy an image of the data from
writable memory to memory marked read-only by the MMU.

The memcpy_real() function copies \a n bytes from memory area \a src to
memory area \a dest, with translation disabled. The memory areas should
not overlap. The memcpy_real() function returns a pointer to dest.

This is a general-purpose API that makes no assumption about the
cacheability of the data, and can also be used to move code from data
areas to text areas as the I-cache is always invalidated after the copy.
The algorithm is as follows.

Flush the \a dest data from the D-cache
Disable translation
memcpy() the \a src to the \a dest
Flush the \a dest data from the D-cache
Invalidate the I-cache
Re-enable translation (if it had been previously enabled)

\note Any synchronization access required for \a dest or \a src is the
responsibility of the caller.
Perform a memcpy () without address translation ( protection ) It sometimes arises that " read - only " data needs to be initialized at run - time . This can be accomplished in general by temporarily disabling translation ( protection ) while the " read - only " data is altered . Another option is to use the memcpy_real () API to copy an image of the data from writable memory to memory marked read - only by the MMU . The memcpy_real () function copies \ a n bytes from memory area \ a src to memory area \ a dest with translation disabled . The memory areas should not overlap . The memcpy_real () function returns a pointer to dest . This is a general - purpose API that makes no assumption about the cacheability of the data and can also be used to move code from data areas to text areas as the I - cache is always invalidated after the copy . The algorithm is as follows . Flush the \ a dest data from the D - cache Disable translation memcpy () the \ a src to the \ a dest Flush the \ a dest data from the D - cache Invalidate the I - cache Re - enable translation ( if it had been previously enabled ) \ note Any synchronization access required for \ a dest or \ a src is the responsibility of the caller .
void*
memcpy_real(void* dest, const void* src, size_t n)
{
    uint32_t msr;
    dcache_flush(dest, n);
    msr = mfmsr();
    mtmsr(msr & ~(MSR_IR | MSR_DR));
    sync();                     
    memcpy(dest, src, n);
    dcache_flush(dest, n);
    icache_invalidate_all();
    mtmsr(msr);
    sync();                       
    return dest;
}
void * memcpy_real ( void * dest , const void * src , size_t n ) { uint32_t msr ; dcache_flush ( dest , n ) ; msr = mfmsr ( ) ; mtmsr ( msr & ~ ( MSR_IR | MSR_DR ) ) ; sync ( ) ; memcpy ( dest , src , n ) ; dcache_flush ( dest , n ) ; icache_invalidate_all ( ) ; mtmsr ( msr ) ; sync ( ) ; return dest ; }
Perform a memcpy() without address translation (protection)
It sometimes arises that "read-only" data needs to be initialized at
run-time.
Perform a memcpy () without address translation ( protection ) It sometimes arises that " read - only " data needs to be initialized at run - time .
/* HW239446! */ /* HW239446! */