Browse Source

deploy: 8d7caa7fc988ec8c3d6761c2fccb58c1532c70f1

jserv 3 năm trước cách đây
mục cha
commit
6969229957
3 tập tin đã thay đổi với 55 bổ sung49 xóa
  1. 22 19
      index.html
  2. 22 19
      lkmpg-for-ht.html
  3. 11 11
      lkmpg-for-ht0x.svg

+ 22 - 19
index.html

@@ -17,7 +17,7 @@
 
 <h2 class='titleHead'>The Linux Kernel Module Programming Guide</h2>
 <div class='author'><span class='ecrm-1200'>Peter Jay Salzman, Michael Burian, Ori Pomerantz, Bob Mottram, Jim Huang</span></div><br />
-<div class='date'><span class='ecrm-1200'>August 10, 2021</span></div>
+<div class='date'><span class='ecrm-1200'>August 11, 2021</span></div>
                                                                   
 
                                                                   
@@ -337,8 +337,9 @@ the logs:
 Now for more of a description of how this module works.
 </p><!-- l. 264 --><p class='indent'>   Kernel modules must have at least two functions: a "start" (initialization) function
 called <code>  <span class='ectt-1000'>init_module()</span>
-</code> which is called when the module is insmoded into the kernel, and an "end" (cleanup) function
-called <code>  <span class='ectt-1000'>cleanup_module()</span>
+</code> which is called when the module is <code>  <span class='ectt-1000'>insmod</span>
+</code>ed into the kernel, and an "end" (cleanup) function called
+<code> <span class='ectt-1000'>cleanup_module()</span>
 </code> which is called just before it is removed from the kernel. Actually, things have
 changed starting with kernel 2.3.13. You can now use whatever name you like for the
 start and end functions of a module, and you will learn how to do this in Section
@@ -348,10 +349,10 @@ use <code>  <span class='ectt-1000'>init_module()</span>
 </code> for their start and end functions.
 </p><!-- l. 271 --><p class='indent'>   Typically, <code>  <span class='ectt-1000'>init_module()</span>
 </code> either registers a handler for something with the kernel, or it replaces one of the kernel
-functions with its own code (usually code to do something and then call the original function).
                                                                   
 
                                                                   
+functions with its own code (usually code to do something and then call the original function).
 The <code>  <span class='ectt-1000'>cleanup_module()</span>
 </code> function is supposed to undo whatever
 <code> <span class='ectt-1000'>init_module()</span>
@@ -359,16 +360,16 @@ The <code>  <span class='ectt-1000'>cleanup_module()</span>
 </p><!-- l. 274 --><p class='indent'>   Lastly, every kernel module needs to include <span class='obeylines-h'><span class='verb'><span class='ectt-1000'>&lt;linux/module.h&gt;</span></span></span>. We
 needed to include <span class='obeylines-h'><span class='verb'><span class='ectt-1000'>&lt;linux/kernel.h&gt;</span></span></span> only for the macro expansion for the
 <code> <span class='ectt-1000'>pr_alert()</span>
-</code> log level, which you’ll learn about in Section <a href='#x1-120992'>2<!-- tex4ht:ref: sec:printk  --></a>.
+</code> log level, which you’ll learn about in Section <a href='#x1-121002'>2<!-- tex4ht:ref: sec:printk  --></a>.
 </p><!-- l. 278 --><p class='indent'>
      </p><ol class='enumerate1'>
-<li class='enumerate' id='x1-12098x1'>A point about coding style. Another thing which may not be immediately
+<li class='enumerate' id='x1-12099x1'>A point about coding style. Another thing which may not be immediately
      obvious  to  anyone  getting  started  with  kernel  programming  is  that
      indentation within your code should be using <span class='ecbx-1000'>tabs </span>and <span class='ecbx-1000'>not spaces</span>. It is
      one of the coding conventions of the kernel. You may not like it, but you’ll
      need to get used to it if you ever submit a patch upstream.
      </li>
-<li class='enumerate' id='x1-12100x2'>Introducing print macros. <a id='x1-120992'></a>In the beginning there was <code>  <span class='ectt-1000'>printk</span>
+<li class='enumerate' id='x1-12101x2'>Introducing print macros. <a id='x1-121002'></a>In the beginning there was <code>  <span class='ectt-1000'>printk</span>
      </code>, usually followed by a priority such as <code>  <span class='ectt-1000'>KERN_INFO</span>
      </code> or <code>  <span class='ectt-1000'>KERN_DEBUG</span>
      </code>. More recently this can also be expressed in abbreviated form using a set of
@@ -378,16 +379,16 @@ needed to include <span class='obeylines-h'><span class='verb'><span class='ectt
      They can be found within <a href='https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/include/linux/printk.h'>include/linux/printk.h</a>. Take time to read through
      the available priority macros.
      </li>
-<li class='enumerate' id='x1-12107x3'>
+<li class='enumerate' id='x1-12108x3'>
      <!-- l. 292 --><p class='noindent'>About Compiling. Kernel modules need to be compiled a bit differently
      from  regular  userspace  apps.  Former  kernel  versions  required  us  to
      care much about these settings, which are usually stored in Makefiles.
      Although hierarchically organized, many redundant settings accumulated
      in sublevel Makefiles and made them large and rather difficult to maintain.
-     Fortunately, there is a new way of doing these things, called kbuild, and
                                                                   
 
                                                                   
+     Fortunately, there is a new way of doing these things, called kbuild, and
      the build process for external loadable modules is now fully integrated into
      the standard kernel build mechanism. To learn more on how to compile
      modules which are not part of the official kernel (such as all the examples
@@ -573,7 +574,7 @@ take the values of the command line arguments as global and then use the
 </code> macro, (defined in <a href='https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/include/linux/moduleparam.h'>include/linux/moduleparam.h</a>) to set the mechanism up. At runtime,
 <code> <span class='ectt-1000'>insmod</span>
 </code> will fill the variables with any command line arguments that are given, like
-<code> <span class='ectt-1000'>insmod ./mymodule.ko myvariable=5</span>
+<code> <span class='ectt-1000'>insmod mymodule.ko myvariable=5</span>
 </code>. The variable declarations and macros should be placed at the beginning of the
 module for clarity. The example code should clear up my admittedly lousy
 explanation.
@@ -1346,13 +1347,15 @@ third method is we can have our driver make the the device file using the
 </p><!-- l. 883 --><p class='noindent'>
 </p>
    <h4 class='subsectionHead' id='unregistering-a-device'><span class='titlemark'>0.6.4   </span> <a id='x1-300000.6.4'></a>Unregistering A Device</h4>
-<!-- l. 885 --><p class='noindent'>We can not allow the kernel module to be rmmod’ed whenever root feels like it. If the
-device file is opened by a process and then we remove the kernel module, using the
-file would cause a call to the memory location where the appropriate function
-(read/write) used to be. If we are lucky, no other code was loaded there, and we’ll get
-an ugly error message. If we are unlucky, another kernel module was loaded into the
-same location, which means a jump into the middle of another function within the
-kernel. The results of this would be impossible to predict, but they can not be very
+<!-- l. 885 --><p class='noindent'>We can not allow the kernel module to be
+<code> <span class='ectt-1000'>rmmod</span>
+</code>’ed whenever root feels like it. If the device file is opened by a process and then we
+remove the kernel module, using the file would cause a call to the memory location
+where the appropriate function (read/write) used to be. If we are lucky, no
+other code was loaded there, and we’ll get an ugly error message. If we are
+unlucky, another kernel module was loaded into the same location, which
+means a jump into the middle of another function within the kernel. The
+results of this would be impossible to predict, but they can not be very
 positive.
 </p><!-- l. 891 --><p class='indent'>   Normally, when you do not want to allow something, you return an error code
 (a negative number) from the function which is supposed to do it. With
@@ -1375,11 +1378,11 @@ decrease and display this counter:
      </li>
      <li class='itemize'><code>  <span class='ectt-1000'>module_put(THIS_MODULE)</span>
      </code>: Decrement the use count.</li></ul>
-<!-- l. 904 --><p class='indent'>   It is important to keep the counter accurate; if you ever do lose track of the
-correct usage count, you will never be able to unload the module; it’s now reboot
                                                                   
 
                                                                   
+<!-- l. 904 --><p class='indent'>   It is important to keep the counter accurate; if you ever do lose track of the
+correct usage count, you will never be able to unload the module; it’s now reboot
 time, boys and girls. This is bound to happen to you sooner or later during a
 module’s development.
 </p><!-- l. 907 --><p class='noindent'>

+ 22 - 19
lkmpg-for-ht.html

@@ -17,7 +17,7 @@
 
 <h2 class='titleHead'>The Linux Kernel Module Programming Guide</h2>
 <div class='author'><span class='ecrm-1200'>Peter Jay Salzman, Michael Burian, Ori Pomerantz, Bob Mottram, Jim Huang</span></div><br />
-<div class='date'><span class='ecrm-1200'>August 10, 2021</span></div>
+<div class='date'><span class='ecrm-1200'>August 11, 2021</span></div>
                                                                   
 
                                                                   
@@ -337,8 +337,9 @@ the logs:
 Now for more of a description of how this module works.
 </p><!-- l. 264 --><p class='indent'>   Kernel modules must have at least two functions: a "start" (initialization) function
 called <code>  <span class='ectt-1000'>init_module()</span>
-</code> which is called when the module is insmoded into the kernel, and an "end" (cleanup) function
-called <code>  <span class='ectt-1000'>cleanup_module()</span>
+</code> which is called when the module is <code>  <span class='ectt-1000'>insmod</span>
+</code>ed into the kernel, and an "end" (cleanup) function called
+<code> <span class='ectt-1000'>cleanup_module()</span>
 </code> which is called just before it is removed from the kernel. Actually, things have
 changed starting with kernel 2.3.13. You can now use whatever name you like for the
 start and end functions of a module, and you will learn how to do this in Section
@@ -348,10 +349,10 @@ use <code>  <span class='ectt-1000'>init_module()</span>
 </code> for their start and end functions.
 </p><!-- l. 271 --><p class='indent'>   Typically, <code>  <span class='ectt-1000'>init_module()</span>
 </code> either registers a handler for something with the kernel, or it replaces one of the kernel
-functions with its own code (usually code to do something and then call the original function).
                                                                   
 
                                                                   
+functions with its own code (usually code to do something and then call the original function).
 The <code>  <span class='ectt-1000'>cleanup_module()</span>
 </code> function is supposed to undo whatever
 <code> <span class='ectt-1000'>init_module()</span>
@@ -359,16 +360,16 @@ The <code>  <span class='ectt-1000'>cleanup_module()</span>
 </p><!-- l. 274 --><p class='indent'>   Lastly, every kernel module needs to include <span class='obeylines-h'><span class='verb'><span class='ectt-1000'>&lt;linux/module.h&gt;</span></span></span>. We
 needed to include <span class='obeylines-h'><span class='verb'><span class='ectt-1000'>&lt;linux/kernel.h&gt;</span></span></span> only for the macro expansion for the
 <code> <span class='ectt-1000'>pr_alert()</span>
-</code> log level, which you’ll learn about in Section <a href='#x1-120992'>2<!-- tex4ht:ref: sec:printk  --></a>.
+</code> log level, which you’ll learn about in Section <a href='#x1-121002'>2<!-- tex4ht:ref: sec:printk  --></a>.
 </p><!-- l. 278 --><p class='indent'>
      </p><ol class='enumerate1'>
-<li class='enumerate' id='x1-12098x1'>A point about coding style. Another thing which may not be immediately
+<li class='enumerate' id='x1-12099x1'>A point about coding style. Another thing which may not be immediately
      obvious  to  anyone  getting  started  with  kernel  programming  is  that
      indentation within your code should be using <span class='ecbx-1000'>tabs </span>and <span class='ecbx-1000'>not spaces</span>. It is
      one of the coding conventions of the kernel. You may not like it, but you’ll
      need to get used to it if you ever submit a patch upstream.
      </li>
-<li class='enumerate' id='x1-12100x2'>Introducing print macros. <a id='x1-120992'></a>In the beginning there was <code>  <span class='ectt-1000'>printk</span>
+<li class='enumerate' id='x1-12101x2'>Introducing print macros. <a id='x1-121002'></a>In the beginning there was <code>  <span class='ectt-1000'>printk</span>
      </code>, usually followed by a priority such as <code>  <span class='ectt-1000'>KERN_INFO</span>
      </code> or <code>  <span class='ectt-1000'>KERN_DEBUG</span>
      </code>. More recently this can also be expressed in abbreviated form using a set of
@@ -378,16 +379,16 @@ needed to include <span class='obeylines-h'><span class='verb'><span class='ectt
      They can be found within <a href='https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/include/linux/printk.h'>include/linux/printk.h</a>. Take time to read through
      the available priority macros.
      </li>
-<li class='enumerate' id='x1-12107x3'>
+<li class='enumerate' id='x1-12108x3'>
      <!-- l. 292 --><p class='noindent'>About Compiling. Kernel modules need to be compiled a bit differently
      from  regular  userspace  apps.  Former  kernel  versions  required  us  to
      care much about these settings, which are usually stored in Makefiles.
      Although hierarchically organized, many redundant settings accumulated
      in sublevel Makefiles and made them large and rather difficult to maintain.
-     Fortunately, there is a new way of doing these things, called kbuild, and
                                                                   
 
                                                                   
+     Fortunately, there is a new way of doing these things, called kbuild, and
      the build process for external loadable modules is now fully integrated into
      the standard kernel build mechanism. To learn more on how to compile
      modules which are not part of the official kernel (such as all the examples
@@ -573,7 +574,7 @@ take the values of the command line arguments as global and then use the
 </code> macro, (defined in <a href='https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/include/linux/moduleparam.h'>include/linux/moduleparam.h</a>) to set the mechanism up. At runtime,
 <code> <span class='ectt-1000'>insmod</span>
 </code> will fill the variables with any command line arguments that are given, like
-<code> <span class='ectt-1000'>insmod ./mymodule.ko myvariable=5</span>
+<code> <span class='ectt-1000'>insmod mymodule.ko myvariable=5</span>
 </code>. The variable declarations and macros should be placed at the beginning of the
 module for clarity. The example code should clear up my admittedly lousy
 explanation.
@@ -1346,13 +1347,15 @@ third method is we can have our driver make the the device file using the
 </p><!-- l. 883 --><p class='noindent'>
 </p>
    <h4 class='subsectionHead' id='unregistering-a-device'><span class='titlemark'>0.6.4   </span> <a id='x1-300000.6.4'></a>Unregistering A Device</h4>
-<!-- l. 885 --><p class='noindent'>We can not allow the kernel module to be rmmod’ed whenever root feels like it. If the
-device file is opened by a process and then we remove the kernel module, using the
-file would cause a call to the memory location where the appropriate function
-(read/write) used to be. If we are lucky, no other code was loaded there, and we’ll get
-an ugly error message. If we are unlucky, another kernel module was loaded into the
-same location, which means a jump into the middle of another function within the
-kernel. The results of this would be impossible to predict, but they can not be very
+<!-- l. 885 --><p class='noindent'>We can not allow the kernel module to be
+<code> <span class='ectt-1000'>rmmod</span>
+</code>’ed whenever root feels like it. If the device file is opened by a process and then we
+remove the kernel module, using the file would cause a call to the memory location
+where the appropriate function (read/write) used to be. If we are lucky, no
+other code was loaded there, and we’ll get an ugly error message. If we are
+unlucky, another kernel module was loaded into the same location, which
+means a jump into the middle of another function within the kernel. The
+results of this would be impossible to predict, but they can not be very
 positive.
 </p><!-- l. 891 --><p class='indent'>   Normally, when you do not want to allow something, you return an error code
 (a negative number) from the function which is supposed to do it. With
@@ -1375,11 +1378,11 @@ decrease and display this counter:
      </li>
      <li class='itemize'><code>  <span class='ectt-1000'>module_put(THIS_MODULE)</span>
      </code>: Decrement the use count.</li></ul>
-<!-- l. 904 --><p class='indent'>   It is important to keep the counter accurate; if you ever do lose track of the
-correct usage count, you will never be able to unload the module; it’s now reboot
                                                                   
 
                                                                   
+<!-- l. 904 --><p class='indent'>   It is important to keep the counter accurate; if you ever do lose track of the
+correct usage count, you will never be able to unload the module; it’s now reboot
 time, boys and girls. This is bound to happen to you sooner or later during a
 module’s development.
 </p><!-- l. 907 --><p class='noindent'>

+ 11 - 11
lkmpg-for-ht0x.svg

@@ -1,6 +1,6 @@
 <?xml version='1.0' encoding='UTF-8'?>
 <!-- This file was generated by dvisvgm 2.11.1 -->
-<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='85.471872pt' height='12.702057pt' viewBox='61.356689 783.260456 85.471872 12.702057'>
+<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='85.471872pt' height='12.702057pt' viewBox='61.356689 811.463806 85.471872 12.702057'>
 <defs>
 <path id='g10-97' d='M3.716065-3.765878C3.536737-4.134496 3.247821-4.403487 2.799502-4.403487C1.633873-4.403487 .398506-2.938979 .398506-1.484433C.398506-.547945 .946451 .109589 1.723537 .109589C1.92279 .109589 2.420922 .069738 3.01868-.637609C3.098381-.219178 3.447073 .109589 3.92528 .109589C4.273973 .109589 4.503113-.119552 4.662516-.438356C4.83188-.797011 4.961395-1.404732 4.961395-1.424658C4.961395-1.524284 4.871731-1.524284 4.841843-1.524284C4.742217-1.524284 4.732254-1.484433 4.702366-1.344956C4.533001-.697385 4.353674-.109589 3.945205-.109589C3.676214-.109589 3.646326-.368618 3.646326-.56787C3.646326-.787049 3.666252-.86675 3.775841-1.305106C3.88543-1.723537 3.905355-1.823163 3.995019-2.201743L4.353674-3.596513C4.423412-3.875467 4.423412-3.895392 4.423412-3.935243C4.423412-4.104608 4.303861-4.204234 4.134496-4.204234C3.895392-4.204234 3.745953-3.985056 3.716065-3.765878ZM3.068493-1.185554C3.01868-1.006227 3.01868-.986301 2.86924-.816936C2.430884-.268991 2.022416-.109589 1.743462-.109589C1.24533-.109589 1.105853-.657534 1.105853-1.046077C1.105853-1.544209 1.424658-2.769614 1.653798-3.227895C1.96264-3.815691 2.410959-4.184309 2.809465-4.184309C3.457036-4.184309 3.596513-3.367372 3.596513-3.307597S3.576588-3.188045 3.566625-3.138232L3.068493-1.185554Z'/>
 <path id='g10-98' d='M2.381071-6.804483C2.381071-6.814446 2.381071-6.914072 2.251557-6.914072C2.022416-6.914072 1.295143-6.834371 1.036115-6.814446C.956413-6.804483 .846824-6.794521 .846824-6.615193C.846824-6.495641 .936488-6.495641 1.085928-6.495641C1.564134-6.495641 1.58406-6.425903 1.58406-6.326276C1.58406-6.256538 1.494396-5.917808 1.444583-5.708593L.627646-2.460772C.508095-1.96264 .468244-1.803238 .468244-1.454545C.468244-.508095 .996264 .109589 1.733499 .109589C2.909091 .109589 4.134496-1.374844 4.134496-2.809465C4.134496-3.716065 3.606476-4.403487 2.809465-4.403487C2.351183-4.403487 1.942715-4.11457 1.643836-3.805729L2.381071-6.804483ZM1.444583-3.038605C1.504359-3.257783 1.504359-3.277709 1.594022-3.387298C2.082192-4.034869 2.530511-4.184309 2.789539-4.184309C3.148194-4.184309 3.417186-3.88543 3.417186-3.247821C3.417186-2.660025 3.088418-1.514321 2.909091-1.135741C2.580324-.468244 2.122042-.109589 1.733499-.109589C1.39477-.109589 1.066002-.37858 1.066002-1.115816C1.066002-1.305106 1.066002-1.494396 1.225405-2.122042L1.444583-3.038605Z'/>
@@ -12,15 +12,15 @@
 <path id='g11-50' d='M1.265255-.767123L2.321295-1.793275C3.875467-3.16812 4.473225-3.706102 4.473225-4.702366C4.473225-5.838107 3.576588-6.635118 2.361146-6.635118C1.235367-6.635118 .498132-5.718555 .498132-4.83188C.498132-4.273973 .996264-4.273973 1.026152-4.273973C1.195517-4.273973 1.544209-4.393524 1.544209-4.801993C1.544209-5.061021 1.364882-5.32005 1.016189-5.32005C.936488-5.32005 .916563-5.32005 .886675-5.310087C1.115816-5.957659 1.653798-6.326276 2.231631-6.326276C3.138232-6.326276 3.566625-5.519303 3.566625-4.702366C3.566625-3.905355 3.068493-3.118306 2.520548-2.500623L.607721-.368618C.498132-.259029 .498132-.239103 .498132 0H4.194271L4.473225-1.733499H4.224159C4.174346-1.43462 4.104608-.996264 4.004981-.846824C3.935243-.767123 3.277709-.767123 3.058531-.767123H1.265255Z'/>
 </defs>
 <g id='page1' transform='matrix(1.4 0 0 1.4 0 0)'>
-<use x='43.826207' y='567.717753' xlink:href='#g11-50'/>
-<use x='48.807546' y='564.102389' xlink:href='#g12-49'/>
-<use x='52.778786' y='564.102389' xlink:href='#g12-54'/>
-<use x='57.248153' y='567.717753' xlink:href='#g10-97'/>
-<use x='64.728173' y='567.717753' xlink:href='#g11-43'/>
-<use x='74.690786' y='567.717753' xlink:href='#g11-50'/>
-<use x='79.672125' y='564.102389' xlink:href='#g12-56'/>
-<use x='84.141495' y='567.717753' xlink:href='#g10-98'/>
-<use x='90.630995' y='567.717753' xlink:href='#g11-43'/>
-<use x='100.593609' y='567.717753' xlink:href='#g10-99'/>
+<use x='43.826207' y='587.863003' xlink:href='#g11-50'/>
+<use x='48.807546' y='584.247639' xlink:href='#g12-49'/>
+<use x='52.778786' y='584.247639' xlink:href='#g12-54'/>
+<use x='57.248153' y='587.863003' xlink:href='#g10-97'/>
+<use x='64.728173' y='587.863003' xlink:href='#g11-43'/>
+<use x='74.690786' y='587.863003' xlink:href='#g11-50'/>
+<use x='79.672125' y='584.247639' xlink:href='#g12-56'/>
+<use x='84.141495' y='587.863003' xlink:href='#g10-98'/>
+<use x='90.630995' y='587.863003' xlink:href='#g11-43'/>
+<use x='100.593609' y='587.863003' xlink:href='#g10-99'/>
 </g>
 </svg>