📄 objelf.h
字号:
#ifndef __OBJELF_H__
#define __OBJELF_H__
/* =================================================================
*
* objelf.h
*
* =================================================================
* ####ECOSGPLCOPYRIGHTBEGIN####
* -------------------------------------------
* This file is part of eCos, the Embedded Configurable Operating
* System.
* Copyright (C) 2005 eCosCentric Ltd.
*
* eCos is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 or (at your option)
* any later version.
*
* eCos is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with eCos; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*
* As a special exception, if other files instantiate templates or
* use macros or inline functions from this file, or you compile this
* file and link it with other works to produce a work based on this
* file, this file does not by itself cause the resulting work to be
* covered by the GNU General Public License. However the source code
* for this file must still be made available in accordance with
* section (3) of the GNU General Public License.
*
* This exception does not invalidate any other reasons why a work
* based on this file might be covered by the GNU General Public
* License.
*
* -------------------------------------------
* ####ECOSGPLCOPYRIGHTEND####
* =================================================================
* #####DESCRIPTIONBEGIN####
*
* Author(s): Anthony Tonizzo (atonizzo@gmail.com)
* Contributors: nickg@ecoscentric.com
* Date: 2005-05-13
* Purpose:
* Description:
*
* ####DESCRIPTIONEND####
*
* =================================================================
*/
//==============================================================================
#include <pkgconf/system.h>
#include <pkgconf/objloader.h>
#include <cyg/hal/hal_tables.h>
//==============================================================================
extern char *cyg_ldr_last_error;
//==============================================================================
#define CYG_LDR_MODE_FILESYSTEM 0
#define CYG_LDR_MODE_FTP 1
#define CYG_LDR_MODE_TFTP 2
#define CYG_LDR_MODE_MEMORY 3
#define CYG_LDR_MODE_HTTP 4
//==============================================================================
typedef struct ELF_OBJECT
{
CYG_ADDRWORD ptr;
cyg_uint32 mode;
size_t (*read)(struct ELF_OBJECT*, size_t, size_t, void*);
cyg_int32 (*seek)(struct ELF_OBJECT*, cyg_uint32);
cyg_int32 (*close)(struct ELF_OBJECT*);
// This is the absolute address in memory where the library resides.
Elf32_Ehdr* p_elfhdr;
// Start of the section header.
Elf32_Shdr* p_sechdr;
cyg_int32 hdrndx_symtab;
cyg_int32 hdrndx_strtab;
cyg_uint32 **sections;
} ELF_OBJECT, *PELF_OBJECT;
//==============================================================================
// Debug functions.
#if CYGPKG_SERVICES_OBJLOADER_DEBUG_LEVEL != 0
#define ELFDEBUG(a) diag_printf(a)
#else
#define ELFDEBUG(a)
#endif
#if CYGPKG_SERVICES_OBJLOADER_DEBUG_LEVEL > 0
void cyg_ldr_print_section_data(PELF_OBJECT);
void cyg_ldr_print_symbol_names(PELF_OBJECT);
void cyg_ldr_print_rel_names(PELF_OBJECT);
#endif
//==============================================================================
// Internal functions
cyg_uint32 *cyg_ldr_load_elf_section(PELF_OBJECT, cyg_uint32);
void cyg_ldr_delete_elf_section(PELF_OBJECT, cyg_uint32);
cyg_uint32 *cyg_ldr_section_address(PELF_OBJECT, cyg_uint32);
void* cyg_ldr_scan_file(PELF_OBJECT);
cyg_int32 cyg_ldr_relocate_section(PELF_OBJECT, cyg_uint32);
void* cyg_ldr_find_symbol(void*, char*);
void* cyg_ldr_symbol_address(PELF_OBJECT, cyg_uint32);
void* cyg_ldr_external_address(PELF_OBJECT, cyg_uint32);
//==============================================================================
// User interface.
PELF_OBJECT cyg_ldr_open_library(CYG_ADDRWORD, cyg_int32);
void cyg_ldr_close_library(void*);
char* cyg_ldr_error(void);
void* cyg_ldr_get_symbol(void*, char*);
//==============================================================================
void *cyg_ldr_malloc(size_t) CYGBLD_ATTRIB_WEAK;
void cyg_ldr_free(void *) CYGBLD_ATTRIB_WEAK;
//==============================================================================
struct cyg_ldr_table_entry
{
char *symbol_name;
void *handler;
} CYG_HAL_TABLE_TYPE;
typedef struct cyg_ldr_table_entry cyg_ldr_table_entry;
#define CYG_LDR_TABLE_ENTRY(__name, __symbol_name, __handler) \
cyg_ldr_table_entry __name CYG_HAL_TABLE_ENTRY(ldr_table) = \
{ __symbol_name, __handler }
//==============================================================================
#define CYG_LDR_TABLE_KAPI_ALARM() \
CYG_LDR_TABLE_ENTRY(cyg_alarm_create_entry, \
"cyg_alarm_create", cyg_alarm_create); \
CYG_LDR_TABLE_ENTRY(cyg_alarm_delete_entry, \
"cyg_alarm_delete", cyg_alarm_delete); \
CYG_LDR_TABLE_ENTRY(cyg_alarm_initialize_entry, \
"cyg_alarm_initialize", cyg_alarm_initialize); \
CYG_LDR_TABLE_ENTRY(cyg_alarm_get_times_entry, \
"cyg_alarm_get_times", cyg_alarm_get_times); \
CYG_LDR_TABLE_ENTRY(cyg_alarm_enable_entry, \
"cyg_alarm_enable", cyg_alarm_enable); \
CYG_LDR_TABLE_ENTRY(cyg_alarm_disable_entry, \
"cyg_alarm_disable", cyg_alarm_disable);
#define CYG_LDR_TABLE_KAPI_CLOCK() \
CYG_LDR_TABLE_ENTRY(cyg_clock_create_entry, \
"cyg_clock_create", cyg_clock_create); \
CYG_LDR_TABLE_ENTRY(cyg_clock_delete_entry, \
"cyg_clock_delete", cyg_clock_delete); \
CYG_LDR_TABLE_ENTRY(cyg_clock_to_counter_entry, \
"cyg_clock_to_counter", cyg_clock_to_counter); \
CYG_LDR_TABLE_ENTRY(cyg_clock_set_resolution_entry, \
"cyg_clock_set_resolution", cyg_clock_set_resolution); \
CYG_LDR_TABLE_ENTRY(cyg_clock_get_resolution_entry, \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -