Zhigang Lu | 65a792e | 2015-09-30 10:11:45 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Tilera Corporation. All Rights Reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation, version 2. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, but |
| 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or |
| 11 | * NON INFRINGEMENT. See the GNU General Public License for |
| 12 | * more details. |
| 13 | */ |
| 14 | |
| 15 | #ifndef _ASM_TILE_JUMP_LABEL_H |
| 16 | #define _ASM_TILE_JUMP_LABEL_H |
| 17 | |
| 18 | #include <arch/opcode.h> |
| 19 | |
| 20 | #define JUMP_LABEL_NOP_SIZE TILE_BUNDLE_SIZE_IN_BYTES |
| 21 | |
| 22 | static __always_inline bool arch_static_branch(struct static_key *key, |
| 23 | bool branch) |
| 24 | { |
| 25 | asm_volatile_goto("1:\n\t" |
| 26 | "nop" "\n\t" |
| 27 | ".pushsection __jump_table, \"aw\"\n\t" |
| 28 | ".quad 1b, %l[l_yes], %0 + %1 \n\t" |
| 29 | ".popsection\n\t" |
| 30 | : : "i" (key), "i" (branch) : : l_yes); |
| 31 | return false; |
| 32 | l_yes: |
| 33 | return true; |
| 34 | } |
| 35 | |
| 36 | static __always_inline bool arch_static_branch_jump(struct static_key *key, |
| 37 | bool branch) |
| 38 | { |
| 39 | asm_volatile_goto("1:\n\t" |
| 40 | "j %l[l_yes]" "\n\t" |
| 41 | ".pushsection __jump_table, \"aw\"\n\t" |
| 42 | ".quad 1b, %l[l_yes], %0 + %1 \n\t" |
| 43 | ".popsection\n\t" |
| 44 | : : "i" (key), "i" (branch) : : l_yes); |
| 45 | return false; |
| 46 | l_yes: |
| 47 | return true; |
| 48 | } |
| 49 | |
| 50 | typedef u64 jump_label_t; |
| 51 | |
| 52 | struct jump_entry { |
| 53 | jump_label_t code; |
| 54 | jump_label_t target; |
| 55 | jump_label_t key; |
| 56 | }; |
| 57 | |
| 58 | #endif /* _ASM_TILE_JUMP_LABEL_H */ |