2
#include <asm/unistd.h>
4
#ifndef __NR_switch_endian
5
#define __NR_switch_endian 363
8
/* a constant to use in the SI field of a little-endian D-form instruction */
9
#define le_si16(x) (((x & 0xff) << 24) | ((x & 0xff00) << 8))
14
* Call into a HBRT BE function
15
* Func desc (opd) will be in BE
16
* Use ldbrx to load from opd
21
/* Before we switch, we need to perform some ABI
22
* conversion. We are currently running LE with the
23
* new ABI v2. The GPR content is the same, we do
24
* need save/restore and adjust r2. At this point r11
30
/* We first create a stack frame compatible with BE, we
31
* do a big one just in case... we save LR into our caller's
32
* frame and r2 in our own frame. This is a BE formatted
33
* frame so we store it as 40(r1), not 24(r1)
37
std %r0,(128 + 16)(%r1)
40
/* Grab the target r2 and function pointer */
41
#if __BYTE_ORDER == __LITTLE_ENDIAN
52
#if __BYTE_ORDER == __LITTLE_ENDIAN
53
/* Switch to the "other endian" */
54
li %r0,__NR_switch_endian
58
.long 0x2100804e /* (byteswapped blrl) */
60
/* Switch endian back */
61
.long 0x00000038 | le_si16(__NR_switch_endian)
62
/* byteswapped li %r0,__NR_switch_endian */
63
.long 0x02000044 /* byteswapped sc */
67
/* Recover our r2, LR, undo stack frame ... */
74
#define CALL_THUNK(name, idx) \
77
ld %r11,hservice_runtime_fixed@got(%r2) ;\
78
ld %r11,(idx * 8)(%r11) ;\
81
/* Instanciate call to HBRT thunks */
82
CALL_THUNK(cxxtestExecute, 1)
83
CALL_THUNK(get_lid_list, 2)
84
CALL_THUNK(occ_load, 3)
85
CALL_THUNK(occ_start, 4)
86
CALL_THUNK(occ_stop, 5)
87
CALL_THUNK(process_occ_error, 6)
88
CALL_THUNK(enable_attns, 7)
89
CALL_THUNK(disable_attns, 8)
90
CALL_THUNK(handle_attns, 9)
91
CALL_THUNK(process_occ_reset, 10)
92
CALL_THUNK(enable_occ_actuation, 11)
93
CALL_THUNK(apply_attr_override, 12)
94
CALL_THUNK(mfg_htmgt_pass_thru, 13)
95
CALL_THUNK(run_command, 14)
99
ld %r11,hbrt_entry@got(%r2)
102
#if __BYTE_ORDER == __LITTLE_ENDIAN
103
/* Callback from HBRT, stack conversion and call into C code,
104
* we arrive here from the thunk macro with r11 containing the
105
* target function and r2 already set from the OPD.
108
/* Create a LE stack frame, save LR */
113
/* Branch to original function */
117
/* Restore stack and LR */
122
/* Switch endian back to BE */
123
li %r0,__NR_switch_endian
127
.long 0x2000804e /* byteswapped blr */
129
/* Callback from HBRT. There is one entry point per function.
131
* We assume the proper r2 is already set via the OPD, so we grab our
132
* target function pointer in r11 and jump to call_le
134
#define CALLBACK_THUNK(name) \
135
.pushsection ".text","ax" ;\
136
.globl name##_thunk ;\
138
.long 0x00000038 | le_si16(__NR_switch_endian) ;\
139
/* byteswapped li %r0,__NR_switch_endian */ ;\
140
.long 0x02000044 /* byteswapped sc */ ;\
141
ld %r11,name@got(%r2) ;\
144
.pushsection ".data.thunk_opd","aw" ;\
145
1: .llong name##_thunk, .TOC., 0 ;\
148
#else /* __BYTE_ORDER == __LITTLE_ENDIAN */
149
#define CALLBACK_THUNK(name) \
153
#define DISABLED_THUNK(name) .llong 0x0
155
/* Here's the callback table generation. It creates the table and
156
* all the thunks for all the callbacks from HBRT to us
160
.globl __hinterface_start
163
/* HBRT interface version */
166
/* Callout pointers */
167
CALLBACK_THUNK(hservice_puts)
168
CALLBACK_THUNK(hservice_assert)
169
CALLBACK_THUNK(hservice_set_page_execute)
170
CALLBACK_THUNK(hservice_malloc)
171
CALLBACK_THUNK(hservice_free)
172
CALLBACK_THUNK(hservice_realloc)
173
DISABLED_THUNK(hservice_send_error_log)
174
CALLBACK_THUNK(hservice_scom_read)
175
CALLBACK_THUNK(hservice_scom_write)
176
DISABLED_THUNK(hservice_lid_load)
177
DISABLED_THUNK(hservice_lid_unload)
178
CALLBACK_THUNK(hservice_get_reserved_mem)
179
DISABLED_THUNK(hservice_wakeup)
180
CALLBACK_THUNK(hservice_nanosleep)
181
DISABLED_THUNK(hservice_report_occ_failure)
182
CALLBACK_THUNK(hservice_clock_gettime)
183
CALLBACK_THUNK(hservice_pnor_read)
184
CALLBACK_THUNK(hservice_pnor_write)
185
CALLBACK_THUNK(hservice_i2c_read)
186
CALLBACK_THUNK(hservice_i2c_write)
187
CALLBACK_THUNK(hservice_ipmi_msg)
188
CALLBACK_THUNK(hservice_memory_error)
189
CALLBACK_THUNK(hservice_get_interface_capabilities)
190
.globl __hinterface_pad
192
/* Reserved space for future growth */
194
.globl __hinterface_end
196
/* Eye catcher for debugging */