staging: ti dspbridge: add DOFF binaries loader
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / tidspbridge / dynload / tramp_table_c6000.c
blobe38d631b3217776b406a871f3778e6376090ac90
1 /*
2 * tramp_table_c6000.c
4 * DSP-BIOS Bridge driver support functions for TI OMAP processors.
6 * Copyright (C) 2005-2006 Texas Instruments, Inc.
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.
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.
17 #include "dload_internal.h"
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
26 #define C6X_TRAMP_WORD_COUNT 8
27 #define C6X_TRAMP_MAX_RELOS 8
29 /* THIS HASH FUNCTION MUST MATCH THE ONE IN reloc_table_c6000.c */
30 #define HASH_FUNC(zz) (((((zz) + 1) * UINT32_C(1845)) >> 11) & 63)
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
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];
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,
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
119 static const struct c6000_gen_code tramp_gen_info[] = {
120 /* Tramp caused by R_C60PCR21 */
122 /* Header - 8 instructions, 2 relos */
124 sizeof(u32) * C6X_TRAMP_WORD_COUNT,
126 FIELD_OFFSET(struct c6000_gen_code, relos)
129 /* Trampoline instructions */
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 */
141 /* Relocations */
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}
155 /* TARGET SPECIFIC FUNCTIONS THAT MUST BE DEFINED */
156 static u32 tramp_size_get(void)
158 return sizeof(u32) * C6X_TRAMP_WORD_COUNT;
161 static u32 tramp_img_pkt_size_get(void)
163 return sizeof(struct c6000_gen_code);