From 3d65a46cc1b7a33bfc6c11ce78df5e2c1723b26d Mon Sep 17 00:00:00 2001 From: Oleksii Vodka Date: Thu, 22 Dec 2022 16:54:14 +0200 Subject: [PATCH 1/6] Homeworks 1. Create readme file Signed-off-by: Oleksii Vodka --- task1-simple-program/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 task1-simple-program/README.md diff --git a/task1-simple-program/README.md b/task1-simple-program/README.md new file mode 100644 index 00000000..8b0a402e --- /dev/null +++ b/task1-simple-program/README.md @@ -0,0 +1,13 @@ +# Simple c program with commits +The main idea of of this task is to demonstrate your ability to work with git and create correctly formed commit. +So, you have to focus on the rules and principals of working with github, not on code complexity. +## Task +1. Please, write simple game "guess a number". User input some number from 0 to 9. Computer also generates random number from 0 to 9. If values are equal, user will get message “You win”. In other case – “You loose”. main() function should return 0 if you win, and non-zero value otherwise. +2. When you working on code, please divide it on several steps. Each steps will be new commit. There are possible steps: + a. Create simple *.c file with empty main() function + b. Write main functionality + c. Rewrite code, that random number generates in you own defined function. +3. Check coding style with checkpatch.pl +4. Also don't forget to create .gitignore file +5. Create pull request to this repo into you own branch (have to be already exist) +6. Good luck \ No newline at end of file From e6bd88b0ee3740d10d5ead8d5e20f6f5df811483 Mon Sep 17 00:00:00 2001 From: Oleksii Vodka Date: Thu, 22 Dec 2022 17:12:57 +0200 Subject: [PATCH 2/6] Homeworks 2: Create readme file Signed-off-by: Oleksii Vodka --- task2-bash/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 task2-bash/README.md diff --git a/task2-bash/README.md b/task2-bash/README.md new file mode 100644 index 00000000..265aa56e --- /dev/null +++ b/task2-bash/README.md @@ -0,0 +1,9 @@ +# Part 2. Bash +The main idea of this task is to increase you level of bash-scripting. + +## Task +1. Please write a bash script that is copping all source code of your project form part1 to /tmp/guesanumber. Compress this folder to gzip archive (please google tar command) with same name. Copy gzip archive to “release” subdirectory in project dir. Please, don't forget to divide script on commits. +2. Please write another script, which run program "guess a number" from task1 in infinity loop, and each iteration ask user to press "y" to continue, "n" to exit, or number to set number of runs of tries without asking "y or n". Script counting users success cases and printing it numbers. Also after each success script says "Good job", otherwise "Wish a good luck next time". Please, don't forget to divide script on commits. +3. Make a pull request. +4. If you want, you may use colors to increase readability of script output. +5. Good luck From 0747309cb9cdcdb06ca8553e1134cc58830df7d3 Mon Sep 17 00:00:00 2001 From: Oleksii Vodka Date: Thu, 22 Dec 2022 17:26:01 +0200 Subject: [PATCH 3/6] Homeworks 3: Create readme file Signed-off-by: Oleksii Vodka --- task3-make/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 task3-make/README.md diff --git a/task3-make/README.md b/task3-make/README.md new file mode 100644 index 00000000..1b43522c --- /dev/null +++ b/task3-make/README.md @@ -0,0 +1,15 @@ + +# Part 3. Make +The main idea of this task in improve your skills in writing Makefiles. + +## Task + +1. Please, divide your source code form Task1 into two source file. First one should contains the main() function. Other one contains all other code. Write a Makefile for your project. +2. Implement options to build your project with gcc or clang +3. Implement options to link second files in regular way, static library (.a) or dynamic library (.so). +4. Implement option to check all project code using checkpatch.pl or cppcheck +5. Implement option to include debug information. +6. Implement option to print all warning during compilation. +7. Implement "clean" options. +8. Submit this Makefile with all code to github as pull request. Don't forget commit each step. +9. Good luck From ce542c7c7fb1ad3d20909d9e21a0968496978697 Mon Sep 17 00:00:00 2001 From: Maksym Khomenko Date: Thu, 23 Feb 2023 22:23:39 +0200 Subject: [PATCH 4/6] Homework task4 simple driver: Implement simple driver that gets 2 arguments and calculates their sum, difference and product, all driver activities are storied in the log with the pr_info function Signed-off-by: Maksym Khomenko --- task4-simple-driver/Makefile | 11 +++++++++++ task4-simple-driver/hello.c | 32 ++++++++++++++++++++++++++++++++ task4-simple-driver/hello.ko | Bin 0 -> 6928 bytes 3 files changed, 43 insertions(+) create mode 100644 task4-simple-driver/Makefile create mode 100644 task4-simple-driver/hello.c create mode 100644 task4-simple-driver/hello.ko diff --git a/task4-simple-driver/Makefile b/task4-simple-driver/Makefile new file mode 100644 index 00000000..067c26a3 --- /dev/null +++ b/task4-simple-driver/Makefile @@ -0,0 +1,11 @@ +ifneq ($(KERNELRELEASE),) +# Kbuild part of makefile +obj-m := hello.o +else +# build for current kernel if KDIR is not specified +KDIR ?= /lib/modules/`uname -r`/build +default: + $(MAKE) -C $(KDIR) M=$(PWD) +clean: + $(MAKE) -C $(KDIR) M=$(PWD) +endif diff --git a/task4-simple-driver/hello.c b/task4-simple-driver/hello.c new file mode 100644 index 00000000..187857b9 --- /dev/null +++ b/task4-simple-driver/hello.c @@ -0,0 +1,32 @@ +#include // Macros used to mark up functions e.g., __init __exit +#include // Core header for loading LKMs into the kernel +#include // Contains types, macros, functions for the kernel + +MODULE_LICENSE("GPL"); ///< The license type -- this affects runtime behavior +MODULE_AUTHOR("Name Surname"); ///< The author -- visible when you use modinfo +MODULE_DESCRIPTION("Description"); ///< The description -- see modinfo +MODULE_VERSION("0.1"); ///< The version of the module + +static int op1 = 0; +static int op2 = 0; + +module_param(op1, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); +MODULE_PARM_DESC(op1, "First parameter of type s32"); + +module_param(op2, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); +MODULE_PARM_DESC(op2, "Second parameter of type s32"); + +static int __init hello_init(void){ +pr_info("HELLO: Hello Kernel!\n"); +pr_info("HELLO: Sum of parameters = %d\n", op1 + op2); +pr_info("HELLO: Difference of parameters = %d\n", op1 - op2); +pr_info("HELLO: Product of parameters = %d\n", op1 * op2); +return 0; +} + +static void __exit hello_exit(void){ +pr_info("HELLO: Goodbye Kernel!\n"); +} + +module_init(hello_init); +module_exit(hello_exit); diff --git a/task4-simple-driver/hello.ko b/task4-simple-driver/hello.ko new file mode 100644 index 0000000000000000000000000000000000000000..251be949538d00523fde4f82be983dcbfa24c68a GIT binary patch literal 6928 zcmeHLU2GIp6u#Rn%AZ(3`~!55q9xGD{?~=6 zLBIzw@u3)F;7Lf(h`vC05Mmvn27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FERyZWof?27+lxPM28*%F>_uI*DDeGr^ zeMpC#b+hhDz%y@Gic=Kou=(<#}N z{cnTuF#n@e3UQvIf0SEF_Sk9ij!GVewz2`1xMI__2nP<9{14^dHC{ zGzv|QSLRQU46m=F1V00d)PI-sW&b-DsehjI6YQAi5b1v^;XHqy$7Rx&ofmF3;p&bu0$6*A_a*R-?h+>(SnSU9uwLBbr`@`BtH1pTOql+4(&zkT9a%pL3yNzh$3IW{bF4^I zj(-&>BPO5UD;N|sSzh*!^$Yr!8|%xsEW4TX<$1FH0m%UC`>8y4ROz6=Z&DuOJ&$z( m&xiLP?*w`70Eyf5*Uc? Date: Thu, 23 Feb 2023 22:27:33 +0200 Subject: [PATCH 5/6] Homework task4 simple driver: Add generated by the compiler files to .gitignore except *.ko Signed-off-by: Maksym Khomenko --- .gitignore | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..d3cbfcac --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +# no .mod files +*.mod* + +# no .o files. +*.o + +# no .cmd files. +*.cmd + +# no .symvers files. +*.symvers + +# no .order files. +*.order + From fe59fc40b4acee2f0e8e9d3a39172a1ce79c3fc5 Mon Sep 17 00:00:00 2001 From: Maksym Khomenko Date: Thu, 23 Feb 2023 23:16:36 +0200 Subject: [PATCH 6/6] Homework task4 simple driver: Refactor hello.c to satisfy the requirements of checkpatch.pl Signed-off-by: Maksym Khomenko --- task4-simple-driver/hello.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/task4-simple-driver/hello.c b/task4-simple-driver/hello.c index 187857b9..1eaedd29 100644 --- a/task4-simple-driver/hello.c +++ b/task4-simple-driver/hello.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 #include // Macros used to mark up functions e.g., __init __exit #include // Core header for loading LKMs into the kernel #include // Contains types, macros, functions for the kernel @@ -7,16 +8,17 @@ MODULE_AUTHOR("Name Surname"); ///< The author -- visible when you use modinfo MODULE_DESCRIPTION("Description"); ///< The description -- see modinfo MODULE_VERSION("0.1"); ///< The version of the module -static int op1 = 0; -static int op2 = 0; +static int op1 = -1; +static int op2 = -1; -module_param(op1, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); +module_param(op1, int, 0660); MODULE_PARM_DESC(op1, "First parameter of type s32"); -module_param(op2, int, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); +module_param(op2, int, 0660); MODULE_PARM_DESC(op2, "Second parameter of type s32"); -static int __init hello_init(void){ +static int __init hello_init(void) +{ pr_info("HELLO: Hello Kernel!\n"); pr_info("HELLO: Sum of parameters = %d\n", op1 + op2); pr_info("HELLO: Difference of parameters = %d\n", op1 - op2); @@ -24,7 +26,8 @@ pr_info("HELLO: Product of parameters = %d\n", op1 * op2); return 0; } -static void __exit hello_exit(void){ +static void __exit hello_exit(void) +{ pr_info("HELLO: Goodbye Kernel!\n"); }