blob: ebeae48328e14e78d7da4aa87c5ecb1a78d5f927 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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}
|