SPRUIG8J January 2018 – March 2024
The cpy_tbl.h file in C7000 cpy_tbl.h File also contains a prototype for a general-purpose copy routine, copy_in(), which is provided as part of the run-time-support library. The copy_in() routine takes a single argument: the address of a linker-generated copy table. The routine then processes the copy table data object and performs the copy of each object component specified in the copy table.
The copy_in() function definition is provided in the cpy_tbl.c run-time-support source file shown in Run-Time-Support cpy_tbl.c File.
/****************************************************************************/
/* 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
}
}