summaryrefslogtreecommitdiff
path: root/nuttx/sched
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx/sched')
-rw-r--r--nuttx/sched/Makefile9
-rw-r--r--nuttx/sched/get_errorptr.c83
-rw-r--r--nuttx/sched/irq_attach.c2
-rw-r--r--nuttx/sched/mq_close.c8
-rw-r--r--nuttx/sched/mq_msgfree.c2
-rw-r--r--nuttx/sched/mq_notify.c12
-rw-r--r--nuttx/sched/mq_open.c5
-rw-r--r--nuttx/sched/mq_receive.c14
-rw-r--r--nuttx/sched/mq_send.c28
-rw-r--r--nuttx/sched/mq_unlink.c6
-rw-r--r--nuttx/sched/os_start.c2
-rw-r--r--nuttx/sched/pthread_condtimedwait.c14
-rw-r--r--nuttx/sched/pthread_create.c8
-rw-r--r--nuttx/sched/pthread_getspecific.c6
-rw-r--r--nuttx/sched/pthread_keycreate.c6
-rw-r--r--nuttx/sched/pthread_keydelete.c3
-rw-r--r--nuttx/sched/pthread_setspecific.c8
-rw-r--r--nuttx/sched/sched_free.c2
-rw-r--r--nuttx/sched/sched_setparam.c12
-rw-r--r--nuttx/sched/sched_setscheduler.c2
-rw-r--r--nuttx/sched/sem_open.c5
-rw-r--r--nuttx/sched/sem_post.c6
-rw-r--r--nuttx/sched/sem_trywait.c6
-rw-r--r--nuttx/sched/sem_wait.c6
-rw-r--r--nuttx/sched/sem_waitirq.c2
-rw-r--r--nuttx/sched/sig_allocatependingsigaction.c4
-rw-r--r--nuttx/sched/sig_deliver.c12
-rw-r--r--nuttx/sched/sig_mqnotempty.c22
-rw-r--r--nuttx/sched/sig_pending.c2
-rw-r--r--nuttx/sched/sig_procmask.c8
-rw-r--r--nuttx/sched/sig_received.c23
-rw-r--r--nuttx/sched/sig_releasependingsigaction.c2
-rw-r--r--nuttx/sched/sig_releasependingsignal.c2
-rw-r--r--nuttx/sched/sig_removependingsignal.c5
-rw-r--r--nuttx/sched/sig_suspend.c2
-rw-r--r--nuttx/sched/sig_timedwait.c49
-rw-r--r--nuttx/sched/task_create.c6
-rw-r--r--nuttx/sched/task_delete.c8
-rw-r--r--nuttx/sched/task_restart.c8
-rw-r--r--nuttx/sched/wd_cancel.c8
-rw-r--r--nuttx/sched/wd_create.c4
-rw-r--r--nuttx/sched/wd_delete.c2
-rw-r--r--nuttx/sched/wd_internal.h7
-rw-r--r--nuttx/sched/wd_start.c126
44 files changed, 395 insertions, 162 deletions
diff --git a/nuttx/sched/Makefile b/nuttx/sched/Makefile
index bc144b797..5efa4a6f0 100644
--- a/nuttx/sched/Makefile
+++ b/nuttx/sched/Makefile
@@ -40,7 +40,7 @@ MKDEP = $(TOPDIR)/tools/mkdeps.sh
ASRCS =
AOBJS = $(ASRCS:.S=.o)
-MISC_SRCS = os_start.c get_errno_ptr.c \
+MISC_SRCS = os_start.c get_errno_ptr.c get_errorptr.c \
sched_setupstreams.c sched_getfiles.c sched_getstreams.c \
sched_setupidlefiles.c sched_setuptaskfiles.c sched_setuppthreadfiles.c \
sched_releasefiles.c
@@ -101,7 +101,7 @@ COBJS = $(CSRCS:.c=.o)
SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS)
-BIN = libsched.a
+BIN = libsched$(LIBEXT)
all: $(BIN)
@@ -112,7 +112,10 @@ $(COBJS): %.o: %.c
$(CC) -c $(CFLAGS) $< -o $@
$(BIN): $(OBJS)
- $(AR) rcs $@ $(OBJS)
+ ( for obj in $(OBJS) ; do \
+ $(AR) $@ $${obj} || \
+ { echo "$(AR) $@ $obj FAILED!" ; exit 1 ; } ; \
+ done ; )
.depend: Makefile $(SRCS)
$(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
diff --git a/nuttx/sched/get_errorptr.c b/nuttx/sched/get_errorptr.c
new file mode 100644
index 000000000..7cfad6cb1
--- /dev/null
+++ b/nuttx/sched/get_errorptr.c
@@ -0,0 +1,83 @@
+/************************************************************
+ * get_errorptr.c
+ *
+ * Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name Gregory Nutt nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ************************************************************/
+
+/************************************************************
+ * Included Files
+ ************************************************************/
+
+#include <sys/types.h>
+#include <errno.h>
+
+/************************************************************
+ * Global Functions
+ ************************************************************/
+
+/************************************************************
+ * Function: get_errorptr
+ *
+ * Description:
+ * Return a pointer that is just ERROR cast to void *.
+ * most fully performing processors don't need anything
+ * like this. Hoever, this little of nonsense is necessary
+ * for some processors where sizeof(pointer) < sizeof(uint32)
+ * and which do not support casts of integers to pointers.
+ *
+ * Parameters:
+ * None
+ *
+ * Return Value:
+ * ERROR cast as a pointer value
+ *
+ * Assumptions:
+ *
+ ************************************************************/
+
+void *get_errnorptr(void)
+{
+#ifdef CONFIG_CAN_CAST_POINTERS
+ return (void*)ERROR;
+#else
+ union
+ {
+ void *verror;
+ sint32 ierror;
+ } u;
+
+ u.ierror = ERROR;
+ return u.verror;
+#endif
+}
+
+
diff --git a/nuttx/sched/irq_attach.c b/nuttx/sched/irq_attach.c
index 2c669071d..d67a04a49 100644
--- a/nuttx/sched/irq_attach.c
+++ b/nuttx/sched/irq_attach.c
@@ -80,7 +80,7 @@ int irq_attach(int irq, xcpt_t isr)
if ((unsigned)irq < NR_IRQS)
{
- int state;
+ irqstate_t state;
/* If the new ISR is NULL, then the ISR is being detached.
* In this case, disable the ISR and direct any interrupts
diff --git a/nuttx/sched/mq_close.c b/nuttx/sched/mq_close.c
index c9817f994..88fe0e043 100644
--- a/nuttx/sched/mq_close.c
+++ b/nuttx/sched/mq_close.c
@@ -113,10 +113,10 @@
int mq_close(mqd_t mqdes)
{
- _TCB *rtcb = (_TCB*)g_readytorun.head;
- msgq_t *msgq;
- uint32 saved_state;
- int ret = ERROR;
+ _TCB *rtcb = (_TCB*)g_readytorun.head;
+ msgq_t *msgq;
+ irqstate_t saved_state;
+ int ret = ERROR;
/* Verify the inputs */
diff --git a/nuttx/sched/mq_msgfree.c b/nuttx/sched/mq_msgfree.c
index 9c5f12af5..f9246d8fc 100644
--- a/nuttx/sched/mq_msgfree.c
+++ b/nuttx/sched/mq_msgfree.c
@@ -86,7 +86,7 @@
void mq_msgfree(mqmsg_t * mqmsg)
{
- uint32 saved_state;
+ irqstate_t saved_state;
/* If this is a generally available pre-allocated message,
* then just put it back in the free list.
diff --git a/nuttx/sched/mq_notify.c b/nuttx/sched/mq_notify.c
index aaed2e45b..3632c7636 100644
--- a/nuttx/sched/mq_notify.c
+++ b/nuttx/sched/mq_notify.c
@@ -141,11 +141,11 @@ int mq_notify(mqd_t mqdes, const struct sigevent *notification)
{
/* Yes... Assign it to the current task. */
- msgq->ntvalue = notification->sigev_value;
- msgq->ntsigno = notification->sigev_signo;
- msgq->ntpid = rtcb->pid;
- msgq->ntmqdes = mqdes;
- ret = OK;
+ msgq->ntvalue.sival_ptr = notification->sigev_value.sival_ptr;
+ msgq->ntsigno = notification->sigev_signo;
+ msgq->ntpid = rtcb->pid;
+ msgq->ntmqdes = mqdes;
+ ret = OK;
}
}
@@ -159,7 +159,7 @@ int mq_notify(mqd_t mqdes, const struct sigevent *notification)
msgq->ntpid = INVALID_PROCESS_ID;
msgq->ntsigno = 0;
- msgq->ntvalue.sival_int = 0;
+ msgq->ntvalue.sival_ptr = NULL;
msgq->ntmqdes = NULL;
ret = OK;
}
diff --git a/nuttx/sched/mq_open.c b/nuttx/sched/mq_open.c
index 97b2af121..d4ad2a322 100644
--- a/nuttx/sched/mq_open.c
+++ b/nuttx/sched/mq_open.c
@@ -42,6 +42,7 @@
#include <mqueue.h>
#include <string.h>
#include <sched.h>
+#include <errno.h>
#include <debug.h>
#include <nuttx/kmalloc.h>
#include "os_internal.h"
@@ -217,7 +218,11 @@ mqd_t mq_open(const char *mq_name, int oflags, ...)
if (mqdes == NULL)
{
+#ifdef CONFIG_CAN_CAST_POINTERS
return (mqd_t)ERROR;
+#else
+ return get_errorptr();
+#endif
}
else
{
diff --git a/nuttx/sched/mq_receive.c b/nuttx/sched/mq_receive.c
index 3dbe662c2..4e7555e13 100644
--- a/nuttx/sched/mq_receive.c
+++ b/nuttx/sched/mq_receive.c
@@ -114,13 +114,13 @@
int mq_receive(mqd_t mqdes, void *msg, size_t msglen, int *prio)
{
- _TCB *rtcb;
- _TCB *btcb;
- msgq_t *msgq;
- mqmsg_t *curr;
- uint32 saved_state;
- ubyte rcvmsglen;
- int ret = ERROR;
+ _TCB *rtcb;
+ _TCB *btcb;
+ msgq_t *msgq;
+ mqmsg_t *curr;
+ irqstate_t saved_state;
+ ubyte rcvmsglen;
+ int ret = ERROR;
/* Verify the input parameters */
diff --git a/nuttx/sched/mq_send.c b/nuttx/sched/mq_send.c
index 431d8613c..0a9a12515 100644
--- a/nuttx/sched/mq_send.c
+++ b/nuttx/sched/mq_send.c
@@ -94,8 +94,8 @@
mqmsg_t *mq_msgalloc(void)
{
- mqmsg_t *mqmsg;
- uint32 saved_state;
+ mqmsg_t *mqmsg;
+ irqstate_t saved_state;
/* If we were called from an interrupt handler, then try to
* get the message from generally available list of messages.
@@ -202,14 +202,14 @@ mqmsg_t *mq_msgalloc(void)
int mq_send(mqd_t mqdes, const void *msg, size_t msglen, int prio)
{
- _TCB *rtcb;
- _TCB *btcb;
- msgq_t *msgq;
- mqmsg_t *curr;
- mqmsg_t *next;
- mqmsg_t *prev;
- uint32 saved_state;
- int ret = ERROR;
+ _TCB *rtcb;
+ _TCB *btcb;
+ msgq_t *msgq;
+ mqmsg_t *curr;
+ mqmsg_t *next;
+ mqmsg_t *prev;
+ irqstate_t saved_state;
+ int ret = ERROR;
/* Verify the input parameters */
@@ -343,7 +343,11 @@ int mq_send(mqd_t mqdes, const void *msg, size_t msglen, int prio)
{
/* Remove the message notification data from the message queue. */
+#ifdef CONFIG_CAN_PASS_STRUCTS
union sigval value = msgq->ntvalue;
+#else
+ void *sival_ptr = msgq->ntvalue.sival_ptr;
+#endif
int signo = msgq->ntsigno;
int pid = msgq->ntpid;
@@ -356,7 +360,11 @@ int mq_send(mqd_t mqdes, const void *msg, size_t msglen, int prio)
/* Queue the signal -- What if this returns an error? */
+#ifdef CONFIG_CAN_PASS_STRUCTS
sig_mqnotempty(pid, signo, value);
+#else
+ sig_mqnotempty(pid, signo, sival_ptr);
+#endif
}
/* Check if any tasks are waiting for the MQ not empty event. */
diff --git a/nuttx/sched/mq_unlink.c b/nuttx/sched/mq_unlink.c
index dc1f95140..066bcacab 100644
--- a/nuttx/sched/mq_unlink.c
+++ b/nuttx/sched/mq_unlink.c
@@ -89,9 +89,9 @@
int mq_unlink(const char *mq_name)
{
- msgq_t *msgq;
- uint32 saved_state;
- int ret = ERROR;
+ msgq_t *msgq;
+ irqstate_t saved_state;
+ int ret = ERROR;
/* Verify the input values */
diff --git a/nuttx/sched/os_start.c b/nuttx/sched/os_start.c
index 638180082..09de22ce3 100644
--- a/nuttx/sched/os_start.c
+++ b/nuttx/sched/os_start.c
@@ -386,7 +386,7 @@ void os_start(void)
{
/* Remove the first delayed deallocation. */
- uint32 saved_state = irqsave();
+ irqstate_t saved_state = irqsave();
void *address = (void*)sq_remfirst(&g_delayeddeallocations);
irqrestore(saved_state);
diff --git a/nuttx/sched/pthread_condtimedwait.c b/nuttx/sched/pthread_condtimedwait.c
index 59d92921e..9ebaf6917 100644
--- a/nuttx/sched/pthread_condtimedwait.c
+++ b/nuttx/sched/pthread_condtimedwait.c
@@ -71,14 +71,18 @@
* Private Functions
************************************************************/
-static void pthread_condtimedout(int pid, int signo, int arg3, int arg4)
+static void pthread_condtimedout(int argc, uint32 pid, uint32 signo, ...)
{
+#ifdef CONFIG_CAN_PASS_STRUCTS
union sigval value;
/* Send the specified signal to the specified task. */
- value.sival_ptr = 0;
- (void)sigqueue(pid, signo, value);
+ value.sival_ptr = NULL;
+ (void)sigqueue((int)pid, (int)signo, value);
+#else
+ (void)sigqueue((int)pid, (int)signo, NULL);
+#endif
}
/************************************************************
@@ -112,8 +116,8 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
sint32 relusec;
sint32 ticks;
int mypid = (int)getpid();
+ irqstate_t int_state;
int ret = OK;
- int int_state;
int status;
dbg("cond=0x%p mutex=0x%p abstime=0x%p\n", cond, mutex, abstime);
@@ -240,7 +244,7 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
/* Start the watchdog */
wd_start(wdog, ticks, (wdentry_t)pthread_condtimedout,
- mypid, ECHO_COND_WAIT_SIGNO, 0, 0);
+ 2, (uint32)mypid, (uint32)ECHO_COND_WAIT_SIGNO);
/* Take the condition semaphore. Do not restore interrupts
* until we return from the wait. This is necessary to
diff --git a/nuttx/sched/pthread_create.c b/nuttx/sched/pthread_create.c
index 5d9104c75..a369f0b49 100644
--- a/nuttx/sched/pthread_create.c
+++ b/nuttx/sched/pthread_create.c
@@ -65,10 +65,10 @@
pthread_attr_t g_default_pthread_attr =
{
- .stacksize = PTHREAD_STACK_DEFAULT,
- .priority = PTHREAD_DEFAULT_PRIORITY,
- .policy = SCHED_RR,
- .inheritsched = PTHREAD_EXPLICIT_SCHED,
+ PTHREAD_STACK_DEFAULT, /* stacksize */
+ PTHREAD_DEFAULT_PRIORITY, /* priority */
+ SCHED_RR, /* policy */
+ PTHREAD_EXPLICIT_SCHED, /* inheritsched */
};
/************************************************************
diff --git a/nuttx/sched/pthread_getspecific.c b/nuttx/sched/pthread_getspecific.c
index 886557f38..afcfba55c 100644
--- a/nuttx/sched/pthread_getspecific.c
+++ b/nuttx/sched/pthread_getspecific.c
@@ -37,6 +37,8 @@
* Included Files
************************************************************/
+#include <nuttx/config.h>
+
#include <sys/types.h>
#include <sched.h>
#include <errno.h>
@@ -103,6 +105,7 @@
void *pthread_getspecific(pthread_key_t key)
{
+#if CONFIG_NPTHREAD_KEYS > 0
_TCB *rtcb = (_TCB*)g_readytorun.head;
void *ret = NULL;
@@ -116,4 +119,7 @@ void *pthread_getspecific(pthread_key_t key)
}
return ret;
+#else
+ return NULL;
+#endif
}
diff --git a/nuttx/sched/pthread_keycreate.c b/nuttx/sched/pthread_keycreate.c
index bda51e53a..00d127160 100644
--- a/nuttx/sched/pthread_keycreate.c
+++ b/nuttx/sched/pthread_keycreate.c
@@ -37,6 +37,8 @@
* Included Files
************************************************************/
+#include <nuttx/config.h>
+
#include <sys/types.h>
#include <sched.h>
#include <errno.h>
@@ -112,6 +114,7 @@
int pthread_key_create(pthread_key_t *key, void (*destructor)(void*))
{
+#if CONFIG_NPTHREAD_KEYS > 0
int ret = EAGAIN;
/* Check if we have exceeded the system-defined number of keys. */
@@ -132,4 +135,7 @@ int pthread_key_create(pthread_key_t *key, void (*destructor)(void*))
}
return ret;
+#else
+ return ENOSYS;
+#endif
}
diff --git a/nuttx/sched/pthread_keydelete.c b/nuttx/sched/pthread_keydelete.c
index 486de00d8..9a53a5e5e 100644
--- a/nuttx/sched/pthread_keydelete.c
+++ b/nuttx/sched/pthread_keydelete.c
@@ -37,6 +37,8 @@
* Included Files
************************************************************/
+#include <nuttx/config.h>
+
#include <sys/types.h>
#include <sched.h>
#include <errno.h>
@@ -91,3 +93,4 @@ int pthread_key_delete(pthread_key_t key)
{
return ENOSYS;
}
+
diff --git a/nuttx/sched/pthread_setspecific.c b/nuttx/sched/pthread_setspecific.c
index c08a18190..5e9ba7fb6 100644
--- a/nuttx/sched/pthread_setspecific.c
+++ b/nuttx/sched/pthread_setspecific.c
@@ -37,6 +37,8 @@
* Included Files
************************************************************/
+#include <nuttx/config.h>
+
#include <sys/types.h>
#include <sched.h>
#include <errno.h>
@@ -111,6 +113,7 @@
int pthread_setspecific(pthread_key_t key, void *value)
{
+#if CONFIG_NPTHREAD_KEYS > 0
_TCB *rtcb = (_TCB*)g_readytorun.head;
int ret = EINVAL;
@@ -128,4 +131,9 @@ int pthread_setspecific(pthread_key_t key, void *value)
}
return ret;
+#else
+ return ENOSYS;
+#endif
}
+
+
diff --git a/nuttx/sched/sched_free.c b/nuttx/sched/sched_free.c
index 9fc2a261d..dc1d34789 100644
--- a/nuttx/sched/sched_free.c
+++ b/nuttx/sched/sched_free.c
@@ -90,7 +90,7 @@ void sched_free(void *address)
{
/* Yes.. Delay the deallocation until a more appropriate time. */
- uint32 saved_state = irqsave();
+ irqstate_t saved_state = irqsave();
sq_addlast((sq_entry_t*)address, &g_delayeddeallocations);
irqrestore(saved_state);
}
diff --git a/nuttx/sched/sched_setparam.c b/nuttx/sched/sched_setparam.c
index 482b62ddb..a1e5af97f 100644
--- a/nuttx/sched/sched_setparam.c
+++ b/nuttx/sched/sched_setparam.c
@@ -105,12 +105,12 @@
int sched_setparam(pid_t pid, const struct sched_param *param)
{
- _TCB *rtcb;
- _TCB *tcb;
- tstate_t task_state;
- uint32 saved_state;
- int sched_priority = param->sched_priority;
- int ret = 0;
+ _TCB *rtcb;
+ _TCB *tcb;
+ tstate_t task_state;
+ irqstate_t saved_state;
+ int sched_priority = param->sched_priority;
+ int ret = 0;
/* Verify that the requested priority is in the valid range */
diff --git a/nuttx/sched/sched_setscheduler.c b/nuttx/sched/sched_setscheduler.c
index 29c0d0c98..7d1b11ba4 100644
--- a/nuttx/sched/sched_setscheduler.c
+++ b/nuttx/sched/sched_setscheduler.c
@@ -112,7 +112,7 @@ int sched_setscheduler(pid_t pid, int policy,
{
_TCB *tcb;
#if CONFIG_RR_INTERVAL > 0
- uint32 saved_state;
+ irqstate_t saved_state;
#endif
int ret;
diff --git a/nuttx/sched/sem_open.c b/nuttx/sched/sem_open.c
index f6139ec5e..6a8c38a4c 100644
--- a/nuttx/sched/sem_open.c
+++ b/nuttx/sched/sem_open.c
@@ -41,6 +41,7 @@
#include <stdarg.h>
#include <string.h>
#include <semaphore.h>
+#include <errno.h>
#include <nuttx/kmalloc.h>
#include "sem_internal.h"
@@ -117,7 +118,11 @@ sem_t *sem_open (const char *name, int oflag, ...)
{
int namelen;
nsem_t *psem;
+#ifdef CONFIG_CAN_CAST_POINTERS
sem_t *sem = (sem_t*)ERROR;
+#else
+ sem_t *sem = get_errorptr();
+#endif
va_list arg; /* Points to each un-named argument */
mode_t mode; /* Creation mode parameter (ignored) */
unsigned int value; /* Semaphore value parameter */
diff --git a/nuttx/sched/sem_post.c b/nuttx/sched/sem_post.c
index c07b1d534..348e88c80 100644
--- a/nuttx/sched/sem_post.c
+++ b/nuttx/sched/sem_post.c
@@ -106,9 +106,9 @@
int sem_post (sem_t *sem)
{
- _TCB *stcb;
- STATUS ret = ERROR;
- uint32 saved_state;
+ _TCB *stcb;
+ STATUS ret = ERROR;
+ irqstate_t saved_state;
/* Make sure we were supplied with a valid semaphore. */
diff --git a/nuttx/sched/sem_trywait.c b/nuttx/sched/sem_trywait.c
index 561ba0b44..384eff0a0 100644
--- a/nuttx/sched/sem_trywait.c
+++ b/nuttx/sched/sem_trywait.c
@@ -98,9 +98,9 @@
int sem_trywait(sem_t *sem)
{
- _TCB *rtcb = (_TCB*)g_readytorun.head;
- uint32 saved_state;
- int ret = ERROR;
+ _TCB *rtcb = (_TCB*)g_readytorun.head;
+ irqstate_t saved_state;
+ int ret = ERROR;
/* Assume any errors reported are due to invalid arguments. */
diff --git a/nuttx/sched/sem_wait.c b/nuttx/sched/sem_wait.c
index 006c55960..78aa7d5e9 100644
--- a/nuttx/sched/sem_wait.c
+++ b/nuttx/sched/sem_wait.c
@@ -99,9 +99,9 @@
int sem_wait (sem_t *sem)
{
- _TCB *rtcb = (_TCB*)g_readytorun.head;
- int ret = ERROR;
- uint32 saved_state;
+ _TCB *rtcb = (_TCB*)g_readytorun.head;
+ int ret = ERROR;
+ irqstate_t saved_state;
/* Assume any errors reported are due to invalid arguments. */
diff --git a/nuttx/sched/sem_waitirq.c b/nuttx/sched/sem_waitirq.c
index 96ab61f44..810663732 100644
--- a/nuttx/sched/sem_waitirq.c
+++ b/nuttx/sched/sem_waitirq.c
@@ -94,7 +94,7 @@
void sem_waitirq (_TCB *wtcb)
{
- uint32 saved_state;
+ irqstate_t saved_state;
/* Disable interrupts. This is necessary (unfortunately) because an
* interrupt handler may attempt to post the semaphore while we are
diff --git a/nuttx/sched/sig_allocatependingsigaction.c b/nuttx/sched/sig_allocatependingsigaction.c
index a6304e205..610596457 100644
--- a/nuttx/sched/sig_allocatependingsigaction.c
+++ b/nuttx/sched/sig_allocatependingsigaction.c
@@ -77,8 +77,8 @@
sigq_t *sig_allocatependingsigaction(void)
{
- sigq_t *sigq;
- uint32 saved_state;
+ sigq_t *sigq;
+ irqstate_t saved_state;
/* Check if we were called from an interrupt handler. */
diff --git a/nuttx/sched/sig_deliver.c b/nuttx/sched/sig_deliver.c
index dfbbc1092..c10633797 100644
--- a/nuttx/sched/sig_deliver.c
+++ b/nuttx/sched/sig_deliver.c
@@ -83,12 +83,12 @@
void sig_deliver(_TCB *stcb)
{
- pid_t rpid;
- sigq_t *sigq;
- sigq_t *next;
- sigset_t savesigprocmask;
- uint32 saved_state;
- int saved_errno;
+ pid_t rpid;
+ sigq_t *sigq;
+ sigq_t *next;
+ sigset_t savesigprocmask;
+ irqstate_t saved_state;
+ int saved_errno;
sched_lock();
diff --git a/nuttx/sched/sig_mqnotempty.c b/nuttx/sched/sig_mqnotempty.c
index cc5a064f6..ab395db2e 100644
--- a/nuttx/sched/sig_mqnotempty.c
+++ b/nuttx/sched/sig_mqnotempty.c
@@ -80,7 +80,11 @@
*
************************************************************/
+#ifdef CONFIG_CAN_PASS_STRUCTS
int sig_mqnotempty (int pid, int signo, const union sigval value)
+#else
+int sig_mqnotempty (int pid, int signo, void *sival_ptr)
+#endif
{
_TCB *stcb;
siginfo_t info;
@@ -91,14 +95,22 @@ int sig_mqnotempty (int pid, int signo, const union sigval value)
/* Get the TCB of the receiving task */
stcb = sched_gettcb(pid);
- dbg("sig_mqnotempty: TCB=0x%08x signo=%d value=%d\n",
- stcb, signo, value.sival_int);
+
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ dbg("TCB=%p signo=%d value=%d\n", stcb, signo, value.sival_int);
+#else
+ dbg("TCB=%p signo=%d sival_ptr=%p\n", stcb, signo, sival_ptr);
+#endif
/* Create the siginfo structure */
- info.si_signo = signo;
- info.si_code = SI_MESGQ;
- info.si_value = value;
+ info.si_signo = signo;
+ info.si_code = SI_MESGQ;
+#ifdef CONFIG_CAN_PASS_STRUCTS
+ info.si_value = value;
+#else
+ info.si_value.sival_ptr = sival_ptr;
+#endif
/* Verify that we can perform the signalling operation */
diff --git a/nuttx/sched/sig_pending.c b/nuttx/sched/sig_pending.c
index 3600c6d94..62b98f3ca 100644
--- a/nuttx/sched/sig_pending.c
+++ b/nuttx/sched/sig_pending.c
@@ -110,7 +110,7 @@ sigset_t sig_pendingset(_TCB *stcb)
{
sigset_t sigpendset;
sigpendq_t *sigpend;
- uint32 saved_state;
+ irqstate_t saved_state;
sigpendset = NULL_SIGNAL_SET;
diff --git a/nuttx/sched/sig_procmask.c b/nuttx/sched/sig_procmask.c
index b733bac0e..dd5dd9eb8 100644
--- a/nuttx/sched/sig_procmask.c
+++ b/nuttx/sched/sig_procmask.c
@@ -114,10 +114,10 @@
int sigprocmask(int how, const sigset_t *set, sigset_t *oset)
{
- _TCB *rtcb = (_TCB*)g_readytorun.head;
- sigset_t oldsigprocmask;
- uint32 saved_state;
- int ret = OK;
+ _TCB *rtcb = (_TCB*)g_readytorun.head;
+ sigset_t oldsigprocmask;
+ irqstate_t saved_state;
+ int ret = OK;
sched_lock();
diff --git a/nuttx/sched/sig_received.c b/nuttx/sched/sig_received.c
index 8a2c3928d..922d4b778 100644
--- a/nuttx/sched/sig_received.c
+++ b/nuttx/sched/sig_received.c
@@ -38,6 +38,7 @@
************************************************************/
#include <sys/types.h>
+#include <string.h>
#include <signal.h>
#include <unistd.h>
#include <sched.h>
@@ -79,7 +80,7 @@ static int sig_queueaction(_TCB *stcb, siginfo_t *info)
{
sigactq_t *sigact;
sigq_t *sigq;
- uint32 saved_state;
+ irqstate_t saved_state;
int ret = OK;
sched_lock();
@@ -106,7 +107,7 @@ static int sig_queueaction(_TCB *stcb, siginfo_t *info)
sigq->action.sighandler = sigact->act.sa_u._sa_sigaction;
sigq->mask = sigact->act.sa_mask;
- sigq->info = *info;
+ memcpy(&sigq->info, info, sizeof(siginfo_t));
/* Put it at the end of the pending signals list */
@@ -131,7 +132,7 @@ static int sig_queueaction(_TCB *stcb, siginfo_t *info)
static sigpendq_t *sig_findpendingsignal(_TCB *stcb, int signo)
{
sigpendq_t *sigpend = NULL;
- uint32 saved_state;
+ irqstate_t saved_state;
/* Verify the caller's sanity */
@@ -163,7 +164,7 @@ static sigpendq_t *sig_findpendingsignal(_TCB *stcb, int signo)
static sigpendq_t *sig_allocatependingsignal(void)
{
sigpendq_t *sigpend;
- uint32 saved_state;
+ irqstate_t saved_state;
/* Check if we were called from an interrupt handler. */
@@ -227,7 +228,7 @@ static sigpendq_t *sig_allocatependingsignal(void)
static sigpendq_t *sig_addpendingsignal(_TCB *stcb, siginfo_t *info)
{
sigpendq_t *sigpend;
- uint32 saved_state;
+ irqstate_t saved_state;
/* Check if the signal is already pending */
@@ -236,7 +237,7 @@ static sigpendq_t *sig_addpendingsignal(_TCB *stcb, siginfo_t *info)
{
/* The signal is already pending... retain only one copy */
- sigpend->info = *info;
+ memcpy(&sigpend->info, info, sizeof(siginfo_t));
}
/* No... There is nothing pending for this signo */
@@ -250,7 +251,7 @@ static sigpendq_t *sig_addpendingsignal(_TCB *stcb, siginfo_t *info)
{
/* Put the signal information into the allocated structure */
- sigpend->info = *info;
+ memcpy(&sigpend->info, info, sizeof(siginfo_t));
/* Add the structure to the pending signal list */
@@ -284,8 +285,8 @@ static sigpendq_t *sig_addpendingsignal(_TCB *stcb, siginfo_t *info)
int sig_received(_TCB *stcb, siginfo_t *info)
{
- int ret = ERROR;
- uint32 saved_state;
+ irqstate_t saved_state;
+ int ret = ERROR;
dbg("sig_received: TCB=0x%08x signo=%d code=%d value=%d\n",
stcb, info->si_signo, info->si_code, info->si_value.sival_int);
@@ -310,7 +311,7 @@ int sig_received(_TCB *stcb, siginfo_t *info)
if (stcb->task_state == TSTATE_WAIT_SIG &&
sigismember(&stcb->sigwaitmask, info->si_signo))
{
- stcb->sigunbinfo = *info;
+ memcpy(&stcb->sigunbinfo, info, sizeof(siginfo_t));
stcb->sigwaitmask = NULL_SIGNAL_SET;
up_unblock_task(stcb);
irqrestore(saved_state);
@@ -352,7 +353,7 @@ int sig_received(_TCB *stcb, siginfo_t *info)
saved_state = irqsave();
if (stcb->task_state == TSTATE_WAIT_SIG)
{
- stcb->sigunbinfo = *info;
+ memcpy(&stcb->sigunbinfo, info, sizeof(siginfo_t));
stcb->sigwaitmask = NULL_SIGNAL_SET;
up_unblock_task(stcb);
}
diff --git a/nuttx/sched/sig_releasependingsigaction.c b/nuttx/sched/sig_releasependingsigaction.c
index 7187c03c7..b25ee79e3 100644
--- a/nuttx/sched/sig_releasependingsigaction.c
+++ b/nuttx/sched/sig_releasependingsigaction.c
@@ -76,7 +76,7 @@
void sig_releasependingsigaction(sigq_t *sigq)
{
- uint32 saved_state;
+ irqstate_t saved_state;
/* If this is a generally available pre-allocated structyre,
* then just put it back in the free list.
diff --git a/nuttx/sched/sig_releasependingsignal.c b/nuttx/sched/sig_releasependingsignal.c
index 453118fb4..43601d7db 100644
--- a/nuttx/sched/sig_releasependingsignal.c
+++ b/nuttx/sched/sig_releasependingsignal.c
@@ -84,7 +84,7 @@
void sig_releasependingsignal(sigpendq_t *sigpend)
{
- uint32 saved_state;
+ irqstate_t saved_state;
/* If this is a generally available pre-allocated structyre,
* then just put it back in the free list.
diff --git a/nuttx/sched/sig_removependingsignal.c b/nuttx/sched/sig_removependingsignal.c
index 4163f13f0..917d6d7e1 100644
--- a/nuttx/sched/sig_removependingsignal.c
+++ b/nuttx/sched/sig_removependingsignal.c
@@ -84,8 +84,9 @@
sigpendq_t *sig_removependingsignal(_TCB *stcb, int signo)
{
- sigpendq_t *currsig, *prevsig;
- uint32 saved_state;
+ sigpendq_t *currsig;
+ sigpendq_t *prevsig;
+ irqstate_t saved_state;
saved_state = irqsave();
for (prevsig = NULL, currsig = (sigpendq_t*)stcb->sigpendingq.head;
diff --git a/nuttx/sched/sig_suspend.c b/nuttx/sched/sig_suspend.c
index d0167b226..92771578f 100644
--- a/nuttx/sched/sig_suspend.c
+++ b/nuttx/sched/sig_suspend.c
@@ -115,7 +115,7 @@ int sigsuspend(const sigset_t *set)
sigset_t intersection;
sigset_t saved_sigprocmask;
sigpendq_t *sigpend;
- uint32 saved_state;
+ irqstate_t saved_state;
int unblocksigno;
/* Several operations must be performed below: We must determine if any
diff --git a/nuttx/sched/sig_timedwait.c b/nuttx/sched/sig_timedwait.c
index 842f68c2f..bba138fa7 100644
--- a/nuttx/sched/sig_timedwait.c
+++ b/nuttx/sched/sig_timedwait.c
@@ -38,6 +38,7 @@
************************************************************/
#include <sys/types.h>
+#include <string.h>
#include <signal.h>
#include <time.h>
#include <wdog.h>
@@ -76,11 +77,24 @@
* A timeout elapsed while waiting for signals to be queued.
************************************************************/
-static void sig_timeout(int itcb, int parm2, int parm3, int parm4)
+static void sig_timeout(int argc, uint32 itcb, ...)
{
- _TCB *wtcb = (_TCB*)itcb;
+ /* On many small machines, pointers are encoded and cannot
+ * be simply cast from uint32 to _TCB*. The following
+ * union works around this (see wdogparm_t). This odd
+ * logic could be conditioned on CONFIG_CAN_CAST_POINTERS,
+ * but it is not too bad in any case.
+ */
- if (!wtcb)
+ union
+ {
+ _TCB *wtcb;
+ uint32 itcb;
+ } u;
+
+ u.itcb = itcb;
+
+ if (!u.wtcb)
{
PANIC(OSERR_TIMEOUTNOTCB);
}
@@ -89,12 +103,12 @@ static void sig_timeout(int itcb, int parm2, int parm3, int parm4)
* still waiting for a signal
*/
- if (wtcb->task_state == TSTATE_WAIT_SIG)
+ if (u.wtcb->task_state == TSTATE_WAIT_SIG)
{
- wtcb->sigunbinfo.si_signo = ERROR;
- wtcb->sigunbinfo.si_code = SI_TIMEOUT;
- wtcb->sigunbinfo.si_value.sival_int = 0;
- up_unblock_task(wtcb);
+ u.wtcb->sigunbinfo.si_signo = ERROR;
+ u.wtcb->sigunbinfo.si_code = SI_TIMEOUT;
+ u.wtcb->sigunbinfo.si_value.sival_int = 0;
+ up_unblock_task(u.wtcb);
}
}
@@ -150,7 +164,7 @@ int sigtimedwait(const sigset_t *set, struct siginfo *info,
sigset_t intersection;
sigpendq_t *sigpend;
WDOG_ID wdog;
- uint32 saved_state;
+ irqstate_t saved_state;
sint32 waitticks;
int ret = ERROR;
@@ -184,7 +198,10 @@ int sigtimedwait(const sigset_t *set, struct siginfo *info,
/* Return the signal info to the caller if so requested */
- if (info) *info = sigpend->info;
+ if (info)
+ {
+ memcpy(info, &sigpend->info, sizeof(struct siginfo));
+ }
/* Then dispose of the pending signal structure properly */
@@ -218,10 +235,18 @@ int sigtimedwait(const sigset_t *set, struct siginfo *info,
wdog = wd_create();
if (wdog)
{
+ /* This little of nonsense is necessary for some
+ * processors where sizeof(pointer) < sizeof(uint32).
+ * see wdog.h.
+ */
+
+ wdparm_t wdparm;
+ wdparm.pvarg = (void*)rtcb;
+
/* Start the watchdog */
wd_start(wdog, waitticks, (wdentry_t)sig_timeout,
- (int)rtcb, 0, 0, 0);
+ 1, wdparm.dwarg);
/* Now wait for either the signal or the watchdog */
@@ -252,7 +277,7 @@ int sigtimedwait(const sigset_t *set, struct siginfo *info,
if (info)
{
- *info = rtcb->sigunbinfo;
+ memcpy(info, &rtcb->sigunbinfo, sizeof(struct siginfo));
}
irqrestore(saved_state);
diff --git a/nuttx/sched/task_create.c b/nuttx/sched/task_create.c
index c1cf11772..79f487a11 100644
--- a/nuttx/sched/task_create.c
+++ b/nuttx/sched/task_create.c
@@ -377,11 +377,7 @@ STATUS task_init(_TCB *tcb, char *name, int priority,
STATUS task_activate(_TCB *tcb)
{
#ifdef CONFIG_SCHED_INSTRUMENTATION
- uint32 flags;
-#endif
-
-#ifdef CONFIG_SCHED_INSTRUMENTATION
- flags = irqsave();
+ irqstate_t flags = irqsave();
/* Check if this is really a re-start */
diff --git a/nuttx/sched/task_delete.c b/nuttx/sched/task_delete.c
index 5a28c3d42..ed169217d 100644
--- a/nuttx/sched/task_delete.c
+++ b/nuttx/sched/task_delete.c
@@ -95,10 +95,10 @@
STATUS task_delete(pid_t pid)
{
- _TCB *rtcb;
- _TCB *dtcb;
- uint32 saved_state;
- STATUS ret = ERROR;
+ _TCB *rtcb;
+ _TCB *dtcb;
+ irqstate_t saved_state;
+ STATUS ret = ERROR;
/* Check if the task to delete is the calling task */
diff --git a/nuttx/sched/task_restart.c b/nuttx/sched/task_restart.c
index 6d4b7a83a..60478c258 100644
--- a/nuttx/sched/task_restart.c
+++ b/nuttx/sched/task_restart.c
@@ -99,10 +99,10 @@
STATUS task_restart(pid_t pid)
{
- _TCB *rtcb;
- _TCB *tcb;
- STATUS status;
- uint32 state;
+ _TCB *rtcb;
+ _TCB *tcb;
+ STATUS status;
+ irqstate_t state;
/* Make sure this task does not become ready-to-run while
* we are futzing with its TCB
diff --git a/nuttx/sched/wd_cancel.c b/nuttx/sched/wd_cancel.c
index 9a3a223fd..c0181e43b 100644
--- a/nuttx/sched/wd_cancel.c
+++ b/nuttx/sched/wd_cancel.c
@@ -87,10 +87,10 @@
STATUS wd_cancel (WDOG_ID wdid)
{
- wdog_t *curr;
- wdog_t *prev;
- uint32 saved_state;
- STATUS ret = ERROR;
+ wdog_t *curr;
+ wdog_t *prev;
+ irqstate_t saved_state;
+ STATUS ret = ERROR;
/* Prohibit timer interactions with the timer queue until the
* cancellation is complete
diff --git a/nuttx/sched/wd_create.c b/nuttx/sched/wd_create.c
index 14a1c5410..0fad7cef9 100644
--- a/nuttx/sched/wd_create.c
+++ b/nuttx/sched/wd_create.c
@@ -87,8 +87,8 @@
WDOG_ID wd_create (void)
{
- wdog_t *wdog;
- sint32 saved_state;
+ wdog_t *wdog;
+ irqstate_t saved_state;
saved_state = irqsave();
wdog = (wdog_t*)sq_remfirst(&g_wdfreelist);
diff --git a/nuttx/sched/wd_delete.c b/nuttx/sched/wd_delete.c
index b4039cce0..96168ec2c 100644
--- a/nuttx/sched/wd_delete.c
+++ b/nuttx/sched/wd_delete.c
@@ -90,7 +90,7 @@
STATUS wd_delete (WDOG_ID wdId)
{
- uint32 saved_state;
+ irqstate_t saved_state;
/* Check if the watchdog has been started. */
diff --git a/nuttx/sched/wd_internal.h b/nuttx/sched/wd_internal.h
index 212c68619..7794d8c12 100644
--- a/nuttx/sched/wd_internal.h
+++ b/nuttx/sched/wd_internal.h
@@ -40,6 +40,7 @@
* Included Files
************************************************************/
+#include <nuttx/config.h>
#include <sys/types.h>
#include <wdog.h>
#include <nuttx/compiler.h>
@@ -64,11 +65,11 @@ struct wdog_s
{
struct wdog_s *next; /* Support for singly linked lists. */
wdentry_t func; /* Function to execute when delay expires */
- sint32 lag; /* Timer associated with the delay */
- uint32 parm[4]; /* Four parameters passed to func */
+ int lag; /* Timer associated with the delay */
boolean active; /* TRUE if the watchdog is actively timing */
+ ubyte argc; /* The number of parameters to pass */
+ uint32 parm[CONFIG_MAX_WDOGPARMS];
};
-
typedef struct wdog_s wdog_t;
/************************************************************
diff --git a/nuttx/sched/wd_start.c b/nuttx/sched/wd_start.c
index 04ece3493..b3534593d 100644
--- a/nuttx/sched/wd_start.c
+++ b/nuttx/sched/wd_start.c
@@ -38,9 +38,12 @@
************************************************************/
#include <sys/types.h>
+#include <stdarg.h>
#include <wdog.h>
#include <unistd.h>
#include <sched.h>
+#include <errno.h>
+#include "os_internal.h"
#include "wd_internal.h"
/************************************************************
@@ -51,6 +54,22 @@
* Private Type Declarations
************************************************************/
+typedef void (*wdentry0_t)(int argc);
+#if CONFIG_MAX_WDOGPARMS > 0
+typedef void (*wdentry1_t)(int argc, uint32 arg1);
+#endif
+#if CONFIG_MAX_WDOGPARMS > 1
+typedef void (*wdentry2_t)(int argc, uint32 arg1, uint32 arg2);
+#endif
+#if CONFIG_MAX_WDOGPARMS > 2
+typedef void (*wdentry3_t)(int argc, uint32 arg1, uint32 arg2,
+ uint32 arg3);
+#endif
+#if CONFIG_MAX_WDOGPARMS > 3
+typedef void (*wdentry4_t)(int argc, uint32 arg1, uint32 arg2,
+ uint32 arg3, uint32 arg4);
+#endif
+
/************************************************************
* Global Variables
************************************************************/
@@ -83,12 +102,12 @@
* Watchdog timers execute only once.
*
* To replace either the timeout delay or the function to
- * be executed, call wd_start again with the same wdId; only
+ * be executed, call wd_start again with the same wdog; only
* the most recent wdStart() on a given watchdog ID has
* any effect.
*
* Parameters:
- * wdId = watchdog ID
+ * wdog = watchdog ID
* delay = Delay count in clock ticks
* wdentry = function to call on timeout
* parm1..4 = parameters to pass to wdentry
@@ -102,19 +121,22 @@
*
************************************************************/
-STATUS wd_start(WDOG_ID wdId, int delay, wdentry_t wdentry,
- int parm1, int parm2, int parm3, int parm4)
+STATUS wd_start(WDOG_ID wdog, int delay, wdentry_t wdentry,
+ int argc, ...)
{
- wdog_t *curr;
- wdog_t *prev;
- wdog_t *next;
- sint32 now;
- sint32 saved_state;
+ va_list ap;
+ wdog_t *curr;
+ wdog_t *prev;
+ wdog_t *next;
+ sint32 now;
+ irqstate_t saved_state;
+ int i;
- /* Verify the wdId */
+ /* Verify the wdog */
- if (!wdId)
+ if (!wdog || argc > CONFIG_MAX_WDOGPARMS || delay < 0)
{
+ *get_errno_ptr() = EINVAL;
return ERROR;
}
@@ -125,18 +147,28 @@ STATUS wd_start(WDOG_ID wdId, int delay, wdentry_t wdentry,
*/
saved_state = irqsave();
- if (wdId->active)
+ if (wdog->active)
{
- wd_cancel(wdId);
+ wd_cancel(wdog);
}
/* Save the data in the watchdog structure */
- wdId->func = wdentry; /* Function to execute when delay expires */
- wdId->parm[0] = parm1; /* Same as the parameter to pass */
- wdId->parm[1] = parm2; /* 2nd parameter not used */
- wdId->parm[2] = parm3; /* 3rd parameter not used */
- wdId->parm[3] = parm4; /* 4th parameter not used */
+ wdog->func = wdentry; /* Function to execute when delay expires */
+ wdog->argc = argc;
+
+ va_start(ap, argc);
+ for (i = 0; i < argc; i++)
+ {
+ wdog->parm[i] = va_arg(ap, uint32);
+ }
+#ifdef CONFIG_DEBUG
+ for (; i < CONFIG_MAX_WDOGPARMS; i++)
+ {
+ wdog->parm[i] = 0;
+ }
+#endif
+ va_end(ap);
/* Calculate delay+1, forcing the delay into a range that we can handle */
@@ -153,7 +185,7 @@ STATUS wd_start(WDOG_ID wdId, int delay, wdentry_t wdentry,
if (g_wdactivelist.head == NULL)
{
- sq_addlast((sq_entry_t*)wdId,&g_wdactivelist);
+ sq_addlast((sq_entry_t*)wdog,&g_wdactivelist);
}
/* There are other active watchdogs in the timer queue */
@@ -180,7 +212,7 @@ STATUS wd_start(WDOG_ID wdId, int delay, wdentry_t wdentry,
now += curr->lag;
}
- /* Check if the new wdId must be inserted before the curr. */
+ /* Check if the new wdog must be inserted before the curr. */
if (delay < now)
{
@@ -196,18 +228,18 @@ STATUS wd_start(WDOG_ID wdId, int delay, wdentry_t wdentry,
if (curr == (wdog_t*)g_wdactivelist.head)
{
- sq_addfirst((sq_entry_t*)wdId, &g_wdactivelist);
+ sq_addfirst((sq_entry_t*)wdog, &g_wdactivelist);
}
else
{
- sq_addafter((sq_entry_t*)prev, (sq_entry_t*)wdId,
+ sq_addafter((sq_entry_t*)prev, (sq_entry_t*)wdog,
&g_wdactivelist);
}
}
/* The new watchdog delay time is greater than the curr delay time,
- * so the new wdId must be inserted after the curr. This only occurs
- * if the wdId is to be added to the end of the list.
+ * so the new wdog must be inserted after the curr. This only occurs
+ * if the wdog is to be added to the end of the list.
*/
else
@@ -215,13 +247,13 @@ STATUS wd_start(WDOG_ID wdId, int delay, wdentry_t wdentry,
delay -= now;
if (!curr->next)
{
- sq_addlast((sq_entry_t*)wdId, &g_wdactivelist);
+ sq_addlast((sq_entry_t*)wdog, &g_wdactivelist);
}
else
{
next = curr->next;
next->lag -= delay;
- sq_addafter((sq_entry_t*)curr, (sq_entry_t*)wdId,
+ sq_addafter((sq_entry_t*)curr, (sq_entry_t*)wdog,
&g_wdactivelist);
}
}
@@ -229,8 +261,8 @@ STATUS wd_start(WDOG_ID wdId, int delay, wdentry_t wdentry,
/* Put the lag into the watchdog structure and mark it as active. */
- wdId->lag = delay;
- wdId->active = TRUE;
+ wdog->lag = delay;
+ wdog->active = TRUE;
irqrestore(saved_state);
return OK;
@@ -304,8 +336,42 @@ void wd_timer(void)
/* Execute the watchdog function */
- (*wdog->func)(wdog->parm[0], wdog->parm[1],
- wdog->parm[2] ,wdog->parm[3]);
+ switch (wdog->argc)
+ {
+ default:
+#ifdef CONFIG_DEBUG
+ PANIC(OSERR_INTERNAL);
+#endif
+ case 0:
+ (*((wdentry0_t)(wdog->func)))(0);
+ break;
+
+#if CONFIG_MAX_WDOGPARMS > 0
+ case 1:
+ (*((wdentry1_t)(wdog->func)))(1, wdog->parm[0]);
+ break;
+#endif
+#if CONFIG_MAX_WDOGPARMS > 1
+ case 2:
+ (*((wdentry2_t)(wdog->func)))(2,
+ wdog->parm[0], wdog->parm[1]);
+ break;
+#endif
+#if CONFIG_MAX_WDOGPARMS > 2
+ case 3:
+ (*((wdentry3_t)(wdog->func)))(3,
+ wdog->parm[0], wdog->parm[1],
+ wdog->parm[2]);
+ break;
+#endif
+#if CONFIG_MAX_WDOGPARMS > 3
+ case 4:
+ (*((wdentry4_t)(wdog->func)))(4,
+ wdog->parm[0], wdog->parm[1],
+ wdog->parm[2] ,wdog->parm[3]);
+ break;
+#endif
+ }
}
}
}