summaryrefslogtreecommitdiffstats
path: root/runtime/docs/html/io_8c-source.html
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/docs/html/io_8c-source.html')
-rw-r--r--runtime/docs/html/io_8c-source.html176
1 files changed, 110 insertions, 66 deletions
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 @@
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.1 -->
-<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
-<h1>io.c</h1><a href="io_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="preprocessor">#ifndef _IO_C_</span>
-00002 <span class="preprocessor"></span><span class="preprocessor">#define _IO_C_</span>
+<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
+<h1>io.c</h1><a href="io_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment">00001 <span class="preprocessor">#ifndef _IO_C_ </span><span class="comment">/* -*- linux-c -*- */</span>
+00002 <span class="preprocessor">#define _IO_C_</span>
00003 <span class="preprocessor"></span>
-00004 <span class="comment">/* -*- linux-c -*- */</span><span class="comment"></span>
-00005 <span class="comment">/** @file io.c</span>
-00006 <span class="comment"> * @brief I/O functions</span>
-00007 <span class="comment"> */</span><span class="comment"></span>
-00008 <span class="comment">/** @addtogroup io I/O</span>
-00009 <span class="comment"> * I/O functions</span>
-00010 <span class="comment"> * @{</span>
-00011 <span class="comment"> */</span>
-00012 <span class="comment"></span>
-00013 <span class="comment">/** Logs Data.</span>
-00014 <span class="comment"> * This function is compatible with printk. In fact it currently</span>
-00015 <span class="comment"> * sends all output to vprintk, after sending "STP: ". This allows</span>
-00016 <span class="comment"> * us to easily detect SystemTap output in the log file. </span>
-00017 <span class="comment"> *</span>
-00018 <span class="comment"> * @param fmt A variable number of args.</span>
-00019 <span class="comment"> * @bug Lines are limited in length by printk buffer. If there is</span>
-00020 <span class="comment"> * no newline in the format string, then other syslog output could</span>
-00021 <span class="comment"> * get appended to the SystemTap line.</span>
-00022 <span class="comment"> * @todo Either deprecate or redefine this as a way to log debug or </span>
-00023 <span class="comment"> * status messages, separate from the normal program output.</span>
-00024 <span class="comment"> */</span>
-<a name="l00025"></a><a class="code" href="group__io.html#ga0">00025</a> <span class="keywordtype">void</span> <a class="code" href="group__io.html#ga0">dlog</a> (<span class="keyword">const</span> <span class="keywordtype">char</span> *fmt, ...)
-00026 {
-00027 va_list args;
-00028 printk(<span class="stringliteral">"STP: "</span>);
-00029 va_start(args, fmt);
-00030 vprintk(fmt, args);
-00031 va_end(args);
-00032 }
-00033 <span class="comment"></span>
-00034 <span class="comment">/** Prints to the trace buffer.</span>
-00035 <span class="comment"> * This function uses the same formatting as printk. It currently</span>
-00036 <span class="comment"> * writes to the system log. </span>
-00037 <span class="comment"> *</span>
-00038 <span class="comment"> * @param fmt A variable number of args.</span>
-00039 <span class="comment"> * @todo Needs replaced with something much faster that does not</span>
-00040 <span class="comment"> * use the system log.</span>
-00041 <span class="comment"> */</span>
-00042
-<a name="l00043"></a><a class="code" href="group__io.html#ga1">00043</a> <span class="keywordtype">void</span> <a class="code" href="group__io.html#ga1">_stp_print</a> (<span class="keyword">const</span> <span class="keywordtype">char</span> *fmt, ...)
-00044 {
-00045 va_list args;
-00046 va_start(args, fmt);
-00047 vprintk(fmt, args);
-00048 va_end(args);
-00049 }
-00050 <span class="comment"></span>
-00051 <span class="comment">/** Prints to the trace buffer.</span>
-00052 <span class="comment"> * This function will write a string to the trace buffer. It currently</span>
-00053 <span class="comment"> * writes to the system log. </span>
-00054 <span class="comment"> *</span>
-00055 <span class="comment"> * @param str String.</span>
-00056 <span class="comment"> * @todo Needs replaced with something much faster that does not</span>
-00057 <span class="comment"> * use the system log.</span>
-00058 <span class="comment"> */</span>
-00059
-<a name="l00060"></a><a class="code" href="group__io.html#ga2">00060</a> <span class="keywordtype">void</span> <a class="code" href="group__io.html#ga2">_stp_print_str</a> (<span class="keywordtype">char</span> *str)
-00061 {
-00062 printk (<span class="stringliteral">"%s"</span>, str);
-00063 }
-00064 <span class="comment"></span>
-00065 <span class="comment">/** @} */</span>
-00066 <span class="preprocessor">#endif </span><span class="comment">/* _IO_C_ */</span>
+00004 <span class="preprocessor">#include "relay-app.h"</span>
+00005 <span class="preprocessor">#include "print.c"</span>
+00006 <span class="comment"></span>
+00007 <span class="comment">/** @file io.c</span>
+00008 <span class="comment"> * @brief I/O functions</span>
+00009 <span class="comment"> */</span><span class="comment"></span>
+00010 <span class="comment">/** @addtogroup io I/O</span>
+00011 <span class="comment"> * I/O functions</span>
+00012 <span class="comment"> * @{</span>
+00013 <span class="comment"> */</span>
+00014 <span class="comment"></span>
+00015 <span class="comment">/** private buffer for _stp_log() */</span>
+<a name="l00016"></a><a class="code" href="group__io.html#ga9">00016</a> <span class="preprocessor">#define STP_LOG_BUF_LEN 2047</span>
+00017 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keywordtype">char</span> _stp_lbuf[NR_CPUS][<a class="code" href="group__io.html#ga9">STP_LOG_BUF_LEN</a> + 1];
+00018 <span class="comment"></span>
+00019 <span class="comment">/** Logs Data.</span>
+00020 <span class="comment"> * This function prints to the system log if stpd has not connected</span>
+00021 <span class="comment"> * yet. Otherwise it sends the message immediately to stpd.</span>
+00022 <span class="comment"> * @param fmt A variable number of args.</span>
+00023 <span class="comment"> * @note Lines are limited in length by printk buffer. If there is</span>
+00024 <span class="comment"> * no newline in the format string, then other syslog output could</span>
+00025 <span class="comment"> * get appended to the SystemTap line.</span>
+00026 <span class="comment"> * @todo Evaluate if this function is necessary.</span>
+00027 <span class="comment"> */</span>
+00028
+<a name="l00029"></a><a class="code" href="group__io.html#ga2">00029</a> <span class="keywordtype">void</span> <a class="code" href="group__io.html#ga2">_stp_log</a> (<span class="keyword">const</span> <span class="keywordtype">char</span> *fmt, ...)
+00030 {
+00031 <span class="keywordtype">int</span> num;
+00032 <span class="keywordtype">char</span> *buf = &amp;_stp_lbuf[smp_processor_id()][0];
+00033 va_list args;
+00034 va_start(args, fmt);
+00035 num = vscnprintf (buf, <a class="code" href="group__io.html#ga9">STP_LOG_BUF_LEN</a>, fmt, args);
+00036 va_end(args);
+00037 buf[num] = <span class="charliteral">'\0'</span>;
+00038
+00039 <span class="keywordflow">if</span> (app.logging)
+00040 send_reply (STP_REALTIME_DATA, buf, num + 1, stpd_pid);
+00041 <span class="keywordflow">else</span>
+00042 printk(<span class="stringliteral">"STP: %s"</span>, buf);
+00043 }
+00044
+00045 <span class="keyword">static</span> <span class="keywordtype">void</span> stpd_app_started(<span class="keywordtype">void</span>)
+00046 {
+00047 printk (<span class="stringliteral">"stpd has started.\n"</span>);
+00048 }
+00049
+00050 <span class="keyword">static</span> <span class="keywordtype">void</span> stpd_app_stopped(<span class="keywordtype">void</span>)
+00051 {
+00052 printk (<span class="stringliteral">"stpd has stopped.\n"</span>);
+00053 }
+00054
+00055 <span class="keyword">static</span> <span class="keywordtype">void</span> probe_exit(<span class="keywordtype">void</span>);
+00056
+00057 <span class="preprocessor">#include &lt;linux/delay.h&gt;</span>
+00058 <span class="keyword">static</span> <span class="keywordtype">int</span> stpd_command (<span class="keywordtype">int</span> type, <span class="keywordtype">void</span> *data)
+00059 {
+00060 <span class="keywordflow">if</span> (type == STP_EXIT) {
+00061 printk (<span class="stringliteral">"STP_EXIT received\n"</span>);
+00062 probe_exit();
+00063 <span class="preprocessor">#ifndef STP_NETLINK_ONLY</span>
+00064 <span class="preprocessor"></span> relay_flush(app.chan);
+00065 ssleep(2); <span class="comment">/* FIXME: time for data to be flushed */</span>
+00066 <span class="preprocessor">#endif</span>
+00067 <span class="preprocessor"></span> send_reply (STP_EXIT, __this_module.name, strlen(__this_module.name) + 1, stpd_pid);
+00068 <span class="keywordflow">return</span> 1;
+00069 }
+00070 <span class="keywordflow">return</span> 0;
+00071 }
+00072
+00073 <span class="comment">/*</span>
+00074 <span class="comment"> * relay-app callbacks</span>
+00075 <span class="comment"> */</span>
+00076 <span class="keyword">static</span> <span class="keyword">struct </span>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 <span class="comment"></span>
+00083 <span class="comment">/** Opens netlink and relayfs connections to stpd.</span>
+00084 <span class="comment"> * This must be called before any I/O is done, probably </span>
+00085 <span class="comment"> * at the start of module initialization.</span>
+00086 <span class="comment"> */</span>
+<a name="l00087"></a><a class="code" href="group__io.html#ga7">00087</a> <span class="keywordtype">int</span> <a class="code" href="group__io.html#ga7">_stp_netlink_open</a>(<span class="keywordtype">void</span>)
+00088 {
+00089 <span class="keywordflow">if</span> (init_relay_app(<span class="stringliteral">"stpd"</span>, <span class="stringliteral">"cpu"</span>, &amp;stp_callbacks)) {
+00090 printk (<span class="stringliteral">"STP: couldn't init relay app\n"</span>);
+00091 <span class="keywordflow">return</span> -1;
+00092 }
+00093 <span class="keywordflow">return</span> 0;
+00094 }
+00095 <span class="comment"></span>
+00096 <span class="comment">/** Closes netlink and relayfs connections to stpd.</span>
+00097 <span class="comment"> * This must be called after all I/O is done, probably </span>
+00098 <span class="comment"> * at the end of module cleanup.</span>
+00099 <span class="comment"> * @returns 0 on success. -1 if there is a problem establishing</span>
+00100 <span class="comment"> * a connection.</span>
+00101 <span class="comment"> */</span>
+00102
+<a name="l00103"></a><a class="code" href="group__io.html#ga8">00103</a> <span class="keywordtype">void</span> <a class="code" href="group__io.html#ga8">_stp_netlink_close</a> (<span class="keywordtype">void</span>)
+00104 {
+00105 send_reply (STP_DONE, NULL, 0, stpd_pid);
+00106 close_relay_app();
+00107 }
+00108 <span class="comment"></span>
+00109 <span class="comment">/** @} */</span>
+00110 <span class="preprocessor">#endif </span><span class="comment">/* _IO_C_ */</span>
</pre></div></body></html>