2 * This file contains miscellaneous low-level functions.
3 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
5 * Largely rewritten by Cort Dougan (cort@cs.nmt.edu)
8 * A couple of functions stolen from arch/ppc/kernel/misc.S for UML
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 2 of the License, or (at your option) any later version.
18 #include <linux/config.h>
19 #include <asm/processor.h>
22 #if defined(CONFIG_4xx) || defined(CONFIG_8xx)
23 #define CACHE_LINE_SIZE 16
24 #define LG_CACHE_LINE_SIZE 4
25 #define MAX_COPY_PREFETCH 1
26 #elif !defined(CONFIG_PPC64BRIDGE)
27 #define CACHE_LINE_SIZE 32
28 #define LG_CACHE_LINE_SIZE 5
29 #define MAX_COPY_PREFETCH 4
31 #define CACHE_LINE_SIZE 128
32 #define LG_CACHE_LINE_SIZE 7
33 #define MAX_COPY_PREFETCH 1
34 #endif /* CONFIG_4xx || CONFIG_8xx */
39 * Clear a page using the dcbz instruction, which doesn't cause any
40 * memory traffic (except to write out any cache lines which get
41 * displaced). This only works on cacheable memory.
44 li r0,4096/CACHE_LINE_SIZE
55 addi r3,r3,CACHE_LINE_SIZE
60 * Copy a whole page. We use the dcbz instruction on the destination
61 * to reduce memory traffic (it eliminates the unnecessary reads of
62 * the destination into cache). This requires that the destination
65 #define COPY_16_BYTES \
81 #if MAX_COPY_PREFETCH > 1
82 li r0,MAX_COPY_PREFETCH
86 addi r11,r11,CACHE_LINE_SIZE
88 #else /* MAX_COPY_PREFETCH == 1 */
90 li r11,CACHE_LINE_SIZE+4
91 #endif /* MAX_COPY_PREFETCH */
92 #endif /* CONFIG_8xx */
94 li r0,4096/CACHE_LINE_SIZE
102 #if CACHE_LINE_SIZE >= 32
104 #if CACHE_LINE_SIZE >= 64
107 #if CACHE_LINE_SIZE >= 128