base/trace/trace.c

Go to the documentation of this file.
00001 /* 00002 * Copyright (C) 2000 Karim Yaghmour <karym@opersys.com> 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License as 00006 * published by the Free Software Foundation; either version 2 of the 00007 * License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00019 /***************************************************************** 00020 * File : rtai_tracer.c 00021 * Description : 00022 * Contains the code for the RTAI tracing driver. 00023 * Author : 00024 * karym@opersys.com 00025 * Date : 00026 * 16/05/00, Initial typing. 00027 * Note : 00028 *****************************************************************/ 00029 00030 #include <linux/module.h> 00031 #include <linux/kernel.h> 00032 #include <linux/errno.h> 00033 #include <rtai_trace.h> 00034 00035 MODULE_LICENSE("GPL"); 00036 00037 /* Local variables */ 00038 static int rt_tracer_registered = 0; /* Is there a tracer registered */ 00039 tracer_call rt_tracer = NULL; /* The registered tracer */ 00040 00041 /**************************************************** 00042 * Function: rt_register_tracer() 00043 * Description: 00044 * Register the tracer to RTAI 00045 * Return values : 00046 * 0, all is OK 00047 * -1, tracer already registered 00048 ****************************************************/ 00049 int rt_register_tracer(tracer_call pmTraceFunction) 00050 { 00051 /* Is there a tracer already registered */ 00052 if(rt_tracer_registered == 1) 00053 return -1; 00054 00055 /* Set the tracer to the one being passed by the caller */ 00056 rt_tracer = pmTraceFunction; 00057 00058 /* Remember that a tracer is now registered */ 00059 rt_tracer_registered = 1; 00060 00061 /* Tell the caller that everything went fine */ 00062 return 0; 00063 } 00064 00065 /*************************************************** 00066 * Function: rt_unregister_tracer() 00067 * Description: 00068 * Unregister the currently registered tracer. 00069 * Return values : 00070 * 0, all is OK 00071 * -ENOMEDIUM, there isn't a registered tracer 00072 * -ENXIO, unregestering wrong tracer 00073 ***************************************************/ 00074 int rt_unregister_tracer(tracer_call pmTraceFunction) 00075 { 00076 /* Is there a tracer already registered */ 00077 if(rt_tracer_registered == 0) 00078 /* Nothing to unregister */ 00079 return -ENOMEDIUM; 00080 00081 /* Is it the tracer that was registered */ 00082 if(rt_tracer == pmTraceFunction) 00083 /* There isn't any tracer in here */ 00084 rt_tracer_registered = 0; 00085 else 00086 return -ENXIO; 00087 00088 /* Reset tracer function */ 00089 rt_tracer = NULL; 00090 00091 /* Reset the registered flag */ 00092 rt_tracer_registered = 0; 00093 00094 /* Tell the caller that everything went OK */ 00095 return 0; 00096 } 00097 00098 /******************************************************* 00099 * Function: rt_trace_event() 00100 * Description: 00101 * Trace an event 00102 * Parameters : 00103 * pmEventID, the event's ID (check out rtai_trace.h) 00104 * pmEventStruct, the structure describing the event 00105 * Return values : 00106 * 0, all is OK 00107 * -ENOMEDIUM, there isn't a registered tracer 00108 * -EBUSY, tracing hasn't started yet 00109 *******************************************************/ 00110 int rt_trace_event(uint8_t pmEventID, 00111 void* pmEventStruct) 00112 { 00113 /* Is there a tracer registered */ 00114 if(rt_tracer_registered != 1) 00115 return -ENOMEDIUM; 00116 00117 /* Call the tracer */ 00118 return (rt_tracer(pmEventID, pmEventStruct)); 00119 } 00120 00121 /******************************************************* 00122 * Function: __rtai_trace_init() 00123 * Description: 00124 * Initializes the RTAI trace module 00125 * Parameters : 00126 * NONE 00127 * Return values : 00128 * 0, all is OK 00129 *******************************************************/ 00130 int __rtai_trace_init(void) 00131 { 00132 return 0; 00133 } 00134 00135 /******************************************************* 00136 * Function: __rtai_trace_exit() 00137 * Description: 00138 * Cleans-up the RTAI trace module 00139 * Parameters : 00140 * NONE 00141 * Return values : 00142 * NONE 00143 *******************************************************/ 00144 void __rtai_trace_exit(void) 00145 { 00146 } 00147 00148 module_init(__rtai_trace_init); 00149 module_exit(__rtai_trace_exit);

Generated on Thu Nov 20 11:49:53 2008 for RTAI API by doxygen 1.3.8