Update of /cvsroot/emc/rtapi/src/rtapi
In directory sc8-pr-cvs1:/tmp/cvs-serv13330/src/rtapi
Modified Files:
rtai_rtapi.c rtai_ulapi.c rtapi.h rtl_rtapi.c rtl_ulapi.c
sim_rtapi.c sim_ulapi.c ulapi.h
Log Message:
added error recovery and cleanup to rtai_rtapi
Index: rtai_rtapi.c
===================================================================
RCS file: /cvsroot/emc/rtapi/src/rtapi/rtai_rtapi.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** rtai_rtapi.c 10 Aug 2003 23:52:35 -0000 1.18
--- rtai_rtapi.c 11 Aug 2003 04:58:39 -0000 1.19
***************
*** 72,78 ****
#include "rtapi.h" /* these decls */
- /* set to 1/0 to enable/disable logging of task creation etc. */
- #define VERBOSE 1
-
/* These structs hold data associated with objects like tasks, etc. */
/* Task handles are pointers to these structs. */
--- 72,75 ----
***************
*** 80,83 ****
[...1045 lines suppressed...]
+ n = 0;
+ while ((n < RTAPI_MAX_FIFOS) && (fifo_array[n] != fifo)) {
+ n++;
+ }
+ if (n == RTAPI_MAX_FIFOS) {
+ return RTAPI_INVAL;
+ }
/* call the OS to destroy the fifo */
rtf_destroy(fifo->fd);
! /* mark the array entry unused */
! fifo_array[n] = NULL;
fifo->magic = 0;
+ /* free the fifo structure */
kfree(fifo);
/* decrement the usage counter */
fifo_usage_count--;
! rtapi_print_msg(RTAPI_MSG_INFO, "RTAPI: delete_fifo %p, count = %d\n",
! fifo, fifo_usage_count);
return RTAPI_SUCCESS;
}
Index: rtai_ulapi.c
===================================================================
RCS file: /cvsroot/emc/rtapi/src/rtapi/rtai_ulapi.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** rtai_ulapi.c 10 Aug 2003 21:13:04 -0000 1.5
--- rtai_ulapi.c 11 Aug 2003 04:58:39 -0000 1.6
***************
*** 88,92 ****
! int ulapi_shmem_new(int key, unsigned int size, ulapi_shmem_handle * shmemptr)
{
ulapi_shmem_handle shmem;
--- 88,92 ----
! int ulapi_shmem_new(int key, unsigned long int size, ulapi_shmem_handle * shmemptr)
{
ulapi_shmem_handle shmem;
Index: rtapi.h
===================================================================
RCS file: /cvsroot/emc/rtapi/src/rtapi/rtapi.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** rtapi.h 10 Aug 2003 23:52:35 -0000 1.16
--- rtapi.h 11 Aug 2003 04:58:39 -0000 1.17
***************
*** 1,3 ****
! #ifndef RTAPI__H
#define RTAPI_H
--- 1,3 ----
! #ifndef RTAPI_H
#define RTAPI_H
***************
*** 115,141 ****
/***********************************************************************
! * TASK RELATED FUNCTIONS *
************************************************************************/
- /** The 'rtapi_prio_xxxx()' functions provide a portable way to set *
- * task priority. The mapping of actual priority to priority number *
- * depends on the RTOS. Priorities range from 'rtapi_prio_lowest()' *
- * to 'rtapi_prio_highest()', inclusive. To use this API, use one of *
- * two methods: *
- * *
- * 1) Set your lowest priority task to 'rtapi_prio_lowest()', and for *
- * each task of the next lowest priority, set their priorities to *
- * 'rtapi_prio_next_higher(previous)'. *
- * *
- * 2) Set your highest priority task to 'rtapi_prio_highest()', and for *
- * each task of the next highest priority, set their priorities to *
- * 'rtapi_prio_next_lower(previous)'. */
-
- extern int rtapi_prio_highest(void);
- extern int rtapi_prio_lowest(void);
- extern int rtapi_prio_next_higher(int prio);
- extern int rtapi_prio_next_lower(int prio);
-
-
/** The clock period is the basic time interval for realtime tasks *
* All task periods, whether specified when starting the task, or *
--- 115,121 ----
/***********************************************************************
! * CLOCK RELATED FUNCTIONS *
************************************************************************/
/** The clock period is the basic time interval for realtime tasks *
* All task periods, whether specified when starting the task, or *
***************
*** 165,168 ****
--- 145,172 ----
+ /***********************************************************************
+ * TASK RELATED FUNCTIONS *
+ ************************************************************************/
+
+ /** The 'rtapi_prio_xxxx()' functions provide a portable way to set *
+ * task priority. The mapping of actual priority to priority number *
+ * depends on the RTOS. Priorities range from 'rtapi_prio_lowest()' *
+ * to 'rtapi_prio_highest()', inclusive. To use this API, use one of *
+ * two methods: *
+ * *
+ * 1) Set your lowest priority task to 'rtapi_prio_lowest()', and for *
+ * each task of the next lowest priority, set their priorities to *
+ * 'rtapi_prio_next_higher(previous)'. *
+ * *
+ * 2) Set your highest priority task to 'rtapi_prio_highest()', and for *
+ * each task of the next highest priority, set their priorities to *
+ * 'rtapi_prio_next_lower(previous)'. */
+
+ extern int rtapi_prio_highest(void);
+ extern int rtapi_prio_lowest(void);
+ extern int rtapi_prio_next_higher(int prio);
+ extern int rtapi_prio_next_lower(int prio);
+
+
/** 'rtapi_task_new()' is the first step in creating a task. Allocs *
* and initializes internal rtapi and rtos data related to the task. *
***************
*** 198,213 ****
* immediately (does not use 'when'), and run until it returns, pauses, *
* or makes a blocking call. *
! * 'when' is the desired start time for the task. If zero, the task *
! * will start immediately. Otherwise, the task will be scheduled to *
! * start at the appropriate time. If the RTOS doesn't support starting *
! * tasks at a specific time, it will return RTAPI_UNSUP and the task *
! * will not be started. Otherwise, the task will be scheduled to start *
! * at the desired time. If the desired time has already passed, the *
! * function will return RTAPI_LATE, and the task start time is unknown. *
! * Be advised that some RTOSs may execute the task once as soon as it *
! * is scheduled, even if it is not to start until some time in the *
! * future. Tasks should use flags or another mechanism to prevent them *
! * from doing anything prematurely. 'when' uses time as returned by *
! * rtapi_get_time(). *
* If non-zero, 'uses_fp' tells the OS that the task uses floating *
* point so it can save the FPU registers on a task switch. Failing *
--- 202,217 ----
* immediately (does not use 'when'), and run until it returns, pauses, *
* or makes a blocking call. *
! * 'when' is the desired start time for the task. If RTAPI_NOW, the *
! * task will start immediately. Otherwise, the task will be scheduled *
! * to start at the appropriate time. If the RTOS doesn't support *
! * starting tasks at a specific time, it will return RTAPI_UNSUP and *
! * the task will not be started. Otherwise, the task will be scheduled *
! * to start at the desired time. If the desired time has already *
! * passed, the task will start immediately, and function will return *
! * RTAPI_LATE. Be advised that some RTOSs may execute the task once as *
! * soon as it is scheduled, even if it is not to start until some time *
! * in the future. Tasks should use flags or another mechanism to *
! * prevent them from doing anything prematurely. 'when' uses time as *
! * returned by rtapi_get_time(). *
* If non-zero, 'uses_fp' tells the OS that the task uses floating *
* point so it can save the FPU registers on a task switch. Failing *
***************
*** 220,224 ****
#define RTAPI_NO_FP 0
#define RTAPI_USES_FP 1
! #define NOW 0
extern int rtapi_task_start(rtapi_task_handle task,
--- 224,228 ----
#define RTAPI_NO_FP 0
#define RTAPI_USES_FP 1
! #define RTAPI_NOW 0
extern int rtapi_task_start(rtapi_task_handle task,
***************
*** 277,281 ****
* Returns a status code. */
! extern int rtapi_shmem_new(int key, unsigned int size,
rtapi_shmem_handle * shmemptr);
--- 281,285 ----
* Returns a status code. */
! extern int rtapi_shmem_new(int key, unsigned long int size,
rtapi_shmem_handle * shmemptr);
***************
*** 345,352 ****
* becomes a fifo handle, which points to internal data for the fifo *
* and is used for subsequent calls dealing with it. Returns a status *
! * code. *
! * *
! * NOTE - The fifo requires (stacksize - 256) to avoid oops messages on *
! * removal. (Does this apply to rtlinux as well ?) */
extern int rtapi_fifo_new(int key, unsigned long int size,
--- 349,356 ----
* becomes a fifo handle, which points to internal data for the fifo *
* and is used for subsequent calls dealing with it. Returns a status *
! * code. */
!
! /* NOTE - RTAI fifos require (stacksize - 256) to avoid oops messages *
! * on removal. (Does this apply to rtlinux as well ?) */
extern int rtapi_fifo_new(int key, unsigned long int size,
***************
*** 367,370 ****
--- 371,379 ----
* responsible for the data format and integrity. */
+ /* Additional NOTE: IMHO you should be able to write any amount of *
+ * data to a fifo, from 1 byte up to (and even beyond) the size of the *
+ * fifo. At a future date, the somewhat peculiar RTAI fifos will be *
+ * replaced with something that works better. John Kasunich */
+
/** 'rtapi_fifo_read()' reads data from 'fifo'. 'buf' is a buffer for *
* the data, and 'size' is the maximum number of bytes to read. *
***************
*** 423,427 ****
/** 'rtapi_outb() writes 'byte' to 'port'. *
! * Note: This function does nothing on the simulated RTOS. */
extern void rtapi_outb(unsigned char byte, unsigned int port);
--- 432,437 ----
/** 'rtapi_outb() writes 'byte' to 'port'. *
! * Note: This function does nothing on the simulated RTOS. *
! * Note: Many platforms provide an inline outb() that is faster */
extern void rtapi_outb(unsigned char byte, unsigned int port);
***************
*** 429,433 ****
/** 'rtapi_inb() gets a byte from 'port'. Returns the byte. *
! * Note: This function always returns zero on the simulated RTOS. */
extern unsigned char rtapi_inb(unsigned int port);
--- 439,444 ----
/** 'rtapi_inb() gets a byte from 'port'. Returns the byte. *
! * Note: This function always returns zero on the simulated RTOS. *
! * Note: Many platforms provide an inline inb() that is faster */
extern unsigned char rtapi_inb(unsigned int port);
Index: rtl_rtapi.c
===================================================================
RCS file: /cvsroot/emc/rtapi/src/rtapi/rtl_rtapi.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** rtl_rtapi.c 10 Aug 2003 21:13:04 -0000 1.5
--- rtl_rtapi.c 11 Aug 2003 04:58:39 -0000 1.6
***************
*** 5,9 ****
*/
- /* This code is hereby released into the public domain. */
/* NO GUARANTEE OF ANY KIND IS PROVIDED. THE CREATERS OF THIS */
/* CODE ACCEPT ABSOLUTELY NO LIABILITY FOR ANY HARM OR LOSSES */
--- 5,8 ----
***************
*** 47,52 ****
#ifdef MODULE_LICENSE
! MODULE_LICENSE("GPL and additional rights");
! /* The additional rights are you can do anything you want. */
#endif
--- 46,50 ----
#ifdef MODULE_LICENSE
! MODULE_LICENSE("GPL");
#endif
***************
*** 518,531 ****
/* find entry in task array */
n = 0;
! while ((n < RTAPI_MAX_TASKS) && (task_array[n]->ostask != task_id)) {
n++;
}
! if (n == RTAPI_MAX_TASKS) {
! return RTAPI_INVAL;
! }
!
! /* return task handle */
! *taskptr = task_array[n];
! return RTAPI_SUCCESS;
}
--- 516,530 ----
/* find entry in task array */
n = 0;
! while (n < RTAPI_MAX_TASKS) {
! if ( task_array[n] != NULL ) {
! if ( &(task_array[n]->ostask) == task_id ) {
! /* found a match */
! *taskptr = task_array[n];
! return RTAPI_SUCCESS;
! }
! }
n++;
}
! return RTAPI_INVAL;
}
Index: rtl_ulapi.c
===================================================================
RCS file: /cvsroot/emc/rtapi/src/rtapi/rtl_ulapi.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** rtl_ulapi.c 10 Aug 2003 21:13:04 -0000 1.5
--- rtl_ulapi.c 11 Aug 2003 04:58:39 -0000 1.6
***************
*** 5,9 ****
*/
- /* This code is hereby released into the public domain. */
/* NO GUARANTEE OF ANY KIND IS PROVIDED. THE CREATERS OF THIS */
/* CODE ACCEPT ABSOLUTELY NO LIABILITY FOR ANY HARM OR LOSSES */
--- 5,8 ----
Index: sim_rtapi.c
===================================================================
RCS file: /cvsroot/emc/rtapi/src/rtapi/sim_rtapi.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** sim_rtapi.c 10 Aug 2003 23:52:35 -0000 1.7
--- sim_rtapi.c 11 Aug 2003 04:58:39 -0000 1.8
***************
*** 306,310 ****
! int rtapi_shmem_new(int key, unsigned int size, rtapi_shmem_handle * shmemptr)
{
rtapi_shmem_handle shmem;
--- 306,310 ----
! int rtapi_shmem_new(int key, unsigned long int size, rtapi_shmem_handle * shmemptr)
{
rtapi_shmem_handle shmem;
Index: sim_ulapi.c
===================================================================
RCS file: /cvsroot/emc/rtapi/src/rtapi/sim_ulapi.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** sim_ulapi.c 9 Aug 2003 19:43:09 -0000 1.3
--- sim_ulapi.c 11 Aug 2003 04:58:39 -0000 1.4
***************
*** 40,44 ****
! int ulapi_shmem_new(int key, unsigned int size, ulapi_shmem_handle * shmemptr)
{
ulapi_shmem_handle shmem;
--- 40,44 ----
! int ulapi_shmem_new(int key, unsigned long int size, ulapi_shmem_handle * shmemptr)
{
ulapi_shmem_handle shmem;
Index: ulapi.h
===================================================================
RCS file: /cvsroot/emc/rtapi/src/rtapi/ulapi.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** ulapi.h 10 Aug 2003 21:13:04 -0000 1.7
--- ulapi.h 11 Aug 2003 04:58:39 -0000 1.8
***************
*** 95,99 ****
* code. */
! extern int ulapi_shmem_new(int key, unsigned int size,
ulapi_shmem_handle * shmemptr);
--- 95,99 ----
* code. */
! extern int ulapi_shmem_new(int key, unsigned long int size,
ulapi_shmem_handle * shmemptr);
|