Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7c884c5
TASK1: Implement Hello World
tberchanov Nov 19, 2021
8f649a7
TASK1: Implemented scissors game
tberchanov Nov 19, 2021
66afb3d
Merge pull request #3 from tberchanov/ht_01_git
alexposukhov Nov 22, 2021
a28c26a
TASK2: develop hwdetect.sh
aberchanov Nov 21, 2021
183ac6b
TASK3: Add module task
serhii-perederii Nov 19, 2021
77a58ed
Task04: Add task for Lection 03
Nov 23, 2021
65d378c
Merge branch 'Kernel-GL-HRK:Anatolii.Berchanov' into Anatolii.Berchanov
tberchanov Nov 23, 2021
fef3718
Merge pull request #16 from tberchanov/task2
alexposukhov Nov 24, 2021
9653f4a
Ht 03 module (#40)
tberchanov Nov 24, 2021
f77fc6b
IMPROVEMENT: Create root gitignore
tberchanov Nov 28, 2021
bcff1b5
Merge pull request #67 from tberchanov/improvement_created_gitignore
tberchanov Nov 28, 2021
ce2f564
IMPROVEMENT: Create root gitignore
tberchanov Nov 28, 2021
f4ade3b
Task05: Add tasks for lesson 5 Time Management
ekovalyov Nov 30, 2021
e620e7a
Task06: Add tasks for lesson 6 Memory Management
ekovalyov Dec 2, 2021
f7825f8
Task04: Implement saving to list
tberchanov Nov 27, 2021
5970b76
Task04: Fix retrievemnt data from `list`
tberchanov Nov 28, 2021
80a27b2
Task04: Implement list cleaning 'list'
tberchanov Nov 29, 2021
2deca0b
Task04: Add logs file
tberchanov Dec 4, 2021
f88ee60
Merge branch 'Kernel-GL-HRK:Anatolii.Berchanov' into Anatolii.Berchanov
tberchanov Dec 13, 2021
8284596
Merge branch 'Anatolii.Berchanov' of github.com:tberchanov/gl_kernel_…
tberchanov Dec 13, 2021
34dc76e
Task05: Add userspace timers program.
tberchanov Dec 5, 2021
d467dbf
Task05: Implement skeleton for time_module.
tberchanov Dec 5, 2021
fa937d8
Task05: Add implementation to time_module.
tberchanov Dec 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
**/.vscode
**/*.out
**/*.o
**/*.cmd
**/*.symvers
**/*.order
**/*.ko
**/*.mod
**/*.mod.c
Binary file added 01_git/scissors/a.out
Binary file not shown.
81 changes: 81 additions & 0 deletions 01_git/scissors/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#include <stdio.h>
#include <stdlib.h>
#include<stdbool.h>

#define UNDEFINED 0
#define ERROR -1

#define ROCK 'r'
#define PAPER 'p'
#define SCISSORS 's'

bool is_command_valid(char command) {
return command == ROCK || command == PAPER || command == SCISSORS;
}

char get_computer_command() {
int command = rand() % 3;
switch (command) {
case 0:
return ROCK;
case 1:
return PAPER;
case 2:
return SCISSORS;
default:
return UNDEFINED;
}
}

char define_winner(char computer_command, char user_command) {
if (!is_command_valid(computer_command) || !is_command_valid(user_command)) {
return ERROR;
}

if (computer_command == user_command) {
return UNDEFINED;
} else if (computer_command == ROCK && user_command == SCISSORS) {
return computer_command;
} else if (computer_command == PAPER && user_command == ROCK) {
return computer_command;
} else if (computer_command == SCISSORS && user_command == PAPER) {
return computer_command;
} else {
return user_command;
}
}

char* get_command_name(char command) {
if (command == ROCK) {
return "rock";
} else if (command == PAPER) {
return "paper";
} else if (command == SCISSORS) {
return "scissors";
} else {
return "";
}
}

int main() {
printf("Please choose: rock (r) - paper (p) - scissors (s)\n");
char computer_command = get_computer_command();
char user_command = getchar();

char* computer_command_name = get_command_name(computer_command);
char* user_command_name = get_command_name(user_command);

printf("You choose %s, I choose %s\n", user_command_name, computer_command_name);

char winner_command = define_winner(computer_command, user_command);

if (winner_command == computer_command) {
printf("I win: %s beats %s\n", computer_command_name, user_command_name);
} else if (winner_command == user_command) {
printf("You win: %s beats %s\n", user_command_name, computer_command_name);
} else {
printf("Draw\n");
}

return 0;
}
5 changes: 5 additions & 0 deletions 01_git/scissors/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

rm a.out
gcc main.c
./a.out
Empty file added 02_bash/hwdetect/echo
Empty file.
49 changes: 49 additions & 0 deletions 02_bash/hwdetect/hwdetect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/sh

devices=`lsusb`
while :
do
sleep 1

new_devices=`lsusb`

# discover disconnected devices
for device in $devices
do
is_present=0
for new_device in $new_devices;
do
if [ $new_device = $device ]
then
is_present=1
break
fi
done

if [ $is_present -eq 0 ]
then
echo "Disconnected: $device"
fi
done

# discover connected devices
for new_device in $new_devices
do
is_present=0
for device in $devices;
do
if [ $new_device = $device ]
then
is_present=1
break
fi
done

if [ $is_present -eq 0 ]
then
echo "Connected: $new_device"
fi
done

devices=$new_devices
done
6 changes: 6 additions & 0 deletions 03_module/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module/*.cmd
module/*.mod*
module/*.ko
/module/*.o
module/Module.symvers
module/modules.order
15 changes: 15 additions & 0 deletions 03_module/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## module home work: create a simple loadable module with parameters

Create a loadadle kernel module which should accept two integer parameters and provide:
- A sum of parameters upon driver load
- A substration of parameters upon driver unload

Info about module parameters can be found at: https://devarea.com/linux-kernel-development-kernel-module-parameters/#.YZfWcpFByV4

Task should be performed using buildroot+qemu approach

The task results should contain:
- The module code
- The Makefile
- Dump of the kernel logs from the target system

Loading