upload tizen1.0 source
[kernel/linux-2.6.36.git] / drivers / staging / tidspbridge / dynload / tramp_table_c6000.c
1 /*
2  * tramp_table_c6000.c
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 #include "dload_internal.h"
18
19 /*  These are defined in coff.h, but may not be available on all platforms
20         so we'll go ahead and define them here. */
21 #ifndef R_C60LO16
22 #define R_C60LO16         0x54  /* C60: MVK Low Half Register */
23 #define R_C60HI16         0x55  /* C60: MVKH/MVKLH High Half Register */
24 #endif
25
26 #define C6X_TRAMP_WORD_COUNT                    8
27 #define C6X_TRAMP_MAX_RELOS                      8
28
29 /*  THIS HASH FUNCTION MUST MATCH THE ONE reloc_table_c6000.c */
30 #define HASH_FUNC(zz) (((((zz) + 1) * 1845UL) >> 11) & 63)
31
32 /*  THIS MUST MATCH reloc_record_t FOR A SYMBOL BASED RELO */
33 struct c6000_relo_record {
34         s32 vaddr;
35         s32 symndx;
36 #ifndef _BIG_ENDIAN
37         u16 disp;
38         u16 type;
39 #else
40         u16 type;
41         u16 disp;
42 #endif
43 };
44
45 struct c6000_gen_code {
46         struct tramp_gen_code_hdr hdr;
47         u32 tramp_instrs[C6X_TRAMP_WORD_COUNT];
48         struct c6000_relo_record relos[C6X_TRAMP_MAX_RELOS];
49 };
50
51 /*  Hash mapping for relos that can cause trampolines. */
52 static const u16 tramp_map[] = {
53         65535,
54         65535,
55         65535,
56         65535,
57         65535,
58         65535,
59         65535,
60         65535,
61         65535,
62         65535,
63         0,
64         65535,
65         65535,
66         65535,
67         65535,
68         65535,
69         65535,
70         65535,
71         65535,
72         65535,
73         65535,
74         65535,
75         65535,
76         65535,
77         65535,
78         65535,
79         65535,
80         65535,
81         65535,
82         65535,
83         65535,
84         65535,
85         65535,
86         65535,
87         65535,
88         65535,
89         65535,
90         65535,
91         65535,
92         65535,
93         65535,
94         65535,
95         65535,
96         65535,
97         65535,
98         65535,
99         65535,
100         65535,
101         65535,
102         65535,
103         65535,
104         65535,
105         65535,
106         65535,
107         65535,
108         65535,
109         65535,
110         65535,
111         65535,
112         65535,
113         65535,
114         65535,
115         65535,
116         65535
117 };
118
119 static const struct c6000_gen_code tramp_gen_info[] = {
120         /*  Tramp caused by R_C60PCR21 */
121         {
122          /*  Header - 8 instructions, 2 relos */
123          {
124           sizeof(u32) * C6X_TRAMP_WORD_COUNT,
125           2,
126           FIELD_OFFSET(struct c6000_gen_code, relos)
127           },
128
129          /*  Trampoline instructions */
130          {
131           0x053C54F7,           /*       STW.D2T2  B10, *sp--[2] */
132           0x0500002A,           /*  || MVK.S2   <blank>, B10 */
133           0x0500006A,           /*       MVKH.S2   <blank>, B10 */
134           0x00280362,           /*       B.S2     B10 */
135           0x053C52E6,           /*       LDW.D2T2  *++sp[2], B10 */
136           0x00006000,           /*       NOP       4 */
137           0x00000000,           /*       NOP */
138           0x00000000            /*       NOP */
139           },
140
141          /*  Relocations */
142          {
143           {4, 0, 0, R_C60LO16},
144           {8, 0, 0, R_C60HI16},
145           {0, 0, 0, 0x0000},
146           {0, 0, 0, 0x0000},
147           {0, 0, 0, 0x0000},
148           {0, 0, 0, 0x0000},
149           {0, 0, 0, 0x0000},
150           {0, 0, 0, 0x0000}
151           }
152          }
153 };
154
155 /*  TARGET SPECIFIC FUNCTIONS THAT MUST BE DEFINED */
156 static u32 tramp_size_get(void)
157 {
158         return sizeof(u32) * C6X_TRAMP_WORD_COUNT;
159 }
160
161 static u32 tramp_img_pkt_size_get(void)
162 {
163         return sizeof(struct c6000_gen_code);
164 }