[ECOS] ecos context switch & stack usage question for Sparc platform

Ottawa Guy ottawaguy81@yahoo.com
Tue Apr 27 21:01:00 GMT 2004

Hello all,
I have two question regarding sparc ECOS porting. 

Question 1
In ECOS I see the stack size grows from low memAddress
to high memAddress. However in sparc platform the
stack grows from high memAddress to lowMem address. I
looked at the BSP code, I was bit confused how it is
handled. In ECOS twothread.c example

 char stack[6000];
 cyg_thread threadInfo;
 cyg_thread_create(4, simple_program, (cyg_addrword_t)
0,"Thread A", (void *) stack, 4096,0, threadInfo);

Since Sparc stack grows from high to low, should it be

cyg_thread_create(4, simple_program, (cyg_addrword_t)
0,"Thread A", (void *) ((unsigned int)stack+6000),
4096,0, threadInfo);

In our application we have been using the first method
without any problem. However I want to confirm this. 

Question 2
I am trying to implement something that would give the
PC of every task running in the system.
I can walk through the list of all task then print
information about the task. I print the stack_ptr by
calling get_saved_context(). I assumed the all
registers are saved into stack during the context
switch, so  %l1,%l2 would give me the PC and nPc.
However I didnt see that happening. Can you suggest me
something. I went through  hal_thread_switch_context()
code, which confirms that, however the stack_ptr value
didnt provide me PC and nPc. Following is the example

        Cyg_Thread *t = Cyg_Thread::get_list_head();

        while( NULL != t )

		printf( "%20s stack base = %08x ptr = %08x size =

 		t = t->get_list_next();

The memory content at (t->get_saved_context()+4)
should content the PC for that task. Right ?? 



Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  

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

More information about the Ecos-discuss mailing list