|
From: <pa...@us...> - 2003-08-22 04:49:20
|
Update of /cvsroot/emc/rtapi/src/rtapi In directory sc8-pr-cvs1:/tmp/cvs-serv5240 Modified Files: rtapi.h rtapi_proc.h Log Message: Sorry John, but I believe the proc_fs macros to be important enough to go in the main rtapi header Index: rtapi.h =================================================================== RCS file: /cvsroot/emc/rtapi/src/rtapi/rtapi.h,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** rtapi.h 20 Aug 2003 03:16:21 -0000 1.26 --- rtapi.h 20 Aug 2003 19:46:38 -0000 1.27 *************** *** 485,487 **** --- 485,547 ---- extern unsigned char rtapi_inb(unsigned int port); + /*********************************************************************** + * PROC_FS MACROS * + ************************************************************************/ + #ifdef CONFIG_PROC_FS + /* Before using these macros, you MUST include linux/proc_fs.h + pior to rtapi.h */ + + /* proc print macros - Contributed by: Erwin Rol (er...@mu...) + and shamelessly ripped from rtai_proc_fs.h, part of the RTAI + project. See http://www.rtai.org for more details. + + macro that holds the local variables that + we use in the PROC_PRINT_* macros. We have + this macro so we can add variables with out + changing the users of this macro, of course + only when the names don't colide! + */ + + #define PROC_PRINT_VARS \ + off_t pos = 0; \ + off_t begin = 0; \ + int len = 0 /* no ";" */ + + /* macro that prints in the procfs read buffer. + this macro expects the function arguments to be + named as follows. + static int FOO(char *page, char **start, + off_t off, int count, int *eof, void *data) */ + + #define PROC_PRINT(fmt,args...) \ + len += sprintf(page + len , fmt, ##args); \ + pos += len; \ + if(pos < off) { \ + len = 0; \ + begin = pos; \ + } \ + if(pos > off + count) \ + goto done; + + /* macro to leave the read function from another + place than at the end. */ + #define PROC_PRINT_RETURN \ + *eof = 1; \ + goto done // no ";" + + /* macro that should only used once at the end of the + read function, to return from another place in the + read function use the PROC_PRINT_RETURN macro. */ + #define PROC_PRINT_DONE \ + *eof = 1; \ + done: \ + *start = page + (off - begin); \ + len -= (off - begin); \ + if(len > count) \ + len = count; \ + if(len < 0) \ + len = 0; \ + return len // no ";" + + #endif /* RTAPI_H */ Index: rtapi_proc.h =================================================================== RCS file: /cvsroot/emc/rtapi/src/rtapi/rtapi_proc.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** rtapi_proc.h 20 Aug 2003 03:16:21 -0000 1.1 --- rtapi_proc.h 20 Aug 2003 19:46:38 -0000 1.2 *************** *** 56,120 **** #include <linux/proc_fs.h> - #ifdef CONFIG_PROC_FS - - /* proc print macros - Contributed by: Erwin Rol (er...@mu...) - and shamelessly ripped from rtai_proc_fs.h, part of the RTAI - project. See http://www.rtai.org for more details. - - macro that holds the local variables that - we use in the PROC_PRINT_* macros. We have - this macro so we can add variables with out - changing the users of this macro, of course - only when the names don't colide! - */ - - #define PROC_PRINT_VARS \ - off_t pos = 0; \ - off_t begin = 0; \ - int len = 0 /* no ";" */ - - /* macro that prints in the procfs read buffer. - this macro expects the function arguments to be - named as follows. - static int FOO(char *page, char **start, - off_t off, int count, int *eof, void *data) */ - - #define PROC_PRINT(fmt,args...) \ - len += sprintf(page + len , fmt, ##args); \ - pos += len; \ - if(pos < off) { \ - len = 0; \ - begin = pos; \ - } \ - if(pos > off + count) \ - goto done; - - /* macro to leave the read function from another - place than at the end. */ - #define PROC_PRINT_RETURN \ - *eof = 1; \ - goto done // no ";" - - /* macro that should only used once at the end of the - read function, to return from another place in the - read function use the PROC_PRINT_RETURN macro. */ - #define PROC_PRINT_DONE \ - *eof = 1; \ - done: \ - *start = page + (off - begin); \ - len -= (off - begin); \ - if(len > count) \ - len = count; \ - if(len < 0) \ - len = 0; \ - return len // no ";" - - /* Internal function for the proc_fs system. */ ! /* 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... */ --- 56,66 ---- #include <linux/proc_fs.h> /* Internal function for the proc_fs system. */ ! /* The proc file system is available in 2.2 and 2.4 kernels with ! minor differences - The 2.4 kernels have a usefull helper function ! for creating the proc_fs entries. ! It is unlikely that the following implimentaion will work on a 2.0 ! series kernel.. */ *************** *** 339,343 **** return -1; } ! // rtapi_dir->owner = THIS_MODULE; /* create read only file "/proc/rtapi/status" */ status_file = create_proc_entry("status", S_IRUGO, rtapi_dir); --- 285,289 ---- return -1; } ! /* create read only file "/proc/rtapi/status" */ status_file = create_proc_entry("status", S_IRUGO, rtapi_dir); *************** *** 346,349 **** --- 292,296 ---- } status_file->read_proc = proc_read_status; + /* create read only file "/proc/rtapi/tasks" */ tasks_file = create_proc_entry("tasks", S_IRUGO, rtapi_dir); *************** *** 352,355 **** --- 299,303 ---- } tasks_file->read_proc = proc_read_tasks; + /* create read only file "/proc/rtapi/shmem" */ shmem_file = create_proc_entry("shmem", S_IRUGO, rtapi_dir); *************** *** 358,361 **** --- 306,310 ---- } shmem_file->read_proc = proc_read_shmem; + /* create read only file "/proc/rtapi/sems" */ sems_file = create_proc_entry("sems", S_IRUGO, rtapi_dir); *************** *** 364,367 **** --- 313,317 ---- } sems_file->read_proc = proc_read_sems; + /* create read only file "/proc/rtapi/fifos" */ fifos_file = create_proc_entry("fifos", S_IRUGO, rtapi_dir); *************** *** 370,373 **** --- 320,324 ---- } fifos_file->read_proc = proc_read_fifos; + /* create read/write file "/proc/rtapi/debug" */ debug_file = create_proc_entry("debug", S_IRUGO | S_IWUGO, rtapi_dir); *************** *** 375,379 **** return -1; } - // debug_file->owner = THIS_MODULE; debug_file->data = NULL; debug_file->read_proc = proc_read_debug; --- 326,329 ---- |