mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
Progress toward clean SDCC compilation
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@18 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
+6
-3
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+4
-4
@@ -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 */
|
||||
|
||||
|
||||
+1
-1
@@ -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.
|
||||
|
||||
+6
-6
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
+7
-7
@@ -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 */
|
||||
|
||||
|
||||
+18
-10
@@ -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. */
|
||||
|
||||
+3
-3
@@ -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 */
|
||||
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 */
|
||||
};
|
||||
|
||||
/************************************************************
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
+3
-3
@@ -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. */
|
||||
|
||||
|
||||
+3
-3
@@ -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. */
|
||||
|
||||
|
||||
+3
-3
@@ -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. */
|
||||
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
@@ -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. */
|
||||
|
||||
|
||||
+6
-6
@@ -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();
|
||||
|
||||
|
||||
+17
-5
@@ -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 */
|
||||
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
+12
-11
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+37
-12
@@ -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);
|
||||
|
||||
|
||||
+1
-5
@@ -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 */
|
||||
|
||||
|
||||
+4
-4
@@ -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 */
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
+4
-4
@@ -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
|
||||
|
||||
+2
-2
@@ -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);
|
||||
|
||||
+1
-1
@@ -90,7 +90,7 @@
|
||||
|
||||
STATUS wd_delete (WDOG_ID wdId)
|
||||
{
|
||||
uint32 saved_state;
|
||||
irqstate_t saved_state;
|
||||
|
||||
/* Check if the watchdog has been started. */
|
||||
|
||||
|
||||
+4
-3
@@ -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;
|
||||
|
||||
/************************************************************
|
||||
|
||||
+96
-30
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user