You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
software/kkk/los_ld_elflib.h

295 lines
10 KiB

1 year ago
/* ----------------------------------------------------------------------------
* Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved.
* Description: Dynload ElfLib HeadFile
* Author: Huawei LiteOS Team
* Create: 2013-01-01
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --------------------------------------------------------------------------- */
/**
* @defgroup los_dynload Dynamic loading
* @ingroup kernel
*/
#ifndef _LOS_LD_ELFLIB_H
#define _LOS_LD_ELFLIB_H
#include "los_typedef.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#ifdef LOSCFG_KERNEL_DYNLOAD_DYN
#ifdef LOSCFG_DYNLOAD_DYN_FROM_FS
/**
* @ingroup los_dynload
* Define an enum type indicates load strategy.
*
* Type of load strategy of dynamic load, ZIP means using zipped shared object, NOZIP means using normal shared object.
*/
enum LOAD_STRATEGY {
ZIP,
NOZIP
};
/*<2A><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ö<EFBFBD><C3B6><EFBFBD><EFBFBD><EFBFBD>͵Ķ<CDB5><C4B6><EFBFBD><E5A3AC><EFBFBD><EFBFBD>ΪLOAD_STRATEGY<47><59><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>ZIP<49><50>NOZIP<49><50>*/
/**
* @ingroup los_dynload
* Define the structure of the parameters used for dynamic.
*
* Information of specified parameters passed in during dynamic load.
*/
typedef struct tagDynloadParam {
enum LOAD_STRATEGY enLoadStrategy;
} DYNLOAD_PARAM_S;
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6B4A2>̬<EFBFBD><CCAC><EFBFBD>صIJ<D8B5><C4B2><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>enLoadStrategy<EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD>ԣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ZIP<EFBFBD><EFBFBD><EFBFBD><EFBFBD>NOZIP<EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>صĺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD>*/
/**
* @ingroup los_dynload
* @brief Register the dynamic parameters.
*
* @par Description:
* This API is used to register the dynamic load parameters.
* @attention
* <ul>
* <li></li>
* </ul>
*
* @param dynloadParam [IN] dynamic load parameters to be registered.
*
* @par Dependency:
* <ul><li>los_ld_elflib.h: the header file that contains the API declaration.</li></ul>
* @see LOS_FindSymByName | LOS_LdDestroy
* @since Huawei LiteOS V100R001C00
*/
extern VOID LOS_DynParamReg(DYNLOAD_PARAM_S *dynloadParam);
/*ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>LOS_DynParamReg<65><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ָ<EFBFBD><D6B8>DYNLOAD_PARAM_S<5F><53><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>
<EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><EFBFBD><EFBFBD>̬<EFBFBD><EFBFBD><EFBFBD>صIJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣע<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>ϵͳ<EFBFBD><EFBFBD>ģ<EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>*/
/**
* @ingroup los_dynload
* @brief Load a shared object file.
*
* @par Description:
* This API is used to load a shared object file under a particular module file path.
* @attention
* <ul>
* <li>The parameter passed to this API should be a legal path of a shared object file.</li>
* </ul>
*
* @param elfFileName [IN] Shared object file path.
*
* @retval NULL The shared object file fails to be loaded.
* @retval VOID* The shared object file is successfully loaded.
* @par Dependency:
* <ul><li>los_ld_elflib.h: the header file that contains the API declaration.</li></ul>
* @see LOS_ModuleUnload
* @since Huawei LiteOS V100R001C00
*/
extern VOID *LOS_SoLoad(CHAR *elfFileName);
#endif /* LOSCFG_DYNLOAD_DYN_FROM_FS */
#ifdef LOSCFG_DYNLOAD_DYN_FROM_MEM
/**
* @ingroup los_dynload
* @brief Load a shared object file from the memory.
*
* @par Description:
* This API is used to load a shared object file that is in memory.
* @attention
* <ul>
* <li>The shared object file does not depend on other shared objects.</li>
* </ul>
*
* @param elfFileName [IN] Shared object file name.
* @param fileNameLen [IN] The length of shared object file name.
* @param elfFileBuf [IN] Shared object file buffer in memory.
* @param bufLen [IN] the length of shared object file buffer in memory.
*
* @retval NULL The shared object file fails to be loaded.
* @retval VOID* The shared object file is successfully loaded.
* @par Dependency:
* <ul><li>los_ld_elflib.h: the header file that contains the API declaration.</li></ul>
* @see LOS_ModuleUnload
* @since Huawei LiteOS V200R003C00
*/
extern VOID *LOS_MemLoad(const CHAR *elfFileName, UINT32 fileNameLen,
const CHAR *elfFileBuf, UINT32 bufLen);
#endif /* LOSCFG_DYNLOAD_DYN_FROM_MEM */
#endif /* LOSCFG_KERNEL_DYNLOAD_DYN */
/*<2A><><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>#ifdef<65><66>#endif<69><66><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD>ͬ<EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EBBBB7><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ö<EFBFBD>̬<EFBFBD><CCAC><EFBFBD>ع<EFBFBD><D8B9>ܡ<EFBFBD>*/
#ifdef LOSCFG_KERNEL_DYNLOAD_REL
/**
* @ingroup los_dynload
* @brief Load a object file.
*
* @par Description:
* This API is used to load a object file under a particular module file path.
* @attention
* <ul>
* <li>The parameter passed to this API should be a legal path of an object file.</li>
* </ul>
*
* @param elfFileName [IN] Object file path.
*
* @retval NULL The object file fails to be loaded.
* @retval VOID* The object file is successfully loaded.
* @par Dependency:
* <ul><li>los_ld_elflib.h: the header file that contains the API declaration.</li></ul>
* @see LOS_ModuleUnload
* @since Huawei LiteOS V100R001C00
*/
extern VOID *LOS_ObjLoad(CHAR *elfFileName);
#endif /* LOSCFG_KERNEL_DYNLOAD_REL */
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EAB6A8>LOSCFG_KERNEL_DYNLOAD_REL<45><4C><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD>̬<EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>LOS_ObjLoad<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>ⲿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>CHAR<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>VOID<EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>ָ<EFBFBD>*/
/**
* @ingroup los_dynload
* @brief Unload a module.
*
* @par Description:
* This API is used to unload a module with a particular module handle.
* @attention
* <ul>
* <li>None.</li>
* </ul>
*
* @param handle [IN] Module handle.
*
* @retval #LOS_NOK The module fails to be unloaded.
* @retval #LOS_OK The module is successfully unloaded.
* @par Dependency:
* <ul><li>los_ld_elflib.h: the header file that contains the API declaration.</li></ul>
* @see LOS_ObjLoad
* @since Huawei LiteOS V100R001C00
*/
extern INT32 LOS_ModuleUnload(VOID *handle);
/*ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>LOS_ModuleUnload<61><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>̬<EFBFBD><CCAC><EFBFBD>ľ<EFBFBD><C4BE><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ظö<EFBFBD>̬<EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD>*/
/**
* @ingroup los_dynload
* @brief Destroy a dynamic loader.
*
* @par Description:
* This API is used to destroy a dynamic linker.
* @attention
* <ul>
* <li>When dynamic loading is no longer needed, call this API to destroy the dynamic linker.</li>
* </ul>
*
* @param None.
*
* @retval None.
* @par Dependency:
* <ul><li>los_ld_elflib.h: the header file that contains the API declaration.</li></ul>
* @see LOS_FindSymByName
* @since Huawei LiteOS V100R001C00
*/
extern VOID LOS_LdDestroy(VOID);
/*<2A><><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD>LOS_LdDestroy<6F><79><EFBFBD>ú<EFBFBD><C3BA><EFBFBD>û<EFBFBD>в<EFBFBD><D0B2><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD>ֵ<EFBFBD><D6B5>
ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>LOS_LdDestroy<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>̬<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Loader<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ*/
/**
* @ingroup los_dynload
* @brief Search for a symbol address.
*
* @par Description:
* This API is used to search for the address of a symbol according to a particular module handle and symbol name.
* @attention
* <ul>
* <li>If the value of handle is NULL, Huawei LiteOS searches for symbols (including system symbols) in the global
* symbol table. If handle is set to a valid module handle, Huawei LiteOS searches for symbols in the module that
* comes with the module handle.</li>
* </ul>
*
* @param handle [IN] Module handle.
* @param name [IN] Name of the symbol to be searched for.
*
* @retval NULL The symbol address is not found.
* @retval VOID* Symbol address.
* @par Dependency:
* <ul><li>los_ld_elflib.h: the header file that contains the API declaration.</li></ul>
* @see LOS_LdDestroy
* @since Huawei LiteOS V100R001C00
*/
extern VOID *LOS_FindSymByName(VOID *handle, CHAR *name);
/**
* @ingroup los_dynload
* @brief Add a default path.
*
* @par Description:
* This API is used to add a path to default paths.
* @attention
* <ul>
* <li></li>
* </ul>
*
* @param path [IN] Path to be added to default paths.
*
* @retval #LOS_NOK The path is added unsuccessfully.
* @retval #LOS_OK The path is added successfully.
* @par Dependency:
* <ul><li>los_ld_elflib.h: the header file that contains the API declaration.</li></ul>
* @see LOS_FindSymByName | LOS_LdDestroy
* @since Huawei LiteOS V100R001C00
*/
extern INT32 LOS_PathAdd(CHAR *path);
/*ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>LOS_PathAdd<64><64><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD>С<EFBFBD>
<EFBFBD>ڶ<EFBFBD>̬<EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̬<EFBFBD><EFBFBD>*/
/**
* @ingroup los_dynload
* @brief Set the memory pool address used by dynload
*
* @par Description:
* This API is used to set the memory pool address used by dynload.
* @attention
* <ul>
* <li>The parameter passed to this API should be a legal memory pool address by managed with LiteOS's memory
* algorithm, and whose value is outside of the LiteOS system memory</li>
* </ul>
*
* @param memPool [IN] the memory pool address.
*
* @retval TRUE Set successful.
* @retval FLASE Set failed.
* @par Dependency:
* <ul><li>los_ld_elflib.h: the header file that contains the API declaration.</li></ul>
* @see LOS_ModuleUnload
* @since Huawei LiteOS V200R002C00
*/
extern BOOL LOS_DynMemPoolSet(VOID *memPool);
/*ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>LOS_DynMemPoolSet<65><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>ָ<EFBFBD>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD>̬<EFBFBD>ڴ<EFBFBD><EFBFBD>أ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD><EFBFBD>غ<EFBFBD>ִ<EFBFBD>ж<EFBFBD>̬<EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD>̬<EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD>ִ<EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD>ء<EFBFBD>*/
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_LD_ELFLIB_H */