The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/arm/arm/bcopy_page.S

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: bcopy_page.S,v 1.7 2003/10/13 21:03:13 scw Exp $       */
    2 
    3 /*-
    4  * Copyright (c) 1995 Scott Stevens
    5  * All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  * 3. All advertising materials mentioning features or use of this software
   16  *    must display the following acknowledgement:
   17  *      This product includes software developed by Scott Stevens.
   18  * 4. The name of the author may not be used to endorse or promote products
   19  *    derived from this software without specific prior written permission.
   20  *
   21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   31  *
   32  * RiscBSD kernel project
   33  *
   34  * bcopy_page.S
   35  *
   36  * page optimised bcopy and bzero routines
   37  *
   38  * Created      : 08/04/95
   39  */
   40 
   41 #include <machine/asm.h>
   42 
   43 __FBSDID("$FreeBSD$");
   44 
   45 #include "assym.s"
   46 
   47 #ifndef _ARM_ARCH_5E
   48 
   49 /* #define BIG_LOOPS */
   50 
   51 /*
   52  * bcopy_page(src, dest)
   53  *
   54  * Optimised copy page routine.
   55  *
   56  * On entry:
   57  *   r0 - src address
   58  *   r1 - dest address
   59  *
   60  * Requires:
   61  *   number of bytes per page (PAGE_SIZE) is a multiple of 512 (BIG_LOOPS), 128
   62  *   otherwise.
   63  */
   64 
   65 #define CHUNK_SIZE      32
   66 
   67 #define PREFETCH_FIRST_CHUNK    /* nothing */
   68 #define PREFETCH_NEXT_CHUNK     /* nothing */
   69 
   70 #ifndef COPY_CHUNK
   71 #define COPY_CHUNK \
   72         PREFETCH_NEXT_CHUNK ; \
   73         ldmia   r0!, {r3-r8,ip,lr} ; \
   74         stmia   r1!, {r3-r8,ip,lr}
   75 #endif /* ! COPY_CHUNK */
   76 
   77 #ifndef SAVE_REGS
   78 #define SAVE_REGS       stmfd   sp!, {r4-r8, lr}
   79 #define RESTORE_REGS    ldmfd   sp!, {r4-r8, pc}
   80 #endif
   81 
   82 ENTRY(bcopy_page)
   83         PREFETCH_FIRST_CHUNK
   84         SAVE_REGS
   85 #ifdef BIG_LOOPS
   86         mov     r2, #(PAGE_SIZE >> 9)
   87 #else
   88         mov     r2, #(PAGE_SIZE >> 7)
   89 #endif
   90 
   91 1:
   92         COPY_CHUNK
   93         COPY_CHUNK
   94         COPY_CHUNK
   95         COPY_CHUNK
   96 
   97 #ifdef BIG_LOOPS
   98         /* There is little point making the loop any larger; unless we are
   99            running with the cache off, the load/store overheads will
  100            completely dominate this loop.  */
  101         COPY_CHUNK
  102         COPY_CHUNK
  103         COPY_CHUNK
  104         COPY_CHUNK
  105 
  106         COPY_CHUNK
  107         COPY_CHUNK
  108         COPY_CHUNK
  109         COPY_CHUNK
  110 
  111         COPY_CHUNK
  112         COPY_CHUNK
  113         COPY_CHUNK
  114         COPY_CHUNK
  115 #endif
  116         subs    r2, r2, #1
  117         bne     1b
  118 
  119         RESTORE_REGS            /* ...and return. */
  120 END(bcopy_page)
  121 
  122 /*
  123  * bzero_page(dest)
  124  *
  125  * Optimised zero page routine.
  126  *
  127  * On entry:
  128  *   r0 - dest address
  129  *
  130  * Requires:
  131  *   number of bytes per page (PAGE_SIZE) is a multiple of 512 (BIG_LOOPS), 128
  132  *   otherwise
  133  */
  134 
  135 ENTRY(bzero_page)
  136         stmfd   sp!, {r4-r8, lr}
  137 #ifdef BIG_LOOPS
  138         mov     r2, #(PAGE_SIZE >> 9)
  139 #else
  140         mov     r2, #(PAGE_SIZE >> 7)
  141 #endif
  142         mov     r3, #0
  143         mov     r4, #0
  144         mov     r5, #0
  145         mov     r6, #0
  146         mov     r7, #0
  147         mov     r8, #0
  148         mov     ip, #0
  149         mov     lr, #0
  150 
  151 1:
  152         stmia   r0!, {r3-r8,ip,lr}
  153         stmia   r0!, {r3-r8,ip,lr}
  154         stmia   r0!, {r3-r8,ip,lr}
  155         stmia   r0!, {r3-r8,ip,lr}
  156 
  157 #ifdef BIG_LOOPS
  158         /* There is little point making the loop any larger; unless we are
  159            running with the cache off, the load/store overheads will
  160            completely dominate this loop.  */
  161         stmia   r0!, {r3-r8,ip,lr}
  162         stmia   r0!, {r3-r8,ip,lr}
  163         stmia   r0!, {r3-r8,ip,lr}
  164         stmia   r0!, {r3-r8,ip,lr}
  165 
  166         stmia   r0!, {r3-r8,ip,lr}
  167         stmia   r0!, {r3-r8,ip,lr}
  168         stmia   r0!, {r3-r8,ip,lr}
  169         stmia   r0!, {r3-r8,ip,lr}
  170 
  171         stmia   r0!, {r3-r8,ip,lr}
  172         stmia   r0!, {r3-r8,ip,lr}
  173         stmia   r0!, {r3-r8,ip,lr}
  174         stmia   r0!, {r3-r8,ip,lr}
  175 
  176 #endif
  177 
  178         subs    r2, r2, #1
  179         bne     1b
  180 
  181         ldmfd   sp!, {r4-r8, pc}
  182 END(bzero_page)
  183 
  184 #else   /* _ARM_ARCH_5E */
  185 
  186 /*
  187  * armv5e version of bcopy_page
  188  */
  189 ENTRY(bcopy_page)
  190         pld     [r0]
  191         stmfd   sp!, {r4, r5}
  192         mov     ip, #32
  193         ldr     r2, [r0], #0x04         /* 0x00 */
  194         ldr     r3, [r0], #0x04         /* 0x04 */
  195 1:      pld     [r0, #0x18]             /* Prefetch 0x20 */
  196         ldr     r4, [r0], #0x04         /* 0x08 */
  197         ldr     r5, [r0], #0x04         /* 0x0c */
  198         strd    r2, [r1], #0x08
  199         ldr     r2, [r0], #0x04         /* 0x10 */
  200         ldr     r3, [r0], #0x04         /* 0x14 */
  201         strd    r4, [r1], #0x08
  202         ldr     r4, [r0], #0x04         /* 0x18 */
  203         ldr     r5, [r0], #0x04         /* 0x1c */
  204         strd    r2, [r1], #0x08
  205         ldr     r2, [r0], #0x04         /* 0x20 */
  206         ldr     r3, [r0], #0x04         /* 0x24 */
  207         pld     [r0, #0x18]             /* Prefetch 0x40 */
  208         strd    r4, [r1], #0x08
  209         ldr     r4, [r0], #0x04         /* 0x28 */
  210         ldr     r5, [r0], #0x04         /* 0x2c */
  211         strd    r2, [r1], #0x08
  212         ldr     r2, [r0], #0x04         /* 0x30 */
  213         ldr     r3, [r0], #0x04         /* 0x34 */
  214         strd    r4, [r1], #0x08
  215         ldr     r4, [r0], #0x04         /* 0x38 */
  216         ldr     r5, [r0], #0x04         /* 0x3c */
  217         strd    r2, [r1], #0x08
  218         ldr     r2, [r0], #0x04         /* 0x40 */
  219         ldr     r3, [r0], #0x04         /* 0x44 */
  220         pld     [r0, #0x18]             /* Prefetch 0x60 */
  221         strd    r4, [r1], #0x08
  222         ldr     r4, [r0], #0x04         /* 0x48 */
  223         ldr     r5, [r0], #0x04         /* 0x4c */
  224         strd    r2, [r1], #0x08
  225         ldr     r2, [r0], #0x04         /* 0x50 */
  226         ldr     r3, [r0], #0x04         /* 0x54 */
  227         strd    r4, [r1], #0x08
  228         ldr     r4, [r0], #0x04         /* 0x58 */
  229         ldr     r5, [r0], #0x04         /* 0x5c */
  230         strd    r2, [r1], #0x08
  231         ldr     r2, [r0], #0x04         /* 0x60 */
  232         ldr     r3, [r0], #0x04         /* 0x64 */
  233         pld     [r0, #0x18]             /* Prefetch 0x80 */
  234         strd    r4, [r1], #0x08
  235         ldr     r4, [r0], #0x04         /* 0x68 */
  236         ldr     r5, [r0], #0x04         /* 0x6c */
  237         strd    r2, [r1], #0x08
  238         ldr     r2, [r0], #0x04         /* 0x70 */
  239         ldr     r3, [r0], #0x04         /* 0x74 */
  240         strd    r4, [r1], #0x08
  241         ldr     r4, [r0], #0x04         /* 0x78 */
  242         ldr     r5, [r0], #0x04         /* 0x7c */
  243         strd    r2, [r1], #0x08
  244         subs    ip, ip, #0x01
  245         ldrgt   r2, [r0], #0x04         /* 0x80 */
  246         ldrgt   r3, [r0], #0x04         /* 0x84 */
  247         strd    r4, [r1], #0x08
  248         bgt     1b
  249         ldmfd   sp!, {r4, r5}
  250         RET
  251 END(bcopy_page)
  252 
  253 /*
  254  * armv5e version of bzero_page
  255  */
  256 ENTRY(bzero_page)
  257         mov     r1, #PAGE_SIZE
  258         mov     r2, #0
  259         mov     r3, #0
  260 1:      strd    r2, [r0], #8            /* 32 */
  261         strd    r2, [r0], #8
  262         strd    r2, [r0], #8
  263         strd    r2, [r0], #8
  264         strd    r2, [r0], #8            /* 64 */
  265         strd    r2, [r0], #8
  266         strd    r2, [r0], #8
  267         strd    r2, [r0], #8
  268         strd    r2, [r0], #8            /* 96 */
  269         strd    r2, [r0], #8
  270         strd    r2, [r0], #8
  271         strd    r2, [r0], #8
  272         strd    r2, [r0], #8            /* 128 */
  273         strd    r2, [r0], #8
  274         strd    r2, [r0], #8
  275         strd    r2, [r0], #8
  276         subs    r1, r1, #128
  277         bne     1b
  278         RET
  279 END(bzero_page)
  280 #endif  /* _ARM_ARCH_5E */

Cache object: dfa5a56a88fc3ba757d529d9bbf4903a


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.