From 8467e6f35df9e7f39c727e51d50c00f96a1081c9 Mon Sep 17 00:00:00 2001
From: Benedikt Spranger <b.spranger@linutronix.de>
Date: Tue, 24 Nov 2009 08:58:33 +0100
Subject: PCI example added

---
 .../module-basics/pres_module-basics_de.tex        | 244 ++++++++++++++++++++-
 1 file changed, 240 insertions(+), 4 deletions(-)

(limited to 'kernel-devel/module-basics/pres_module-basics_de.tex')

diff --git a/kernel-devel/module-basics/pres_module-basics_de.tex b/kernel-devel/module-basics/pres_module-basics_de.tex
index 3e62220..a62397c 100644
--- a/kernel-devel/module-basics/pres_module-basics_de.tex
+++ b/kernel-devel/module-basics/pres_module-basics_de.tex
@@ -11,8 +11,7 @@
 \institute{Linutronix GmbH}
 
 \begin{document}
-\lstset{language=[ANSI]C}
-
+\lstset{language=[ANSI]C, moredelim=[is][\color{blue}]{|}{|}}
 \maketitle
 
 % ----- Slide Aufbau ------------------
@@ -69,6 +68,7 @@ module_exit(vain_exit);
 MODULE_AUTHOR("Benedikt Spranger <b.spranger@linutronix.de>");
 MODULE_DESCRIPTION("a more or less useless module");
 MODULE_LICENSE("GPL v2");
+MODULE_VERSION("0815");
 \end{lstlisting}
 \end{tiny}
 \end{itemize}
@@ -104,8 +104,8 @@ make[1]: Entering directory `/usr/src/linux-2.6.30'
   CC [M]  /path/to/vain/vain.o
   Building modules, stage 2.
   MODPOST 1 modules
-  CC      /path/to//vain/vain.mod.o
-  LD [M]  /path/to//vain/vain.ko
+  CC      /path/to/vain/vain.mod.o
+  LD [M]  /path/to/vain/vain.ko
 make[1]: Leaving directory `/usr/src/linux-2.6.30'
 $
 \end{verbatim}
@@ -132,4 +132,240 @@ vain_exit: done
 \end{itemize}
 \end{frame}
 
+% ----- Slide Komplexere Module ------------------
+\begin{frame}
+\frametitle{Komplexere Modul}
+\pause
+\begin{itemize}
+\item Teil eines Bussystems
+\pause
+\begin{itemize}
+\item USB
+\pause
+\item PCI
+\pause
+\item Platform
+\pause
+\item \dots
+\pause
+\end{itemize}
+\item Teil eines Subsystems
+\pause
+\begin{itemize}
+\item Character-Devices
+\pause
+\item Block-Devices
+\pause
+\item Network-Devices
+\pause
+\item \dots
+\end{itemize}
+\end{itemize}
+\end{frame}
+
+% ----- Slide PCI Treiber ------------------
+\begin{frame}[fragile]
+\frametitle{Aufbau eines PCI Treiber Moduls}
+\pause
+\begin{itemize}
+\item Header
+\pause
+\begin{tiny}
+\begin{lstlisting}[frame=trBL]
+#include <linux/init.h>
+#include <linux/module.h>
+|#include <linux/pci.h>|
+\end{lstlisting}
+\end{tiny}
+\pause
+\item Init
+\pause
+\begin{tiny}
+\begin{lstlisting}[frame=trBL]
+static int vain_pci_init(void)
+{
+        int err;
+
+        |err = pci_register_driver(&vain_pci_driver);|
+
+        if (!err)
+                printk(KERN_INFO "vain_pci_init: done\n");
+        return err;
+}
+
+module_init(vain_pci_init);
+\end{lstlisting}
+\end{tiny}
+\end{itemize}
+\end{frame}
+
+% ----- Slide PCI Treiber (fort.) ------------------
+\begin{frame}[fragile]
+\frametitle{Aufbau eines PCI Treiber Moduls (fort.)}
+\begin{itemize}
+\item Exit
+\pause
+\begin{tiny}
+\begin{lstlisting}[frame=trBL]
+static void vain_pci_exit(void)
+{
+        |pci_unregister_driver(&vain_pci_driver);|
+        printk(KERN_INFO ``vain_pci_exit: done\n'');
+}
+
+module_exit(vain_pci_exit);
+\end{lstlisting}
+\end{tiny}
+\end{itemize}
+\end{frame}
+
+% ----- Slide PCI Treiber (fort.) ------------------
+\begin{frame}[fragile]
+\frametitle{Aufbau eines PCI Treiber Moduls (fort.)}
+\begin{itemize}
+\item struct pci\_driver
+\pause
+\begin{tiny}
+\begin{lstlisting}[frame=trBL]
+|static struct pci_driver vain_pci_driver = {
+        .name =         "vain_pci",
+        .id_table =     vain_pci_ids,
+        .probe =        vain_pci_probe,
+        .remove =       __devexit_p(vain_pci_remove),
+};|
+\end{lstlisting}
+\end{tiny}
+\end{itemize}
+\end{frame}
+
+% ----- Slide PCI Treiber (fort.) ------------------
+\begin{frame}[fragile]
+\frametitle{Aufbau eines PCI Treiber Moduls (fort.)}
+\begin{itemize}
+\item struct struct pci\_device\_id
+\pause
+\begin{tiny}
+\begin{lstlisting}[frame=trBL]
+|static struct pci_device_id vain_pci_ids[] __devinitdata = {
+        {PCI_VENDOR_ID_ILLEGAL_VENDOR, PCI_DEVICE_ID_ILLEGAL_VENDOR_DEVICE,
+         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
+        {0, }
+};|
+\end{lstlisting}
+\end{tiny}
+\end{itemize}
+\end{frame}
+
+% ----- Slide PCI Treiber (fort.) ------------------
+\begin{frame}[fragile]
+\frametitle{Aufbau eines PCI Treiber Moduls (fort.)}
+\begin{itemize}
+\item probe
+\pause
+\begin{tiny}
+\begin{lstlisting}[frame=trBL]
+|static int __devinit vain_pci_probe(struct pci_dev *pdev,
+                                    const struct pci_device_id *ent)
+{
+        int ret;
+
+        ret = pci_enable_device(pdev);
+        if (ret)
+        	goto err_free;
+
+        ret = pci_request_regions(pdev, "vain_pci");
+        if (ret)
+                goto err_disable_device;
+
+        info->base = pci_ioremap_bar(pdev, 0);
+        if (!info->base) {
+                ret = -ENODEV;
+                goto err_rel_regs;
+        }
+
+        return 0;|
+\end{lstlisting}
+\dots
+\end{tiny}
+\end{itemize}
+\end{frame}
+
+% ----- Slide PCI Treiber (fort.) ------------------
+\begin{frame}[fragile]
+\frametitle{Aufbau eines PCI Treiber Moduls (fort.)}
+\begin{itemize}
+\item remove
+\pause
+\begin{tiny}
+\begin{lstlisting}[frame=trBL]
+|static void __devexit vain_pci_remove(struct pci_dev *pdev)
+{
+        struct vain_pci_info *info = pci_get_drvdata(pdev);
+
+        iounmap(info->base);
+        pci_release_regions(pdev);
+        pci_disable_device(pdev);
+        pci_set_drvdata(pdev, NULL);
+
+        kfree (info);
+}|
+\end{lstlisting}
+\end{tiny}
+\end{itemize}
+\end{frame}
+
+% ----- Slide PCI Treiber Hintergrund ------------------
+\begin{frame}
+\frametitle{PCI Treiber Hintergrund}
+\includegraphics[width=7cm]{images/PCI_driver.png}
+\end{frame}
+
+% ----- Slide PCI Rumpf Treiber ------------------
+\begin{frame}[fragile]
+\frametitle{PCI Rumpf Treiber}
+\begin{tiny}
+\lstinputlisting{vain_pci/vain_pci_1.c}
+\end{tiny}
+\end{frame}
+
+% ----- Slide PCI Rumpf Treiber (fort.) ------------------
+\begin{frame}[fragile]
+\frametitle{PCI Rumpf Treiber (fort.)}
+\begin{tiny}
+\lstinputlisting{vain_pci/vain_pci_2.c}
+\end{tiny}
+\end{frame}
+
+% ----- Slide PCI Rumpf Treiber (fort.) ------------------
+\begin{frame}[fragile]
+\frametitle{PCI Rumpf Treiber (fort.)}
+\begin{tiny}
+\lstinputlisting{vain_pci/vain_pci_3.c}
+\end{tiny}
+\end{frame}
+
+% ----- Slide PCI Rumpf Treiber (fort.) ------------------
+\begin{frame}[fragile]
+\frametitle{PCI Rumpf Treiber (fort.)}
+\begin{tiny}
+\lstinputlisting{vain_pci/vain_pci_4.c}
+\end{tiny}
+\end{frame}
+
+% ----- Slide PCI Rumpf Treiber (fort.) ------------------
+\begin{frame}[fragile]
+\frametitle{PCI Rumpf Treiber (fort.)}
+\begin{tiny}
+\lstinputlisting{vain_pci/vain_pci_5.c}
+\end{tiny}
+\end{frame}
+
+% ----- Slide PCI Rumpf Treiber (fort.) ------------------
+\begin{frame}[fragile]
+\frametitle{PCI Rumpf Treiber (fort.)}
+\begin{tiny}
+\lstinputlisting{vain_pci/vain_pci_6.c}
+\end{tiny}
+\end{frame}
+
 \end{document}
-- 
cgit v1.2.3

