| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * arch/arm/include/asm/assembler.h |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 1996-2000 Russell King |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 8 | | - * published by the Free Software Foundation. |
|---|
| 9 | 6 | * |
|---|
| 10 | 7 | * This file contains arm architecture specific defines |
|---|
| 11 | 8 | * for the different processors. |
|---|
| .. | .. |
|---|
| 107 | 104 | |
|---|
| 108 | 105 | .macro enable_irq_notrace |
|---|
| 109 | 106 | msr cpsr_c, #SVC_MODE |
|---|
| 107 | + .endm |
|---|
| 108 | +#endif |
|---|
| 109 | + |
|---|
| 110 | +#if __LINUX_ARM_ARCH__ < 7 |
|---|
| 111 | + .macro dsb, args |
|---|
| 112 | + mcr p15, 0, r0, c7, c10, 4 |
|---|
| 113 | + .endm |
|---|
| 114 | + |
|---|
| 115 | + .macro isb, args |
|---|
| 116 | + mcr p15, 0, r0, c7, c5, 4 |
|---|
| 110 | 117 | .endm |
|---|
| 111 | 118 | #endif |
|---|
| 112 | 119 | |
|---|
| .. | .. |
|---|
| 243 | 250 | .endm |
|---|
| 244 | 251 | #endif |
|---|
| 245 | 252 | |
|---|
| 246 | | -#define USER(x...) \ |
|---|
| 253 | +#define USERL(l, x...) \ |
|---|
| 247 | 254 | 9999: x; \ |
|---|
| 248 | 255 | .pushsection __ex_table,"a"; \ |
|---|
| 249 | 256 | .align 3; \ |
|---|
| 250 | | - .long 9999b,9001f; \ |
|---|
| 257 | + .long 9999b,l; \ |
|---|
| 251 | 258 | .popsection |
|---|
| 259 | + |
|---|
| 260 | +#define USER(x...) USERL(9001f, x) |
|---|
| 252 | 261 | |
|---|
| 253 | 262 | #ifdef CONFIG_SMP |
|---|
| 254 | 263 | #define ALT_SMP(instr...) \ |
|---|
| .. | .. |
|---|
| 270 | 279 | .endif ;\ |
|---|
| 271 | 280 | .popsection |
|---|
| 272 | 281 | #define ALT_UP_B(label) \ |
|---|
| 273 | | - .equ up_b_offset, label - 9998b ;\ |
|---|
| 274 | 282 | .pushsection ".alt.smp.init", "a" ;\ |
|---|
| 275 | 283 | .long 9998b ;\ |
|---|
| 276 | | - W(b) . + up_b_offset ;\ |
|---|
| 284 | + W(b) . + (label - 9998b) ;\ |
|---|
| 277 | 285 | .popsection |
|---|
| 278 | 286 | #else |
|---|
| 279 | 287 | #define ALT_SMP(instr...) |
|---|
| .. | .. |
|---|
| 496 | 504 | #define _ASM_NOKPROBE(entry) |
|---|
| 497 | 505 | #endif |
|---|
| 498 | 506 | |
|---|
| 507 | + .macro __adldst_l, op, reg, sym, tmp, c |
|---|
| 508 | + .if __LINUX_ARM_ARCH__ < 7 |
|---|
| 509 | + ldr\c \tmp, .La\@ |
|---|
| 510 | + .subsection 1 |
|---|
| 511 | + .align 2 |
|---|
| 512 | +.La\@: .long \sym - .Lpc\@ |
|---|
| 513 | + .previous |
|---|
| 514 | + .else |
|---|
| 515 | + .ifnb \c |
|---|
| 516 | + THUMB( ittt \c ) |
|---|
| 517 | + .endif |
|---|
| 518 | + movw\c \tmp, #:lower16:\sym - .Lpc\@ |
|---|
| 519 | + movt\c \tmp, #:upper16:\sym - .Lpc\@ |
|---|
| 520 | + .endif |
|---|
| 521 | + |
|---|
| 522 | +#ifndef CONFIG_THUMB2_KERNEL |
|---|
| 523 | + .set .Lpc\@, . + 8 // PC bias |
|---|
| 524 | + .ifc \op, add |
|---|
| 525 | + add\c \reg, \tmp, pc |
|---|
| 526 | + .else |
|---|
| 527 | + \op\c \reg, [pc, \tmp] |
|---|
| 528 | + .endif |
|---|
| 529 | +#else |
|---|
| 530 | +.Lb\@: add\c \tmp, \tmp, pc |
|---|
| 531 | + /* |
|---|
| 532 | + * In Thumb-2 builds, the PC bias depends on whether we are currently |
|---|
| 533 | + * emitting into a .arm or a .thumb section. The size of the add opcode |
|---|
| 534 | + * above will be 2 bytes when emitting in Thumb mode and 4 bytes when |
|---|
| 535 | + * emitting in ARM mode, so let's use this to account for the bias. |
|---|
| 536 | + */ |
|---|
| 537 | + .set .Lpc\@, . + (. - .Lb\@) |
|---|
| 538 | + |
|---|
| 539 | + .ifnc \op, add |
|---|
| 540 | + \op\c \reg, [\tmp] |
|---|
| 541 | + .endif |
|---|
| 542 | +#endif |
|---|
| 543 | + .endm |
|---|
| 544 | + |
|---|
| 545 | + /* |
|---|
| 546 | + * mov_l - move a constant value or [relocated] address into a register |
|---|
| 547 | + */ |
|---|
| 548 | + .macro mov_l, dst:req, imm:req |
|---|
| 549 | + .if __LINUX_ARM_ARCH__ < 7 |
|---|
| 550 | + ldr \dst, =\imm |
|---|
| 551 | + .else |
|---|
| 552 | + movw \dst, #:lower16:\imm |
|---|
| 553 | + movt \dst, #:upper16:\imm |
|---|
| 554 | + .endif |
|---|
| 555 | + .endm |
|---|
| 556 | + |
|---|
| 557 | + /* |
|---|
| 558 | + * adr_l - adr pseudo-op with unlimited range |
|---|
| 559 | + * |
|---|
| 560 | + * @dst: destination register |
|---|
| 561 | + * @sym: name of the symbol |
|---|
| 562 | + * @cond: conditional opcode suffix |
|---|
| 563 | + */ |
|---|
| 564 | + .macro adr_l, dst:req, sym:req, cond |
|---|
| 565 | + __adldst_l add, \dst, \sym, \dst, \cond |
|---|
| 566 | + .endm |
|---|
| 567 | + |
|---|
| 568 | + /* |
|---|
| 569 | + * ldr_l - ldr <literal> pseudo-op with unlimited range |
|---|
| 570 | + * |
|---|
| 571 | + * @dst: destination register |
|---|
| 572 | + * @sym: name of the symbol |
|---|
| 573 | + * @cond: conditional opcode suffix |
|---|
| 574 | + */ |
|---|
| 575 | + .macro ldr_l, dst:req, sym:req, cond |
|---|
| 576 | + __adldst_l ldr, \dst, \sym, \dst, \cond |
|---|
| 577 | + .endm |
|---|
| 578 | + |
|---|
| 579 | + /* |
|---|
| 580 | + * str_l - str <literal> pseudo-op with unlimited range |
|---|
| 581 | + * |
|---|
| 582 | + * @src: source register |
|---|
| 583 | + * @sym: name of the symbol |
|---|
| 584 | + * @tmp: mandatory scratch register |
|---|
| 585 | + * @cond: conditional opcode suffix |
|---|
| 586 | + */ |
|---|
| 587 | + .macro str_l, src:req, sym:req, tmp:req, cond |
|---|
| 588 | + __adldst_l str, \src, \sym, \tmp, \cond |
|---|
| 589 | + .endm |
|---|
| 590 | + |
|---|
| 591 | + /* |
|---|
| 592 | + * rev_l - byte-swap a 32-bit value |
|---|
| 593 | + * |
|---|
| 594 | + * @val: source/destination register |
|---|
| 595 | + * @tmp: scratch register |
|---|
| 596 | + */ |
|---|
| 597 | + .macro rev_l, val:req, tmp:req |
|---|
| 598 | + .if __LINUX_ARM_ARCH__ < 6 |
|---|
| 599 | + eor \tmp, \val, \val, ror #16 |
|---|
| 600 | + bic \tmp, \tmp, #0x00ff0000 |
|---|
| 601 | + mov \val, \val, ror #8 |
|---|
| 602 | + eor \val, \val, \tmp, lsr #8 |
|---|
| 603 | + .else |
|---|
| 604 | + rev \val, \val |
|---|
| 605 | + .endif |
|---|
| 606 | + .endm |
|---|
| 607 | + |
|---|
| 499 | 608 | #endif /* __ASM_ASSEMBLER_H__ */ |
|---|