Home | History | Annotate | Line # | Download | only in arm
cpufunc_asm_arm1136.S revision 1.2
      1  1.2  matt /* $NetBSD: cpufunc_asm_arm1136.S,v 1.2 2008/04/27 18:58:43 matt Exp $ */
      2  1.2  matt 
      3  1.2  matt /*
      4  1.2  matt  * Copyright (c) 2007 Microsoft
      5  1.2  matt  * All rights reserved.
      6  1.2  matt  *
      7  1.2  matt  * Redistribution and use in source and binary forms, with or without
      8  1.2  matt  * modification, are permitted provided that the following conditions
      9  1.2  matt  * are met:
     10  1.2  matt  * 1. Redistributions of source code must retain the above copyright
     11  1.2  matt  *    notice, this list of conditions and the following disclaimer.
     12  1.2  matt  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.2  matt  *    notice, this list of conditions and the following disclaimer in the
     14  1.2  matt  *    documentation and/or other materials provided with the distribution.
     15  1.2  matt  * 3. All advertising materials mentioning features or use of this software
     16  1.2  matt  *    must display the following acknowledgement:
     17  1.2  matt  *	This product includes software developed by Microsoft
     18  1.2  matt  *
     19  1.2  matt  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
     20  1.2  matt  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     21  1.2  matt  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     22  1.2  matt  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTERS BE LIABLE FOR ANY DIRECT,
     23  1.2  matt  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     24  1.2  matt  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     25  1.2  matt  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26  1.2  matt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     27  1.2  matt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     28  1.2  matt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     29  1.2  matt  * SUCH DAMAGE.
     30  1.2  matt  */
     31  1.2  matt 
     32  1.2  matt #include "assym.h"
     33  1.2  matt #include <machine/cpu.h>
     34  1.2  matt #include <machine/asm.h>
     35  1.2  matt 
     36  1.2  matt RCSID("$NetBSD: cpufunc_asm_arm1136.S,v 1.2 2008/04/27 18:58:43 matt Exp $")
     37  1.2  matt 
     38  1.2  matt #if 0
     39  1.2  matt #define Invalidate_I_cache(Rtmp1, Rtmp2) \
     40  1.2  matt 	mcr	p15, 0, Rtmp1, c7, c5, 0	/* Invalidate Entire I cache */
     41  1.2  matt #else
     42  1.2  matt /*
     43  1.2  matt  * Workaround Erratum 411920
     44  1.2  matt  *
     45  1.2  matt  *	- value of arg 'reg' Should Be Zero
     46  1.2  matt  */
     47  1.2  matt #define Invalidate_I_cache(Rtmp1, Rtmp2) \
     48  1.2  matt 	mov	Rtmp1, #0;		/* SBZ */			\
     49  1.2  matt 	mrs	Rtmp2, cpsr;						\
     50  1.2  matt 	cpsid	ifa;							\
     51  1.2  matt 	mcr	p15, 0, Rtmp1, c7, c5, 0;	/* Nuke Whole Icache */	\
     52  1.2  matt 	mcr	p15, 0, Rtmp1, c7, c5, 0;	/* Nuke Whole Icache */	\
     53  1.2  matt 	mcr	p15, 0, Rtmp1, c7, c5, 0;	/* Nuke Whole Icache */	\
     54  1.2  matt 	mcr	p15, 0, Rtmp1, c7, c5, 0;	/* Nuke Whole Icache */	\
     55  1.2  matt 	msr	cpsr_cx, Rtmp2;						\
     56  1.2  matt 	nop;								\
     57  1.2  matt 	nop;								\
     58  1.2  matt 	nop;								\
     59  1.2  matt 	nop;								\
     60  1.2  matt 	nop;								\
     61  1.2  matt 	nop;								\
     62  1.2  matt 	nop;								\
     63  1.2  matt 	nop;								\
     64  1.2  matt 	nop;								\
     65  1.2  matt 	nop;								\
     66  1.2  matt 	nop;
     67  1.2  matt #endif
     68  1.2  matt 
     69  1.2  matt #if 1
     70  1.2  matt #define Flush_D_cache(reg) \
     71  1.2  matt 	mov	reg, #0;		/* SBZ */					\
     72  1.2  matt 	mcr	p15, 0, reg, c7, c14, 0;/* Clean and Invalidate Entire Data Cache */	\
     73  1.2  matt 	mcr	p15, 0, reg, c7, c10, 4;/* Data Synchronization Barrier */
     74  1.2  matt #else
     75  1.2  matt #define Flush_D_cache(reg) \
     76  1.2  matt 1:	mov	reg, #0;		/* SBZ */					\
     77  1.2  matt 	mcr	p15, 0, reg, c7, c14, 0;/* Clean and Invalidate Entire Data Cache */	\
     78  1.2  matt 	mrc	p15, 0, reg, C7, C10, 6;/* Read Cache Dirty Status Register */		\
     79  1.2  matt 	ands	reg, reg, #01;		/* Check if it is clean */			\
     80  1.2  matt 	bne	1b;			/* loop if not */				\
     81  1.2  matt 	mcr	p15, 0, reg, c7, c10, 4;/* Data Synchronization Barrier */
     82  1.2  matt #endif
     83  1.2  matt 
     84  1.2  matt ENTRY(arm1136_setttb)
     85  1.2  matt #ifdef PMAP_CACHE_VIVT
     86  1.2  matt 	Flush_D_cache(r1)
     87  1.2  matt 	Invalidate_I_cache(r1, r2)
     88  1.2  matt #endif
     89  1.2  matt 	mcr	p15, 0, r0, c2, c0, 0	/* load new TTB */
     90  1.2  matt 	mcr	p15, 0, r1, c8, c7, 0	/* invalidate I+D TLBs */
     91  1.2  matt 	mcr	p15, 0, r1, c7, c10, 4	/* drain write buffer */
     92  1.2  matt 	RET
     93  1.2  matt 
     94  1.2  matt ENTRY_NP(arm1136_idcache_wbinv_all)
     95  1.2  matt 	Flush_D_cache(r0)
     96  1.2  matt 	Invalidate_I_cache(r0, r1)
     97  1.2  matt 	RET
     98  1.2  matt 
     99  1.2  matt ENTRY_NP(arm1136_dcache_wbinv_all)
    100  1.2  matt 	Flush_D_cache(r0)
    101  1.2  matt 	RET
    102  1.2  matt 
    103  1.2  matt ENTRY_NP(arm1136_icache_sync_all)
    104  1.2  matt 	Flush_D_cache(r0)
    105  1.2  matt 	Invalidate_I_cache(r0, r1)
    106  1.2  matt 	RET
    107  1.2  matt 
    108  1.2  matt ENTRY_NP(arm1136_flush_prefetchbuf)
    109  1.2  matt 	mcr	p15, 0, r0, c7, c5, 4	/* Flush Prefetch Buffer */
    110  1.2  matt 	RET
    111  1.2  matt 
    112  1.2  matt ENTRY_NP(arm1136_icache_sync_range)
    113  1.2  matt 	add	r1, r1, r0
    114  1.2  matt 	sub	r1, r1, #1
    115  1.2  matt 	/* Erratum 371025, workaround #2 */
    116  1.2  matt 	mrs	r2, cpsr		/* save the CPSR */
    117  1.2  matt 	cpsid	ifa			/* disable interrupts (irq,fiq,abort) */
    118  1.2  matt 	mov	r3, #0
    119  1.2  matt 	mcr	p15, 0, r3, c13, c0, 0	/* write FCSE (uTLB invalidate) */
    120  1.2  matt 	mcr	p15, 0, r3, c7, c5, 4	/* flush prefetch buffer */
    121  1.2  matt 	add	r3, pc, #0x24
    122  1.2  matt 	mcr	p15, 0, r3, c7, c13, 1	/* prefetch I-cache line */
    123  1.2  matt 	mcrr	p15, 0, r1, r0, c5	/* invalidate I-cache range */
    124  1.2  matt 	msr	cpsr_cx, r2		/* local_irq_restore */
    125  1.2  matt 	nop
    126  1.2  matt 	nop
    127  1.2  matt 	nop
    128  1.2  matt 	nop
    129  1.2  matt 	nop
    130  1.2  matt 	nop
    131  1.2  matt 	nop
    132  1.2  matt 
    133  1.2  matt 	mcrr	p15, 0, r1, r0, c12	/* clean and invalidate D cache range */
    134  1.2  matt 	mcr	p15, 0, r0, c7, c10, 4	/* drain the write buffer */
    135  1.2  matt 	RET
    136  1.2  matt 
    137  1.2  matt ENTRY_NP(arm1136_idcache_wbinv_range)
    138  1.2  matt 	add	r1, r1, r0
    139  1.2  matt 	sub	r1, r1, #1
    140  1.2  matt 	/* Erratum 371025, workaround #2 */
    141  1.2  matt 	mrs	r2, cpsr		/* save the CPSR */
    142  1.2  matt 	cpsid	ifa			/* disable interrupts (irq,fiq,abort) */
    143  1.2  matt 	mov	r3, #0
    144  1.2  matt 	mcr	p15, 0, r3, c13, c0, 0	/* write FCSE (uTLB invalidate) */
    145  1.2  matt 	mcr	p15, 0, r3, c7, c5, 4	/* flush prefetch buffer */
    146  1.2  matt 	add	r3, pc, #0x24
    147  1.2  matt 	mcr	p15, 0, r3, c7, c13, 1	/* prefetch I-cache line */
    148  1.2  matt 	mcrr	p15, 0, r1, r0, c5	/* invalidate I-cache range */
    149  1.2  matt 	msr	cpsr_cx, r2		/* local_irq_restore */
    150  1.2  matt 	nop
    151  1.2  matt 	nop
    152  1.2  matt 	nop
    153  1.2  matt 	nop
    154  1.2  matt 	nop
    155  1.2  matt 	nop
    156  1.2  matt 	nop
    157  1.2  matt 
    158  1.2  matt 	mcrr	p15, 0, r1, r0, c14	/* clean and invalidate D cache range */
    159  1.2  matt 	mcr	p15, 0, r0, c7, c10, 4	/* drain the write buffer */
    160  1.2  matt 	RET
    161  1.2  matt 
    162  1.2  matt ENTRY_NP(arm1136_sleep_rev0)		/* errata 336501 */
    163  1.2  matt 	mov	r0, #0
    164  1.2  matt 	mcr	p15, 0, r0, c7, c10, 2	/* clean data cache line (via index) */
    165  1.2  matt 	mcr	p15, 0, r0, c7, c10, 5	/* data memory barrier */
    166  1.2  matt 	mcr	p15, 0, r0, c7, c0, 4	/* wait for interrupt */
    167  1.2  matt 	RET
    168