| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: cpufunc_asm_arm11.S,v 1.10 2013/08/18 06:28:18 matt Exp $ */ | | 1 | /* $NetBSD: cpufunc_asm_arm11.S,v 1.11 2014/02/20 17:27:46 matt Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2002, 2005 ARM Limited | | 4 | * Copyright (c) 2002, 2005 ARM Limited |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -47,92 +47,113 @@ | | | @@ -47,92 +47,113 @@ |
47 | ENTRY(arm11_setttb) | | 47 | ENTRY(arm11_setttb) |
48 | #ifdef PMAP_CACHE_VIVT | | 48 | #ifdef PMAP_CACHE_VIVT |
49 | #error arm11 does not have a VIVT cache. | | 49 | #error arm11 does not have a VIVT cache. |
50 | #endif | | 50 | #endif |
51 | | | 51 | |
52 | mcr p15, 0, r0, c2, c0, 0 /* load new TTB */ | | 52 | mcr p15, 0, r0, c2, c0, 0 /* load new TTB */ |
53 | | | 53 | |
54 | cmp r1, #0 | | 54 | cmp r1, #0 |
55 | mcrne p15, 0, r0, c8, c7, 0 /* invalidate I+D TLBs */ | | 55 | mcrne p15, 0, r0, c8, c7, 0 /* invalidate I+D TLBs */ |
56 | mcrne p15, 0, r0, c7, c10, 4 /* drain write buffer */ | | 56 | mcrne p15, 0, r0, c7, c10, 4 /* drain write buffer */ |
57 | RET | | 57 | RET |
58 | END(arm11_setttb) | | 58 | END(arm11_setttb) |
59 | | | 59 | |
60 | /* | | | |
61 | * TLB functions | | | |
62 | */ | | | |
63 | ENTRY(arm11_tlb_flushID_SE) | | | |
64 | mcr p15, 0, r0, c8, c6, 1 /* flush D tlb single entry */ | | | |
65 | mcr p15, 0, r0, c8, c5, 1 /* flush I tlb single entry */ | | | |
66 | mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */ | | | |
67 | RET | | | |
68 | END(arm11_tlb_flushID_SE) | | | |
69 | | | | |
70 | ENTRY(arm11_tlb_flushI_SE) | | | |
71 | mcr p15, 0, r0, c8, c5, 1 /* flush I tlb single entry */ | | | |
72 | mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */ | | | |
73 | RET | | | |
74 | END(arm11_tlb_flushI_SE) | | | |
75 | | | | |
76 | | | 60 | |
77 | /* | | 61 | /* |
78 | * Context switch. | | 62 | * Context switch. |
79 | * | | 63 | * |
80 | * These are the CPU-specific parts of the context switcher cpu_switchto() | | 64 | * These are the CPU-specific parts of the context switcher cpu_switchto() |
81 | * These functions actually perform the TTB reload. | | 65 | * These functions actually perform the TTB reload. |
82 | */ | | 66 | */ |
83 | ENTRY(arm11_context_switch) | | 67 | ENTRY(arm11_context_switch) |
84 | /* | | 68 | /* |
85 | * We can assume that the caches will only contain kernel addresses | | 69 | * We can assume that the caches will only contain kernel addresses |
86 | * at this point. So no need to flush them again. | | 70 | * at this point. So no need to flush them again. |
87 | */ | | 71 | */ |
88 | mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */ | | 72 | mcr p15, 0, r0, c7, c10, 4 /* drain the write buffer */ |
89 | mcr p15, 0, r0, c2, c0, 0 /* set the new TTB */ | | 73 | mcr p15, 0, r0, c2, c0, 0 /* set the new TTB */ |
90 | mcr p15, 0, r0, c8, c7, 0 /* and flush the I+D tlbs */ | | 74 | mcr p15, 0, r0, c8, c7, 0 /* and flush the I+D tlbs */ |
91 | | | 75 | |
92 | /* Paranoia -- make sure the pipeline is empty. */ | | 76 | /* Paranoia -- make sure the pipeline is empty. */ |
93 | nop | | 77 | nop |
94 | nop | | 78 | nop |
95 | nop | | 79 | nop |
96 | RET | | 80 | RET |
97 | END(arm11_context_switch) | | 81 | END(arm11_context_switch) |
98 | | | 82 | |
99 | /* | | 83 | /* |
100 | * TLB functions | | 84 | * TLB functions |
101 | */ | | 85 | */ |
102 | ENTRY(arm11_tlb_flushID) | | | |
103 | mcr p15, 0, r0, c8, c7, 0 /* flush I+D tlb */ | | | |
104 | mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */ | | | |
105 | RET | | | |
106 | END(arm11_tlb_flushID) | | | |
107 | | | 86 | |
108 | ENTRY(arm11_tlb_flushI) | | 87 | ENTRY(arm11_tlb_flushI) |
| | | 88 | mov r0, #0 |
109 | mcr p15, 0, r0, c8, c5, 0 /* flush I tlb */ | | 89 | mcr p15, 0, r0, c8, c5, 0 /* flush I tlb */ |
110 | mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */ | | 90 | mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */ |
111 | RET | | 91 | RET |
112 | END(arm11_tlb_flushI) | | 92 | END(arm11_tlb_flushI) |
113 | | | 93 | |
| | | 94 | ENTRY(arm11_tlb_flushI_SE) |
| | | 95 | #ifdef ARM_MMU_EXTENDED |
| | | 96 | orr r0, r0, r1 /* insert ASID into MVA */ |
| | | 97 | #endif |
| | | 98 | mcr p15, 0, r0, c8, c5, 1 /* flush I tlb single entry */ |
| | | 99 | mov r0, #0 |
| | | 100 | mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */ |
| | | 101 | RET |
| | | 102 | END(arm11_tlb_flushI_SE) |
| | | 103 | |
114 | ENTRY(arm11_tlb_flushD) | | 104 | ENTRY(arm11_tlb_flushD) |
| | | 105 | mov r0, #0 |
115 | mcr p15, 0, r0, c8, c6, 0 /* flush D tlb */ | | 106 | mcr p15, 0, r0, c8, c6, 0 /* flush D tlb */ |
116 | mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */ | | 107 | mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */ |
117 | RET | | 108 | RET |
118 | END(arm11_tlb_flushD) | | 109 | END(arm11_tlb_flushD) |
119 | | | 110 | |
120 | ENTRY(arm11_tlb_flushD_SE) | | 111 | ENTRY(arm11_tlb_flushD_SE) |
| | | 112 | #ifdef ARM_MMU_EXTENDED |
| | | 113 | orr r0, r0, r1 /* insert ASID into MVA */ |
| | | 114 | #endif |
121 | mcr p15, 0, r0, c8, c6, 1 /* flush D tlb single entry */ | | 115 | mcr p15, 0, r0, c8, c6, 1 /* flush D tlb single entry */ |
| | | 116 | mov r0, #0 |
122 | mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */ | | 117 | mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */ |
123 | RET | | 118 | RET |
124 | END(arm11_tlb_flushD_SE) | | 119 | END(arm11_tlb_flushD_SE) |
125 | | | 120 | |
| | | 121 | ENTRY(arm11_tlb_flushID) |
| | | 122 | mov r0, #0 |
| | | 123 | mcr p15, 0, r0, c8, c7, 0 /* flush I+D tlb */ |
| | | 124 | mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */ |
| | | 125 | RET |
| | | 126 | END(arm11_tlb_flushID) |
| | | 127 | |
| | | 128 | ENTRY(arm11_tlb_flushID_SE) |
| | | 129 | #ifdef ARM_MMU_EXTENDED |
| | | 130 | orr r0, r0, r1 /* insert ASID into MVA */ |
| | | 131 | #endif |
| | | 132 | mcr p15, 0, r0, c8, c7, 1 /* flush I+D tlb single entry */ |
| | | 133 | mov r0, #0 |
| | | 134 | mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */ |
| | | 135 | RET |
| | | 136 | END(arm11_tlb_flushID_SE) |
| | | 137 | |
| | | 138 | #ifdef ARM_MMU_EXTENDED |
| | | 139 | ENTRY(arm11_tlb_flushID_ASID) |
| | | 140 | mcr p15, 0, r0, c8, c7, 2 /* flush I+D tlb */ |
| | | 141 | mov r0, #0 |
| | | 142 | mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */ |
| | | 143 | RET |
| | | 144 | END(arm11_tlb_flushID_ASID) |
| | | 145 | #endif |
| | | 146 | |
126 | /* | | 147 | /* |
127 | * Other functions | | 148 | * Other functions |
128 | */ | | 149 | */ |
129 | ENTRY(arm11_drain_writebuf) | | 150 | ENTRY(arm11_drain_writebuf) |
130 | mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */ | | 151 | mcr p15, 0, r0, c7, c10, 4 /* drain write buffer */ |
131 | RET | | 152 | RET |
132 | END(arm11_drain_writebuf) | | 153 | END(arm11_drain_writebuf) |
133 | | | 154 | |
134 | ENTRY_NP(arm11_sleep) | | 155 | ENTRY_NP(arm11_sleep) |
135 | mov r0, #0 | | 156 | mov r0, #0 |
136 | mcr p15, 0, r0, c7, c0, 4 /* wait for interrupt */ | | 157 | mcr p15, 0, r0, c7, c0, 4 /* wait for interrupt */ |
137 | RET | | 158 | RET |
138 | END(arm11_sleep) | | 159 | END(arm11_sleep) |