root/opal/mca/patcher/base/base.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. mca_patcher_base_addr_text

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2006 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
  10  *                         University of Stuttgart.  All rights reserved.
  11  * Copyright (c) 2004-2005 The Regents of the University of California.
  12  *                         All rights reserved.
  13  * Copyright (c) 2016      Los Alamos National Security, LLC. All rights
  14  *                         reserved.
  15  * $COPYRIGHT$
  16  *
  17  * Additional copyrights may follow
  18  *
  19  * $HEADER$
  20  *
  21  */
  22 
  23 #ifndef OPAL_PATCHER_BASE_H
  24 #define OPAL_PATCHER_BASE_H
  25 
  26 #include "opal_config.h"
  27 #include "opal/mca/base/mca_base_framework.h"
  28 #include "opal/mca/patcher/patcher.h"
  29 
  30 
  31 BEGIN_C_DECLS
  32 
  33 #define MCA_BASE_PATCHER_MAX_PATCH 32
  34 
  35 struct mca_patcher_base_patch_t;
  36 
  37 typedef void (*mca_patcher_base_restore_fn_t) (struct mca_patcher_base_patch_t *);
  38 
  39 struct mca_patcher_base_patch_t {
  40     /** patches are list items */
  41     opal_list_item_t super;
  42     /** name symbol to patch */
  43     char            *patch_symbol;
  44     /** address of function to call instead */
  45     uintptr_t        patch_value;
  46     /** original address of function */
  47     uintptr_t        patch_orig;
  48     /** patch data */
  49     unsigned char    patch_data[MCA_BASE_PATCHER_MAX_PATCH];
  50     /** original data */
  51     unsigned char    patch_orig_data[MCA_BASE_PATCHER_MAX_PATCH];
  52     /** size of patch data */
  53     unsigned         patch_data_size;
  54     /** function to undo the patch */
  55     mca_patcher_base_restore_fn_t patch_restore;
  56 };
  57 
  58 typedef struct mca_patcher_base_patch_t mca_patcher_base_patch_t;
  59 
  60 OBJ_CLASS_DECLARATION(mca_patcher_base_patch_t);
  61 
  62 /**
  63  * Framework struct declaration for this framework
  64  */
  65 OPAL_DECLSPEC extern mca_base_framework_t opal_patcher_base_framework;
  66 OPAL_DECLSPEC int opal_patcher_base_select (void);
  67 OPAL_DECLSPEC int mca_patcher_base_patch_hook (mca_patcher_base_module_t *module, uintptr_t hook);
  68 OPAL_DECLSPEC void mca_base_patcher_patch_apply_binary (mca_patcher_base_patch_t *patch);
  69 
  70 static inline uintptr_t mca_patcher_base_addr_text (uintptr_t addr) {
  71 #if (OPAL_ASSEMBLY_ARCH == OPAL_POWERPC64) && (!defined (_CALL_ELF) || (_CALL_ELF != 2))
  72     struct odp_t {
  73         uintptr_t text;
  74         uintptr_t toc;
  75     } *odp = (struct odp_t *) addr;
  76     return (odp)?odp->text:0;
  77 #else
  78     return addr;
  79 #endif
  80 }
  81 
  82 END_C_DECLS
  83 #endif /* OPAL_BASE_PATCHER_H */

/* [<][>][^][v][top][bottom][index][help] */