projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Refactor all module. Clean up. Fix comments. Some patch to work with preemtive kernel...
[bertos.git]
/
bertos
/
emul
/
timer_posix.c
diff --git
a/bertos/emul/timer_posix.c
b/bertos/emul/timer_posix.c
index 6b42458e1e06f17f040ddbf9c86c15af417c87cf..70990a21afd551fb828c436a85381a4d6b0cc425 100644
(file)
--- a/
bertos/emul/timer_posix.c
+++ b/
bertos/emul/timer_posix.c
@@
-26,22
+26,23
@@
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*
- * Copyright 2005,2008 Develer S.r.l. (http://www.develer.com/)
- *
+ * Copyright 2005, 2008 Develer S.r.l. (http://www.develer.com/)
* -->
*
* -->
*
- * \
version $Id$
+ * \
brief Low-level timer module for Qt emulator (implementation).
*
*
+ * \version $Id$
* \author Bernie Innocenti <bernie@codewiz.org>
* \author Bernie Innocenti <bernie@codewiz.org>
- *
- * \brief Low-level timer module for Qt emulator (implementation).
*/
*/
-#include <cfg/compiler.h> // hptime.t
+
//
#include <cfg/compiler.h> // hptime.t
#include <os/hptime.h>
#include <os/hptime.h>
+#include <kern/irq.h> // irq_register()
+#if !CONFIG_KERN_IRQ
#include <signal.h> // sigaction()
#include <signal.h> // sigaction()
-#include <sys/time.h> // setitimer()
#include <string.h> // memset()
#include <string.h> // memset()
+#endif
+#include <sys/time.h> // setitimer()
// Forward declaration for the user interrupt server routine.
// Forward declaration for the user interrupt server routine.
@@
-50,18
+51,22
@@
void timer_isr(int);
/// HW dependent timer initialization.
static void timer_hw_init(void)
{
/// HW dependent timer initialization.
static void timer_hw_init(void)
{
- struct sigaction sa;
- memset(&sa, 0, sizeof(sa));
+ #if CONFIG_KERN_IRQ
+ irq_register(SIGALRM, (void (*)(void))timer_isr);
+ #else // ! CONFIG_KERN_IRQ
+ struct sigaction sa;
+ memset(&sa, 0, sizeof(sa));
- // Setup interrupt callback
- sa.sa_handler = timer_isr;
- sigemptyset(&sa.sa_mask);
- sigaddset(&sa.sa_mask, SIGALRM);
- sa.sa_flags = SA_RESTART;
- sigaction(SIGALRM, &sa, NULL);
+ // Setup interrupt callback
+ sa.sa_handler = timer_isr;
+ sigemptyset(&sa.sa_mask);
+ sigaddset(&sa.sa_mask, SIGALRM);
+ sa.sa_flags = SA_RESTART;
+ sigaction(SIGALRM, &sa, NULL);
+ #endif // CONFIG_KERN_IRQ
// Setup POSIX realtime timer to interrupt every 1/TIMER_TICKS_PER_SEC.
// Setup POSIX realtime timer to interrupt every 1/TIMER_TICKS_PER_SEC.
- static struct itimerval itv =
+ static
const
struct itimerval itv =
{
{ 0, 1000000 / TIMER_TICKS_PER_SEC }, /* it_interval */
{ 0, 1000000 / TIMER_TICKS_PER_SEC } /* it_value */
{
{ 0, 1000000 / TIMER_TICKS_PER_SEC }, /* it_interval */
{ 0, 1000000 / TIMER_TICKS_PER_SEC } /* it_value */
@@
-69,7
+74,20
@@
static void timer_hw_init(void)
setitimer(ITIMER_REAL, &itv, NULL);
}
setitimer(ITIMER_REAL, &itv, NULL);
}
+static void timer_hw_cleanup(void)
+{
+ static const struct itimerval itv =
+ {
+ { 0, 0 }, /* it_interval */
+ { 0, 0 } /* it_value */
+ };
+ setitimer(ITIMER_REAL, &itv, NULL);
+ signal(SIGALRM, SIG_DFL);
+}
+
INLINE hptime_t timer_hw_hpread(void)
{
return hptime_get();
}
INLINE hptime_t timer_hw_hpread(void)
{
return hptime_get();
}
+
+#define timer_hw_triggered() (true)