|
From: <pa...@us...> - 2003-08-12 21:31:34
|
Update of /cvsroot/emc/rtapi/src/rtapi
In directory sc8-pr-cvs1:/tmp/cvs-serv24989
Modified Files:
rtai_rtapi.c
Log Message:
Verbosity can now be changed by 'echo 2 > /proc/rtapi'
Index: rtai_rtapi.c
===================================================================
RCS file: /cvsroot/emc/rtapi/src/rtapi/rtai_rtapi.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** rtai_rtapi.c 11 Aug 2003 19:17:06 -0000 1.20
--- rtai_rtapi.c 12 Aug 2003 21:28:22 -0000 1.21
***************
*** 45,48 ****
--- 45,52 ----
#include <linux/proc_fs.h> /* So we can use the /proc file system */
#include <linux/slab.h> /* replaces malloc.h in recent kernels */
+ #include <linux/proc_fs.h> /* proc_fs functions */
+ #include <linux/ctype.h> /* isdigit */
+
+ #include <asm/uaccess.h> /* copy_from_user() */
#include <rtai.h>
#include <rtai_sched.h>
***************
*** 113,120 ****
/* lists of resources */
! static rtapi_task_handle task_array[RTAPI_MAX_TASKS];
! static rtapi_shmem_handle shmem_array[RTAPI_MAX_SHMEMS];
! static rtapi_sem_handle sem_array[RTAPI_MAX_SEMS];
! static rtapi_fifo_handle fifo_array[RTAPI_MAX_FIFOS];
/* Usage counters to keep track of new/delete calls */
--- 117,124 ----
/* lists of resources */
! static rtapi_task_handle task_array[RTAPI_MAX_TASKS];
! static rtapi_shmem_handle shmem_array[RTAPI_MAX_SHMEMS];
! static rtapi_sem_handle sem_array[RTAPI_MAX_SEMS];
! static rtapi_fifo_handle fifo_array[RTAPI_MAX_FIFOS];
/* Usage counters to keep track of new/delete calls */
***************
*** 140,145 ****
/* FIXME - according to my book, this interface is only available
for 2.4 kernels. I'm afraid this code will break on 2.0 or 2.2 */
! static int proc_read(char *page, char **start, off_t off,
! int count, int *eof, void *data)
{
PROC_PRINT_VARS;
--- 144,154 ----
/* FIXME - according to my book, this interface is only available
for 2.4 kernels. I'm afraid this code will break on 2.0 or 2.2 */
! /* The current implimentation may well break on a 2.2 series kernel,
! but the process is the same... */
!
! static struct proc_dir_entry *rtapi_proc; /* struct for proc_fs entities */
! static char proc_data[2]; /* Space for one char plus EOF */
! static int proc_read_rtapi(char *page, char **start, off_t off,
! int count, int *eof, void *data)
{
PROC_PRINT_VARS;
***************
*** 153,157 ****
PROC_PRINT("Active Interrupts = %i\n", int_usage_count);
PROC_PRINT(" Timer period = %li nSec\n", timer_period);
! if ( timer_running ) {
PROC_PRINT(" Timer status = Running\n");
} else {
--- 162,166 ----
PROC_PRINT("Active Interrupts = %i\n", int_usage_count);
PROC_PRINT(" Timer period = %li nSec\n", timer_period);
! if (timer_running) {
PROC_PRINT(" Timer status = Running\n");
} else {
***************
*** 162,165 ****
--- 171,202 ----
PROC_PRINT_DONE;
}
+
+ static int proc_write_rtapi(struct file *file,
+ const char *buffer,
+ unsigned long count, void *data)
+ {
+ int len;
+ char *buf = data; /* Pointer to the data buffer */
+ char temp;
+
+ if (count > 2) { /* If more data than expected is present */
+ len = 2; /* just use the first char.. */
+ } else {
+ len = count;
+ }
+ if (copy_from_user(buf, buffer, len)) { /* copy from user space */
+ return -1;
+ }
+
+ sscanf(data, "%s", &temp);
+ if (isdigit(temp)) { /* check it is a number */
+ /* Kernel implimentation of strtoul is used here.. */
+ rtapi_msg_level = (int) simple_strtoul(&temp, NULL, 0);
+ }
+
+ return len;
+ }
+
+
#endif
***************
*** 179,184 ****
rtapi_usage_count++;
/* MOD_INC_USE_COUNT;*/
! rtapi_print_msg (RTAPI_MSG_INFO, "RTAPI: init called, module count = %d\n",
! rtapi_usage_count );
return RTAPI_SUCCESS;
}
--- 216,221 ----
rtapi_usage_count++;
/* MOD_INC_USE_COUNT;*/
! rtapi_print_msg(RTAPI_MSG_INFO, "RTAPI: init called, module count = %d\n",
! rtapi_usage_count);
return RTAPI_SUCCESS;
}
***************
*** 187,191 ****
{
rtapi_usage_count--;
! if ( rtapi_usage_count == 0 ) {
if (timer_running != 0) {
stop_rt_timer();
--- 224,228 ----
{
rtapi_usage_count--;
! if (rtapi_usage_count == 0) {
if (timer_running != 0) {
stop_rt_timer();
***************
*** 196,201 ****
}
/* MOD_DEC_USE_COUNT;*/
! rtapi_print_msg (RTAPI_MSG_INFO, "RTAPI: exit called, module count = %d\n",
! rtapi_usage_count );
return RTAPI_SUCCESS;
}
--- 233,238 ----
}
/* MOD_DEC_USE_COUNT;*/
! rtapi_print_msg(RTAPI_MSG_INFO, "RTAPI: exit called, module count = %d\n",
! rtapi_usage_count);
return RTAPI_SUCCESS;
}
***************
*** 213,222 ****
/* register a proc entry */
#ifdef CONFIG_PROC_FS
! create_proc_read_entry("rtai/rtapi", /* name */
! 0, /* default mode */
! NULL, /* parent dir */
! proc_read, /* function */
! NULL /* client data */
! );
#endif
/* clear all the resource arrays */
--- 250,263 ----
/* register a proc entry */
#ifdef CONFIG_PROC_FS
! rtapi_proc = create_proc_entry("rtapi", 0644, NULL);
!
! if (rtapi_proc != NULL) { /* It isn't a fatal error if create_proc fails */
! rtapi_proc->data = &proc_data; /* workspace for the input data */
! rtapi_proc->read_proc = proc_read_rtapi; /* The read function */
! rtapi_proc->write_proc = proc_write_rtapi; /* and the write function */
! rtapi_proc->owner = THIS_MODULE;
! } else {
! rtapi_print_msg(RTAPI_MSG_WARN, "Could not open /proc/rtapi\n");
! }
#endif
/* clear all the resource arrays */
***************
*** 262,268 ****
fifo_usage_count);
/* clean up leftover fifos */
! for ( n = 0 ; n < RTAPI_MAX_FIFOS ; n++ ) {
! if ( fifo_array[n] != NULL ) {
! rtapi_fifo_delete(fifo_array[n]);
}
}
--- 303,309 ----
fifo_usage_count);
/* clean up leftover fifos */
! for (n = 0; n < RTAPI_MAX_FIFOS; n++) {
! if (fifo_array[n] != NULL) {
! rtapi_fifo_delete(fifo_array[n]);
}
}
***************
*** 273,279 ****
sem_usage_count);
/* clean up leftover sems */
! for ( n = 0 ; n < RTAPI_MAX_SEMS ; n++ ) {
! if ( sem_array[n] != NULL ) {
! rtapi_sem_delete(sem_array[n]);
}
}
--- 314,320 ----
sem_usage_count);
/* clean up leftover sems */
! for (n = 0; n < RTAPI_MAX_SEMS; n++) {
! if (sem_array[n] != NULL) {
! rtapi_sem_delete(sem_array[n]);
}
}
***************
*** 284,290 ****
shmem_usage_count);
/* clean up leftover shmems */
! for ( n = 0 ; n < RTAPI_MAX_SHMEMS ; n++ ) {
! if ( shmem_array[n] != NULL ) {
! rtapi_shmem_delete(shmem_array[n]);
}
}
--- 325,331 ----
shmem_usage_count);
/* clean up leftover shmems */
! for (n = 0; n < RTAPI_MAX_SHMEMS; n++) {
! if (shmem_array[n] != NULL) {
! rtapi_shmem_delete(shmem_array[n]);
}
}
***************
*** 295,301 ****
task_usage_count);
/* clean up leftover tasks */
! for ( n = 0 ; n < RTAPI_MAX_TASKS ; n++ ) {
! if ( task_array[n] != NULL ) {
! rtapi_task_delete(task_array[n]);
}
}
--- 336,342 ----
task_usage_count);
/* clean up leftover tasks */
! for (n = 0; n < RTAPI_MAX_TASKS; n++) {
! if (task_array[n] != NULL) {
! rtapi_task_delete(task_array[n]);
}
}
***************
*** 314,318 ****
/* Remove proc dir entry */
#ifdef CONFIG_PROC_FS
! remove_proc_entry("rtai/rtapi", NULL);
#endif
rtapi_print_msg(RTAPI_MSG_INFO, "RTAPI: Exit complete\n");
--- 355,361 ----
/* Remove proc dir entry */
#ifdef CONFIG_PROC_FS
! if (rtapi_proc != NULL) {
! remove_proc_entry("rtai/rtapi", NULL);
! }
#endif
rtapi_print_msg(RTAPI_MSG_INFO, "RTAPI: Exit complete\n");
***************
*** 450,460 ****
}
/* make sure task is stopped */
! if ( task->started != 0 ) {
/* stop it */
rtapi_print_msg(RTAPI_MSG_WARN,
! "RTAPI: WARNING: tried to delete_task %p, while running\n",
! task);
retval = rtapi_task_stop(task);
! if ( retval != RTAPI_SUCCESS ) {
return retval;
}
--- 493,503 ----
}
/* make sure task is stopped */
! if (task->started != 0) {
/* stop it */
rtapi_print_msg(RTAPI_MSG_WARN,
! "RTAPI: WARNING: tried to delete_task %p, while running\n",
! task);
retval = rtapi_task_stop(task);
! if (retval != RTAPI_SUCCESS) {
return retval;
}
***************
*** 479,484 ****
unsigned long int stacksize,
unsigned long int period_nsec,
! unsigned long long when,
! unsigned char uses_fp)
{
int retval;
--- 522,526 ----
unsigned long int stacksize,
unsigned long int period_nsec,
! unsigned long long when, unsigned char uses_fp)
{
int retval;
***************
*** 517,521 ****
nano2count((RTIME) period_nsec));
if (retval != 0) {
! return RTAPI_FAIL;
}
} else {
--- 559,563 ----
nano2count((RTIME) period_nsec));
if (retval != 0) {
! return RTAPI_FAIL;
}
} else {
***************
*** 525,533 ****
nano2count((RTIME) period_nsec));
if (retval != 0) {
! return RTAPI_FAIL;
}
/* check to see if we got done in time */
! if (rt_get_time() > nano2count((RTIME)when)) {
! retval = RTAPI_LATE;
}
}
--- 567,575 ----
nano2count((RTIME) period_nsec));
if (retval != 0) {
! return RTAPI_FAIL;
}
/* check to see if we got done in time */
! if (rt_get_time() > nano2count((RTIME) when)) {
! retval = RTAPI_LATE;
}
}
***************
*** 643,651 ****
n = 0;
while (n < RTAPI_MAX_TASKS) {
! if ( task_array[n] != NULL ) {
! if ( &(task_array[n]->ostask) == ptr ) {
! /* found a match */
! *taskptr = task_array[n];
! return RTAPI_SUCCESS;
}
}
--- 685,693 ----
n = 0;
while (n < RTAPI_MAX_TASKS) {
! if (task_array[n] != NULL) {
! if (&(task_array[n]->ostask) == ptr) {
! /* found a match */
! *taskptr = task_array[n];
! return RTAPI_SUCCESS;
}
}
***************
*** 657,661 ****
int rtapi_shmem_new(int key, unsigned long int size,
! rtapi_shmem_handle * shmemptr)
{
rtapi_shmem_handle shmem;
--- 699,703 ----
int rtapi_shmem_new(int key, unsigned long int size,
! rtapi_shmem_handle * shmemptr)
{
rtapi_shmem_handle shmem;
***************
*** 696,701 ****
/* return handle to the caller */
*shmemptr = shmem;
! rtapi_print_msg(RTAPI_MSG_INFO, "RTAPI: new_shmem %p, key = %d, count = %d\n",
! shmem, key, shmem_usage_count);
return RTAPI_SUCCESS;
}
--- 738,744 ----
/* return handle to the caller */
*shmemptr = shmem;
! rtapi_print_msg(RTAPI_MSG_INFO,
! "RTAPI: new_shmem %p, key = %d, count = %d\n", shmem, key,
! shmem_usage_count);
return RTAPI_SUCCESS;
}
***************
*** 745,750 ****
/* decrement the usage counter */
shmem_usage_count--;
! rtapi_print_msg(RTAPI_MSG_INFO, "RTAPI: delete_shmem %p, count = %d\n", shmem,
! shmem_usage_count);
return RTAPI_SUCCESS;
}
--- 788,793 ----
/* decrement the usage counter */
shmem_usage_count--;
! rtapi_print_msg(RTAPI_MSG_INFO, "RTAPI: delete_shmem %p, count = %d\n",
! shmem, shmem_usage_count);
return RTAPI_SUCCESS;
}
|