/*1* This file contains miscellaneous low-level functions.2* Copyright (C) 1995-1996 Gary Thomas ([email protected])3*4* Largely rewritten by Cort Dougan ([email protected])5* and Paul Mackerras.6*7* A couple of functions stolen from arch/ppc/kernel/misc.S for UML8* by Chris Emerson.9*10* This program is free software; you can redistribute it and/or11* modify it under the terms of the GNU General Public License12* as published by the Free Software Foundation; either version13* 2 of the License, or (at your option) any later version.14*15*/1617#include <asm/processor.h>18#include "ppc_asm.h"1920#if defined(CONFIG_4xx) || defined(CONFIG_8xx)21#define CACHE_LINE_SIZE 1622#define LG_CACHE_LINE_SIZE 423#define MAX_COPY_PREFETCH 124#else25#define CACHE_LINE_SIZE 3226#define LG_CACHE_LINE_SIZE 527#define MAX_COPY_PREFETCH 428#endif /* CONFIG_4xx || CONFIG_8xx */2930.text3132/*33* Clear a page using the dcbz instruction, which doesn't cause any34* memory traffic (except to write out any cache lines which get35* displaced). This only works on cacheable memory.36*/37_GLOBAL(clear_page)38li r0,4096/CACHE_LINE_SIZE39mtctr r040#ifdef CONFIG_8xx41li r4, 0421: stw r4, 0(r3)43stw r4, 4(r3)44stw r4, 8(r3)45stw r4, 12(r3)46#else471: dcbz 0,r348#endif49addi r3,r3,CACHE_LINE_SIZE50bdnz 1b51blr5253/*54* Copy a whole page. We use the dcbz instruction on the destination55* to reduce memory traffic (it eliminates the unnecessary reads of56* the destination into cache). This requires that the destination57* is cacheable.58*/59#define COPY_16_BYTES \60lwz r6,4(r4); \61lwz r7,8(r4); \62lwz r8,12(r4); \63lwzu r9,16(r4); \64stw r6,4(r3); \65stw r7,8(r3); \66stw r8,12(r3); \67stwu r9,16(r3)6869_GLOBAL(copy_page)70addi r3,r3,-471addi r4,r4,-472li r5,47374#ifndef CONFIG_8xx75#if MAX_COPY_PREFETCH > 176li r0,MAX_COPY_PREFETCH77li r11,478mtctr r07911: dcbt r11,r480addi r11,r11,CACHE_LINE_SIZE81bdnz 11b82#else /* MAX_COPY_PREFETCH == 1 */83dcbt r5,r484li r11,CACHE_LINE_SIZE+485#endif /* MAX_COPY_PREFETCH */86#endif /* CONFIG_8xx */8788li r0,4096/CACHE_LINE_SIZE89mtctr r0901:91#ifndef CONFIG_8xx92dcbt r11,r493dcbz r5,r394#endif95COPY_16_BYTES96#if CACHE_LINE_SIZE >= 3297COPY_16_BYTES98#if CACHE_LINE_SIZE >= 6499COPY_16_BYTES100COPY_16_BYTES101#if CACHE_LINE_SIZE >= 128102COPY_16_BYTES103COPY_16_BYTES104COPY_16_BYTES105COPY_16_BYTES106#endif107#endif108#endif109bdnz 1b110blr111112113