LCOV - code coverage report
Current view: top level - arch/arm/kernel - insn.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 18 0.0 %
Date: 2014-04-16 Functions: 0 2 0.0 %
Branches: 0 8 0.0 %

           Branch data     Line data    Source code
       1                 :            : #include <linux/bug.h>
       2                 :            : #include <linux/kernel.h>
       3                 :            : #include <asm/opcodes.h>
       4                 :            : 
       5                 :            : static unsigned long
       6                 :          0 : __arm_gen_branch_thumb2(unsigned long pc, unsigned long addr, bool link)
       7                 :            : {
       8                 :            :         unsigned long s, j1, j2, i1, i2, imm10, imm11;
       9                 :            :         unsigned long first, second;
      10                 :            :         long offset;
      11                 :            : 
      12                 :          0 :         offset = (long)addr - (long)(pc + 4);
      13         [ #  # ]:          0 :         if (offset < -16777216 || offset > 16777214) {
      14 [ #  # ][ #  # ]:          0 :                 WARN_ON_ONCE(1);
      15                 :            :                 return 0;
      16                 :            :         }
      17                 :            : 
      18                 :          0 :         s       = (offset >> 24) & 0x1;
      19                 :          0 :         i1      = (offset >> 23) & 0x1;
      20                 :          0 :         i2      = (offset >> 22) & 0x1;
      21                 :          0 :         imm10   = (offset >> 12) & 0x3ff;
      22                 :          0 :         imm11   = (offset >>  1) & 0x7ff;
      23                 :            : 
      24                 :          0 :         j1 = (!i1) ^ s;
      25                 :          0 :         j2 = (!i2) ^ s;
      26                 :            : 
      27                 :          0 :         first = 0xf000 | (s << 10) | imm10;
      28                 :          0 :         second = 0x9000 | (j1 << 13) | (j2 << 11) | imm11;
      29         [ #  # ]:          0 :         if (link)
      30                 :          0 :                 second |= 1 << 14;
      31                 :            : 
      32                 :          0 :         return __opcode_thumb32_compose(first, second);
      33                 :            : }
      34                 :            : 
      35                 :            : static unsigned long
      36                 :            : __arm_gen_branch_arm(unsigned long pc, unsigned long addr, bool link)
      37                 :            : {
      38                 :            :         unsigned long opcode = 0xea000000;
      39                 :            :         long offset;
      40                 :            : 
      41                 :            :         if (link)
      42                 :            :                 opcode |= 1 << 24;
      43                 :            : 
      44                 :            :         offset = (long)addr - (long)(pc + 8);
      45                 :            :         if (unlikely(offset < -33554432 || offset > 33554428)) {
      46                 :            :                 WARN_ON_ONCE(1);
      47                 :            :                 return 0;
      48                 :            :         }
      49                 :            : 
      50                 :            :         offset = (offset >> 2) & 0x00ffffff;
      51                 :            : 
      52                 :            :         return opcode | offset;
      53                 :            : }
      54                 :            : 
      55                 :            : unsigned long
      56                 :          0 : __arm_gen_branch(unsigned long pc, unsigned long addr, bool link)
      57                 :            : {
      58                 :            :         if (IS_ENABLED(CONFIG_THUMB2_KERNEL))
      59                 :          0 :                 return __arm_gen_branch_thumb2(pc, addr, link);
      60                 :            :         else
      61                 :            :                 return __arm_gen_branch_arm(pc, addr, link);
      62                 :            : }

Generated by: LCOV version 1.9