ZHCU947F June 2015 – August 2025
GUID-B0B5E3E6-40E4-4908-8D5C-44FC82EF9458.html#STDZ0757771中的 cpy_tbl.h 文件还包含运行时支持库中提供的通用复制例程 copy_in() 的原型。copy_in() 例程只接受一个参数:由链接器生成的复制表的地址。该例程随后会处理复制表数据对象,并执行复制表中指定的每个对象组件的复制。
#STDZ075141显示的 cpy_tbl.c 运行时支持源文件中提供了 copy_in() 函数定义。
/****************************************************************************/
/* cpy_tbl.c */
/* */
/* Copyright (c) 2011 Texas Instruments Incorporated */
/* */
/* General purpose copy routine. Given the address of a link-generated */
/* COPY_TABLE data structure, effect the copy of all object components */
/* that are designated for copy via the corresponding LCF table() operator. */
/* */
/****************************************************************************/
#include <cpy_tbl.h>
#include <string.h>
typedef void (*handler_fptr)(const unsigned char *in, unsigned char *out);
/****************************************************************************/
/* COPY_IN() */
/****************************************************************************/
void copy_in(COPY_TABLE *tp)
{
unsigned short I;
for (I = 0; I < tp->num_recs; I++)
{
COPY_RECORD crp = tp->recs[i];
unsigned char *ld_addr = (unsigned char *)crp.load_addr;
unsigned char *rn_addr = (unsigned char *)crp.run_addr;
if (crp.size)
{
/*------------------------------------------------------------------*/
/* Copy record has a non-zero size so the data is not compressed. */
/* Just copy the data. */
/*------------------------------------------------------------------*/
memcpy(rn_addr, ld_addr, crp.size);
}
#ifdef __TI_EABI__
else if (HANDLER_TABLE)
{
/*------------------------------------------------------------------*/
/* Copy record has size zero so the data is compressed. The first */
/* byte of the load data has the handler index. Use this index with */
/* the handler table to get the handler for this data. Then call */
/* the handler by passing the load and run address. */
/*------------------------------------------------------------------*/
unsigned char index = *((unsigned char *)ld_addr++);
handler_fptr hndl = (handler_fptr)(&HANDLER_TABLE)[index];
(*hndl)((const unsigned char *)ld_addr, (unsigned char *)rn_addr);
}
#endif
}
}