linux/Documentation/pti/pti_intel_mid.txt
<<
" /spa v2 /formv2 a " href="../linux+v3.7.4/Documentan n /on /on _intel_mid.txt">" img src="../.stan c/gfx/right.png" alt=">>">" /spa v2" spa class="lxr_search">" " input typvalhidden" namvalnavtarget" n n val">" input typvaltext" namvalsearch" idalsearch">" butt2iotypvalsubmit">Search" Prefs2 /a>" /spa v2 /divv2 form acn n ="ajax+*" method="post" onsubmit="return false;">" input typvalhidden" namvalajax_lookup" idalajax_lookup" n n val">" /formv2" div class="headingbott2m">" div idalfile_contents"v
 
1 /a>The Intel MID PTI project is HW implemented in Intel At2m

 
2 /a>system-on-a-chip designs based 2iothe Parallel Trace

 
3 /a>Interface for MIPI P1149.7 cJTAG standard.  The kernel solun n 

 
4 /a>for this platform involvesothe following files:

 
5 /a>"
 
6 /a>./include/linux/on .h"
 
7 /a>./drivers/.../n_tracesink.h"
 
8 /a>./drivers/.../n_tracerouter.c"
 
9 /a>./drivers/.../n_tracesink.c"
 3.8.a>./drivers/.../on .c"
 11 /a>"
 12 /a>on .c is the driver that enables n rious debugging features"
 13 /a>popular 2ioplatforms from certain mobile manufacturers."
 14 /a>n_tracerouter.c and n_tracesink.c allow extra system informan n  to"
 15 /a>be collected and routed to the on  driver, such as trace

 16 /a>debugging data from a modem.  Although n_tracerouter

 17 /a>and n_tracesink are a part of the complete PTI solun n ,

 18 /a>these two line disciplines ca  work separately from

 19 /a>on .c and route any data stream from one /dev/tty node

 2.8.a>to another /dev/tty node via kernel-space.  This provides"
 21 /a>a stable, reliable connecn n  that will not break unless"
 22 /a>the user-space applican n  shuts down (plus avoids"
 23 /a>kernel->user->kernel context switch overheads of routing"
 24 /a>data)."
 25 /a>"
 26 /a>An example debugging usage for this driver system:

 27 /a>
 
*Hook /dev/ttyPTI0 to syslogd.  Opening this port will also start

 28 /a>
 
 a console device to further capture debugging messages to PTI."
 29 /a>
 
*Hook /dev/ttyPTI1 to modem debugging data to write to PTI HW."
 30 /a>
 
 This is where n_tracerouter and n_tracesink are used."
 31 /a>
 
*Hook /dev/on  to a user-level debugging applican n  for writing"
 32 /a>
 
 to PTI HW."
 33 /a>
 
*Use mipi_* Kernel Driver API in other device drivers for"
 34 /a>
 
 debugging to PTI by first requesting a PTI write address via"
 35 /a>
 
 mipi_request_masterchannel(1)."
 36 /a>"
 37 /a>Below is example pseudo-code n  how a 'privileged' applican n "
 38 /a>ca  hook up n_tracerouter and n_tracesink to any tty n "
 39 /a>a system.  'Privileged' means the applican n  has enough

 40 /a>privileges to successfully manipulate the ldisc drivers

 41 /a>but is not just blindly executing as 'root'. Keep in mind

 42 /a>the use of ioctl(,TIOCSETD,) is not specific to the n_tracerouter

 43 /a>and n_tracesink line discpline drivers but is a generic"
 44 /a>operan n  for a program to use a line discpline driver"
 45 /a>n  a tty port other thaiothe default n_tty."
 46 /a>"
 47 /a>/////////// To hook up n_tracerouter and n_tracesink /////////"
 48 /a>"
 49 /a>// Note that n_tracerouter depends on n_tracesink.

 50 /a>#include <errno.h>

 51 /a>#define ONE_TTY "/dev/ttyOne"

 52 /a>#define TWO_TTY "/dev/ttyTwo"

 53 /a>"
 54 /a>// needed global to hand onto ldisc connecn n "
 55 /a>stan c int g_fd_source = -1;

 56 /a>stan c int g_fd_sink  = -1;

 57 /a>"
 58 /a>// these two vars used to grab LDISC n n vs from loaded ldisc drivers

 59 /a>// in OS.  Look at /proc/tty/ldiscs to getothe right numbers from

 60 /a>// the ldiscs loaded iiothe system.

 61 /a>int source_ldisc_num, sink_ldisc_num = -1;

 62 /a>int retn n;

 63 /a>"
 64 /a>g_fd_source = open(ONE_TTY, O_RDWR); // must be R/W"
 65 /a>g_fd_sink   = open(TWO_TTY, O_RDWR); // must be R/W"
 66 /a>"
 67 /a>if (g_fd_source <= 0) || (g_fd_sink <= 0) {"
 68 /a>
 
// doubt you'll want to use these exact error lines of code

 69 /a>
 
printf("Error on open(). errno: %d\n",errno);

 70 /a>
 
return errno;

 71 /a>}

 72 /a>"
 73 /a>retn n = ioctl(g_fd_sink, TIOCSETD, &sink_ldisc_num);

 74 /a>if (retn n < 0) {"
 75 /a>
 
printf("Error on ioctl().  errno: %d\n", errno);

 76 /a>
 
return errno;

 77 /a>}

 78 /a>"
 79 /a>retn n = ioctl(g_fd_source, TIOCSETD, &source_ldisc_num);

 80 /a>if (retn n < 0) {"
 81 /a>
 
printf("Error on ioctl().  errno: %d\n", errno);

 82 /a>
 
return errno;

 83 /a>}

 84 /a>"
 85 /a>/////////// To disconnecn n_tracerouter and n_tracesink ////////"
 86 /a>"
 87 /a>// First make sure data through the ldiscs has stopped."
 88 /a>"
 89 /a>// Second, disconnecn ldiscs.  This provides a"
 90 /a>// little cleaner shutdown n  tty stack.

 91 /a>sink_ldisc_num = 0;

 92 /a>source_ldisc_num = 0;

 93 /a>ioctl(g_fd_uart, TIOCSETD, &sink_ldisc_num);

 94 /a>ioctl(g_fd_gadget, TIOCSETD, &source_ldisc_num);

 95 /a>"
 96 /a>// Three, program closes connecn n , and cleanup:

 97 /a>close(g_fd_uart);

 98 /a>close(g_fd_gadget);

 99 /a>g_fd_uart = g_fd_gadget = NULL;

100 /a>
The origin n LXR software by the LXR community /a>, this experimental vers n by lxr@linux.no8.a>. /divv2 div class="subfooter"> lxr.linux.no kindly hosted by Redpill Linpro AS /a>, provider of Linux consulting and operan n s services since 1995. /divv2 /bodyv2 /htmlv2