This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Entry point


On 2007-04-25, LONY David <david.lony@pragmadev.com> wrote:

> I'm new to eCos and I wanted to know if it possible to define an entry 
> point when eCos start?

eCos will call cyg_user_start() (if it exists in your program)
_before_ the scheduler is started.  The scheduler will start
after cyg_user_start() returns.   If there is no
cyg_user_start() in your program, the default one will create a
thread and call main() from within that thread.

> For instance, I have this kind of code :
>
> #include <stdio.h>
>
> main()
> {
>
>     printf("Hello\n");
>     return;
> }
>
> In Linux Synthetic Target template it would work great... but if I 
> change my code to this :
>
> #include <stdio.h>
>
> void test()
> {
>     printf("Hello\n");
>     return;
> }
>
> How I can specified to eCos kernel to execute this function?

Call it "main" instead of test.

> I see in gdb (when I debug eCos) that the function
> cyg_user_start is called so I change my code to this:
>
> #include <stdio.h>
>
> void cyg_user_start(void)
> {
>     printf("Hello\n");
> }
>
> And It work too...

It works differently, though.  The scheduler isn't running yet.


> But I don't know if it's the good method to do this...

That depends on what you want to do.  If you need to do
initialization before the scheduler starts, do it in
cyg_user_start().   If you just want to start running your code
code in a thread (after the scheduler is started), then provide
a main() instead of a cyg_user_start().

> Could someone help me please? PS : I'm using the uitron
> profile... (sorry for my english, I'm French and I know that
> my english it's bad...)

Why don't you want to call your entry-point function "main"?

-- 
Grant Edwards                   grante             Yow! I represent a
                                  at               sardine!!
                               visi.com            


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]