2828#include <dlfcn.h>
2929#include <assert.h>
3030
31- #if defined( __i386__ ) || defined( __x86_64__ ) || defined( __ia64__ )
31+ #if ( OPAL_ASSEMBLY_ARCH == OPAL_IA32 ) || ( OPAL_ASSEMBLY_ARCH == OPAL_IA64 ) || ( OPAL_ASSEMBLY_ARCH == OPAL_AMD64 )
3232
33- #if defined( __ia64__ )
33+ #if ( OPAL_ASSEMBLY_ARCH == OPAL_IA64 )
3434
3535#define INSERT_BIT (d ,p ,v ) do { \
3636 unsigned char c=*(d); \
@@ -87,18 +87,18 @@ static int mca_patcher_overwrite_apply_patch (mca_patcher_base_patch_t *patch)
8787 uintptr_t func_new_addr = patch -> patch_value ;
8888
8989 {
90- #if defined( __i386__ )
90+ #if ( OPAL_ASSEMBLY_ARCH == OPAL_IA32 )
9191 patch -> patch_data_size = 5 ;
9292 * (unsigned char * )(patch -> patch_data + 0 ) = 0xe9 ;
9393 * (unsigned int * ) (patch -> patch_data + 1 ) = (unsigned int )(func_new_addr - patch -> patch_orig - 5 );
94- #elif defined( __x86_64__ )
94+ #elif ( OPAL_ASSEMBLY_ARCH == OPAL_AMD64 )
9595 patch -> patch_data_size = 13 ;
9696 * (unsigned short * )(patch -> patch_data + 0 ) = 0xbb49 ;
9797 * (unsigned long * )(patch -> patch_data + 2 ) = (unsigned long ) func_new_addr ;
9898 * (unsigned char * ) (patch -> patch_data + 10 ) = 0x41 ;
9999 * (unsigned char * ) (patch -> patch_data + 11 ) = 0xff ;
100100 * (unsigned char * ) (patch -> patch_data + 12 ) = 0xe3 ;
101- #elif defined( __ia64__ )
101+ #elif ( OPAL_ASSEMBLY_ARCH == OPAL_IA64 )
102102 {
103103/*
104104 * target64 = IP + ((i << 59 | imm39 << 20 | imm20) << 4)
@@ -155,7 +155,7 @@ static int mca_patcher_overwrite_apply_patch (mca_patcher_base_patch_t *patch)
155155
156156/* end of #if defined(__i386__) || defined(__x86_64__) || defined(__ia64__) */
157157// ------------------------------------------------- PPC equivalent:
158- #elif defined( __PPC__ )
158+ #elif ( OPAL_ASSEMBLY_ARCH == OPAL_POWERPC32 ) || ( OPAL_ASSEMBLY_ARCH == OPAL_POWERPC64 )
159159
160160// PowerPC instructions used in patching
161161// Reference: "PowerPC User Instruction Set Architecture"
@@ -183,7 +183,7 @@ static unsigned int rldicr(unsigned int RT, unsigned int RS, unsigned int SH, un
183183static int
184184PatchLoadImm (uintptr_t addr , unsigned int reg , size_t value )
185185{
186- #if defined( __PPC64__ )
186+ #if ( OPAL_ASSEMBLY_ARCH == OPAL_POWERPC64 )
187187 * (unsigned int * ) (addr + 0 ) = addis ( reg , 0 , (value >> 48 ));
188188 * (unsigned int * ) (addr + 4 ) = ori ( reg , reg , (value >> 32 ));
189189 * (unsigned int * ) (addr + 8 ) = rldicr ( reg , reg , 32 , 31 );
@@ -208,7 +208,7 @@ static int mca_patcher_overwrite_apply_patch (mca_patcher_base_patch_t *patch)
208208 hook_addr = mca_patcher_base_addr_text (patch -> patch_value );
209209
210210// Patch for hook function:
211- #if (defined( __PPC64__ ) || defined( __powerpc64__ ) || defined( __PPC__ ) )
211+ #if (OPAL_ASSEMBLY_ARCH == OPAL_POWERPC64 )
212212 rc = mca_patcher_base_patch_hook (& mca_patcher_overwrite_module , hook_addr );
213213 if (OPAL_SUCCESS != rc ) {
214214 return rc ;
@@ -286,7 +286,7 @@ static int mca_patcher_overwrite_patch_symbol (const char *func_symbol_name, uin
286286
287287 old_addr = (unsigned long )sym_addr ;
288288
289- #if defined( __ia64__ )
289+ #if ( OPAL_ASSEMBLY_ARCH == OPAL_IA64 )
290290 /* On IA64 addresses are all indirect */
291291 func_new_addr = * (unsigned long * )func_new_addr ;
292292 old_addr = * (unsigned long * ) old_addr ;
0 commit comments