Path: blob/master/arch/powerpc/include/asm/code-patching.h
15117 views
#ifndef _ASM_POWERPC_CODE_PATCHING_H1#define _ASM_POWERPC_CODE_PATCHING_H23/*4* Copyright 2008, Michael Ellerman, IBM Corporation.5*6* This program is free software; you can redistribute it and/or7* modify it under the terms of the GNU General Public License8* as published by the Free Software Foundation; either version9* 2 of the License, or (at your option) any later version.10*/1112#include <asm/types.h>13#include <asm/ppc-opcode.h>1415/* Flags for create_branch:16* "b" == create_branch(addr, target, 0);17* "ba" == create_branch(addr, target, BRANCH_ABSOLUTE);18* "bl" == create_branch(addr, target, BRANCH_SET_LINK);19* "bla" == create_branch(addr, target, BRANCH_ABSOLUTE | BRANCH_SET_LINK);20*/21#define BRANCH_SET_LINK 0x122#define BRANCH_ABSOLUTE 0x22324unsigned int create_branch(const unsigned int *addr,25unsigned long target, int flags);26unsigned int create_cond_branch(const unsigned int *addr,27unsigned long target, int flags);28void patch_branch(unsigned int *addr, unsigned long target, int flags);29void patch_instruction(unsigned int *addr, unsigned int instr);3031int instr_is_relative_branch(unsigned int instr);32int instr_is_branch_to_addr(const unsigned int *instr, unsigned long addr);33unsigned long branch_target(const unsigned int *instr);34unsigned int translate_branch(const unsigned int *dest,35const unsigned int *src);3637static inline unsigned long ppc_function_entry(void *func)38{39#ifdef CONFIG_PPC6440/*41* On PPC64 the function pointer actually points to the function's42* descriptor. The first entry in the descriptor is the address43* of the function text.44*/45return ((func_descr_t *)func)->entry;46#else47return (unsigned long)func;48#endif49}5051#endif /* _ASM_POWERPC_CODE_PATCHING_H */525354