• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1@/*
2@ * Copyright (c) 2009-2022 Huawei Technologies Co., Ltd. All rights reserved.
3@ *
4@ * UniProton is licensed under Mulan PSL v2.
5@ * You can use this software according to the terms and conditions of the Mulan PSL v2.
6@ * You may obtain a copy of Mulan PSL v2 at:
7@ *          http://license.coscl.org.cn/MulanPSL2
8@ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
9@ * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
10@ * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
11@ * See the Mulan PSL v2 for more details.
12@ * Create: 2009-12-22
13@ * Description: thread scheduler
14@ */
15.global os_asm_invalidate_dcache_all
16.global os_asm_invalidate_icache_all
17.global os_asm_invalidate_tlb_all
18
19    .type os_asm_dcache_level, "function"
20os_asm_dcache_level:
21    lsl    x12, x0, #1
22    msr    csselr_el1, x12
23    isb
24    mrs    x6, ccsidr_el1
25    and    x2, x6, #7
26    add    x2, x2, #4
27    mov    x3, #0x3ff
28    and    x3, x3, x6, lsr #3
29    clz    w5, w3
30    mov    x4, #0x7fff
31    and    x4, x4, x6, lsr #13
32
33loop_set:
34    mov    x6, x3
35loop_way:
36    lsl    x7, x6, x5
37    orr    x9, x12, x7
38    lsl    x7, x4, x2
39    orr    x9, x9, x7
40    tbz    w1, #1, 3f
41    dc     csw, x9
42    b      2f
433:  tbz    w1, #0, 1f
44    dc     isw, x9
45    b      2f
461:  dc     cisw, x9
472:  subs   x6, x6, #1
48    b.ge   loop_way
49    subs   x4, x4, #1
50    b.ge   loop_set
51
52    ret
53
54    .type os_asm_dcache_all, "function"
55os_asm_dcache_all:
56    mov    x1, x0
57    dsb    sy
58    mrs    x10, clidr_el1
59    lsr    x11, x10, #24
60    and    x11, x11, #0x7
61    cbz    x11, finished
62    mov    x15, x30
63    mov    x0, #0
64
65loop_level:
66    lsl    x12, x0, #1
67    add    x12, x12, x0
68    lsr    x12, x10, x12
69    and    x12, x12, #7
70    cmp    x12, #2
71    b.lt   skip
72    bl     os_asm_dcache_level
73skip:
74    add    x0, x0, #1
75    cmp    x11, x0
76    b.gt   loop_level
77
78    mov    x0, #0
79    msr    csselr_el1, x0
80    dsb    sy
81    isb
82    mov    x30, x15
83
84finished:
85    ret
86
87    .type os_asm_invalidate_dcache_all, "function"
88os_asm_invalidate_dcache_all:
89    mov    x0, #0x1
90    b      os_asm_dcache_all
91
92    .type os_asm_invalidate_icache_all, "function"
93os_asm_invalidate_icache_all:
94    ic     ialluis
95    isb    sy
96    ret
97
98    .type os_asm_invalidate_tlb_all, "function"
99os_asm_invalidate_tlb_all:
100    tlbi   vmalle1
101    dsb    sy
102    isb
103    ret
104