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>
@@ -1500,43 +1501,41 @@ u32 aarch64_insn_gen_extr(enum aarch64_insn_variant variant,
1500
1501
return aarch64_insn_encode_register (AARCH64_INSN_REGTYPE_RM , insn , Rm );
1501
1502
}
1502
1503
1503
- u32 aarch64_insn_gen_dmb (enum aarch64_insn_mb_type type )
1504
+ static u32 __get_barrier_crm_val (enum aarch64_insn_mb_type type )
1504
1505
{
1505
- u32 opt ;
1506
- u32 insn ;
1507
-
1508
1506
switch (type ) {
1509
1507
case AARCH64_INSN_MB_SY :
1510
- opt = 0xf ;
1511
- break ;
1508
+ return 0xf ;
1512
1509
case AARCH64_INSN_MB_ST :
1513
- opt = 0xe ;
1514
- break ;
1510
+ return 0xe ;
1515
1511
case AARCH64_INSN_MB_LD :
1516
- opt = 0xd ;
1517
- break ;
1512
+ return 0xd ;
1518
1513
case AARCH64_INSN_MB_ISH :
1519
- opt = 0xb ;
1520
- break ;
1514
+ return 0xb ;
1521
1515
case AARCH64_INSN_MB_ISHST :
1522
- opt = 0xa ;
1523
- break ;
1516
+ return 0xa ;
1524
1517
case AARCH64_INSN_MB_ISHLD :
1525
- opt = 0x9 ;
1526
- break ;
1518
+ return 0x9 ;
1527
1519
case AARCH64_INSN_MB_NSH :
1528
- opt = 0x7 ;
1529
- break ;
1520
+ return 0x7 ;
1530
1521
case AARCH64_INSN_MB_NSHST :
1531
- opt = 0x6 ;
1532
- break ;
1522
+ return 0x6 ;
1533
1523
case AARCH64_INSN_MB_NSHLD :
1534
- opt = 0x5 ;
1535
- break ;
1524
+ return 0x5 ;
1536
1525
default :
1537
- pr_err ("%s: unknown dmb type %d\n" , __func__ , type );
1526
+ pr_err ("%s: unknown barrier type %d\n" , __func__ , type );
1538
1527
return AARCH64_BREAK_FAULT ;
1539
1528
}
1529
+ }
1530
+
1531
+ u32 aarch64_insn_gen_dmb (enum aarch64_insn_mb_type type )
1532
+ {
1533
+ u32 opt ;
1534
+ u32 insn ;
1535
+
1536
+ opt = __get_barrier_crm_val (type );
1537
+ if (opt == AARCH64_BREAK_FAULT )
1538
+ return AARCH64_BREAK_FAULT ;
1540
1539
1541
1540
insn = aarch64_insn_get_dmb_value ();
1542
1541
insn &= ~GENMASK (11 , 8 );
@@ -1545,6 +1544,21 @@ u32 aarch64_insn_gen_dmb(enum aarch64_insn_mb_type type)
1545
1544
return insn ;
1546
1545
}
1547
1546
1547
+ u32 aarch64_insn_gen_dsb (enum aarch64_insn_mb_type type )
1548
+ {
1549
+ u32 opt , insn ;
1550
+
1551
+ opt = __get_barrier_crm_val (type );
1552
+ if (opt == AARCH64_BREAK_FAULT )
1553
+ return AARCH64_BREAK_FAULT ;
1554
+
1555
+ insn = aarch64_insn_get_dsb_base_value ();
1556
+ insn &= ~GENMASK (11 , 8 );
1557
+ insn |= (opt << 8 );
1558
+
1559
+ return insn ;
1560
+ }
1561
+
1548
1562
u32 aarch64_insn_gen_mrs (enum aarch64_insn_register result ,
1549
1563
enum aarch64_insn_system_register sysreg )
1550
1564
{
0 commit comments