blob: 608aa57799c8194a88d39d2e9b6d9968e072ac8c [file] [log] [blame]
David Daney94bb0c12010-12-28 13:26:23 -08001/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 2010 Cavium Networks, Inc.
7 */
8#ifndef _ASM_MIPS_JUMP_LABEL_H
9#define _ASM_MIPS_JUMP_LABEL_H
10
Anton Blanchard55dd0df2015-04-09 13:51:30 +100011#ifndef __ASSEMBLY__
David Daney94bb0c12010-12-28 13:26:23 -080012
Anton Blanchard55dd0df2015-04-09 13:51:30 +100013#include <linux/types.h>
David Daney94bb0c12010-12-28 13:26:23 -080014
15#define JUMP_LABEL_NOP_SIZE 4
16
17#ifdef CONFIG_64BIT
18#define WORD_INSN ".dword"
19#else
20#define WORD_INSN ".word"
21#endif
22
Maciej W. Rozycki935c2db2014-11-17 16:10:32 +000023#ifdef CONFIG_CPU_MICROMIPS
24#define NOP_INSN "nop32"
25#else
26#define NOP_INSN "nop"
27#endif
28
Ingo Molnarc5905af2012-02-24 08:31:31 +010029static __always_inline bool arch_static_branch(struct static_key *key)
Jason Barond430d3d2011-03-16 17:29:47 -040030{
Maciej W. Rozycki935c2db2014-11-17 16:10:32 +000031 asm_volatile_goto("1:\t" NOP_INSN "\n\t"
Jason Barond430d3d2011-03-16 17:29:47 -040032 "nop\n\t"
33 ".pushsection __jump_table, \"aw\"\n\t"
34 WORD_INSN " 1b, %l[l_yes], %0\n\t"
35 ".popsection\n\t"
36 : : "i" (key) : : l_yes);
37 return false;
38l_yes:
39 return true;
40}
David Daney94bb0c12010-12-28 13:26:23 -080041
David Daney94bb0c12010-12-28 13:26:23 -080042#ifdef CONFIG_64BIT
43typedef u64 jump_label_t;
44#else
45typedef u32 jump_label_t;
46#endif
47
48struct jump_entry {
49 jump_label_t code;
50 jump_label_t target;
51 jump_label_t key;
52};
53
Anton Blanchard55dd0df2015-04-09 13:51:30 +100054#endif /* __ASSEMBLY__ */
David Daney94bb0c12010-12-28 13:26:23 -080055#endif /* _ASM_MIPS_JUMP_LABEL_H */