Initial commit

This commit is contained in:
github-classroom[bot] 2024-11-17 22:15:14 +00:00 committed by GitHub
commit 5cb3fd2d1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 151 additions and 0 deletions

17
Module/Makefile Normal file
View File

@ -0,0 +1,17 @@
KERNELDIR=/lib/modules/`uname -r`/build
# This the the Makefile for the device driver (not your demonstration program)
#Change the base name here to your module file name - no extension
BASENAME=helloworld
MODULES = $(BASENAME).ko
obj-m += $(BASENAME).o
all:
make -C $(KERNELDIR) M=$(PWD) modules
clean:
make -C $(KERNELDIR) M=$(PWD) clean

71
README.md Normal file
View File

@ -0,0 +1,71 @@
# CSC415-Device-Driver
## SETUP REQUIREMENTS:
Because this is a newer version of the OS than prior semesters, there have been some changes which require you execute the following four lines in you Ubuntu terminal window before you start this project.
```
sudo apt update
sudo apt install gcc-12
sudo apt install pahole
sudo ln -sf /sys/kernel/btf/vmlinux /usr/lib/modules/$(uname -r)/build/vmlinux
```
Failure to do the above commands may prevent your project from compiling correctly.
**Background**:
The Linux operating system consists of the Kernel some other minor components and then a large number of Device Drivers. Device drivers are the key to how various hardware devices interface with the computer.
**Task**:
Develop a device driver that can be loaded and run in Linux. Then add some functionality to the device driver such as the user/application passing in a string to the device driver and the device driver returns an encrypted version of the string or passes in the excrypted string and returns the original string. Include a document on how to build, load and interact with the device driver (after the description in the write up template) along with screen shots of output.
**Requirements**:
It must be written in C. It must be a valid an loadable device driver with at least some user/application functionality. That includes an open, release, read, write, and at least one ioctl command. It must also be able to be unloaded, and indicate that it has unloaded from the system. Make use of the printk and copy_to_user functions. The read and write functions should follow the concept of linux files and be relevent to reading or writing.
Part of the grading of the driver will be based on the functionality you choose to implement. It can not be trivial functionality.
This must be run in the linux virtual machine.
You must also write a user application that utilizes your device driver.
There are TWO directories in your GitHub: The first is `Module` that has your kernel module. The second is `Test` that will have your test user application.
The writeup should have a detailed description of what your device driver does and clear instructions on how to build your kernel module and your test program and how to install the kernel module and how to use your test program.
**Example**:
Encrypt data, read and write a string, use ioctl to determine to encrypt or decrypt and to set an key. If ioctl set to encrypt, write a string, then read back the encrypted data. Switch ioctl to decrypt then write the encrypted string and read back the original message (decrypted).
**NOTE:**
No basic calculator or palindrome allowed!
**Submission**:
Submit your write-up as a PDF on Canvas, and your code and Makefile (modify that provided) in Git along with the PDF.
**Hint**:
The provided module makefile is a key to building kernel modules.
Make sure there are no spaces in the entire path to the Module directory.
**Grading**:
This project will be graded based on meeting the following rubric.
**Rubric**:
|Component | Points |
|:------------------------------------------------------------------------|------:|
|Loadable Device Driver with Functionality as specified | 35 |
|Correctness of load and unload functions | 10 |
|Test - user/application interaction with the device driver | 20 |
|Inline comments - meaningful describing concepts and functionality | 13 |
|Standard Header a define in all prior projects for each file | 2 |
|Write-up of project | 20 |
|Write-up includes Screen shots showing all elements of functionality | |
| (include load and unload as well as application interaction | |

63
Test/Makefile Normal file
View File

@ -0,0 +1,63 @@
# File: Standard Makefile for CSC415
#
# Description - This make file should be used for all your projects
# It should be modified as needed for each homework
#
# ROOTNAME should be set you your lastname_firstname_HW. Except for
# and group projects, this will not change throughout the semester
#
# HW should be set to the assignment number (i.e. 1, 2, 3, etc.)
#
# FOPTION can be set to blank (nothing) or to any thing starting with an
# underscore (_). This is the suffix of your file name.
#
# With these three options above set your filename for your homework
# assignment will look like: bierman_robert_HW1_main.c
#
# RUNOPTIONS can be set to default values you want passed into the program
# this can also be overridden on the command line
#
# OBJ - You can append to this line for additional files necessary for
# your program, but only when you have multiple files. Follow the convention
# but hard code the suffix as needed.
#
# To Use the Makefile - Edit as above
# then from the command line run: make
# That command will build your program, and the program will be named the same
# as your main c file without an extension.
#
# You can then execute from the command line: make run
# This will actually run your program
#
# Using the command: make clean
# will delete the executable and any object files in your directory.
#
FIRSTNAME=
LASTNAME=
ROOTNAME=$(LASTNAME)_$(FIRSTNAME)_HW
HW=6
FOPTION=_main
RUNOPTIONS=
CC=gcc
CFLAGS= -g -I.
LIBS =-l pthread
DEPS =
OBJ = $(ROOTNAME)$(HW)$(FOPTION).o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
$(ROOTNAME)$(HW)$(FOPTION): $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
clean:
rm *.o $(ROOTNAME)$(HW)$(FOPTION)
run: $(ROOTNAME)$(HW)$(FOPTION)
./$(ROOTNAME)$(HW)$(FOPTION) $(RUNOPTIONS)
vrun: $(ROOTNAME)$(HW)$(FOPTION)
valgrind ./$(ROOTNAME)$(HW)$(FOPTION) $(RUNOPTIONS)