Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* NGpage.S: Niagara optimize clear and copy page.
0003  *
0004  * Copyright (C) 2006 (davem@davemloft.net)
0005  */
0006 
0007 #include <asm/asi.h>
0008 #include <asm/page.h>
0009 
0010     .text
0011     .align  32
0012 
0013     /* This is heavily simplified from the sun4u variants
0014      * because Niagara does not have any D-cache aliasing issues
0015      * and also we don't need to use the FPU in order to implement
0016      * an optimal page copy/clear.
0017      */
0018 
0019 NGcopy_user_page:   /* %o0=dest, %o1=src, %o2=vaddr */
0020     save        %sp, -192, %sp
0021     rd      %asi, %g3
0022     wr      %g0, ASI_BLK_INIT_QUAD_LDD_P, %asi
0023     set     PAGE_SIZE, %g7
0024     prefetch    [%i1 + 0x00], #one_read
0025     prefetch    [%i1 + 0x40], #one_read
0026 
0027 1:  prefetch    [%i1 + 0x80], #one_read
0028     prefetch    [%i1 + 0xc0], #one_read
0029     ldda        [%i1 + 0x00] %asi, %o2
0030     ldda        [%i1 + 0x10] %asi, %o4
0031     ldda        [%i1 + 0x20] %asi, %l2
0032     ldda        [%i1 + 0x30] %asi, %l4
0033     stxa        %o2, [%i0 + 0x00] %asi
0034     stxa        %o3, [%i0 + 0x08] %asi
0035     stxa        %o4, [%i0 + 0x10] %asi
0036     stxa        %o5, [%i0 + 0x18] %asi
0037     stxa        %l2, [%i0 + 0x20] %asi
0038     stxa        %l3, [%i0 + 0x28] %asi
0039     stxa        %l4, [%i0 + 0x30] %asi
0040     stxa        %l5, [%i0 + 0x38] %asi
0041     ldda        [%i1 + 0x40] %asi, %o2
0042     ldda        [%i1 + 0x50] %asi, %o4
0043     ldda        [%i1 + 0x60] %asi, %l2
0044     ldda        [%i1 + 0x70] %asi, %l4
0045     stxa        %o2, [%i0 + 0x40] %asi
0046     stxa        %o3, [%i0 + 0x48] %asi
0047     stxa        %o4, [%i0 + 0x50] %asi
0048     stxa        %o5, [%i0 + 0x58] %asi
0049     stxa        %l2, [%i0 + 0x60] %asi
0050     stxa        %l3, [%i0 + 0x68] %asi
0051     stxa        %l4, [%i0 + 0x70] %asi
0052     stxa        %l5, [%i0 + 0x78] %asi
0053     add     %i1, 128, %i1
0054     subcc       %g7, 128, %g7
0055     bne,pt      %xcc, 1b
0056      add        %i0, 128, %i0
0057     wr      %g3, 0x0, %asi
0058     membar      #Sync
0059     ret
0060      restore
0061 
0062     .align      32
0063     .globl      NGclear_page
0064     .globl      NGclear_user_page
0065 NGclear_page:       /* %o0=dest */
0066 NGclear_user_page:  /* %o0=dest, %o1=vaddr */
0067     rd      %asi, %g3
0068     wr      %g0, ASI_BLK_INIT_QUAD_LDD_P, %asi
0069     set     PAGE_SIZE, %g7
0070 
0071 1:  stxa        %g0, [%o0 + 0x00] %asi
0072     stxa        %g0, [%o0 + 0x08] %asi
0073     stxa        %g0, [%o0 + 0x10] %asi
0074     stxa        %g0, [%o0 + 0x18] %asi
0075     stxa        %g0, [%o0 + 0x20] %asi
0076     stxa        %g0, [%o0 + 0x28] %asi
0077     stxa        %g0, [%o0 + 0x30] %asi
0078     stxa        %g0, [%o0 + 0x38] %asi
0079     stxa        %g0, [%o0 + 0x40] %asi
0080     stxa        %g0, [%o0 + 0x48] %asi
0081     stxa        %g0, [%o0 + 0x50] %asi
0082     stxa        %g0, [%o0 + 0x58] %asi
0083     stxa        %g0, [%o0 + 0x60] %asi
0084     stxa        %g0, [%o0 + 0x68] %asi
0085     stxa        %g0, [%o0 + 0x70] %asi
0086     stxa        %g0, [%o0 + 0x78] %asi
0087     stxa        %g0, [%o0 + 0x80] %asi
0088     stxa        %g0, [%o0 + 0x88] %asi
0089     stxa        %g0, [%o0 + 0x90] %asi
0090     stxa        %g0, [%o0 + 0x98] %asi
0091     stxa        %g0, [%o0 + 0xa0] %asi
0092     stxa        %g0, [%o0 + 0xa8] %asi
0093     stxa        %g0, [%o0 + 0xb0] %asi
0094     stxa        %g0, [%o0 + 0xb8] %asi
0095     stxa        %g0, [%o0 + 0xc0] %asi
0096     stxa        %g0, [%o0 + 0xc8] %asi
0097     stxa        %g0, [%o0 + 0xd0] %asi
0098     stxa        %g0, [%o0 + 0xd8] %asi
0099     stxa        %g0, [%o0 + 0xe0] %asi
0100     stxa        %g0, [%o0 + 0xe8] %asi
0101     stxa        %g0, [%o0 + 0xf0] %asi
0102     stxa        %g0, [%o0 + 0xf8] %asi
0103     subcc       %g7, 256, %g7
0104     bne,pt      %xcc, 1b
0105      add        %o0, 256, %o0
0106     wr      %g3, 0x0, %asi
0107     membar      #Sync
0108     retl
0109      nop
0110 
0111 #define BRANCH_ALWAYS   0x10680000
0112 #define NOP     0x01000000
0113 #define NG_DO_PATCH(OLD, NEW)   \
0114     sethi   %hi(NEW), %g1; \
0115     or  %g1, %lo(NEW), %g1; \
0116     sethi   %hi(OLD), %g2; \
0117     or  %g2, %lo(OLD), %g2; \
0118     sub %g1, %g2, %g1; \
0119     sethi   %hi(BRANCH_ALWAYS), %g3; \
0120     sll %g1, 11, %g1; \
0121     srl %g1, 11 + 2, %g1; \
0122     or  %g3, %lo(BRANCH_ALWAYS), %g3; \
0123     or  %g3, %g1, %g3; \
0124     stw %g3, [%g2]; \
0125     sethi   %hi(NOP), %g3; \
0126     or  %g3, %lo(NOP), %g3; \
0127     stw %g3, [%g2 + 0x4]; \
0128     flush   %g2;
0129 
0130     .globl  niagara_patch_pageops
0131     .type   niagara_patch_pageops,#function
0132 niagara_patch_pageops:
0133     NG_DO_PATCH(copy_user_page, NGcopy_user_page)
0134     NG_DO_PATCH(_clear_page, NGclear_page)
0135     NG_DO_PATCH(clear_user_page, NGclear_user_page)
0136     retl
0137      nop
0138     .size   niagara_patch_pageops,.-niagara_patch_pageops