Path: blob/master/arch/sparc/include/asm/btfixup.h
17482 views
/*1* asm/btfixup.h: Macros for boot time linking.2*3* Copyright (C) 1998 Jakub Jelinek ([email protected])4*/56#ifndef _SPARC_BTFIXUP_H7#define _SPARC_BTFIXUP_H89#include <linux/init.h>1011#ifndef __ASSEMBLY__1213#ifdef MODULE14extern unsigned int ___illegal_use_of_BTFIXUP_SIMM13_in_module(void);15extern unsigned int ___illegal_use_of_BTFIXUP_SETHI_in_module(void);16extern unsigned int ___illegal_use_of_BTFIXUP_HALF_in_module(void);17extern unsigned int ___illegal_use_of_BTFIXUP_INT_in_module(void);1819#define BTFIXUP_SIMM13(__name) ___illegal_use_of_BTFIXUP_SIMM13_in_module()20#define BTFIXUP_HALF(__name) ___illegal_use_of_BTFIXUP_HALF_in_module()21#define BTFIXUP_SETHI(__name) ___illegal_use_of_BTFIXUP_SETHI_in_module()22#define BTFIXUP_INT(__name) ___illegal_use_of_BTFIXUP_INT_in_module()23#define BTFIXUP_BLACKBOX(__name) ___illegal_use_of_BTFIXUP_BLACKBOX_in_module2425#else2627#define BTFIXUP_SIMM13(__name) ___sf_##__name()28#define BTFIXUP_HALF(__name) ___af_##__name()29#define BTFIXUP_SETHI(__name) ___hf_##__name()30#define BTFIXUP_INT(__name) ((unsigned int)&___i_##__name)31/* This must be written in assembly and present in a sethi */32#define BTFIXUP_BLACKBOX(__name) ___b_##__name33#endif /* MODULE */3435/* Fixup call xx */3637#define BTFIXUPDEF_CALL(__type, __name, __args...) \38extern __type ___f_##__name(__args); \39extern unsigned ___fs_##__name[3];40#define BTFIXUPDEF_CALL_CONST(__type, __name, __args...) \41extern __type ___f_##__name(__args) __attribute_const__; \42extern unsigned ___fs_##__name[3];43#define BTFIXUP_CALL(__name) ___f_##__name4445#define BTFIXUPDEF_BLACKBOX(__name) \46extern unsigned ___bs_##__name[2];4748/* Put bottom 13bits into some register variable */4950#define BTFIXUPDEF_SIMM13(__name) \51static inline unsigned int ___sf_##__name(void) __attribute_const__; \52extern unsigned ___ss_##__name[2]; \53static inline unsigned int ___sf_##__name(void) { \54unsigned int ret; \55__asm__ ("or %%g0, ___s_" #__name ", %0" : "=r"(ret)); \56return ret; \57}58#define BTFIXUPDEF_SIMM13_INIT(__name,__val) \59static inline unsigned int ___sf_##__name(void) __attribute_const__; \60extern unsigned ___ss_##__name[2]; \61static inline unsigned int ___sf_##__name(void) { \62unsigned int ret; \63__asm__ ("or %%g0, ___s_" #__name "__btset_" #__val ", %0" : "=r"(ret));\64return ret; \65}6667/* Put either bottom 13 bits, or upper 22 bits into some register variable68* (depending on the value, this will lead into sethi FIX, reg; or69* mov FIX, reg; )70*/7172#define BTFIXUPDEF_HALF(__name) \73static inline unsigned int ___af_##__name(void) __attribute_const__; \74extern unsigned ___as_##__name[2]; \75static inline unsigned int ___af_##__name(void) { \76unsigned int ret; \77__asm__ ("or %%g0, ___a_" #__name ", %0" : "=r"(ret)); \78return ret; \79}80#define BTFIXUPDEF_HALF_INIT(__name,__val) \81static inline unsigned int ___af_##__name(void) __attribute_const__; \82extern unsigned ___as_##__name[2]; \83static inline unsigned int ___af_##__name(void) { \84unsigned int ret; \85__asm__ ("or %%g0, ___a_" #__name "__btset_" #__val ", %0" : "=r"(ret));\86return ret; \87}8889/* Put upper 22 bits into some register variable */9091#define BTFIXUPDEF_SETHI(__name) \92static inline unsigned int ___hf_##__name(void) __attribute_const__; \93extern unsigned ___hs_##__name[2]; \94static inline unsigned int ___hf_##__name(void) { \95unsigned int ret; \96__asm__ ("sethi %%hi(___h_" #__name "), %0" : "=r"(ret)); \97return ret; \98}99#define BTFIXUPDEF_SETHI_INIT(__name,__val) \100static inline unsigned int ___hf_##__name(void) __attribute_const__; \101extern unsigned ___hs_##__name[2]; \102static inline unsigned int ___hf_##__name(void) { \103unsigned int ret; \104__asm__ ("sethi %%hi(___h_" #__name "__btset_" #__val "), %0" : \105"=r"(ret)); \106return ret; \107}108109/* Put a full 32bit integer into some register variable */110111#define BTFIXUPDEF_INT(__name) \112extern unsigned char ___i_##__name; \113extern unsigned ___is_##__name[2];114115#define BTFIXUPCALL_NORM 0x00000000 /* Always call */116#define BTFIXUPCALL_NOP 0x01000000 /* Possibly optimize to nop */117#define BTFIXUPCALL_RETINT(i) (0x90102000|((i) & 0x1fff)) /* Possibly optimize to mov i, %o0 */118#define BTFIXUPCALL_ORINT(i) (0x90122000|((i) & 0x1fff)) /* Possibly optimize to or %o0, i, %o0 */119#define BTFIXUPCALL_RETO0 0x01000000 /* Return first parameter, actually a nop */120#define BTFIXUPCALL_ANDNINT(i) (0x902a2000|((i) & 0x1fff)) /* Possibly optimize to andn %o0, i, %o0 */121#define BTFIXUPCALL_SWAPO0O1 0xd27a0000 /* Possibly optimize to swap [%o0],%o1 */122#define BTFIXUPCALL_SWAPO0G0 0xc07a0000 /* Possibly optimize to swap [%o0],%g0 */123#define BTFIXUPCALL_SWAPG1G2 0xc4784000 /* Possibly optimize to swap [%g1],%g2 */124#define BTFIXUPCALL_STG0O0 0xc0220000 /* Possibly optimize to st %g0,[%o0] */125#define BTFIXUPCALL_STO1O0 0xd2220000 /* Possibly optimize to st %o1,[%o0] */126127#define BTFIXUPSET_CALL(__name, __addr, __insn) \128do { \129___fs_##__name[0] |= 1; \130___fs_##__name[1] = (unsigned long)__addr; \131___fs_##__name[2] = __insn; \132} while (0)133134#define BTFIXUPSET_BLACKBOX(__name, __func) \135do { \136___bs_##__name[0] |= 1; \137___bs_##__name[1] = (unsigned long)__func; \138} while (0)139140#define BTFIXUPCOPY_CALL(__name, __from) \141do { \142___fs_##__name[0] |= 1; \143___fs_##__name[1] = ___fs_##__from[1]; \144___fs_##__name[2] = ___fs_##__from[2]; \145} while (0)146147#define BTFIXUPSET_SIMM13(__name, __val) \148do { \149___ss_##__name[0] |= 1; \150___ss_##__name[1] = (unsigned)__val; \151} while (0)152153#define BTFIXUPCOPY_SIMM13(__name, __from) \154do { \155___ss_##__name[0] |= 1; \156___ss_##__name[1] = ___ss_##__from[1]; \157} while (0)158159#define BTFIXUPSET_HALF(__name, __val) \160do { \161___as_##__name[0] |= 1; \162___as_##__name[1] = (unsigned)__val; \163} while (0)164165#define BTFIXUPCOPY_HALF(__name, __from) \166do { \167___as_##__name[0] |= 1; \168___as_##__name[1] = ___as_##__from[1]; \169} while (0)170171#define BTFIXUPSET_SETHI(__name, __val) \172do { \173___hs_##__name[0] |= 1; \174___hs_##__name[1] = (unsigned)__val; \175} while (0)176177#define BTFIXUPCOPY_SETHI(__name, __from) \178do { \179___hs_##__name[0] |= 1; \180___hs_##__name[1] = ___hs_##__from[1]; \181} while (0)182183#define BTFIXUPSET_INT(__name, __val) \184do { \185___is_##__name[0] |= 1; \186___is_##__name[1] = (unsigned)__val; \187} while (0)188189#define BTFIXUPCOPY_INT(__name, __from) \190do { \191___is_##__name[0] |= 1; \192___is_##__name[1] = ___is_##__from[1]; \193} while (0)194195#define BTFIXUPVAL_CALL(__name) \196((unsigned long)___fs_##__name[1])197198extern void btfixup(void);199200#else /* __ASSEMBLY__ */201202#define BTFIXUP_SETHI(__name) %hi(___h_ ## __name)203#define BTFIXUP_SETHI_INIT(__name,__val) %hi(___h_ ## __name ## __btset_ ## __val)204205#endif /* __ASSEMBLY__ */206207#endif /* !(_SPARC_BTFIXUP_H) */208209210