\input{configpres}

\title{Character Device Driver Interaction}
\maketitle

\subsection{Character Devices}

\begin{frame}
\frametitle{Syscall Interface}
\begin{center}
\includegraphics[width=5cm]{images/syscall.png}
\end{center}
\end{frame}

\begin{frame}
\frametitle{Character Device Driver Interaction}
\begin{itemize}
\item open
\item release
\item read
\item write
\item fsync
\item llseek
\item poll
\item mmap
\item ioctl
\item \dots
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{open}
\begin{itemize}
\item Prototype
\begin{tiny}
\begin{lstlisting}[frame=trBL]
int (*open) (struct inode *, struct file *);
\end{lstlisting}
\end{tiny}
\item Description
\begin{description}
\item [open:] The first operation on a character device. The function implementation is optional. If not implemented, it will always succeed and the driver is not informed of the open.
\end{description}
\item Data Flow
\end{itemize}
\begin{center}
\includegraphics[width=5cm]{images/open.png}
\end{center}
\end{frame}

\begin{frame}[fragile]
\frametitle{release}
\begin{itemize}
\item Prototype
\begin{tiny}
\begin{lstlisting}[frame=trBL]
int (*release) (struct inode *, struct file *);
\end{lstlisting}
\end{tiny}
\item Description
\begin{description}
\item [release:] The last operation on a character device. The function implementation is optional. If not implemented, it will always succeed and the driver is not informed of the release.
\end{description}
\item Data Flow
\end{itemize}
\begin{center}
\includegraphics[width=5cm]{images/release.png}
\end{center}
\end{frame}

\begin{frame}[fragile]
\frametitle{read}
\begin{itemize}
\item Prototype
\begin{tiny}
\begin{lstlisting}[frame=trBL]
ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
\end{lstlisting}
\end{tiny}
\item Description
\begin{description}
\item [read:] Read data from the character device. The data is copied to userspace using the \emph{copy\_to\_user} function.
\end{description}
\item Data Flow
\end{itemize}
\begin{center}
\includegraphics[width=5cm]{images/read.png}
\end{center}
\end{frame}

\begin{frame}[fragile]
\frametitle{write}
\begin{itemize}
\item Prototype
\begin{tiny}
\begin{lstlisting}[frame=trBL]
ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
\end{lstlisting}
\end{tiny}
\item Description
\begin{description}
\item [write:] Write data to the character device. The data is copied from usersapce using the \emph{copy\_from\_user} function.
\end{description}
\item Data Flow
\end{itemize}
\begin{center}
\includegraphics[width=5cm]{images/write.png}
\end{center}
\end{frame}

\begin{frame}[fragile]
\frametitle{fsync}
\begin{itemize}
\item Prototype
\begin{tiny}
\begin{lstlisting}[frame=trBL]
int (*fsync) (struct file *, struct dentry *, int datasync);
\end{lstlisting}
\end{tiny}
\item Description
\begin{description}
\item [fsync:] Flush all cached data to the device.
\end{description}
\item Data Flow
\end{itemize}
\begin{center}
\includegraphics[width=5cm]{images/fsync.png}
\end{center}
\end{frame}

\begin{frame}[fragile]
\frametitle{llseek}
\begin{itemize}
\item Prototype
\begin{tiny}
\begin{lstlisting}[frame=trBL]
loff_t (*llseek) (struct file *, loff_t, int);
\end{lstlisting}
\end{tiny}
\item Description
\begin{description}
\item [llseek:] Set the current position for read and write access.
\end{description}
\item Data Flow
\end{itemize}
\begin{center}
\includegraphics[width=5cm]{images/llseek.png}
\end{center}
\end{frame}

\begin{frame}[fragile]
\frametitle{poll}
\begin{itemize}
\item Prototype
\begin{tiny}
\begin{lstlisting}[frame=trBL]
unsigned int (*poll) (struct file *, struct poll_table_struct *);
\end{lstlisting}
\end{tiny}
\item Description
\begin{description}
\item [poll:] Implements poll, epoll, and select functionality. If it is not implemented, blocking I/O is not possible.
\end{description}
\item Data Flow
\end{itemize}
\begin{center}
\includegraphics[width=5cm]{images/poll.png}
\end{center}
\end{frame}

\begin{frame}[fragile]
\frametitle{mmap}
\begin{itemize}
\item Prototype
\begin{tiny}
\begin{lstlisting}[frame=trBL]
int (*mmap) (struct file *, struct vm_area_struct *);
\end{lstlisting}
\end{tiny}
\item Description
\begin{description}
\item [mmap:] Creates a mapping of the device memory for the userspace process context.
\end{description}
\item Data Flow
\end{itemize}
\begin{center}
\includegraphics[width=5cm]{images/mmap.png}
\end{center}
\end{frame}

\begin{frame}[fragile]
\frametitle{ioctl}
\begin{itemize}
\item Prototype
\begin{tiny}
\begin{lstlisting}[frame=trBL]
int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
\end{lstlisting}
\end{tiny}
\item Description
\begin{description}
\item [ioctl:] Implements device-specific commands. This should be avoided since better, standard interfaces for most cases already exist.
\end{description}
\item Data Flow
\end{itemize}
\begin{center}
\includegraphics[width=5cm]{images/ioctl.png}
\end{center}
\end{frame}

\input{tailpres}
