MityDSP Documentation Index
Using _cl_int00 to pre-initialize global variables

The Code Composer Compiler is not ISO compliant because it does not set otherwise uninitialized global variables to zero.

While all Critical Link libraries are written with this in mind, some third party and legacy code relies on this feature. Most notably, the lwIP code upon which the MityDSP network stack is based.

To get around this problem, a "pre-initialization" function has been provided in the MityDSP core library. The uninitialized data will be placed in the .bss and .far sections by the compiler. Generally, these are the only areas that need to be modified by _cl_int00. To use this function, specify "_cl_int00" as the code entry point for your executable (using the -e option for the linker, which may be set in your project file).

In addition, _cl_int00 must be installed as the target of the HWI_RESET vector. This is done in the application's .tcf file. If your application uses the MityDSP platform files, this is done for you automatically. Otherwise, make sure the following line appears in your .tcf file (this may be done with the graphical editor):

    bios.HWI.instance("HWI_RESET").fxn = prog.extern("cl_int00");
Unfortunately, symbols are not provided by the linker for the start of the
.far section, so the addresses have to be provided manually for each project.
This is accomplished by placing the following code somewhere in the application.
The declaration area of an application's main() function is a convenient place 
to insert it...

@code 

/*/////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\*/ // NOTE: These variables are for the pre-init routine _cl_int00, which is used to // // zero uninitialized variables for 3rd party application software that // // requires it. These variables are contained in the ".far" and ".bss" // // linker memory sections. The start and end of .bss is defined by symbols // // automatically generated by the linker. Unfortunately, the start and // // end of .far has no such symbols, so they must be defined here. // // // // To determine these locations for your application, compile and link // // your application. Make sure the -m option is defined for the linker // // so a map file is produced. Open the map file and find the beginning // // of the .far section, and use this address as ___far__, below. Find the // // last entry in .far and use this address as ___fend__, below. Note that // // ___fend__ can be past the end of .far (to allow future application // // growth), so long as it doesn't cross into any initialized data segment. // // If ___fend__ is set to zero, the .far segment is assumed to extend // // until the beginning of .bss, which is a safe assumption in most cases. // // // asm(" .def ___far__"); // asm(" .def ___fend__"); // #ifdef MITYDSP_PRO // asm("___far__ .set 0xe2000000"); // START OF ".far" MEMORY // asm("___fend__ .set 0x00000000"); // END OF ".far" MEMORY // #else // asm("___far__ .set 0x80500000"); // START OF ".far" MEMORY // asm("___fend__ .set 0x00000000"); // END OF ".far" MEMORY // #endif // /*\\\\\\\\\\\\\\\\\\\\\/////////////////////////////////////////*/

In no circumstances should any initialized data (e.g. the .text section) be initialized with _cl_int00. This could lead to failure of the application.


  
Generated on Mon Apr 22 2013 11:33:02 for MityDSP Core by  Doxygen Version 1.8.1.1
Copyright © 2009, Critical Link LLC, All rights reserved.