On Wed, Jul 11, 2012 at 3:38 AM, Георгий Охохонин <oxoxo...@gmail.com> wrote:
> 2012/7/11 Peter Bigot <big...@acm.org>
>
>> On Tue, Jul 10, 2012 at 10:47 PM, Георгий Охохонин <oxoxo...@gmail.com>
>> wrote:
>> > Hello dear mspgcc users!
>> >
>> > Can somebody tell me, what does the attribute 'task' mean?
>>
>> The best description of task right now outside the source is probably
>>
>> http://www.mail-archive.com/mspgcc-users@lists.sourceforge.net/msg03043.html
>>
>> Apparently "task" was added after the manual was written and the
>> manual wasn't updated.  Other function attributes are documented at
>> http://mspgcc.sourceforge.net/manual/x877.html which is mostly right.
>>
>> See
>> http://mspgcc.git.sourceforge.net/git/gitweb.cgi?p=mspgcc/gcc;a=blob;f=gcc/config/msp430/msp430-function.c;h=52ab756894062b3db73e95911849a889070a358a;hb=HEAD#l418
>> for the corresponding source code.
>>
>> > And what could mean this warning: frame allocation destroys caller
>> register
>> > due to 'task' [-Wattributes]?
>>
>> What "naked" does is skip the function prolog (save caller registers,
>> allocate a stack frame for local variables) and epilog (pop the local
>> stack frame, restore registers, return to caller).
>>
>> "task" differs from "naked" in that it will allocate space on the
>> stack for any local variables.  It still won't save caller registers,
>> and doesn't execute a return instruction.
>>
>> A frame pointer is needed when there are places within the function
>> where gcc needs to know the value of the stack pointer on entry (for
>> example, to access parameters passed on the stack), but for whatever
>> reason can't figure it out by subtracting a constant value from the
>> current stack pointer.  gcc stores this frame pointer in register r4
>> on entry to the stack.  Normally, the caller's value for r4 would have
>> been saved in the function prolog, and restored in the epilog.  For
>> "naked" and "task" functions, this isn't done, so what gcc's telling
>> you is that it's generated code that will destroy the caller's frame
>> pointer.
>>
>> This is probably a serious problem, and you will have to look at the
>> source code and assembly code generated for the task function to
>> determine what might be causing the need for a frame pointer, and try
>> to eliminate it.  Generally, a "task" function should do nothing but
>> save registers and switch context to a different thread.  If the cause
>> is
>> https://sourceforge.net/tracker/?func=detail&aid=3458330&group_id=42303&atid=432701
>> ,
>> you'll have to use another solution to changing the stack pointer,
>> because as I think about it that's probably not a bug.
>>
>> An example of doing RTOS task switching using current mspgcc is in the
>> FreeRTOS-mspgcc repository at
>>
>> https://github.com/pabigot/freertos-mspgcc/blob/master/Source/portable/GCC/MSP430/port.c
>> .
>>
>> Peter
>>
>> >
>> > Thank you.
>> >
>> > --
>> > George.
>> >
>> >
>> ------------------------------------------------------------------------------
>> > Live Security Virtual Conference
>> > Exclusive live event will cover all the ways today's security and
>> > threat landscape has changed and how IT managers can respond. Discussions
>> > will include endpoint security, mobile security and the latest in malware
>> > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> > _______________________________________________
>> > Mspgcc-users mailing list
>> > Mspgcc-users@lists.sourceforge.net
>> > https://lists.sourceforge.net/lists/listinfo/mspgcc-users
>> >
>>
>
>
> Peter, thank you for prompt reply!
>
>
> Program I am working on now was made with mspgcc 3.2.3. And there were not
> such warnings.
> They have appeared with current mspgcc version (20120406). May be you have
> any idea why is it so?

Either 3.2.3 did not allocate a frame pointer for your code, or the
compiler didn't notice when the problem had occurred and it had no
effect on your code.

> And one more question, I need to use my own start up code. What function I
> should use: NAKED(_reset_vector__) _RESET() or there is something else? As
> I have understood from the manual
> http://mspgcc.sourceforge.net/manual/x1185.html they are similar to each
> other.
> But when analysing .map files I have found that NAKED(_reset_vector__) does
> not redefining standart startup procedure, while _RESET() does.

Replacing startup code is an advanced technique, and what you need to
do has changed a lot from the manual.  I recommend avoiding all those
NAKED and RESET macros in favor of the underlying attributes.

You will need to be familiar with these two files:
http://mspgcc.git.sourceforge.net/git/gitweb.cgi?p=mspgcc/gcc;a=blob;f=gcc/config/msp430/crt0.S;h=112ef093fa2d6b73e48ad664f56a25b5e28d0846;hb=refs/heads/gcc-4_6/gcc-4.6.3
http://mspgcc.git.sourceforge.net/git/gitweb.cgi?p=mspgcc/binutils;a=blob;f=ld/scripttempl/elf32msp430.sc;h=e27e53641c6288033c34a4fcc143734b3213b6a6;hb=HEAD

See also 
http://www.mail-archive.com/mspgcc-users@lists.sourceforge.net/msg11000.html

Once you understand what those are doing, consider whether you can
reach your goal by adding your own startup code within one of the
unused init sections rather than replacing what mspgcc does.  E.g.:

void __attribute__((__section__(".init5"),__naked__))
cache_boot_wdtctl ()
{
  wdtctl_on_boot = WDTCTL;
}

Peter

>
> ---
> Thank you.
> George.
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Mspgcc-users mailing list
> Mspgcc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
>

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to