* [ECOS] Cortex M3 idle sleep
@ 2009-02-13 15:54 Simon Kallweit
2009-02-13 16:08 ` Nick Garnett
0 siblings, 1 reply; 6+ messages in thread
From: Simon Kallweit @ 2009-02-13 15:54 UTC (permalink / raw)
To: eCos Disuss
Hello
Would it make sense to include support for sleeping ("wfi" instruction)
in idle thread for the cortex m3 architecture? The current code in
hal_arch.h looks like:
#if 0 //ndef HAL_IDLE_THREAD_ACTION
#define HAL_IDLE_THREAD_ACTION(__count) __asm__ volatile ( "wfi\n" )
#else
#define HAL_IDLE_THREAD_ACTION(__count) CYG_EMPTY_STATEMENT
#endif
I guess this is not what it was meant to be. I would propose to add an option like CYGHWR_HAL_CORTEXM_IDLE_SLEEP to enable the wfi instruction:
#ifndef HAL_IDLE_THREAD_ACTION
# ifdef CYGHWR_HAL_CORTEXM_IDLE_SLEEP
# define HAL_IDLE_THREAD_ACTION(__count) __asm__ volatile ( "wfi\n" )
# else
# define HAL_IDLE_THREAD_ACTION(__count) CYG_EMPTY_STATEMENT
# endif
#endif
Also, currently var_arch.h gets not included in the hal_arch.h header, so it's impossible to override for example the HAL_IDLE_THREAD_ACTION macro. I guess this was just overlooked, or is it intentional?
I can provide a patch if there are no objections.
Best regards
Simon
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [ECOS] Cortex M3 idle sleep
2009-02-13 15:54 [ECOS] Cortex M3 idle sleep Simon Kallweit
@ 2009-02-13 16:08 ` Nick Garnett
2009-02-13 16:21 ` Simon Kallweit
0 siblings, 1 reply; 6+ messages in thread
From: Nick Garnett @ 2009-02-13 16:08 UTC (permalink / raw)
To: Simon Kallweit; +Cc: eCos Disuss
Simon Kallweit <simon.kallweit@intefo.ch> writes:
> Hello
>
> Would it make sense to include support for sleeping ("wfi"
> instruction) in idle thread for the cortex m3 architecture? The
> current code in hal_arch.h looks like:
>
> #if 0 //ndef HAL_IDLE_THREAD_ACTION
> #define HAL_IDLE_THREAD_ACTION(__count) __asm__ volatile ( "wfi\n" )
> #else
> #define HAL_IDLE_THREAD_ACTION(__count) CYG_EMPTY_STATEMENT
> #endif
>
> I guess this is not what it was meant to be. I would propose to add an option like CYGHWR_HAL_CORTEXM_IDLE_SLEEP to enable the wfi instruction:
>
> #ifndef HAL_IDLE_THREAD_ACTION
> # ifdef CYGHWR_HAL_CORTEXM_IDLE_SLEEP
> # define HAL_IDLE_THREAD_ACTION(__count) __asm__ volatile ( "wfi\n" )
> # else
> # define HAL_IDLE_THREAD_ACTION(__count) CYG_EMPTY_STATEMENT
> # endif
> #endif
>
> Also, currently var_arch.h gets not included in the hal_arch.h header, so it's impossible to override for example the HAL_IDLE_THREAD_ACTION macro. I guess this was just overlooked, or is it intentional?
>
> I can provide a patch if there are no objections.
The "#if 0" is an oversight on my part. When debugging via JTAG I was
having difficulties breaking in to an idle system. Stopping it using
WFI solved this. The #else part is also a consequence of this, so that
code should really be:
#ifndef HAL_IDLE_THREAD_ACTION
#define HAL_IDLE_THREAD_ACTION(__count) __asm__ volatile ( "wfi\n" )
#endif
Given this I don't really see any need for the
CYGHWR_HAL_CORTEXM_IDLE_SLEEP option. If a variant or platform HAL
needs to override this it can very easily by redefining
HAL_IDLE_THREAD_ACTION().
var_arch.h should certainly be included in hal_arch.h. It is only
because the STM32 has an empty var_arch.h that we haven't noticed this
before.
--
Nick Garnett eCos Kernel Architect
eCosCentric Limited http://www.eCosCentric.com The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK. Tel: +44 1223 245571
Registered in England and Wales: Reg No: 4422071
Besuchen Sie uns vom 3.-5.03.09 auf der Embedded World 2009, Stand 11-300
Visit us at Embedded World 2009, Nürnberg, Germany, 3-5 Mar, Stand 11-300
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [ECOS] Cortex M3 idle sleep
2009-02-13 16:08 ` Nick Garnett
@ 2009-02-13 16:21 ` Simon Kallweit
2009-02-13 16:46 ` Nick Garnett
0 siblings, 1 reply; 6+ messages in thread
From: Simon Kallweit @ 2009-02-13 16:21 UTC (permalink / raw)
To: Nick Garnett; +Cc: eCos Disuss
Nick Garnett wrote:
> Simon Kallweit <simon.kallweit@intefo.ch> writes:
>
>
>> Hello
>>
>> Would it make sense to include support for sleeping ("wfi"
>> instruction) in idle thread for the cortex m3 architecture? The
>> current code in hal_arch.h looks like:
>>
>> #if 0 //ndef HAL_IDLE_THREAD_ACTION
>> #define HAL_IDLE_THREAD_ACTION(__count) __asm__ volatile ( "wfi\n" )
>> #else
>> #define HAL_IDLE_THREAD_ACTION(__count) CYG_EMPTY_STATEMENT
>> #endif
>>
>> I guess this is not what it was meant to be. I would propose to add an option like CYGHWR_HAL_CORTEXM_IDLE_SLEEP to enable the wfi instruction:
>>
>> #ifndef HAL_IDLE_THREAD_ACTION
>> # ifdef CYGHWR_HAL_CORTEXM_IDLE_SLEEP
>> # define HAL_IDLE_THREAD_ACTION(__count) __asm__ volatile ( "wfi\n" )
>> # else
>> # define HAL_IDLE_THREAD_ACTION(__count) CYG_EMPTY_STATEMENT
>> # endif
>> #endif
>>
>> Also, currently var_arch.h gets not included in the hal_arch.h header, so it's impossible to override for example the HAL_IDLE_THREAD_ACTION macro. I guess this was just overlooked, or is it intentional?
>>
>> I can provide a patch if there are no objections.
>>
>
>
> The "#if 0" is an oversight on my part. When debugging via JTAG I was
> having difficulties breaking in to an idle system. Stopping it using
> WFI solved this. The #else part is also a consequence of this, so that
> code should really be:
>
Well that's actually the reason for me to propose a
CYGHWR_HAL_CORTEXM_IDLE_SLEEP configuration option. During debugging,
wfi is rather troublesome, so I thought it might be a good idea to make
it configurable. Or is this too much cruft?
Simon
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [ECOS] Cortex M3 idle sleep
2009-02-13 16:21 ` Simon Kallweit
@ 2009-02-13 16:46 ` Nick Garnett
2009-02-13 16:52 ` Simon Kallweit
0 siblings, 1 reply; 6+ messages in thread
From: Nick Garnett @ 2009-02-13 16:46 UTC (permalink / raw)
To: Simon Kallweit; +Cc: eCos Disuss
Simon Kallweit <simon.kallweit@intefo.ch> writes:
> Nick Garnett wrote:
> > The "#if 0" is an oversight on my part. When debugging via JTAG I was
> > having difficulties breaking in to an idle system. Stopping it using
> > WFI solved this. The #else part is also a consequence of this, so that
> > code should really be:
> >
>
> Well that's actually the reason for me to propose a
> CYGHWR_HAL_CORTEXM_IDLE_SLEEP configuration option. During debugging,
> wfi is rather troublesome, so I thought it might be a good idea to
> make it configurable. Or is this too much cruft?
I think it might be too much cruft.
I don't know how other people work but I tend to like
enabling/disabling debug stuff by editing the source rather than
messing with the configuration. The latter is often more complicated
and it takes a lot longer to recompile everything. CVS usually reminds
me to undo the change before checking in -- except in this case where
there was no original to diff against, and I forgot about this edit.
So I would actually prefer something more like this:
#if 1
# ifndef HAL_IDLE_THREAD_ACTION
# define HAL_IDLE_THREAD_ACTION(__count) __asm__ volatile ( "wfi\n" )
# endif
#else
# define HAL_IDLE_THREAD_ACTION(__count) CYG_EMPTY_STATEMENT
#endif
So that I can easily override any idle thread action when I need
to. However I appreciate that this is not necessarily to everyone's
taste, and would usually make sure any such construct never escaped my
own source tree.
--
Nick Garnett eCos Kernel Architect
eCosCentric Limited http://www.eCosCentric.com The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK. Tel: +44 1223 245571
Registered in England and Wales: Reg No: 4422071
Besuchen Sie uns vom 3.-5.03.09 auf der Embedded World 2009, Stand 11-300
Visit us at Embedded World 2009, Nürnberg, Germany, 3-5 Mar, Stand 11-300
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [ECOS] Cortex M3 idle sleep
2009-02-13 16:46 ` Nick Garnett
@ 2009-02-13 16:52 ` Simon Kallweit
2009-02-13 17:00 ` Nick Garnett
0 siblings, 1 reply; 6+ messages in thread
From: Simon Kallweit @ 2009-02-13 16:52 UTC (permalink / raw)
To: Nick Garnett; +Cc: eCos Disuss
Nick Garnett wrote:
> Simon Kallweit <simon.kallweit@intefo.ch> writes:
>
>
>> Nick Garnett wrote:
>>
>>> The "#if 0" is an oversight on my part. When debugging via JTAG I was
>>> having difficulties breaking in to an idle system. Stopping it using
>>> WFI solved this. The #else part is also a consequence of this, so that
>>> code should really be:
>>>
>>>
>> Well that's actually the reason for me to propose a
>> CYGHWR_HAL_CORTEXM_IDLE_SLEEP configuration option. During debugging,
>> wfi is rather troublesome, so I thought it might be a good idea to
>> make it configurable. Or is this too much cruft?
>>
>
> I think it might be too much cruft.
>
> I don't know how other people work but I tend to like
> enabling/disabling debug stuff by editing the source rather than
> messing with the configuration. The latter is often more complicated
> and it takes a lot longer to recompile everything. CVS usually reminds
> me to undo the change before checking in -- except in this case where
> there was no original to diff against, and I forgot about this edit.
>
Well you're probably right. So let's just clean things up then :)
Simon
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [ECOS] Cortex M3 idle sleep
2009-02-13 16:52 ` Simon Kallweit
@ 2009-02-13 17:00 ` Nick Garnett
0 siblings, 0 replies; 6+ messages in thread
From: Nick Garnett @ 2009-02-13 17:00 UTC (permalink / raw)
To: Simon Kallweit; +Cc: eCos Disuss
Simon Kallweit <simon.kallweit@intefo.ch> writes:
> Nick Garnett wrote:
> > Simon Kallweit <simon.kallweit@intefo.ch> writes:
> >
> >
> >> Nick Garnett wrote:
> >>
> >>> The "#if 0" is an oversight on my part. When debugging via JTAG I was
> >>> having difficulties breaking in to an idle system. Stopping it using
> >>> WFI solved this. The #else part is also a consequence of this, so that
> >>> code should really be:
> >>>
> >>>
> >> Well that's actually the reason for me to propose a
> >> CYGHWR_HAL_CORTEXM_IDLE_SLEEP configuration option. During debugging,
> >> wfi is rather troublesome, so I thought it might be a good idea to
> >> make it configurable. Or is this too much cruft?
> >>
> >
> > I think it might be too much cruft.
> >
> > I don't know how other people work but I tend to like
> > enabling/disabling debug stuff by editing the source rather than
> > messing with the configuration. The latter is often more complicated
> > and it takes a lot longer to recompile everything. CVS usually reminds
> > me to undo the change before checking in -- except in this case where
> > there was no original to diff against, and I forgot about this edit.
> >
>
> Well you're probably right. So let's just clean things up then :)
Yep. I'll do this right now.
--
Nick Garnett eCos Kernel Architect
eCosCentric Limited http://www.eCosCentric.com The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK. Tel: +44 1223 245571
Registered in England and Wales: Reg No: 4422071
Besuchen Sie uns vom 3.-5.03.09 auf der Embedded World 2009, Stand 11-300
Visit us at Embedded World 2009, Nürnberg, Germany, 3-5 Mar, Stand 11-300
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-02-13 17:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-13 15:54 [ECOS] Cortex M3 idle sleep Simon Kallweit
2009-02-13 16:08 ` Nick Garnett
2009-02-13 16:21 ` Simon Kallweit
2009-02-13 16:46 ` Nick Garnett
2009-02-13 16:52 ` Simon Kallweit
2009-02-13 17:00 ` Nick Garnett
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).