From 655ee2825121e149a9976e562946892efb20aea1 Mon Sep 17 00:00:00 2001 From: hunt Date: Thu, 7 Apr 2005 21:48:47 +0000 Subject: *** empty log message *** --- runtime/docs/html/io_8c-source.html | 176 ++++++++++++++++++++++-------------- 1 file changed, 110 insertions(+), 66 deletions(-) (limited to 'runtime/docs/html/io_8c-source.html') diff --git a/runtime/docs/html/io_8c-source.html b/runtime/docs/html/io_8c-source.html index 064ef3f8..82721232 100644 --- a/runtime/docs/html/io_8c-source.html +++ b/runtime/docs/html/io_8c-source.html @@ -4,71 +4,115 @@ -
Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages
-

io.c

Go to the documentation of this file.
00001 #ifndef _IO_C_
-00002 #define _IO_C_
+
+

io.c

Go to the documentation of this file.
00001 #ifndef _IO_C_ /* -*- linux-c -*- */
+00002 #define _IO_C_
 00003 
-00004 /* -*- linux-c -*- */
-00005 /** @file io.c
-00006  * @brief I/O functions
-00007  */
-00008 /** @addtogroup io I/O
-00009  * I/O functions
-00010  * @{
-00011  */
-00012 
-00013 /** Logs Data.
-00014  * This function is compatible with printk.  In fact it currently
-00015  * sends all output to vprintk, after sending "STP: ". This allows
-00016  * us to easily detect SystemTap output in the log file. 
-00017  *
-00018  * @param fmt A variable number of args.
-00019  * @bug Lines are limited in length by printk buffer. If there is
-00020  * no newline in the format string, then other syslog output could
-00021  * get appended to the SystemTap line.
-00022  * @todo Either deprecate or redefine this as a way to log debug or 
-00023  * status messages, separate from the normal program output.
-00024  */
-00025 void dlog (const char *fmt, ...)
-00026 {
-00027   va_list args;
-00028   printk("STP: ");
-00029   va_start(args, fmt);
-00030   vprintk(fmt, args);
-00031   va_end(args);
-00032 }
-00033 
-00034 /** Prints to the trace buffer.
-00035  * This function uses the same formatting as printk.  It currently
-00036  * writes to the system log. 
-00037  *
-00038  * @param fmt A variable number of args.
-00039  * @todo Needs replaced with something much faster that does not
-00040  * use the system log.
-00041  */
-00042 
-00043 void _stp_print (const char *fmt, ...)
-00044 {
-00045   va_list args;
-00046   va_start(args, fmt);
-00047   vprintk(fmt, args);
-00048   va_end(args);
-00049 }
-00050 
-00051 /** Prints to the trace buffer.
-00052  * This function will write a string to the trace buffer.  It currently
-00053  * writes to the system log. 
-00054  *
-00055  * @param str String.
-00056  * @todo Needs replaced with something much faster that does not
-00057  * use the system log.
-00058  */
-00059 
-00060 void _stp_print_str (char *str)
-00061 {
-00062   printk ("%s", str);
-00063 }
-00064 
-00065 /** @} */
-00066 #endif /* _IO_C_ */
+00004 #include "relay-app.h"
+00005 #include "print.c"
+00006 
+00007 /** @file io.c
+00008  * @brief I/O functions
+00009  */
+00010 /** @addtogroup io I/O
+00011  * I/O functions
+00012  * @{
+00013  */
+00014 
+00015 /** private buffer for _stp_log() */
+00016 #define STP_LOG_BUF_LEN 2047
+00017 static char _stp_lbuf[NR_CPUS][STP_LOG_BUF_LEN + 1];
+00018 
+00019 /** Logs Data.
+00020  * This function prints to the system log if stpd has not connected
+00021  * yet.  Otherwise it sends the message immediately to stpd.
+00022  * @param fmt A variable number of args.
+00023  * @note Lines are limited in length by printk buffer. If there is
+00024  * no newline in the format string, then other syslog output could
+00025  * get appended to the SystemTap line.
+00026  * @todo Evaluate if this function is necessary.
+00027  */
+00028 
+00029 void _stp_log (const char *fmt, ...)
+00030 {
+00031         int num;
+00032         char *buf = &_stp_lbuf[smp_processor_id()][0];
+00033         va_list args;
+00034         va_start(args, fmt);
+00035         num = vscnprintf (buf, STP_LOG_BUF_LEN, fmt, args);
+00036         va_end(args);
+00037         buf[num] = '\0';
+00038 
+00039         if (app.logging)
+00040                 send_reply (STP_REALTIME_DATA, buf, num + 1, stpd_pid);
+00041         else
+00042                 printk("STP: %s", buf);
+00043 }
+00044 
+00045 static void stpd_app_started(void)
+00046 {
+00047         printk ("stpd has started.\n");
+00048 }
+00049 
+00050 static void stpd_app_stopped(void)
+00051 {
+00052         printk ("stpd has stopped.\n");
+00053 }
+00054 
+00055 static void probe_exit(void);
+00056 
+00057 #include <linux/delay.h>
+00058 static int stpd_command (int type, void *data)
+00059 {
+00060         if (type == STP_EXIT) {
+00061                 printk ("STP_EXIT received\n");
+00062                 probe_exit();
+00063 #ifndef STP_NETLINK_ONLY
+00064                 relay_flush(app.chan);
+00065                 ssleep(2); /* FIXME: time for data to be flushed */
+00066 #endif
+00067                 send_reply (STP_EXIT, __this_module.name, strlen(__this_module.name) + 1, stpd_pid);
+00068                 return 1;
+00069         }
+00070         return 0;
+00071 }
+00072 
+00073 /*
+00074  * relay-app callbacks
+00075  */
+00076 static struct relay_app_callbacks stp_callbacks =
+00077 {
+00078         .app_started = stpd_app_started,
+00079         .app_stopped = stpd_app_stopped,
+00080         .user_command = stpd_command
+00081 };
+00082 
+00083 /** Opens netlink and relayfs connections to stpd.
+00084  * This must be called before any I/O is done, probably 
+00085  * at the start of module initialization.
+00086  */
+00087 int _stp_netlink_open(void)
+00088 {
+00089         if (init_relay_app("stpd", "cpu", &stp_callbacks)) {
+00090                 printk ("STP: couldn't init relay app\n");
+00091                 return -1;
+00092         }
+00093         return 0;
+00094 }
+00095 
+00096 /** Closes netlink and relayfs connections to stpd.
+00097  * This must be called after all I/O is done, probably 
+00098  * at the end of module cleanup.
+00099  * @returns 0 on success.  -1 if there is a problem establishing
+00100  * a connection.
+00101  */
+00102         
+00103 void _stp_netlink_close (void)
+00104 {
+00105         send_reply (STP_DONE, NULL, 0, stpd_pid);
+00106         close_relay_app();
+00107 }
+00108 
+00109 /** @} */
+00110 #endif /* _IO_C_ */
 
-- cgit