1 /*
2  * reloc_table.h
3  *
4  * DSP-BIOS Bridge driver support functions for TI OMAP processors.
5  *
6  * Copyright (C) 2005-2006 Texas Instruments, Inc.
7  *
8  * This package is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11  *
12  * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
13  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
14  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15  */
16 
17 #ifndef _RELOC_TABLE_H_
18 #define _RELOC_TABLE_H_
19 /*
20  * Table of relocation operator properties
21  */
22 #include <linux/types.h>
23 
24 /* How does this relocation operation access the program image? */
25 #define ROP_N	0		/* does not access image */
26 #define ROP_R	1		/* read from image */
27 #define ROP_W	2		/* write to image */
28 #define ROP_RW	3		/* read from and write to image */
29 
30 /* For program image access, what are the overflow rules for the bit field? */
31 /* Beware! Procedure repack depends on this encoding */
32 #define ROP_ANY	0		/* no overflow ever, just truncate the value */
33 #define ROP_SGN	1		/* signed field */
34 #define ROP_UNS	2		/* unsigned field */
35 #define ROP_MAX 3	/* allow maximum range of either signed or unsigned */
36 
37 /* How does the relocation operation use the symbol reference */
38 #define ROP_IGN	0		/* no symbol is referenced */
39 #define ROP_LIT 0		/* use rp->UVAL literal field */
40 #define ROP_SYM	1		/* symbol value is used in relocation */
41 #define ROP_SYMD 2		/* delta value vs last link is used */
42 
43 /* How does the reloc op use the stack? */
44 #define RSTK_N 0		/* Does not use */
45 #define RSTK_POP 1		/* Does a POP */
46 #define RSTK_UOP 2		/* Unary op, stack position unaffected */
47 #define RSTK_PSH 3		/* Does a push */
48 
49 /*
50  * Computational actions performed by the dynamic loader
51  */
52 enum dload_actions {
53 	/* don't alter the current val (from stack or mem fetch) */
54 	RACT_VAL,
55 	/* set value to reference amount (from symbol reference) */
56 	RACT_ASGN,
57 	RACT_ADD,		/* add reference to value */
58 	RACT_PCR,		/* add reference minus PC delta to value */
59 	RACT_ADDISP,		/* add reference plus R_DISP */
60 	RACT_ASGPC,		/* set value to section addr plus reference */
61 
62 	RACT_PLUS,		/* stack + */
63 	RACT_SUB,		/* stack - */
64 	RACT_NEG,		/* stack unary - */
65 
66 	RACT_MPY,		/* stack * */
67 	RACT_DIV,		/* stack / */
68 	RACT_MOD,		/* stack % */
69 
70 	RACT_SR,		/* stack unsigned >> */
71 	RACT_ASR,		/* stack signed >> */
72 	RACT_SL,		/* stack << */
73 	RACT_AND,		/* stack & */
74 	RACT_OR,		/* stack | */
75 	RACT_XOR,		/* stack ^ */
76 	RACT_NOT,		/* stack ~ */
77 	RACT_C6SECT,		/* for C60 R_SECT op */
78 	RACT_C6BASE,		/* for C60 R_BASE op */
79 	RACT_C6DSPL,		/* for C60 scaled 15-bit displacement */
80 	RACT_PCR23T		/* for ARM Thumb long branch */
81 };
82 
83 /*
84  * macros used to extract values
85  */
86 #define RFV_POSN(aaa) ((aaa) & 0xF)
87 #define RFV_WIDTH(aaa) (((aaa) >> 4) & 0x3F)
88 #define RFV_ACTION(aaa) ((aaa) >> 10)
89 
90 #define RFV_SIGN(iii) (((iii) >> 2) & 0x3)
91 #define RFV_SYM(iii) (((iii) >> 4) & 0x3)
92 #define RFV_STK(iii) (((iii) >> 6) & 0x3)
93 #define RFV_ACCS(iii) ((iii) & 0x3)
94 
95 #if (TMS32060)
96 #define RFV_SCALE(iii) ((iii) >> 11)
97 #define RFV_BIGOFF(iii) (((iii) >> 8) & 0x7)
98 #else
99 #define RFV_BIGOFF(iii) ((iii) >> 8)
100 #endif
101 
102 #endif /* _RELOC_TABLE_H_ */
103