DSPRelated.com
Forums

load time and run time memory

Started by deep...@ti.com March 10, 2008
hi
i tried to run my code from different memory location from that of load address using load and run commands in linker command file.but the program halts when it branches out to run time address since the code is not found in run time address,is there any way to copy code from load time address to run time address.

/*part of .map file*/
.deepth1 0 80000420 00000020 RUN ADDR = 60010000
80000420 00000020 func.obj (.text)

.deepth2 0 80000440 00000020 RUN ADDR = 60010000
80000440 00000020 same.obj (.text)

Check Out Industry's First Single-Chip, Multi-Format, Real-Time HD Video Transcoding Solution for Commercial & Consumer End Equipment: www.ti.com/dm6467
Deepth-

> i tried to run my code from different memory location from that of load address using load and run commands in linker
> command file.but the program halts when it branches out to run time address since the code is not found in run time
> address,is there any way to copy code from load time address to run time address.
>
> /*part of .map file*/
> .deepth1 0 80000420 00000020 RUN ADDR = 60010000
> 80000420 00000020 func.obj (.text)
>
> .deepth2 0 80000440 00000020 RUN ADDR = 60010000
> 80000440 00000020 same.obj (.text)

According to the 6000 DSP/BIOS API Reference Guide:

http://focus.ti.com/lit/ug/spru403o/spru403o.pdf

"The application must copy the section from its load address to its run address." (page 277)

So that means your code has to do it before you allow the code to attempt to branch to the run-time address.

-Jeff

Check Out Industry's First Single-Chip, Multi-Format, Real-Time HD Video Transcoding Solution for Commercial & Consumer End Equipment: www.ti.com/dm6467
Deepth-

Another suggestion: look for TI documentation on how to use the .label directive.
This can be used to create "begin" and "end" marker symbols that you can access in
your code. For example, you could create markers "code_sec_beg" and "code_sec_end"
then in your application you would know the load-addreess start and length of code to
copy.

-Jeff

-------- Original Message --------
Subject: Re: [code-comp] load time and run time memory
Date: Mon, 10 Mar 2008 09:55:34 -0600 (CST)
From: "Jeff Brower"
To: d...@ti.com
CC: c...

Deepth-

> i tried to run my code from different memory location from that of load address using load and run commands in linker
> command file.but the program halts when it branches out to run time address since the code is not found in run time
> address,is there any way to copy code from load time address to run time address.
>
> /*part of .map file*/
> .deepth1 0 80000420 00000020 RUN ADDR = 60010000
> 80000420 00000020 func.obj (.text)
>
> .deepth2 0 80000440 00000020 RUN ADDR = 60010000
> 80000440 00000020 same.obj (.text)

According to the 6000 DSP/BIOS API Reference Guide:

http://focus.ti.com/lit/ug/spru403o/spru403o.pdf

"The application must copy the section from its load address to its run address."
(page 277)

So that means your code has to do it before you allow the code to attempt to branch
to the run-time address.

-Jeff
Check Out Industry's First Single-Chip, Multi-Format, Real-Time HD Video Transcoding Solution for Commercial & Consumer End Equipment: www.ti.com/dm6467
Deepth--
Depending upong what you are trying to achieve- memory overlay(same
run mem for 2 or more different algos) or just diff load and run
address for all algos - the technique of code copy will vary slightly.
(Note the latter idea is mostly of no use in practice as its 2x mem
requirement than normal. Are you doing the latter? Whats your
objective? There is usually a easier alternate for what you are
doing...)

But in general, for both cases the application(programmer) must copy
the code onto run time memory well in time for the code to start
running from there. The run time environment will simply expect your
code to be present in the right place. 3 things to remember for
overlay are:

1] Create seperate section for every peice of code that you want to overlay
2] Create your own CMD file for multiple sections using UNION keyword
3] Last but not lease, copy code from load location to run location

The older method of doing 3] was using DMA or Memcopy routines in RTS.
The newer method for this is using TABLE directive and copy_in()
routine for ease of use. Please refer chapter 7 of C6000 manual-
SPRU186P for some code examples for this.

--Bhooshan

On Mon, Mar 10, 2008 at 11:51 AM, wrote:
> hi
> i tried to run my code from different memory location from that of load
> address using load and run commands in linker command file.but the program
> halts when it branches out to run time address since the code is not found
> in run time address,is there any way to copy code from load time address to
> run time address.
>
> /*part of .map file*/
> .deepth1 0 80000420 00000020 RUN ADDR = 60010000
> 80000420 00000020 func.obj (.text)
>
> .deepth2 0 80000440 00000020 RUN ADDR = 60010000
> 80000440 00000020 same.obj (.text)

-------------------------------
"I've missed more than 9000 shots in my career.
I've lost almost 300 games. 26 times I've been trusted to take the
game winning shot and missed.
I've failed over and over again in my life.
And that is why I succeed."
-- Michael Jordan
--------------------------------
Check Out Industry's First Single-Chip, Multi-Format, Real-Time HD Video Transcoding Solution for Commercial & Consumer End Equipment: www.ti.com/dm6467
FYI, here is a code snippet on how to do copy table:
/* */
/* DEMO.C - Demonstrate linker features copy tables and automatic section */
/* splitting. Most of the interesting linker details are in the */
/* linker command file demo.cmd. */
/* */
/*---*/
/*****************************************************************************/
#include
#include

/*---*/
/* Declare the copy tables that are created in the linker command file. */
/* Use "far" because they reside in external memory, i.e. too far to be */
/* accessed at an offset from the DP like the other global variables. */
/*---*/
extern far COPY_TABLE func1_ctbl, func23_ctbl;

extern void c6416_invalidate_prog_cache(COPY_TABLE *tp);

/*---*/
/* func1 and func2/func3 share the same run address in L2 SRAM. Both sets */
/* of func load in external memory. Note the load allocation of func2/func3 */
/* is split across multiple memory ranges. */
/*---*/
void func1(void);
void func2(void), func3(void);

/*---*/
/* These funcs are all loaded in external memory. Section splitting is used */
/* allocate them across a range of artificially small memory ranges. */
/*---*/
extern void func4(void);
extern void func5(void);
extern void func6(void);
extern void func7(void);

/*---*/
/* The global variable incremented by each of the funcs. By the time the */
/* demo is over x = 1+2+3+4+5+6+7 = 28. */
/*---*/
int x = 0;

void main()
{
/*-----------------------------------*/
/* Copy the code for func1 from EMIFA to L2RAM. Then, invalidate the */
/* program cache for this memory block(s). See c6416_cache.c for */
/* details. Then, can call func1. */
/*-----------------------------------*/
copy_in(&func1_ctbl);
c6416_invalidate_prog_cache(&func1_ctbl);
func1();

/*-----------------------------------*/
/* Note func2 and func3 are allocated together. The load allocation */
/* is spread across multiple blocks of EMIFA. These multiple blocks are */
/* reflected in the multiple entries in the copy table. All of this */
/* detail is comprehended in the copy table and copy_in routine. Thus, */
/* this code is similar to that for func1. */
/*-----------------------------------*/
copy_in(&func23_ctbl);
c6416_invalidate_prog_cache(&func23_ctbl);
func2();
func3();

/*-----------------------------------*/
/* The remaining funcs demonstrate automatic section splitting. */
/*-----------------------------------*/
func4();
func5();
func6();
func7();

printf("linker example %s!\n", (x != 28) ? "FAILED" : "PASSED");
}

#pragma CODE_SECTION(func1, ".func1_scn")
void func1(void)
{
printf("hit func1, run address is %p, x is %d\n", func1, x);
x += 1;
}

#pragma CODE_SECTION(func2, ".func2_scn")
void func2(void)
{
printf("hit func2, run address is %p, x is %d\n", func2, x);
x += 2;
}

#pragma CODE_SECTION(func3, ".func3_scn")
void func3(void)
{
printf("hit func3, run address is %p, x is %d\n", func3, x);
x += 3;
}

/*****************************************************************************/
--Bhooshan

On Tue, Mar 11, 2008 at 4:09 PM, Bhooshan Iyer wrote:
> Deepth--
> Depending upong what you are trying to achieve- memory overlay(same
> run mem for 2 or more different algos) or just diff load and run
> address for all algos - the technique of code copy will vary slightly.
> (Note the latter idea is mostly of no use in practice as its 2x mem
> requirement than normal. Are you doing the latter? Whats your
> objective? There is usually a easier alternate for what you are
> doing...)
>
> But in general, for both cases the application(programmer) must copy
> the code onto run time memory well in time for the code to start
> running from there. The run time environment will simply expect your
> code to be present in the right place. 3 things to remember for
> overlay are:
>
> 1] Create seperate section for every peice of code that you want to overlay
> 2] Create your own CMD file for multiple sections using UNION keyword
> 3] Last but not lease, copy code from load location to run location
>
> The older method of doing 3] was using DMA or Memcopy routines in RTS.
> The newer method for this is using TABLE directive and copy_in()
> routine for ease of use. Please refer chapter 7 of C6000 manual-
> SPRU186P for some code examples for this.
>
> --Bhooshan
>
> On Mon, Mar 10, 2008 at 11:51 AM, wrote:
> >
> >
> >
> >
> > hi
> > i tried to run my code from different memory location from that of load
> > address using load and run commands in linker command file.but the program
> > halts when it branches out to run time address since the code is not found
> > in run time address,is there any way to copy code from load time address to
> > run time address.
> >
> > /*part of .map file*/
> > .deepth1 0 80000420 00000020 RUN ADDR = 60010000
> > 80000420 00000020 func.obj (.text)
> >
> > .deepth2 0 80000440 00000020 RUN ADDR = 60010000
> > 80000440 00000020 same.obj (.text)
> >
> > -------------------------------
> "I've missed more than 9000 shots in my career.
> I've lost almost 300 games. 26 times I've been trusted to take the
> game winning shot and missed.
> I've failed over and over again in my life.
> And that is why I succeed."
> -- Michael Jordan
> --------------------------------
>

--
-------------------------------
"I've missed more than 9000 shots in my career.
I've lost almost 300 games. 26 times I've been trusted to take the
game winning shot and missed.
I've failed over and over again in my life.
And that is why I succeed."
-- Michael Jordan
--------------------------------
Check Out Industry's First Single-Chip, Multi-Format, Real-Time HD Video Transcoding Solution for Commercial & Consumer End Equipment: www.ti.com/dm6467