12 \newcommand{\hdrs}[1]{\large{\textit{\insertsection}}\\\Large{\textbf{#1}}}
13 \newcommand{\hdrss}[1]{\large{\textit{\insertsubsection}}\\\large{\textbf{#1}}}
20 % alternativetitlepage=true,
22 %\setbeamertemplate{footline}{}
23 \setbeamersize{text margin left=10mm}
24 \setbeamersize{text margin right=5mm}
27 \usepackage[english]{babel}
28 \usepackage[latin1]{inputenc}
30 \usepackage[T1]{fontenc}
39 \definecolor{diffcommit}{rgb}{.50, .50, .00}
40 \definecolor{diffauthor}{rgb}{.50, .50, .00}
41 \definecolor{diffdate} {rgb}{.50, .50, .00}
42 \definecolor{diffdiff} {rgb}{.30, .30, .90}
43 \definecolor{diffindex} {rgb}{.50, .00, .50}
44 \definecolor{diffstart} {rgb}{.00, .50, .50}
45 \definecolor{diffadd} {rgb}{.00, .60, .00}
46 \definecolor{diffdel} {rgb}{.80, .00, .00}
48 \lstdefinelanguage{diff}{
49 basicstyle=\ttfamily\small,
50 morecomment=[f][\color{diffcommit}]{commit},
51 morecomment=[f][\color{diffauthor}]{Author},
52 morecomment=[f][\color{diffdate}]{Date},
53 morecomment=[f][\color{diffdiff}]{diff},
54 morecomment=[f][\color{diffindex}]{index},
55 morecomment=[f][\color{diffstart}]{@@},
56 morecomment=[f][\color{diffadd}]{+},
57 morecomment=[f][\color{diffdel}]{-},
58 morecomment=[f][\color{diffindex}]{+++},
59 morecomment=[f][\color{diffindex}]{---},
62 \lstset{language=diff,
64 keywordstyle=\color{blue}\ttfamily,
65 stringstyle=\color{red}\ttfamily,
66 commentstyle=\color{green}\ttfamily,
67 morecomment=[l][\color{magenta}]{\#} }
82 \title[Kernel Programming]{%
83 Introduction to Linux Kernel Programming
92 \small{San Fernando Valley Linux Users Group}
108 % - Booting the kernel
109 % - Kernel source tree
115 % - /dev, proc, sysfs
117 % - Devices and Drivers
135 \section{Examples Patches}
137 \begin{frame}[fragile]{\hdrs{The Typo Fix}}
138 \begin{lstlisting}[language=diff,basicstyle=\tiny]
139 commit 9eac0ae1683575375de8c63166b3596b11d3b56a
140 Author: Krzysztof Kozlowski <krzk@kernel.org>
141 Date: 2019-01-08 13:11:40 +0100
143 dt-bindings: soc: qcom: Fix trivial language typos
145 Fix few trivial language typos in bindings.
147 Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
148 Signed-off-by: Rob Herring <robh@kernel.org>
150 diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,glink.txt b/Docume...
151 index 0b8cc533ca83..cf759e5f9b10 100644
152 --- a/Documentation/devicetree/bindings/soc/qcom/qcom,glink.txt
153 +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,glink.txt
154 @@ -55,7 +55,7 @@ of these nodes are defined by the individual bindings for the...
156 The following example represents the GLINK RPM node on a MSM8996 device, with
157 the function for the "rpm_request" channel defined, which is used for
158 -regualtors and root clocks.
159 +regulators and root clocks.
161 apcs_glb: mailbox@9820000 {
162 compatible = "qcom,msm8996-apcs-hmss-global";
166 \begin{frame}[fragile]{\hdrs{The Hardware ID}}
167 \begin{lstlisting}[language=diff,basicstyle=\tiny]
168 commit 7ab21a8692094872298df172f54d55cba72fd308
169 Author: Andy Spencer <spenceal@rose-hulman.edu>
170 Date: 2009-01-02 16:19:13 +0000
172 i8k: Enable i8k on Dell Precision Systems
174 Patch to enable i8k on Dell Precisions.
176 Signed-off-by: Andy Spencer <spenceal@rose-hulman.edu>
177 Signed-off-by: Alan Cox <alan@redhat.com>
178 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
180 diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c
181 index b60d425ce8d1..099fc89a5bdd 100644
182 --- a/drivers/char/i8k.c
183 +++ b/drivers/char/i8k.c
184 @@ -485,6 +485,13 @@ static struct dmi_system_id __initdata i8k_dmi_table[] = {
185 DMI_MATCH(DMI_PRODUCT_NAME, "MP061"),
189 + .ident = "Dell Precision",
191 + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
192 + DMI_MATCH(DMI_PRODUCT_NAME, "Precision"),
200 \begin{frame}[fragile]{\hdrs{The Driver Debug}}
201 \begin{lstlisting}[language=diff,basicstyle=\tiny]
202 commit ab1796ebdad3017965754d86db64d3cba5c416b9
203 Author: Andy Spencer <andy753421@ucla.edu>
204 Date: 2014-05-02 06:48:13 +0000
206 RTL8192CU: Increase max APFM_ONMAC polling count
208 With certain hardware combinations the poll interval is exceeded before
209 initialization completes.
211 Tested on a MacBookPro10,1 using a Sabrent USB-A11N USB adapter.
213 Signed-off-by: Andy Spencer <andy753421@ucla.edu>
214 Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
215 Signed-off-by: John W. Linville <linville@tuxdriver.com>
217 diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/rtlw...
218 index 68b5c7e92cfb..31b79e78c63c 100644
219 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
220 +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c
221 @@ -511,7 +511,7 @@ static int _rtl92cu_init_power_on(struct ieee80211_hw *hw)
222 pr_info("MAC auto ON okay!\n");
225 - if (pollingCount++ > 100) {
226 + if (pollingCount++ > 1000) {
227 RT_TRACE(rtlpriv, COMP_INIT, DBG_EMERG,
228 "Failed to polling REG_APS_FSMCO[APFM_ONMAC] done!\n");
233 \begin{frame}[fragile]{\hdrs{The New Protocol}}
235 \item New network protocols, filesystems, security modules, etc.
236 \item Software only improvmenets to the kernel.
237 \item No hardware required, can be tested in a VM.
238 \item Typocally done in net/, fs/, security/, etc.
242 \begin{frame}[fragile]{\hdrs{The New Driver}}
244 \item Add support for a new hardware device.
245 \item Cononical example: I2C/SPI thermal sensors. (lm70.c)
246 \item Find the data sheet
247 \item Typocally use an existing driver as an example.
248 \item Requires hardware to test on.
249 \item Typocally done in drivers/.
253 \begin{frame}[fragile]{\hdrs{The New Board}}
255 \item Simmilar new drivers but focuse on boot.
256 \item Typocally for embedded Linux.
257 \item May require bootloader changes.
258 \item Typocally done in arch/.
264 % - Booting the kernel
265 % - Kernel source tree
268 \section{Development}
270 \begin{frame}{\hdrs{Kernel compiling}}
271 Could be an entire talk on it's own...
274 \item \$ make menuconfig
276 \item \$ make install
278 \item invokes \$HOME/bin/installkernel
280 \item \$ make modules\_install
285 \item vmlinux: Main build output, ELF file with debug symbols.
286 \item bzImage: Bootable kernel image (wraps vmlinux).
287 \item uImage, etc: Like bzImage for other architctures.
292 \begin{frame}{\hdrs{Booting the kernel}}
296 \item Compile, reboot, compile, reboot..
298 \item Least efficient, but often needed for debugging.
300 \item Run the kenrel it in a VM.
302 \item Great for experimenting.
303 \item Won't work for for driver.
305 \item Dynamic kernel module loading.
307 \item Good for most driver work.
308 \item Easy to crash your PC.
310 \item Boot it on a dedicated machine.
312 \item Generally used for embedded Linux.
313 \item Prevents crashing your workstation.
318 \begin{frame}{\hdrs{Kernel source tree}}
320 \item arch/: architecture specific code
321 \item drivers/: well... drivers
322 \item fs/: file systems
323 \item kernel/: core kernel code (process management, etc)
324 \item lib/: utility code, C library type stuff
325 \item mm/: memroy management
326 \item include/: shared include files
330 \begin{frame}{\hdrs{Sending patches}}
331 \url{https://www.kernel.org/doc/html/latest/process/submitting-patches.html}
333 \item Linux uses mailing lists patches and code review.
334 \item Maintainers tend to use pull requests and merges, but general
335 contributors usually do not.
336 \item Different subsystem (netdev) have slightly different rules.
337 \item Patchwork is useful for tracking and reviewing patches:
338 \url{https://patchwork.kernel.org}
346 % - /dev, proc, sysfs
348 % - Devices and Drivers
350 \section{Kernel Modules}
352 \begin{frame}[fragile]{\hdrs{Hello, World}}
353 \begin{lstlisting}[language=C,basicstyle=\scriptsize]
354 #include <linux/module.h>
355 #include <linux/kernel.h>
356 #include <linux/init.h>
358 static int __init hello_init(void)
360 pr_info("Hello SFVLUG.\n");
364 static void __exit hello_exit(void)
366 pr_info("Goodbye SFVLUG.\n");
369 module_init(hello_init);
370 module_exit(hello_exit);
372 MODULE_LICENSE("GPL");
373 MODULE_AUTHOR("Andy Spencer <andy753421@gmail.com>");
374 MODULE_DESCRIPTION("SFVLUG!");
378 %\begin{frame}[fragile]{\hdrs{Makefile / Kconfig}}
379 % \begin{lstlisting}[Building it]
383 %\begin{frame}{\hdrs{User Interfaces}}
389 %\begin{frame}{\hdrs{Devices and Drivers}}