From bf7bd4abcdd1e9ae1030c7a9dfae70c35791d771 Mon Sep 17 00:00:00 2001
From: Holger Dengler <dengler@linutronix.de>
Date: Fri, 11 Jan 2019 08:35:40 +0100
Subject: linux-basic: Add Userspace-to-Kernel API slides

Signed-off-by: Holger Dengler <dengler@linutronix.de>
---
 linux-basics/api/frm_devicenodes.tex | 91 ++++++++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)
 create mode 100644 linux-basics/api/frm_devicenodes.tex

(limited to 'linux-basics/api/frm_devicenodes.tex')

diff --git a/linux-basics/api/frm_devicenodes.tex b/linux-basics/api/frm_devicenodes.tex
new file mode 100644
index 0000000..ebeae48
--- /dev/null
+++ b/linux-basics/api/frm_devicenodes.tex
@@ -0,0 +1,91 @@
+\subsubsection{Device Nodes}
+% ----------------------------
+\begin{frame}[fragile]
+\frametitle{Basics}
+\begin{itemize}
+\item Reference to Device Drivers and its Instances
+\item Re-use file-syscalls to extend the System API
+\item File-syscall redirection to Device Driver
+\end{itemize}
+\begin{beamerboxesrounded}[shadow=true]{Access to HW by Userspace applications}
+\begin{scriptsize}
+\begin{verbatim}
+/* open file (permissions will be checked)*/
+fd = open("/dev/ttyS0, flags);
+
+/* read data from HW */
+read(fd, buf, buf_len);
+
+/* write data to HW */
+write(fd, buf, buf_len);
+
+/* close file after usage
+close(fd);
+\end{verbatim}
+\end{scriptsize}
+\end{beamerboxesrounded}
+\end{frame}
+% Device nodes are the main interfaces to device drivers. The device nodes
+% are special files, which appears in a filesytem. Userspace application can
+% interact with with the hardware via these device nodes. Instead of
+% creating additional syscalls for accessing the hardware, the device node
+% concept re-uses the file systemcalls read(), write(), and ioctl().
+
+% ----------------------------
+\begin{frame}[fragile]
+\frametitle{Special File}
+\begin{itemize}
+\item Special Files (inodes)
+\item File Type: Block or Character
+\item Major Number
+ \begin{itemize}
+ \item Reference to Device Driver
+ \item Handled by common Kernel code
+ \end{itemize}
+\item Minor Number
+ \begin{itemize}
+ \item Reference to Device Instance
+ \item Handled by Device Driver
+ \end{itemize}
+\item Permissions manage access to HW
+\end{itemize}
+\end{frame}
+% There are two types of devide nodes, block and character devices. Each
+% device node has a major and minor number. The type and major number is
+% used to find the right driver in the right subsystem for the hardware
+% access. The minor number is used by the driver for handling multiple
+% instances. This allows to handle multiple instances of the same controller
+% type with one single device driver implementation.
+
+% ----------------------------
+\begin{frame}[fragile]
+\frametitle{Special File: Diagram}
+\begin{figure}[h]
+\centering
+\includegraphics[width=8cm]{images/devicenode.png}
+\end{figure}
+\end{frame}
+
+% ----------------------------
+\begin{frame}[fragile]
+\frametitle{Manage Special Files}
+\begin{itemize}
+\item manually: \texttt{mknod /dev/ttyS0 c 4 65}
+\item hotplug: userspace /dev (udev)
+\item kernel: \texttt{mount -t devtmpfs none /dev}
+\end{itemize}
+\end{frame}
+% The device nodes can be created manually with the command "mknod", or by
+% the hotplug mechanism userspace /dev (udev). The kernel also provides a
+% pseudo fs "devtmpfs" with device nodes for all existing deivces. This is
+% very useful for small devices, where it's too complex to setup udev and
+% its rules.
+
+% ----------------------------
+\subsubsection*{}
+\begin{frame}
+\frametitle{Resources}
+\begin{itemize}
+\item \href{http://man7.org/linux/man-pages/man7/udev.7.html}{man 7 udev}
+\end{itemize}
+\end{frame}
-- 
cgit v1.2.3

