source: EcnlProtoTool/trunk/asp3_dcre/mbed/targets/cmsis/TOOLCHAIN_GCC/TARGET_CORTEX_A/cache.S@ 270

Last change on this file since 270 was 270, checked in by coas-nagasima, 7 years ago

mruby版ECNLプロトタイピング・ツールを追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/plain
File size: 4.6 KB
Line 
1/* Copyright (c) 2009 - 2012 ARM LIMITED
2
3 All rights reserved.
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
6 - Redistributions of source code must retain the above copyright
7 notice, this list of conditions and the following disclaimer.
8 - Redistributions in binary form must reproduce the above copyright
9 notice, this list of conditions and the following disclaimer in the
10 documentation and/or other materials provided with the distribution.
11 - Neither the name of ARM nor the names of its contributors may be used
12 to endorse or promote products derived from this software without
13 specific prior written permission.
14 *
15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
19 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 POSSIBILITY OF SUCH DAMAGE.
26 ---------------------------------------------------------------------------*/
27
28/*----------------------------------------------------------------------------
29 * Functions
30 *---------------------------------------------------------------------------*/
31 .text
32 .global __v7_all_cache
33/*
34 * __STATIC_ASM void __v7_all_cache(uint32_t op) {
35 */
36__v7_all_cache:
37 .arm
38
39 PUSH {R4-R11}
40
41 MRC p15, 1, R6, c0, c0, 1 /* Read CLIDR */
42 ANDS R3, R6, #0x07000000 /* Extract coherency level */
43 MOV R3, R3, LSR #23 /* Total cache levels << 1 */
44 BEQ Finished /* If 0, no need to clean */
45
46 MOV R10, #0 /* R10 holds current cache level << 1 */
47Loop1: ADD R2, R10, R10, LSR #1 /* R2 holds cache "Set" position */
48 MOV R1, R6, LSR R2 /* Bottom 3 bits are the Cache-type for this level */
49 AND R1, R1, #7 /* Isolate those lower 3 bits */
50 CMP R1, #2
51 BLT Skip /* No cache or only instruction cache at this level */
52
53 MCR p15, 2, R10, c0, c0, 0 /* Write the Cache Size selection register */
54 ISB /* ISB to sync the change to the CacheSizeID reg */
55 MRC p15, 1, R1, c0, c0, 0 /* Reads current Cache Size ID register */
56 AND R2, R1, #7 /* Extract the line length field */
57 ADD R2, R2, #4 /* Add 4 for the line length offset (log2 16 bytes) */
58 LDR R4, =0x3FF
59 ANDS R4, R4, R1, LSR #3 /* R4 is the max number on the way size (right aligned) */
60 CLZ R5, R4 /* R5 is the bit position of the way size increment */
61 LDR R7, =0x7FFF
62 ANDS R7, R7, R1, LSR #13 /* R7 is the max number of the index size (right aligned) */
63
64Loop2: MOV R9, R4 /* R9 working copy of the max way size (right aligned) */
65
66Loop3: ORR R11, R10, R9, LSL R5 /* Factor in the Way number and cache number into R11 */
67 ORR R11, R11, R7, LSL R2 /* Factor in the Set number */
68 CMP R0, #0
69 BNE Dccsw
70 MCR p15, 0, R11, c7, c6, 2 /* DCISW. Invalidate by Set/Way */
71 B cont
72Dccsw: CMP R0, #1
73 BNE Dccisw
74 MCR p15, 0, R11, c7, c10, 2 /* DCCSW. Clean by Set/Way */
75 B cont
76Dccisw: MCR p15, 0, R11, c7, c14, 2 /* DCCISW, Clean and Invalidate by Set/Way */
77cont: SUBS R9, R9, #1 /* Decrement the Way number */
78 BGE Loop3
79 SUBS R7, R7, #1 /* Decrement the Set number */
80 BGE Loop2
81Skip: ADD R10, R10, #2 /* increment the cache number */
82 CMP R3, R10
83 BGT Loop1
84
85Finished:
86 DSB
87 POP {R4-R11}
88 BX lr
89
90
91 .END
92/*----------------------------------------------------------------------------
93 * end of file
94 *---------------------------------------------------------------------------*/
Note: See TracBrowser for help on using the repository browser.