Skip to content
Snippets Groups Projects
Select Git revision
  • d82227cf8f0b42ff42c21ed47025fdf54cb1698d
  • seco_lf-6.6.52-2.2.1 default protected
  • seco_lf-6.6.52-2.2.1_mx8m-sscg
  • integrate/gitlab-ci/cleaos-913-add-retry-build-job-into-the-configuration/into/seco_lf-6.6.52-2.2.1
  • integrate/gitlab-ci/cleaos-913-add-retry-build-job-into-the-configuration/into/seco_lf-5.10.y
  • seco_lf-5.10.y protected
  • seco_lf-6.6.52-2.2.1_d18-e71
  • seco_lf-6.6.52-2.2.1_e88-lt9611uxc-i2s
  • seco_lf-6.6.52-2.2.1_e39-sdio-wp
  • seco_lf-6.6.52-2.2.1_d18-e71-dev
  • seco_lf-6.6.52-2.2.1_d18-dt-dto-elems
  • integrate/gitlab-ci/create-config-validation-json-schema/into/seco_lf-6.6.52-2.2.1
  • integrate/gitlab-ci/create-config-validation-json-schema/into/seco_lf-5.10.y
  • seco_lf-6.6.52-2.2.1_e88-e83-dev
  • seco_lf-6.6.52-2.2.1_e88-e83-init
  • seco_lf-6.6.52-2.2.1_e88-g101ean02
  • seco_lf-6.6.52-2.2.1_e88-sscg
  • integrate/gitlab-ci/use-board-only-instead-codename-and-board-in-the-configuration/into/seco_lf-5.10.y
  • integrate/gitlab-ci/use-board-only-instead-codename-and-board-in-the-configuration/into/seco_lf-6.6.52-2.2.1
  • integrate/gitlab-ci/cleaos-894-rename-distros-into-build-tergets/into/seco_lf-5.10.y
  • integrate/gitlab-ci/cleaos-894-rename-distros-into-build-tergets/into/seco_lf-6.6.52-2.2.1
  • lf-6.6.52-2.2.1
  • lf-6.1.55-2.2.1
  • lf-6.6.3-1.0.0
  • lf-6.6.3-imx95-er2
  • lf-6.1.55-2.2.0
  • lf-6.6.y-imx95-er1
  • lf-5.15.71-2.2.2
  • lf-6.1.36-2.1.0
  • lf-5.15.71-2.2.1
  • lf-6.1.22-2.0.0
  • lf-6.1.1-1.0.1
  • rel_imx_5.4.24_2.1.4
  • rel_imx_4.9.88_2.0.13
  • rel_imx_4.14.98_2.3.5
  • lf-6.1.1-1.0.0
  • rel_imx_5.4.3_2.0.2
  • lf-5.15.71-2.2.0
  • lf-5.10.72-2.2.3
  • lf-5.15.52-2.1.0
  • imx_5.15.52_imx8ulp_er1
41 results

insn.c

Blame
  • user avatar
    Rabin Vincent authored and Russell King committed
    Extract out the instruction generation code so that it can be used
    for jump labels too.
    
    Signed-off-by: default avatarRabin Vincent <rabin@rab.in>
    Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
    d82227cf
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    insn.c 1.29 KiB
    #include <linux/kernel.h>
    #include <asm/opcodes.h>
    
    static unsigned long
    __arm_gen_branch_thumb2(unsigned long pc, unsigned long addr, bool link)
    {
    	unsigned long s, j1, j2, i1, i2, imm10, imm11;
    	unsigned long first, second;
    	long offset;
    
    	offset = (long)addr - (long)(pc + 4);
    	if (offset < -16777216 || offset > 16777214) {
    		WARN_ON_ONCE(1);
    		return 0;
    	}
    
    	s	= (offset >> 24) & 0x1;
    	i1	= (offset >> 23) & 0x1;
    	i2	= (offset >> 22) & 0x1;
    	imm10	= (offset >> 12) & 0x3ff;
    	imm11	= (offset >>  1) & 0x7ff;
    
    	j1 = (!i1) ^ s;
    	j2 = (!i2) ^ s;
    
    	first = 0xf000 | (s << 10) | imm10;
    	second = 0x9000 | (j1 << 13) | (j2 << 11) | imm11;
    	if (link)
    		second |= 1 << 14;
    
    	return __opcode_thumb32_compose(first, second);
    }
    
    static unsigned long
    __arm_gen_branch_arm(unsigned long pc, unsigned long addr, bool link)
    {
    	unsigned long opcode = 0xea000000;
    	long offset;
    
    	if (link)
    		opcode |= 1 << 24;
    
    	offset = (long)addr - (long)(pc + 8);
    	if (unlikely(offset < -33554432 || offset > 33554428)) {
    		WARN_ON_ONCE(1);
    		return 0;
    	}
    
    	offset = (offset >> 2) & 0x00ffffff;
    
    	return opcode | offset;
    }
    
    unsigned long
    __arm_gen_branch(unsigned long pc, unsigned long addr, bool link)
    {
    	if (IS_ENABLED(CONFIG_THUMB2_KERNEL))
    		return __arm_gen_branch_thumb2(pc, addr, link);
    	else
    		return __arm_gen_branch_arm(pc, addr, link);
    }