This is the mail archive of the ecos-discuss@sources.redhat.com 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]

ecos context switch & stack usage question for Sparc platform


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();

        printf("\nThreads:\n\n");
    
        while( NULL != t )
        {

		printf( "%20s stack base = %08x ptr = %08x size =
%08x\n",
                         "",
                         t->get_stack_base(),
                         t->get_saved_context(),
                         t->get_stack_size()
                );

 		t = t->get_list_next();
	}




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

               Thanks
                    Ottawa


 



	
		
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 

-- 
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]