-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
03 module task #119
Open
marynamalakhova
wants to merge
4
commits into
Kernel-GL-HRK:Maryna.Malakhova
Choose a base branch
from
marynamalakhova:03_module_task
base: Maryna.Malakhova
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+89
−0
Open
03 module task #119
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
TARGET = msimplemodule | ||
obj-m += $(TARGET).o | ||
default: | ||
$(MAKE) -C $(BUILD_KERNEL) M=$(CURDIR) modules | ||
|
||
clean: | ||
$(MAKE) -C $(BUILD_KERNEL) M=$(CURDIR) clean | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/mnt # uname -a | ||
Linux (none) 4.19.176 #4 SMP Tue Mar 16 12:55:37 EET 2021 armv7l GNU/Linux | ||
/mnt # lsmod | ||
/mnt # insmod msimplemodule.ko | ||
[ 400.031994] simple module: iparam = -1 | ||
insmod: can't insert 'msimplemodule.ko': Operation not permitted | ||
/mnt # | ||
/mnt # | ||
/mnt # | ||
/mnt # dmesg -c | ||
[ 400.031994] simple module: iparam = -1 | ||
/mnt # | ||
/mnt # lsmod | ||
/mnt # | ||
/mnt # | ||
/mnt # insmod msimplemodule.ko iparam=0 | ||
[ 477.652962] simple module: iparam = 0 | ||
/mnt # dmesg -c | ||
[ 477.652962] simple module: iparam = 0 | ||
/mnt # | ||
/mnt # | ||
/mnt # lsmod | ||
msimplemodule 16384 0 - Live 0xbf020000 (O) | ||
/mnt # rmmod msimplemodule.ko | ||
/mnt # insmod msimplemodule.ko iparam=1 | ||
[ 498.952910] simple module: iparam = 1 | ||
insmod: can't insert 'msimplemodule.ko': Operation not permitted | ||
/mnt # | ||
/mnt # | ||
/mnt # | ||
/mnt # lsmod | ||
/mnt # dmesg -c | ||
[ 498.952910] simple module: iparam = 1 | ||
/mnt # insmod msimplemodule.ko iparam=-1 | ||
[ 518.104298] simple module: iparam = -1 | ||
insmod: can't insert 'msimplemodule.ko': Operation not permitted | ||
/mnt # dmesg -c | ||
[ 518.104298] simple module: iparam = -1 | ||
/mnt # | ||
/mnt # | ||
/mnt # lsmod | ||
/mnt # insmod msimplemodule.ko iparam=0 | ||
[ 531.005574] simple module: iparam = 0 | ||
/mnt # | ||
/mnt # | ||
/mnt # | ||
/mnt # lsmod | ||
msimplemodule 16384 0 - Live 0xbf038000 (O) | ||
/mnt # dmesg | ||
[ 531.005574] simple module: iparam = 0 | ||
/mnt # rmmod msimplemodule.ko |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
#define pr_fmt(fmt) "%s: " fmt, KBUILD_MODNAME | ||
#include <linux/init.h> // Macros used to mark up functions __init __exit | ||
#include <linux/module.h> // Core header for loading LKMs into the kernel | ||
#include <linux/kernel.h> // Contains types, macros, functions for the kernel | ||
#include <linux/moduleparam.h> | ||
|
||
static int iparam = -1; | ||
module_param(iparam, int, 0); | ||
|
||
static int __init hello_init(void) | ||
{ | ||
pr_debug("loading started\n"); | ||
pr_info("iparam = %d\n", iparam); | ||
iparam = iparam > 0 ? -iparam : iparam; | ||
return iparam; | ||
} | ||
|
||
static void __exit hello_exit(void) | ||
{ | ||
pr_debug("module exits\n"); | ||
} | ||
|
||
|
||
module_init(hello_init); | ||
module_exit(hello_exit); | ||
|
||
MODULE_AUTHOR("Malakhova.Maryna <[email protected]>"); | ||
MODULE_DESCRIPTION("Simple Kernel module"); | ||
MODULE_LICENSE("GPL"); | ||
MODULE_VERSION("0.1"); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makefile expects
BUILD_KERNEL
being defined in environment,but neither code, nor commit message don't explain this.