feat(lab02): update to ex3
This commit is contained in:
3 files changed
+61
-14
No files matched your search
+60
-14
@@ -1,5 +1,5 @@
|
||||
// #import "@preview/hei-synd-report:0.1.1": *
|
||||
#import "@preview/hei-synd-thesis:0.3.1": *
|
||||
#import "@preview/hei-synd-thesis:0.4.0": *
|
||||
#import "/doc/metadata.typ": *
|
||||
#import "/doc/resources/glossary.typ": *
|
||||
#show:make-glossary
|
||||
@@ -56,7 +56,10 @@ In this laboratory, we see how to setup our environnement and how to have severa
|
||||
|
||||
We also see how to debug our system with a remote debugger. That allow us to use debug in our code editor (vscode) a programm that run on the target.
|
||||
|
||||
// PLACEHOLEDER SCHEMA
|
||||
#figure(
|
||||
image("/doc/resources/img/dev-environment.drawio.svg"),
|
||||
caption: "Development environment schema"
|
||||
) <fig:dev-env>
|
||||
|
||||
|
||||
== Questions
|
||||
@@ -99,6 +102,19 @@ If we develop only user space program, we don't need to load kernel by tftp. But
|
||||
#pagebreak()
|
||||
= Linux Kernel Programming
|
||||
|
||||
== Cheatsheet commands
|
||||
- `modinfo <module.ko>`: display information about a kernel module
|
||||
- `insmod <module.ko>`: install a kernel module (without checking for dependencies)
|
||||
- `rmmod <module.ko>`: uninstall a kernel module
|
||||
- `lsmod`: list the currently loaded kernel modules
|
||||
- `dmesg`: display the kernel log
|
||||
- `cat /proc/modules`: display the currently loaded kernel modules with more details
|
||||
- `modprobe <module>`: install a kernel module and its dependencies
|
||||
- `modprobe -r <module>`: uninstall a kernel module and its dependencies
|
||||
- `make`: build the kernel module
|
||||
- `make install`: install the kernel module in the root filesystem
|
||||
|
||||
|
||||
== Exercises
|
||||
|
||||
//-------------------
|
||||
@@ -114,7 +130,7 @@ If we develop only user space program, we don't need to load kernel by tftp. But
|
||||
Create the skeleton of a kernel module and generate it outside the kernel sources using a Makefile. The module should display a message when it is registered and when it is uninstalled.
|
||||
]
|
||||
|
||||
We already have a skeleton in `src/02-modules/exercice01`. We see on the Makefile that the module is generated outside the kernel sources with the `KDIR` variable imported from `src/kernel_settings`. This variable point to the kernel sources.
|
||||
We already have a skeleton in `src/02-modules/exercice01` (now `solutions/02_modules/exercice01` that we move to `src/01-skeleton`). We see on the Makefile that the module is generated outside the kernel sources with the `KDIR` variable imported from `src/kernel_settings`. This variable point to the kernel sources.
|
||||
The Makefile also use the `PWD` variable to the current directory.
|
||||
The `make` command will use these variables to generate the module in the current directory.
|
||||
|
||||
@@ -129,11 +145,12 @@ $(MAKE) -C $(KDIR) M=$(PWD) ARCH=$(CPU) CROSS_COMPILE=$(TOOLS) modules
|
||||
|
||||
```bash
|
||||
|> modinfo mymodule.ko
|
||||
filename: /workspace/src/02_modules/exercice01/mymodule.ko
|
||||
filename: /workspace/src/01-skeleton/mymodule.ko
|
||||
license: GPL
|
||||
description: Module skeleton
|
||||
author: Daniel Gachet <daniel.gachet@hefr.ch>
|
||||
depends:
|
||||
author: Klagarge <remi@heredero.ch>
|
||||
author: Fastium <fastium.pro@proton.me>
|
||||
depends:
|
||||
name: mymodule
|
||||
vermagic: 5.15.148 SMP preempt mod_unload aarch64
|
||||
parm: text:charp
|
||||
@@ -174,6 +191,7 @@ mymodule 16384 0
|
||||
mymodule 16384 0 - Live 0xffff8000011bf000 (O)
|
||||
···
|
||||
```
|
||||
The `/proc/modules` file give us more details about the state of the module. We see it is now live (charged in memory and running)
|
||||
|
||||
//--------------
|
||||
#subtask[
|
||||
@@ -199,6 +217,7 @@ mymodule 16384 0 - Live 0xffff8000011bf000 (O)
|
||||
[ 3359.811183] Linux module 01 skeleton loaded
|
||||
```
|
||||
|
||||
#pagebreak()
|
||||
//-------------------
|
||||
// Exercise 2: Adapt the kernel module to receive parameters
|
||||
//-------------------
|
||||
@@ -209,13 +228,26 @@ mymodule 16384 0 - Live 0xffff8000011bf000 (O)
|
||||
],
|
||||
)
|
||||
|
||||
```bash
|
||||
|> modprobe mymodule
|
||||
[ 3583.616662] Linux module skeleton ex02 loaded
|
||||
|> dmesg | tail -5
|
||||
[ 3559.279143] number: 1
|
||||
[ 3581.198562] Linux module skeleton unloaded
|
||||
[ 3583.616662] Linux module skeleton ex02 loaded
|
||||
[ 3583.621085] text: The answer to the Ultimate Question of Life, The Universe, and Everything
|
||||
[ 3583.621085] number: 42
|
||||
|> modprobe -r mymodule
|
||||
[ 3588.404778] Linux module skeleton unloaded
|
||||
|
||||
```
|
||||
|
||||
//-------------------
|
||||
// Exercise 3: What does it mean the 4 values in ```/proc/sys/kernel/printk``` ?
|
||||
//-------------------
|
||||
#task(
|
||||
[What does it mean the 4 values in ```/proc/sys/kernel/printk``` ?],
|
||||
[
|
||||
]
|
||||
[]
|
||||
)
|
||||
|
||||
We can show what there is in:
|
||||
@@ -226,15 +258,29 @@ We can show what there is in:
|
||||
```
|
||||
The number specified the level of output in a console.
|
||||
|
||||
This file specifies the log level for:
|
||||
- current: 7
|
||||
- default: 4
|
||||
- minimum: 1
|
||||
- boot-time-default: 7
|
||||
This file specifies the log level for: \
|
||||
current (7), default (4), minimum (1) and boot-time default (7).
|
||||
|
||||
This number matches with this table (#link("https://www.kernel.org/doc/html/latest/core-api/printk-basics.html", [printk documentation])):
|
||||
#image("resources/img/printk-log-levels.png")
|
||||
|
||||
#table(
|
||||
columns: (2fr, 1fr, 3fr),
|
||||
|
||||
[*Name*], [*String*], [*Alias function*],
|
||||
|
||||
[KERN_EMERG], ["0"], [pr_emerg()],
|
||||
[KERN_ALERT], ["1"], [pr_alert()],
|
||||
[KERN_CRIT], ["2"], [pr_crit()],
|
||||
[KERN_ERR], ["3"], [pr_err()],
|
||||
[KERN_WARNING], ["4"], [pr_warning()],
|
||||
[KERN_NOTICE], ["5"], [pr_notice()],
|
||||
[KERN_INFO], ["6"], [pr_info()],
|
||||
[KERN_DEBUG], ["7"], [pr_debug() and pr_devel() if DEBUG is defined],
|
||||
[KERN_DEFAULT], [""], [],
|
||||
[KERN_CONT], ["c"], [pr_cont()],
|
||||
)
|
||||
|
||||
#pagebreak()
|
||||
//-------------------
|
||||
// Exercise 4: Create module with dynamic allocation and a chained list
|
||||
//-------------------
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" style="background: transparent; background-color: transparent;" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="666px" height="398px" viewBox="-0.5 -0.5 666 398" content="<mxfile><diagram name="Page-1" id="RzmYo_imKgWcYN3XHb4n">7Vxbc5s6EP41frSHmwA/JnHSTHqZTt32tI8yCJsTjFwhx05+/RFY2IBkbIdrTpPMtGYRMnzf7mp3tWSg3yy3HwhcLT5jFwUDTXG3A30y0DRVN8bsv1jyvJOAMdgJ5sR3+aCDYOq/IC5UuHTtuyjKDaQYB9Rf5YUODkPk0JwMEoI3+WEeDvLfuoJzJAimDgxE6T++Sxc7qQ2Ug/we+fNF+s2qws8sYTqYC6IFdPEmI9JvB/oNwZjuPi23NyiIwUtx2V13d+Ts/sYICuk5FwTmzy+OCYbLHx8f/3w38M9hNByqfJqIPqdPjFwGAD/EhC7wHIcwuD1Irwlehy6Kp1XY0WHMJ4xXTKgy4b+I0mfOJlxTzEQLugz4WbT16a/M59/xVCMN8MPJlk+dHDynByElz7+yB9nL4uPDdclReqEIVPrQeE0c/tS/77+vX24/24vw4cE2P75YwfV4qOpc4yCZI37t00QLNtbPbw/0t0P+LOj68ep6yCeMoct8A+fhA8JLxG6IDSAogNR/yusW5Co63487sMg+cCIvIVXbTfwEgzX/qun0fhDrxx37d4qIDwMp75/gjNlvjisY+POQfXYYeogwwRMi1GcGcsVPLH3X3akFivwXOEvmi3FfYT+kybOB6wGYSJkoVUpu03zKgyXFd4C2pUDzs0NlpJoKZ/Fs8Pl0X+P7P8xl7C7gfmyogvwE2PMipiNF7vb3dBadpVqYoXOCnUdGRgzRcoUjtOd2gSMqMHuw15jQzcKnaLqCieZvmNfO8x3EKvAVRz71sZT3T4UBNDb602oyw5TiZZk5XkCrZozGVo4PzeLKsTl4aS310ouMh9ZtpbrZlTmBDE1fYIhXfjU+juJYF1E18KGn4JeRYbVKhsQFTm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2fobmWc02ktL5q8huoG7faV1VahXwvvaVxf9eM6J220/QhcmypJnh6LZc01pVVS7teyi9rqysMB20s4Zps9/BvrSt337gnVmAmeBPyogKMdWWWrMIK9Zei6+9HUaEGarRi8cCS9YY3VT6QMiOWej6zp6Z/GS355rB9H3CGFLNNUsTesJSUjc9uSFO8iAX4/2NCDGtUoMQWKUnLpK2U2SQvnXBOqiweHbyQ5cJosb+9Grgqvk8Fzn+fqrl3JcUevTqW+ovZ2lvIScJ2vNZAR7HRFZz/wpbZGB2y1K+uVK8OzNQCZtJXttrdh9QFVPpe+Wzvr1jwLOj0PiR3Az3Zh9THb53TBqvZ5rmc1t7MVilSe3uUtvdGUndm+qqqBjAKyZlaXtYojk//EFRddQ15It3bZp423xbkpZsstIc/1qXf/gc=</diagram></mxfile>"><defs><linearGradient x1="0%" y1="0%" x2="0%" y2="100%" id="drawio-svg-kEzeUsMfkgmiFLXX6xGR-gradient-light-dark_fff2cc_281d00_-1-light-dark_ffd966_543300_-1-s-0"><stop offset="0%" stop-color="#fff2cc" stop-opacity="1" style="stop-color: light-dark(rgb(255, 242, 204), rgb(40, 29, 0)); stop-opacity: 1;"/><stop offset="100%" stop-color="#ffd966" stop-opacity="1" style="stop-color: light-dark(rgb(255, 217, 102), rgb(84, 51, 0)); stop-opacity: 1;"/></linearGradient><linearGradient x1="0%" y1="0%" x2="0%" y2="100%" id="drawio-svg-kEzeUsMfkgmiFLXX6xGR-gradient-light-dark_f5f5f5_1a1a1a_-1-light-dark_b3b3b3_535353_-1-s-0"><stop offset="0%" stop-color="#f5f5f5" stop-opacity="1" style="stop-color: light-dark(rgb(245, 245, 245), rgb(26, 26, 26)); stop-opacity: 1;"/><stop offset="100%" stop-color="#b3b3b3" stop-opacity="1" style="stop-color: light-dark(rgb(179, 179, 179), rgb(83, 83, 83)); stop-opacity: 1;"/></linearGradient><linearGradient x1="0%" y1="0%" x2="0%" y2="100%" id="drawio-svg-kEzeUsMfkgmiFLXX6xGR-gradient-light-dark_d5e8d4_1f2f1e_-1-light-dark_97d077_295a0d_-1-s-0"><stop offset="0%" stop-color="#d5e8d4" stop-opacity="1" style="stop-color: light-dark(rgb(213, 232, 212), rgb(31, 47, 30)); stop-opacity: 1;"/><stop offset="100%" stop-color="#97d077" stop-opacity="1" style="stop-color: light-dark(rgb(151, 208, 119), rgb(41, 90, 13)); stop-opacity: 1;"/></linearGradient><linearGradient x1="0%" y1="0%" x2="0%" y2="100%" id="drawio-svg-kEzeUsMfkgmiFLXX6xGR-gradient-light-dark_dae8fc_1d293b_-1-light-dark_7ea6e0_436697_-1-s-0"><stop offset="0%" stop-color="#dae8fc" stop-opacity="1" style="stop-color: light-dark(rgb(218, 232, 252), rgb(29, 41, 59)); stop-opacity: 1;"/><stop offset="100%" stop-color="#7ea6e0" stop-opacity="1" style="stop-color: light-dark(rgb(126, 166, 224), rgb(67, 102, 151)); stop-opacity: 1;"/></linearGradient><linearGradient x1="0%" y1="0%" x2="0%" y2="100%" id="drawio-svg-kEzeUsMfkgmiFLXX6xGR-gradient-light-dark_ffcd28_6a3f00_-1-light-dark_ffa500_a05300_-1-s-0"><stop offset="0%" stop-color="#ffcd28" stop-opacity="1" style="stop-color: light-dark(rgb(255, 205, 40), rgb(106, 63, 0)); stop-opacity: 1;"/><stop offset="100%" stop-color="#ffa500" stop-opacity="1" style="stop-color: light-dark(rgb(255, 165, 0), rgb(160, 83,Line truncated
|
||||
|
After Width: | Height: | Size: 46 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 247 KiB |
Reference in new issue
Block a user