SPRU513Z August 2001 – October 2023 SM320F28335-EP
The cpy_tbl.h file in TMS320C28x 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 */
/* */
/* General purpose copy routine. Given the address of a linker-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>
void copy_in(COPY_TABLE *tp)
{
unsigned int i;
for (i = 0; i < tp->num_recs; i++)
{
COPY_RECORD *crp = &tp->recs[i];
unsigned int cpy_type = 0;
unsigned int j;
if (crp->src_pgid) cpy_type += 2;
if (crp->dst_pgid) cpy_type += 1;
for (j = 0; j < crp->size; j++)
{
switch (cpy_type)
{
case 3: ddcopy(crp->src_addr + j, crp->dst_addr + j); break;
case 2: dpcopy(crp->src_addr + j, crp->dst_addr + j); break;
case 1: pdcopy(crp->src_addr + j, crp->dst_addr + j); break;
case 0: ppcopy(crp->src_addr + j, crp->dst_addr + j); break;
}
}
}
}
The load (or source) page id and the run (or destination) page id are used to choose which low-level copy routine is called to move a word of data from the load location to the run location. A page id of 0 indicates that the specified address is in program memory, and a page id of 1 indicates that the address is in data memory. The hardware provides special instructions, PREAD and PWRITE, to move code/data into and out of program memory.