Resending to newsgrp... > Hello, > > I'm trying to write a library that would need some DSP/BIOS > semaphores (SEM) & mailboxes (MBX). > > This library is to be used in several projects, so that I > would like to make the SEM and MBX declarations in the .c > file itself, and not in each project's .cdb file (DSP/BIOS > configuration file). > > For performance & memory footprint reasons, I want to use > static declarations (no SEM_create,... functions). > You can still achieve these goals of portability + low footprint due to static config. Here's 1 option :- - use Textual Configuration. It can be found under C:\ti\bin\utilities\tconf\tconf.exe Assuming you have a module ABC with SEMaphores and MBX's u might have :- /* * ======== abc.tci ======== * * Defines the portable configuration for my module named 'abc' */ /* create ABC_mySem semaphore object */ sem = SEM.create( "ABC_mySem" ); sem.comment = "semaphore object exported from module ABC"; sem.count = 0; // initialize the semaphore count /* create ABC_myMbx mailbox object */ mbx = MBX.create( "ABC_myMbx" ); mbx.comment = "mailbox object exported from module ABC"; mbx.length = 5; /* max. 5 messages */ mbx.messageSize = 3 * APPWORDSIZE; /* three words in structure */ then an application could use this portable, non-ISA-specific script, as follows :- /* * ======== appcfg.tcf ======== * * TCF file from which app.cdb configuration database is generated. * It includes individual (TCI) modules in charge of different * sections of the configuration, then generates the CDB file. */ //utils.importFile( "appBoard.tci" ); APPWORDSIZE = 4; /* word size in 8-bit bytes (octets) */ utils.loadPlatform("Dsk6211"); utils.getProgObjs(prog); utils.importFile( "abc.tci" ); /* * With all the DSP/BIOS objects created and defined, we can now * generate the CDB file -- if there have been no errors -- and that * completes the configuration script. */ if (config.hasReportedError == false) { prog.gen(); } else { throw new Error( "Error in config script -- database not generated." ); } To run this do :- [mydir] C:\ti\bin\utilities\tconf\tconf appcfg.tcf This will populate the .cdb file. > For semaphores, It seems to work by using the following > code in the .c file : > > #include <sem.h> > SEM_OBJECT(SEM_TEST, 0); > > -> I can use the semaphore with for example SEM_post(&SEM_TEST); > Instead of using SEM_OBJECT best is to use either :- (i) config tool (and by defintion tconf as above if u wish) - declare ABC_mySem in config - in code do, #include <sem.h> extern far SEM_Obj ABC_mySem; use it as normally...config has already done the sem initialiation for u (ii) declare a SEM obj statically #include <sem.h> SEM_Obj ABC_mySem; SEM_new (&ABC_mySem); // initialize ABC_mySem semaphore object SEM_new is in the API ref manual whilst SEM_OBJECT is 'semi-internal' hence SEM_new is a better bet. > I didn't find such a trick for mailboxes. Is this possible ? > > If not, I'll be forced to use the configuration tool. Then, > how is it possible to use a symbolic value for the mailbox's > size and message size ? > > For example, I have a lib_process.h file containing the message > structure PROCESS_MSG for my mailbox. > Can I use sizeof(PROCESS_MSG) in the configuration tool ? > I suppose that it is not possible, since lib_process.h > is not included in the generated files. Good question. You cant use sizeof(PROCESS_MSG) in config but 1 fallback is you could at least check the sizes at runtime via e.g. :- CtrlMsg txMsg; myAssertFxn( sizeof(CtrlMsg) == mbxProcess.size) ); // ensure our msg size matches MBX config sz Again though, we're using internal fields of MBX structure here so thats not 100% perfect. An enhancement request was filed for an MBX_getSize() macro. > > Jean-Francois cheers, Al --------------------------------- |
Re : Static SEM & MBX declarations without DSP/BIOS config file...
Started by ●March 15, 2003