aboutsummaryrefslogtreecommitdiff
path: root/sem1/osc/mm1
diff options
context:
space:
mode:
Diffstat (limited to 'sem1/osc/mm1')
-rw-r--r--sem1/osc/mm1/.gitignore10
-rw-r--r--sem1/osc/mm1/mm1/Makefile7
-rw-r--r--sem1/osc/mm1/mm1/Readme.md34
-rw-r--r--sem1/osc/mm1/mm1/jmod.c70
-rw-r--r--sem1/osc/mm1/mm2/tprog.c71
5 files changed, 0 insertions, 192 deletions
diff --git a/sem1/osc/mm1/.gitignore b/sem1/osc/mm1/.gitignore
deleted file mode 100644
index b18a498..0000000
--- a/sem1/osc/mm1/.gitignore
+++ /dev/null
@@ -1,10 +0,0 @@
-jmod.ko
-.jmod.ko.cmd
-jmod.mod.c
-jmod.mod.o
-.jmod.mod.o.cmd
-jmod.o
-.jmod.o.cmd
-modules.order
-Module.symvers
-.tmp_versions
diff --git a/sem1/osc/mm1/mm1/Makefile b/sem1/osc/mm1/mm1/Makefile
deleted file mode 100644
index 13c8e62..0000000
--- a/sem1/osc/mm1/mm1/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-obj-m += jmod.o
-
-all:
- make -C /lib/modules/$(shell uname -r)/build M=$(shell pwd) modules
-clean:
- make -C /lib/modules/$(shell uname -r)/build M=$(shell pwd) clean
-
diff --git a/sem1/osc/mm1/mm1/Readme.md b/sem1/osc/mm1/mm1/Readme.md
deleted file mode 100644
index fcc6cb3..0000000
--- a/sem1/osc/mm1/mm1/Readme.md
+++ /dev/null
@@ -1,34 +0,0 @@
-# Opgaver til operativ systemer
-
-Ligenu er det ikke delt op i mapper.
-
-## Kør mini kernel modul
-
-Compile med make.
-Husk at peg makefile på din kernel modul mappe.
-Denne er testet på ubuntu server 19.04.
-
-```
-make
-```
-
-Nu burde der være kommet et jmod.ko som kan loades med.
-
-```
-sudo insmod jmod.ko
-```
-
-Hvis du får permission denied kan du få flere information ved at checke `dmesg` loggen.
-
-Nu kan du hente major number ind fra dmesg. Led efter `COOL_MODULE:`.
-Dette nummer bruger du til at assign den en node
-
-```
-sudo mknod /dev/cooldev c MAJOR 0
-```
-
-Dette vil map kernel-modul/driver til cooldev i /dev/ mappen.
-Husk at skriv til MAJOR nummer fra `dmesg` i stedet for MAJOR.
-
-Hvis man læser man pagen kan man se at det bliver lavet som en character unbuffered file.
-MINOR nummeret er 0 da vores driver alligevel ikke bruger det til noget.
diff --git a/sem1/osc/mm1/mm1/jmod.c b/sem1/osc/mm1/mm1/jmod.c
deleted file mode 100644
index a07077c..0000000
--- a/sem1/osc/mm1/mm1/jmod.c
+++ /dev/null
@@ -1,70 +0,0 @@
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/fs.h>
-#include <asm/uaccess.h>
-
-static int major_num;
-static int busy;
-
-
-static int cool_open(struct inode *inode, struct file *file) {
- /* Check if we are already serving someone */
- if (busy) {
- return -EBUSY;
- }
-
- busy = 1;
- return 0;
-}
-
-static int cool_release (struct inode *inode, struct file *file) {
- busy = 0;
-
- return 0;
-}
-
-static ssize_t cool_read (struct file *filp, char *buffer, size_t len, loff_t *offset) {
-
- char str[12] = "hej med dig";
- int i;
-
- for (i = 0; i < len; i++) {
- put_user(str[i % 12], buffer++);
- }
-
- return i;
-}
-
-static struct file_operations file_ops = {
- .owner = THIS_MODULE,
- .read = cool_read,
- .open = cool_open,
- .release = cool_release
-};
-
-static int __init jmod_init(void)
-{
- printk(KERN_INFO "COOL_MODULE: Registering cooldev\n");
-
- major_num = register_chrdev(0, "cooldev", &file_ops);
- if (major_num < 0) {
- printk(KERN_ERR "COOL_MODULE: Could not register major\n");
- return 1;
- }
-
- printk(KERN_INFO "COOL_MODULE: Got major %d\n", major_num);
-
- return 0;
-}
-
-
-static void __exit jmod_exit(void)
-{
- printk(KERN_INFO "COOL_MODULE: Nou moe\n");
- unregister_chrdev(major_num, "cooldev");
-}
-
-module_init( jmod_init );
-module_exit( jmod_exit );
-
diff --git a/sem1/osc/mm1/mm2/tprog.c b/sem1/osc/mm1/mm2/tprog.c
deleted file mode 100644
index 377555f..0000000
--- a/sem1/osc/mm1/mm2/tprog.c
+++ /dev/null
@@ -1,71 +0,0 @@
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/time.h>
-
-#define STARTSEC 10
-#define ENDUSEC 500000
-#define SPEED 0.8
-
-struct itimerval timer;
-
-void timer_handler(int signum) {
- /* Handy structure reference */
- struct timeval *tv = &timer.it_value;
- printf("Hey we hit the alarm\n\a");
-
- /* Calculate new alarm */
- tv->tv_sec *= SPEED;
- if (tv->tv_sec == 0) {
- /* If tv_usec is 0 set i to 1 sec otherwise half it */
- if (tv->tv_usec == 0) {
- tv->tv_usec = 999999;
- } else if (tv->tv_usec > ENDUSEC) {
- tv->tv_usec *= SPEED;
- if (tv->tv_usec < ENDUSEC) {
- tv->tv_usec = ENDUSEC;
- }
- } else {
- /* Return letting the timer be set to ENDUSEC */
- return;
- }
- }
-
- printf("Set to %d and %d\n", timer.it_value.tv_sec, timer.it_value.tv_usec);
- /* Set alarm */
- int err = setitimer(ITIMER_REAL, &timer, NULL);
- if (err) {
- printf("Hey we got an error guys\n");
- exit(1);
- }
-}
-
-int main() {
- /* Setup handler for timer */
- struct sigaction sa;
- memset(&sa, 0, sizeof(sa)); /* Remeber to set all fields to zero */
-
- sa.sa_handler = &timer_handler;
- sigaction(SIGALRM, &sa, NULL);
-
- /* Setup timer values */
- timer.it_value.tv_sec = STARTSEC;
- timer.it_value.tv_usec = 0;
-
- timer.it_interval.tv_sec = 0;
- timer.it_interval.tv_usec = ENDUSEC;
-
- /* Start the timer */
- setitimer(ITIMER_REAL, &timer, NULL);
-
- /* Select signals */
- sigset_t sigset;
- sigemptyset(&sigset);
- sigaddset(&sigset, SIGTERM);
-
- /* Wait for termination */
- sigwait(&sigset, NULL);
-
- return 0;
-}