avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [avr-libc-dev] Re: snprintf bug ?


From: Darcy Watkins
Subject: RE: [avr-libc-dev] Re: snprintf bug ?
Date: Fri, 14 Oct 2005 14:46:09 -0700

Hi,

I use a naked main function in a system because I have to use .init...
sections to set up an external SRAM interface and locate the stack somewhere
else than at the top of internal SRAM.

In the one system, the naked main just calls another function that never
returns.  The stack initialized in .init2 is used until a kernel takes over
and creates stacks for the threads.

void initialize_external_sram (void) __attribute__ ((naked)) \
    __attribute__ ((section (".init1")));

void initialize_external_sram (void)
{
...
}

char __stack_space[64] __attribute__ ((section (".noinit")));

void initialize_startup_stack (void) __attribute__ ((naked)) \
    __attribute__ ((section (".init2")));

void initialize_startup_stack(void)
{
        SP = (uint16_t) (__stack_space + sizeof(__stack_space) - 1);
}

void initialize_and_launch_os(void);

int main(void) __attribute__ ((naked));

int main(void)
{
        // Initialize and launch OS as set up in ossetup.c
        initialize_and_launch_os();  // never returns

        return 0; // needed to avoid compiler warning
}


So my question is... is the call from main to initialize_and_launch_os()
sufficent to ensure that I have a frame pointer for the local variables
within initialize_and_launch_os() or do I have a problem lurking in the dark
waiting to "get" me?

Note: initialize_and_launch_os() is NOT a naked function, but has local
automatic variables.

Another question...

int main(void) __attribute__ ((noreturn));

int main(void)
{
        // Initialize and launch OS as set up in ossetup.c
        initialize_and_launch_os();  // never returns

        return 0; // needed to avoid compiler warning
}

... will declaring main as "noreturn" suppress the automatic stack
initialization at the top of internal SRAM?   ... or will I get stung there?
(Currently, not having my main naked results in my stack initialization in
.init1 being overridden by automatic generated code at the beginning of
main).



Regards,

Darcy

--------------------------------------------------------------
Darcy L. Watkins             email: address@hidden
Senior Software Developer++  phone: (604) 455-2000
TASC Systems, Inc.           fax:   (604) 888-2712
9415 - 202 Street,           web:   http://www.tascsystems.com
Langley B.C. Canada V1M 4B5
--------------------------------------------------------------





reply via email to

[Prev in Thread] Current Thread [Next in Thread]