/*1* PPC EDAC common defs2*3* Author: Dave Jiang <[email protected]>4*5* 2007 (c) MontaVista Software, Inc. This file is licensed under6* the terms of the GNU General Public License version 2. This program7* is licensed "as is" without any warranty of any kind, whether express8* or implied.9*/10#ifndef ASM_EDAC_H11#define ASM_EDAC_H12/*13* ECC atomic, DMA, SMP and interrupt safe scrub function.14* Implements the per arch atomic_scrub() that EDAC use for software15* ECC scrubbing. It reads memory and then writes back the original16* value, allowing the hardware to detect and correct memory errors.17*/18static __inline__ void atomic_scrub(void *va, u32 size)19{20unsigned int *virt_addr = va;21unsigned int temp;22unsigned int i;2324for (i = 0; i < size / sizeof(*virt_addr); i++, virt_addr++) {25/* Very carefully read and write to memory atomically26* so we are interrupt, DMA and SMP safe.27*/28__asm__ __volatile__ ("\n\291: lwarx %0,0,%1\n\30stwcx. %0,0,%1\n\31bne- 1b\n\32isync"33: "=&r"(temp)34: "r"(virt_addr)35: "cr0", "memory");36}37}3839#endif404142