|
5 | 5 | *
|
6 | 6 | * Copyright (C) 2014-2016 Zi Shen Lim <[email protected]>
|
7 | 7 | */
|
| 8 | +#include <linux/bitfield.h> |
8 | 9 | #include <linux/bitops.h>
|
9 | 10 | #include <linux/bug.h>
|
10 | 11 | #include <linux/printk.h>
|
@@ -1630,47 +1631,60 @@ u32 aarch64_insn_gen_extr(enum aarch64_insn_variant variant,
|
1630 | 1631 | return aarch64_insn_encode_register(AARCH64_INSN_REGTYPE_RM, insn, Rm);
|
1631 | 1632 | }
|
1632 | 1633 |
|
1633 |
| -u32 aarch64_insn_gen_dmb(enum aarch64_insn_mb_type type) |
| 1634 | +static u32 __get_barrier_crm_val(enum aarch64_insn_mb_type type) |
1634 | 1635 | {
|
1635 |
| - u32 opt; |
1636 |
| - u32 insn; |
1637 |
| - |
1638 | 1636 | switch (type) {
|
1639 | 1637 | case AARCH64_INSN_MB_SY:
|
1640 |
| - opt = 0xf; |
1641 |
| - break; |
| 1638 | + return 0xf; |
1642 | 1639 | case AARCH64_INSN_MB_ST:
|
1643 |
| - opt = 0xe; |
1644 |
| - break; |
| 1640 | + return 0xe; |
1645 | 1641 | case AARCH64_INSN_MB_LD:
|
1646 |
| - opt = 0xd; |
1647 |
| - break; |
| 1642 | + return 0xd; |
1648 | 1643 | case AARCH64_INSN_MB_ISH:
|
1649 |
| - opt = 0xb; |
1650 |
| - break; |
| 1644 | + return 0xb; |
1651 | 1645 | case AARCH64_INSN_MB_ISHST:
|
1652 |
| - opt = 0xa; |
1653 |
| - break; |
| 1646 | + return 0xa; |
1654 | 1647 | case AARCH64_INSN_MB_ISHLD:
|
1655 |
| - opt = 0x9; |
1656 |
| - break; |
| 1648 | + return 0x9; |
1657 | 1649 | case AARCH64_INSN_MB_NSH:
|
1658 |
| - opt = 0x7; |
1659 |
| - break; |
| 1650 | + return 0x7; |
1660 | 1651 | case AARCH64_INSN_MB_NSHST:
|
1661 |
| - opt = 0x6; |
1662 |
| - break; |
| 1652 | + return 0x6; |
1663 | 1653 | case AARCH64_INSN_MB_NSHLD:
|
1664 |
| - opt = 0x5; |
1665 |
| - break; |
| 1654 | + return 0x5; |
1666 | 1655 | default:
|
1667 |
| - pr_err("%s: unknown dmb type %d\n", __func__, type); |
| 1656 | + pr_err("%s: unknown barrier type %d\n", __func__, type); |
1668 | 1657 | return AARCH64_BREAK_FAULT;
|
1669 | 1658 | }
|
| 1659 | +} |
| 1660 | + |
| 1661 | +u32 aarch64_insn_gen_dmb(enum aarch64_insn_mb_type type) |
| 1662 | +{ |
| 1663 | + u32 opt; |
| 1664 | + u32 insn; |
| 1665 | + |
| 1666 | + opt = __get_barrier_crm_val(type); |
| 1667 | + if (opt == AARCH64_BREAK_FAULT) |
| 1668 | + return AARCH64_BREAK_FAULT; |
1670 | 1669 |
|
1671 | 1670 | insn = aarch64_insn_get_dmb_value();
|
1672 | 1671 | insn &= ~GENMASK(11, 8);
|
1673 | 1672 | insn |= (opt << 8);
|
1674 | 1673 |
|
1675 | 1674 | return insn;
|
1676 | 1675 | }
|
| 1676 | + |
| 1677 | +u32 aarch64_insn_gen_dsb(enum aarch64_insn_mb_type type) |
| 1678 | +{ |
| 1679 | + u32 opt, insn; |
| 1680 | + |
| 1681 | + opt = __get_barrier_crm_val(type); |
| 1682 | + if (opt == AARCH64_BREAK_FAULT) |
| 1683 | + return AARCH64_BREAK_FAULT; |
| 1684 | + |
| 1685 | + insn = aarch64_insn_get_dsb_base_value(); |
| 1686 | + insn &= ~GENMASK(11, 8); |
| 1687 | + insn |= (opt << 8); |
| 1688 | + |
| 1689 | + return insn; |
| 1690 | +} |
0 commit comments