Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/threads.h> |
| 14 | |
| 15 | #if (NR_CPUS > 2) |
| 16 | #error code only tested for 1 or 2 CPUs. |
| 17 | #endif |
| 18 | |
| 19 | /* Add 1 slot to store the register count for ETM state */ |
| 20 | #define MAX_ETM_REGS (56 + 1) |
| 21 | #define MAX_ETM_STATE_SIZE (MAX_ETM_REGS * 4) |
| 22 | |
| 23 | .global etm_read_reg |
| 24 | etm_read_reg: |
| 25 | cmp r0, #0x7F |
| 26 | bhi read_high |
| 27 | ldr r2, =read_table |
| 28 | add r2, r2, r0, lsl #3 |
| 29 | mov pc, r2 |
| 30 | |
| 31 | read_high: |
| 32 | cmp r0, #0xC1 |
| 33 | beq read_c1 |
| 34 | cmp r0, #0xC4 |
| 35 | beq read_c4 |
| 36 | cmp r0, #0xC5 |
| 37 | beq read_c5 |
| 38 | mov r0, #0 |
| 39 | bx lr |
| 40 | |
| 41 | read_c1: |
| 42 | mrc p14, 1, r0, c1, c1, 4 // register 0xC1 (OS Lock Status Reg) |
| 43 | bx lr |
| 44 | |
| 45 | read_c4: |
| 46 | mrc p14, 1, r0, c1, c4, 4 // register 0xC4 (Powerdown Ctl Reg) |
| 47 | bx lr |
| 48 | |
| 49 | read_c5: |
| 50 | mrc p14, 1, r0, c1, c5, 4 // register 0xC5 (Powerdown Status Reg) |
| 51 | bx lr |
| 52 | |
| 53 | read_table: |
| 54 | mrc p14, 1, r0, c0, c0, 0 // register 0x00 |
| 55 | bx lr |
| 56 | mrc p14, 1, r0, c0, c1, 0 // register 0x01 |
| 57 | bx lr |
| 58 | mrc p14, 1, r0, c0, c2, 0 // register 0x02 |
| 59 | bx lr |
| 60 | mrc p14, 1, r0, c0, c3, 0 // register 0x03 |
| 61 | bx lr |
| 62 | mrc p14, 1, r0, c0, c4, 0 // register 0x04 |
| 63 | bx lr |
| 64 | mrc p14, 1, r0, c0, c5, 0 // register 0x05 |
| 65 | bx lr |
| 66 | mrc p14, 1, r0, c0, c6, 0 // register 0x06 |
| 67 | bx lr |
| 68 | mrc p14, 1, r0, c0, c7, 0 // register 0x07 |
| 69 | bx lr |
| 70 | mrc p14, 1, r0, c0, c8, 0 // register 0x08 |
| 71 | bx lr |
| 72 | mrc p14, 1, r0, c0, c9, 0 // register 0x09 |
| 73 | bx lr |
| 74 | mrc p14, 1, r0, c0, c10, 0 // register 0x0A |
| 75 | bx lr |
| 76 | mrc p14, 1, r0, c0, c11, 0 // register 0x0B |
| 77 | bx lr |
| 78 | mrc p14, 1, r0, c0, c12, 0 // register 0x0C |
| 79 | bx lr |
| 80 | mrc p14, 1, r0, c0, c13, 0 // register 0x0D |
| 81 | bx lr |
| 82 | mrc p14, 1, r0, c0, c14, 0 // register 0x0E |
| 83 | bx lr |
| 84 | mrc p14, 1, r0, c0, c15, 0 // register 0x0F |
| 85 | bx lr |
| 86 | mrc p14, 1, r0, c0, c0, 1 // register 0x10 |
| 87 | bx lr |
| 88 | mrc p14, 1, r0, c0, c1, 1 // register 0x11 |
| 89 | bx lr |
| 90 | mrc p14, 1, r0, c0, c2, 1 // register 0x12 |
| 91 | bx lr |
| 92 | mrc p14, 1, r0, c0, c3, 1 // register 0x13 |
| 93 | bx lr |
| 94 | mrc p14, 1, r0, c0, c4, 1 // register 0x14 |
| 95 | bx lr |
| 96 | mrc p14, 1, r0, c0, c5, 1 // register 0x15 |
| 97 | bx lr |
| 98 | mrc p14, 1, r0, c0, c6, 1 // register 0x16 |
| 99 | bx lr |
| 100 | mrc p14, 1, r0, c0, c7, 1 // register 0x17 |
| 101 | bx lr |
| 102 | mrc p14, 1, r0, c0, c8, 1 // register 0x18 |
| 103 | bx lr |
| 104 | mrc p14, 1, r0, c0, c9, 1 // register 0x19 |
| 105 | bx lr |
| 106 | mrc p14, 1, r0, c0, c10, 1 // register 0x1A |
| 107 | bx lr |
| 108 | mrc p14, 1, r0, c0, c11, 1 // register 0x1B |
| 109 | bx lr |
| 110 | mrc p14, 1, r0, c0, c12, 1 // register 0x1C |
| 111 | bx lr |
| 112 | mrc p14, 1, r0, c0, c13, 1 // register 0x1D |
| 113 | bx lr |
| 114 | mrc p14, 1, r0, c0, c14, 1 // register 0x1E |
| 115 | bx lr |
| 116 | mrc p14, 1, r0, c0, c15, 1 // register 0x1F |
| 117 | bx lr |
| 118 | mrc p14, 1, r0, c0, c0, 2 // register 0x20 |
| 119 | bx lr |
| 120 | mrc p14, 1, r0, c0, c1, 2 // register 0x21 |
| 121 | bx lr |
| 122 | mrc p14, 1, r0, c0, c2, 2 // register 0x22 |
| 123 | bx lr |
| 124 | mrc p14, 1, r0, c0, c3, 2 // register 0x23 |
| 125 | bx lr |
| 126 | mrc p14, 1, r0, c0, c4, 2 // register 0x24 |
| 127 | bx lr |
| 128 | mrc p14, 1, r0, c0, c5, 2 // register 0x25 |
| 129 | bx lr |
| 130 | mrc p14, 1, r0, c0, c6, 2 // register 0x26 |
| 131 | bx lr |
| 132 | mrc p14, 1, r0, c0, c7, 2 // register 0x27 |
| 133 | bx lr |
| 134 | mrc p14, 1, r0, c0, c8, 2 // register 0x28 |
| 135 | bx lr |
| 136 | mrc p14, 1, r0, c0, c9, 2 // register 0x29 |
| 137 | bx lr |
| 138 | mrc p14, 1, r0, c0, c10, 2 // register 0x2A |
| 139 | bx lr |
| 140 | mrc p14, 1, r0, c0, c11, 2 // register 0x2B |
| 141 | bx lr |
| 142 | mrc p14, 1, r0, c0, c12, 2 // register 0x2C |
| 143 | bx lr |
| 144 | mrc p14, 1, r0, c0, c13, 2 // register 0x2D |
| 145 | bx lr |
| 146 | mrc p14, 1, r0, c0, c14, 2 // register 0x2E |
| 147 | bx lr |
| 148 | mrc p14, 1, r0, c0, c15, 2 // register 0x2F |
| 149 | bx lr |
| 150 | mrc p14, 1, r0, c0, c0, 3 // register 0x30 |
| 151 | bx lr |
| 152 | mrc p14, 1, r0, c0, c1, 3 // register 0x31 |
| 153 | bx lr |
| 154 | mrc p14, 1, r0, c0, c2, 3 // register 0x32 |
| 155 | bx lr |
| 156 | mrc p14, 1, r0, c0, c3, 3 // register 0x33 |
| 157 | bx lr |
| 158 | mrc p14, 1, r0, c0, c4, 3 // register 0x34 |
| 159 | bx lr |
| 160 | mrc p14, 1, r0, c0, c5, 3 // register 0x35 |
| 161 | bx lr |
| 162 | mrc p14, 1, r0, c0, c6, 3 // register 0x36 |
| 163 | bx lr |
| 164 | mrc p14, 1, r0, c0, c7, 3 // register 0x37 |
| 165 | bx lr |
| 166 | mrc p14, 1, r0, c0, c8, 3 // register 0x38 |
| 167 | bx lr |
| 168 | mrc p14, 1, r0, c0, c9, 3 // register 0x39 |
| 169 | bx lr |
| 170 | mrc p14, 1, r0, c0, c10, 3 // register 0x3A |
| 171 | bx lr |
| 172 | mrc p14, 1, r0, c0, c11, 3 // register 0x3B |
| 173 | bx lr |
| 174 | mrc p14, 1, r0, c0, c12, 3 // register 0x3C |
| 175 | bx lr |
| 176 | mrc p14, 1, r0, c0, c13, 3 // register 0x3D |
| 177 | bx lr |
| 178 | mrc p14, 1, r0, c0, c14, 3 // register 0x3E |
| 179 | bx lr |
| 180 | mrc p14, 1, r0, c0, c15, 3 // register 0x3F |
| 181 | bx lr |
| 182 | mrc p14, 1, r0, c0, c0, 4 // register 0x40 |
| 183 | bx lr |
| 184 | mrc p14, 1, r0, c0, c1, 4 // register 0x41 |
| 185 | bx lr |
| 186 | mrc p14, 1, r0, c0, c2, 4 // register 0x42 |
| 187 | bx lr |
| 188 | mrc p14, 1, r0, c0, c3, 4 // register 0x43 |
| 189 | bx lr |
| 190 | mrc p14, 1, r0, c0, c4, 4 // register 0x44 |
| 191 | bx lr |
| 192 | mrc p14, 1, r0, c0, c5, 4 // register 0x45 |
| 193 | bx lr |
| 194 | mrc p14, 1, r0, c0, c6, 4 // register 0x46 |
| 195 | bx lr |
| 196 | mrc p14, 1, r0, c0, c7, 4 // register 0x47 |
| 197 | bx lr |
| 198 | mrc p14, 1, r0, c0, c8, 4 // register 0x48 |
| 199 | bx lr |
| 200 | mrc p14, 1, r0, c0, c9, 4 // register 0x49 |
| 201 | bx lr |
| 202 | mrc p14, 1, r0, c0, c10, 4 // register 0x4A |
| 203 | bx lr |
| 204 | mrc p14, 1, r0, c0, c11, 4 // register 0x4B |
| 205 | bx lr |
| 206 | mrc p14, 1, r0, c0, c12, 4 // register 0x4C |
| 207 | bx lr |
| 208 | mrc p14, 1, r0, c0, c13, 4 // register 0x4D |
| 209 | bx lr |
| 210 | mrc p14, 1, r0, c0, c14, 4 // register 0x4E |
| 211 | bx lr |
| 212 | mrc p14, 1, r0, c0, c15, 4 // register 0x4F |
| 213 | bx lr |
| 214 | mrc p14, 1, r0, c0, c0, 5 // register 0x50 |
| 215 | bx lr |
| 216 | mrc p14, 1, r0, c0, c1, 5 // register 0x51 |
| 217 | bx lr |
| 218 | mrc p14, 1, r0, c0, c2, 5 // register 0x52 |
| 219 | bx lr |
| 220 | mrc p14, 1, r0, c0, c3, 5 // register 0x53 |
| 221 | bx lr |
| 222 | mrc p14, 1, r0, c0, c4, 5 // register 0x54 |
| 223 | bx lr |
| 224 | mrc p14, 1, r0, c0, c5, 5 // register 0x55 |
| 225 | bx lr |
| 226 | mrc p14, 1, r0, c0, c6, 5 // register 0x56 |
| 227 | bx lr |
| 228 | mrc p14, 1, r0, c0, c7, 5 // register 0x57 |
| 229 | bx lr |
| 230 | mrc p14, 1, r0, c0, c8, 5 // register 0x58 |
| 231 | bx lr |
| 232 | mrc p14, 1, r0, c0, c9, 5 // register 0x59 |
| 233 | bx lr |
| 234 | mrc p14, 1, r0, c0, c10, 5 // register 0x5A |
| 235 | bx lr |
| 236 | mrc p14, 1, r0, c0, c11, 5 // register 0x5B |
| 237 | bx lr |
| 238 | mrc p14, 1, r0, c0, c12, 5 // register 0x5C |
| 239 | bx lr |
| 240 | mrc p14, 1, r0, c0, c13, 5 // register 0x5D |
| 241 | bx lr |
| 242 | mrc p14, 1, r0, c0, c14, 5 // register 0x5E |
| 243 | bx lr |
| 244 | mrc p14, 1, r0, c0, c15, 5 // register 0x5F |
| 245 | bx lr |
| 246 | mrc p14, 1, r0, c0, c0, 6 // register 0x60 |
| 247 | bx lr |
| 248 | mrc p14, 1, r0, c0, c1, 6 // register 0x61 |
| 249 | bx lr |
| 250 | mrc p14, 1, r0, c0, c2, 6 // register 0x62 |
| 251 | bx lr |
| 252 | mrc p14, 1, r0, c0, c3, 6 // register 0x63 |
| 253 | bx lr |
| 254 | mrc p14, 1, r0, c0, c4, 6 // register 0x64 |
| 255 | bx lr |
| 256 | mrc p14, 1, r0, c0, c5, 6 // register 0x65 |
| 257 | bx lr |
| 258 | mrc p14, 1, r0, c0, c6, 6 // register 0x66 |
| 259 | bx lr |
| 260 | mrc p14, 1, r0, c0, c7, 6 // register 0x67 |
| 261 | bx lr |
| 262 | mrc p14, 1, r0, c0, c8, 6 // register 0x68 |
| 263 | bx lr |
| 264 | mrc p14, 1, r0, c0, c9, 6 // register 0x69 |
| 265 | bx lr |
| 266 | mrc p14, 1, r0, c0, c10, 6 // register 0x6A |
| 267 | bx lr |
| 268 | mrc p14, 1, r0, c0, c11, 6 // register 0x6B |
| 269 | bx lr |
| 270 | mrc p14, 1, r0, c0, c12, 6 // register 0x6C |
| 271 | bx lr |
| 272 | mrc p14, 1, r0, c0, c13, 6 // register 0x6D |
| 273 | bx lr |
| 274 | mrc p14, 1, r0, c0, c14, 6 // register 0x6E |
| 275 | bx lr |
| 276 | mrc p14, 1, r0, c0, c15, 6 // register 0x6F |
| 277 | bx lr |
| 278 | mrc p14, 1, r0, c0, c0, 7 // register 0x70 |
| 279 | bx lr |
| 280 | mrc p14, 1, r0, c0, c1, 7 // register 0x71 |
| 281 | bx lr |
| 282 | mrc p14, 1, r0, c0, c2, 7 // register 0x72 |
| 283 | bx lr |
| 284 | mrc p14, 1, r0, c0, c3, 7 // register 0x73 |
| 285 | bx lr |
| 286 | mrc p14, 1, r0, c0, c4, 7 // register 0x74 |
| 287 | bx lr |
| 288 | mrc p14, 1, r0, c0, c5, 7 // register 0x75 |
| 289 | bx lr |
| 290 | mrc p14, 1, r0, c0, c6, 7 // register 0x76 |
| 291 | bx lr |
| 292 | mrc p14, 1, r0, c0, c7, 7 // register 0x77 |
| 293 | bx lr |
| 294 | mrc p14, 1, r0, c0, c8, 7 // register 0x78 |
| 295 | bx lr |
| 296 | mrc p14, 1, r0, c0, c9, 7 // register 0x79 |
| 297 | bx lr |
| 298 | mrc p14, 1, r0, c0, c10, 7 // register 0x7A |
| 299 | bx lr |
| 300 | mrc p14, 1, r0, c0, c11, 7 // register 0x7B |
| 301 | bx lr |
| 302 | mrc p14, 1, r0, c0, c12, 7 // register 0x7C |
| 303 | bx lr |
| 304 | mrc p14, 1, r0, c0, c13, 7 // register 0x7D |
| 305 | bx lr |
| 306 | mrc p14, 1, r0, c0, c14, 7 // register 0x7E |
| 307 | bx lr |
| 308 | mrc p14, 1, r0, c0, c15, 7 // register 0x7F |
| 309 | bx lr |
| 310 | |
| 311 | .global etm_write_reg |
| 312 | etm_write_reg: |
| 313 | cmp r0, #0x7F |
| 314 | bhi write_high |
| 315 | ldr r2, =write_table |
| 316 | add r2, r2, r0, lsl #3 |
| 317 | mov pc, r2 |
| 318 | |
| 319 | write_high: |
| 320 | cmp r0, #0xC0 |
| 321 | beq write_c0 |
| 322 | cmp r0, #0xC4 |
| 323 | beq write_c4 |
| 324 | bx lr |
| 325 | |
| 326 | write_c0: |
| 327 | mcr p14, 1, r1, c1, c0, 4 // register 0xC0 (OS Lock Access Reg) |
| 328 | bx lr |
| 329 | |
| 330 | write_c4: |
| 331 | mcr p14, 1, r1, c1, c4, 4 // register 0xC4 (Powerdown Ctl Reg) |
| 332 | bx lr |
| 333 | |
| 334 | write_table: |
| 335 | mcr p14, 1, r1, c0, c0, 0 // register 0x00 |
| 336 | bx lr |
| 337 | mcr p14, 1, r1, c0, c1, 0 // register 0x01 |
| 338 | bx lr |
| 339 | mcr p14, 1, r1, c0, c2, 0 // register 0x02 |
| 340 | bx lr |
| 341 | mcr p14, 1, r1, c0, c3, 0 // register 0x03 |
| 342 | bx lr |
| 343 | mcr p14, 1, r1, c0, c4, 0 // register 0x04 |
| 344 | bx lr |
| 345 | mcr p14, 1, r1, c0, c5, 0 // register 0x05 |
| 346 | bx lr |
| 347 | mcr p14, 1, r1, c0, c6, 0 // register 0x06 |
| 348 | bx lr |
| 349 | mcr p14, 1, r1, c0, c7, 0 // register 0x07 |
| 350 | bx lr |
| 351 | mcr p14, 1, r1, c0, c8, 0 // register 0x08 |
| 352 | bx lr |
| 353 | mcr p14, 1, r1, c0, c9, 0 // register 0x09 |
| 354 | bx lr |
| 355 | mcr p14, 1, r1, c0, c10, 0 // register 0x0A |
| 356 | bx lr |
| 357 | mcr p14, 1, r1, c0, c11, 0 // register 0x0B |
| 358 | bx lr |
| 359 | mcr p14, 1, r1, c0, c12, 0 // register 0x0C |
| 360 | bx lr |
| 361 | mcr p14, 1, r1, c0, c13, 0 // register 0x0D |
| 362 | bx lr |
| 363 | mcr p14, 1, r1, c0, c14, 0 // register 0x0E |
| 364 | bx lr |
| 365 | mcr p14, 1, r1, c0, c15, 0 // register 0x0F |
| 366 | bx lr |
| 367 | mcr p14, 1, r1, c0, c0, 1 // register 0x10 |
| 368 | bx lr |
| 369 | mcr p14, 1, r1, c0, c1, 1 // register 0x11 |
| 370 | bx lr |
| 371 | mcr p14, 1, r1, c0, c2, 1 // register 0x12 |
| 372 | bx lr |
| 373 | mcr p14, 1, r1, c0, c3, 1 // register 0x13 |
| 374 | bx lr |
| 375 | mcr p14, 1, r1, c0, c4, 1 // register 0x14 |
| 376 | bx lr |
| 377 | mcr p14, 1, r1, c0, c5, 1 // register 0x15 |
| 378 | bx lr |
| 379 | mcr p14, 1, r1, c0, c6, 1 // register 0x16 |
| 380 | bx lr |
| 381 | mcr p14, 1, r1, c0, c7, 1 // register 0x17 |
| 382 | bx lr |
| 383 | mcr p14, 1, r1, c0, c8, 1 // register 0x18 |
| 384 | bx lr |
| 385 | mcr p14, 1, r1, c0, c9, 1 // register 0x19 |
| 386 | bx lr |
| 387 | mcr p14, 1, r1, c0, c10, 1 // register 0x1A |
| 388 | bx lr |
| 389 | mcr p14, 1, r1, c0, c11, 1 // register 0x1B |
| 390 | bx lr |
| 391 | mcr p14, 1, r1, c0, c12, 1 // register 0x1C |
| 392 | bx lr |
| 393 | mcr p14, 1, r1, c0, c13, 1 // register 0x1D |
| 394 | bx lr |
| 395 | mcr p14, 1, r1, c0, c14, 1 // register 0x1E |
| 396 | bx lr |
| 397 | mcr p14, 1, r1, c0, c15, 1 // register 0x1F |
| 398 | bx lr |
| 399 | mcr p14, 1, r1, c0, c0, 2 // register 0x20 |
| 400 | bx lr |
| 401 | mcr p14, 1, r1, c0, c1, 2 // register 0x21 |
| 402 | bx lr |
| 403 | mcr p14, 1, r1, c0, c2, 2 // register 0x22 |
| 404 | bx lr |
| 405 | mcr p14, 1, r1, c0, c3, 2 // register 0x23 |
| 406 | bx lr |
| 407 | mcr p14, 1, r1, c0, c4, 2 // register 0x24 |
| 408 | bx lr |
| 409 | mcr p14, 1, r1, c0, c5, 2 // register 0x25 |
| 410 | bx lr |
| 411 | mcr p14, 1, r1, c0, c6, 2 // register 0x26 |
| 412 | bx lr |
| 413 | mcr p14, 1, r1, c0, c7, 2 // register 0x27 |
| 414 | bx lr |
| 415 | mcr p14, 1, r1, c0, c8, 2 // register 0x28 |
| 416 | bx lr |
| 417 | mcr p14, 1, r1, c0, c9, 2 // register 0x29 |
| 418 | bx lr |
| 419 | mcr p14, 1, r1, c0, c10, 2 // register 0x2A |
| 420 | bx lr |
| 421 | mcr p14, 1, r1, c0, c11, 2 // register 0x2B |
| 422 | bx lr |
| 423 | mcr p14, 1, r1, c0, c12, 2 // register 0x2C |
| 424 | bx lr |
| 425 | mcr p14, 1, r1, c0, c13, 2 // register 0x2D |
| 426 | bx lr |
| 427 | mcr p14, 1, r1, c0, c14, 2 // register 0x2E |
| 428 | bx lr |
| 429 | mcr p14, 1, r1, c0, c15, 2 // register 0x2F |
| 430 | bx lr |
| 431 | mcr p14, 1, r1, c0, c0, 3 // register 0x30 |
| 432 | bx lr |
| 433 | mcr p14, 1, r1, c0, c1, 3 // register 0x31 |
| 434 | bx lr |
| 435 | mcr p14, 1, r1, c0, c2, 3 // register 0x32 |
| 436 | bx lr |
| 437 | mcr p14, 1, r1, c0, c3, 3 // register 0x33 |
| 438 | bx lr |
| 439 | mcr p14, 1, r1, c0, c4, 3 // register 0x34 |
| 440 | bx lr |
| 441 | mcr p14, 1, r1, c0, c5, 3 // register 0x35 |
| 442 | bx lr |
| 443 | mcr p14, 1, r1, c0, c6, 3 // register 0x36 |
| 444 | bx lr |
| 445 | mcr p14, 1, r1, c0, c7, 3 // register 0x37 |
| 446 | bx lr |
| 447 | mcr p14, 1, r1, c0, c8, 3 // register 0x38 |
| 448 | bx lr |
| 449 | mcr p14, 1, r1, c0, c9, 3 // register 0x39 |
| 450 | bx lr |
| 451 | mcr p14, 1, r1, c0, c10, 3 // register 0x3A |
| 452 | bx lr |
| 453 | mcr p14, 1, r1, c0, c11, 3 // register 0x3B |
| 454 | bx lr |
| 455 | mcr p14, 1, r1, c0, c12, 3 // register 0x3C |
| 456 | bx lr |
| 457 | mcr p14, 1, r1, c0, c13, 3 // register 0x3D |
| 458 | bx lr |
| 459 | mcr p14, 1, r1, c0, c14, 3 // register 0x3E |
| 460 | bx lr |
| 461 | mcr p14, 1, r1, c0, c15, 3 // register 0x3F |
| 462 | bx lr |
| 463 | mcr p14, 1, r1, c0, c0, 4 // register 0x40 |
| 464 | bx lr |
| 465 | mcr p14, 1, r1, c0, c1, 4 // register 0x41 |
| 466 | bx lr |
| 467 | mcr p14, 1, r1, c0, c2, 4 // register 0x42 |
| 468 | bx lr |
| 469 | mcr p14, 1, r1, c0, c3, 4 // register 0x43 |
| 470 | bx lr |
| 471 | mcr p14, 1, r1, c0, c4, 4 // register 0x44 |
| 472 | bx lr |
| 473 | mcr p14, 1, r1, c0, c5, 4 // register 0x45 |
| 474 | bx lr |
| 475 | mcr p14, 1, r1, c0, c6, 4 // register 0x46 |
| 476 | bx lr |
| 477 | mcr p14, 1, r1, c0, c7, 4 // register 0x47 |
| 478 | bx lr |
| 479 | mcr p14, 1, r1, c0, c8, 4 // register 0x48 |
| 480 | bx lr |
| 481 | mcr p14, 1, r1, c0, c9, 4 // register 0x49 |
| 482 | bx lr |
| 483 | mcr p14, 1, r1, c0, c10, 4 // register 0x4A |
| 484 | bx lr |
| 485 | mcr p14, 1, r1, c0, c11, 4 // register 0x4B |
| 486 | bx lr |
| 487 | mcr p14, 1, r1, c0, c12, 4 // register 0x4C |
| 488 | bx lr |
| 489 | mcr p14, 1, r1, c0, c13, 4 // register 0x4D |
| 490 | bx lr |
| 491 | mcr p14, 1, r1, c0, c14, 4 // register 0x4E |
| 492 | bx lr |
| 493 | mcr p14, 1, r1, c0, c15, 4 // register 0x4F |
| 494 | bx lr |
| 495 | mcr p14, 1, r1, c0, c0, 5 // register 0x50 |
| 496 | bx lr |
| 497 | mcr p14, 1, r1, c0, c1, 5 // register 0x51 |
| 498 | bx lr |
| 499 | mcr p14, 1, r1, c0, c2, 5 // register 0x52 |
| 500 | bx lr |
| 501 | mcr p14, 1, r1, c0, c3, 5 // register 0x53 |
| 502 | bx lr |
| 503 | mcr p14, 1, r1, c0, c4, 5 // register 0x54 |
| 504 | bx lr |
| 505 | mcr p14, 1, r1, c0, c5, 5 // register 0x55 |
| 506 | bx lr |
| 507 | mcr p14, 1, r1, c0, c6, 5 // register 0x56 |
| 508 | bx lr |
| 509 | mcr p14, 1, r1, c0, c7, 5 // register 0x57 |
| 510 | bx lr |
| 511 | mcr p14, 1, r1, c0, c8, 5 // register 0x58 |
| 512 | bx lr |
| 513 | mcr p14, 1, r1, c0, c9, 5 // register 0x59 |
| 514 | bx lr |
| 515 | mcr p14, 1, r1, c0, c10, 5 // register 0x5A |
| 516 | bx lr |
| 517 | mcr p14, 1, r1, c0, c11, 5 // register 0x5B |
| 518 | bx lr |
| 519 | mcr p14, 1, r1, c0, c12, 5 // register 0x5C |
| 520 | bx lr |
| 521 | mcr p14, 1, r1, c0, c13, 5 // register 0x5D |
| 522 | bx lr |
| 523 | mcr p14, 1, r1, c0, c14, 5 // register 0x5E |
| 524 | bx lr |
| 525 | mcr p14, 1, r1, c0, c15, 5 // register 0x5F |
| 526 | bx lr |
| 527 | mcr p14, 1, r1, c0, c0, 6 // register 0x60 |
| 528 | bx lr |
| 529 | mcr p14, 1, r1, c0, c1, 6 // register 0x61 |
| 530 | bx lr |
| 531 | mcr p14, 1, r1, c0, c2, 6 // register 0x62 |
| 532 | bx lr |
| 533 | mcr p14, 1, r1, c0, c3, 6 // register 0x63 |
| 534 | bx lr |
| 535 | mcr p14, 1, r1, c0, c4, 6 // register 0x64 |
| 536 | bx lr |
| 537 | mcr p14, 1, r1, c0, c5, 6 // register 0x65 |
| 538 | bx lr |
| 539 | mcr p14, 1, r1, c0, c6, 6 // register 0x66 |
| 540 | bx lr |
| 541 | mcr p14, 1, r1, c0, c7, 6 // register 0x67 |
| 542 | bx lr |
| 543 | mcr p14, 1, r1, c0, c8, 6 // register 0x68 |
| 544 | bx lr |
| 545 | mcr p14, 1, r1, c0, c9, 6 // register 0x69 |
| 546 | bx lr |
| 547 | mcr p14, 1, r1, c0, c10, 6 // register 0x6A |
| 548 | bx lr |
| 549 | mcr p14, 1, r1, c0, c11, 6 // register 0x6B |
| 550 | bx lr |
| 551 | mcr p14, 1, r1, c0, c12, 6 // register 0x6C |
| 552 | bx lr |
| 553 | mcr p14, 1, r1, c0, c13, 6 // register 0x6D |
| 554 | bx lr |
| 555 | mcr p14, 1, r1, c0, c14, 6 // register 0x6E |
| 556 | bx lr |
| 557 | mcr p14, 1, r1, c0, c15, 6 // register 0x6F |
| 558 | bx lr |
| 559 | mcr p14, 1, r1, c0, c0, 7 // register 0x70 |
| 560 | bx lr |
| 561 | mcr p14, 1, r1, c0, c1, 7 // register 0x71 |
| 562 | bx lr |
| 563 | mcr p14, 1, r1, c0, c2, 7 // register 0x72 |
| 564 | bx lr |
| 565 | mcr p14, 1, r1, c0, c3, 7 // register 0x73 |
| 566 | bx lr |
| 567 | mcr p14, 1, r1, c0, c4, 7 // register 0x74 |
| 568 | bx lr |
| 569 | mcr p14, 1, r1, c0, c5, 7 // register 0x75 |
| 570 | bx lr |
| 571 | mcr p14, 1, r1, c0, c6, 7 // register 0x76 |
| 572 | bx lr |
| 573 | mcr p14, 1, r1, c0, c7, 7 // register 0x77 |
| 574 | bx lr |
| 575 | mcr p14, 1, r1, c0, c8, 7 // register 0x78 |
| 576 | bx lr |
| 577 | mcr p14, 1, r1, c0, c9, 7 // register 0x79 |
| 578 | bx lr |
| 579 | mcr p14, 1, r1, c0, c10, 7 // register 0x7A |
| 580 | bx lr |
| 581 | mcr p14, 1, r1, c0, c11, 7 // register 0x7B |
| 582 | bx lr |
| 583 | mcr p14, 1, r1, c0, c12, 7 // register 0x7C |
| 584 | bx lr |
| 585 | mcr p14, 1, r1, c0, c13, 7 // register 0x7D |
| 586 | bx lr |
| 587 | mcr p14, 1, r1, c0, c14, 7 // register 0x7E |
| 588 | bx lr |
| 589 | mcr p14, 1, r1, c0, c15, 7 // register 0x7F |
| 590 | bx lr |
| 591 | |
| 592 | .global l2tevselr0_write |
| 593 | l2tevselr0_write: |
| 594 | mcr p15, 3, r0, c15, c5, 2 |
| 595 | bx lr |
| 596 | |
| 597 | .global etm_save_reg |
| 598 | etm_save_reg: |
| 599 | ldr r3, =etm_state /* store state at etm_state */ |
| 600 | #if (NR_CPUS >= 2) |
| 601 | mrc p15, 0, r2, c0, c0, 5 /* MPIDR */ |
| 602 | and r2, r2, #15 /* What CPU am I */ |
| 603 | ldr r1, =MAX_ETM_STATE_SIZE |
| 604 | mul r2, r2, r1 |
| 605 | add r3, r3, r2 |
| 606 | #endif |
| 607 | |
| 608 | /* save etm state */ |
| 609 | mrc p14, 1, r0, c1, c5, 4 /* read ETM PDSR to clear sticky bit */ |
| 610 | isb |
| 611 | ldr r1, =0xc5ACCE55 /* set ETMOSLAR lock */ |
| 612 | mcr p14, 1, r1, c1, c0, 4 |
| 613 | isb |
| 614 | |
| 615 | mrc p14, 1, r1, c1, c2, 4 /* ETMOSSRR state register count */ |
| 616 | cmp r1, #(MAX_ETM_REGS) /* check for state overflow */ |
| 617 | movgt r1, #0 /* if not enough space, don't save */ |
| 618 | str r1,[r3],#4 /* save count for restore */ |
| 619 | |
| 620 | 1: cmp r1, #0 |
| 621 | mrcne p14, 1, r2, c1, c2, 4 /* ETMOSSRR state value */ |
| 622 | strne r2, [r3], #4 /* push value */ |
| 623 | subne r1, r1, #1 |
| 624 | bne 1b |
| 625 | |
| 626 | mcr p14, 1, r1, c1, c0, 4 /* r1 = 0, unlock ETMOSLAR */ |
| 627 | isb |
| 628 | |
| 629 | bx lr |
| 630 | |
| 631 | .global etm_restore_reg |
| 632 | etm_restore_reg: |
| 633 | /* restore debug registers after power collapse */ |
| 634 | ldr r3, =etm_state /* load state from etm_state */ |
| 635 | #if (NR_CPUS >= 2) |
| 636 | mrc p15, 0, r2, c0, c0, 5 /* MPIDR */ |
| 637 | and r2, r2, #15 /* What CPU am I */ |
| 638 | ldr r1, =MAX_ETM_STATE_SIZE |
| 639 | mul r2, r2, r1 |
| 640 | add r3, r3, r2 |
| 641 | #endif |
| 642 | |
| 643 | /* restore etm state */ |
| 644 | mrc p14, 1, r0, c1, c5, 4 /* read ETM PDSR to clear sticky bit */ |
| 645 | isb |
| 646 | ldr r1, =0xc5ACCE55 /* set ETMOSLAR lock */ |
| 647 | mcr p14, 1, r1, c1, c0, 4 |
| 648 | isb |
| 649 | |
| 650 | mrc p14, 1, r1, c1, c2, 4 /* ETMOSSRR dummy read (required)*/ |
| 651 | ldr r1, [r3], #4 /* load saved count */ |
| 652 | cmp r1, #0 /* skip if none stored */ |
| 653 | beq end_etm_restore_reg |
| 654 | |
| 655 | 1: ldr r2,[r3],#4 |
| 656 | mcr p14, 1, r2, c1, c2, 4 /* ETMOSSRR write state value */ |
| 657 | subs r1, r1, #1 |
| 658 | bne 1b |
| 659 | end_etm_restore_reg: |
| 660 | mcr p14, 1, r1, c1, c0, 4 /* r1 = 0, unlock ETMOSLAR */ |
| 661 | isb |
| 662 | |
| 663 | bx lr |
| 664 | |
| 665 | |
| 666 | .data |
| 667 | |
| 668 | etm_state: |
| 669 | .space MAX_ETM_STATE_SIZE * NR_CPUS |