From: dopefishh Date: Fri, 25 Sep 2015 11:04:29 +0000 (+0200) Subject: ex09 done with lpt X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=b0982d5285b5169b3de15d37c5f64ae39a944c18;p=des2015.git ex09 done with lpt --- diff --git a/mart/ex09/Makefile b/mart/ex09/Makefile index 8826d35..690a5d1 100644 --- a/mart/ex09/Makefile +++ b/mart/ex09/Makefile @@ -3,7 +3,7 @@ LDFLAGS=$(shell xeno-config --xeno-ldflags)\ -lnative -lrtdk -Xlinker -rpath\ -Xlinker $(shell xeno-config --libdir) -BINARIES=ex09a1 ex09a2 +BINARIES=ex09a1 ex09a2 ex09b all: $(BINARIES) diff --git a/mart/ex09/ex09a1.c b/mart/ex09/ex09a1.c index fdd2f28..faa29fe 100644 --- a/mart/ex09/ex09a1.c +++ b/mart/ex09/ex09a1.c @@ -17,9 +17,10 @@ void keyboard_handler(void *arg) { RT_INTR intr; rt_intr_create(&intr, "keyboard handler", KBDIRQ, I_PROPAGATE); - int keypresses = 0; + int kps = 0; while(1){ - rt_printf("#Keypresses: %d\n", keypresses += rt_intr_wait(&intr, TM_INFINITE)); + rt_printf("#Kbd interrupt %d\n", + kps += rt_intr_wait(&intr, TM_INFINITE)); } } diff --git a/mart/ex09/ex09a2.c b/mart/ex09/ex09a2.c index bac6c53..b702176 100644 --- a/mart/ex09/ex09a2.c +++ b/mart/ex09/ex09a2.c @@ -32,9 +32,9 @@ void keyboard_handler(void *arg) RT_TASK_INFO ctaskinfo; ctask = rt_task_self(); rt_intr_create(&intr, "keyboard handler", KBDIRQ, I_PROPAGATE); - int keypresses = 0; + int kps = 0; while(1){ - rt_printf("#Keypresses: %d\n", keypresses += rt_intr_wait(&intr, TM_INFINITE)); + rt_printf("Kbd interrupts: %d\n", kps += rt_intr_wait(&intr, TM_INFINITE)); rt_task_inquire(ctask, &ctaskinfo); rt_printf("Prio: %d\n", ctaskinfo.cprio); } diff --git a/mart/ex09/ex09b.c b/mart/ex09/ex09b.c new file mode 100644 index 0000000..f7e37a5 --- /dev/null +++ b/mart/ex09/ex09b.c @@ -0,0 +1,50 @@ +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#define LPT1IRQ 7 + +RT_TASK task; + +void lpt1_handler(void *arg) +{ + RT_INTR intr; + rt_intr_create(&intr, "lpt1 handler", LPT1IRQ, 0); + int bps = 0; + while(1){ + rt_printf("lpt1 interrupt: %d\n", + bps += rt_intr_wait(&intr, TM_INFINITE)); + } +} + +int main(int argc, char* argv[]) +{ + rt_print_auto_init(1); + + /* setup lpt1 */ + ioperm(0x37A, 1, 1); + unsigned char byte = inb(0x37A); + byte |= 0x10; + outb(byte, 0x37A); + + mlockall(MCL_CURRENT | MCL_FUTURE); + + rt_task_create(&task, "task", 0, 50, 0); + rt_task_start(&task, &lpt1_handler, 0); + + rt_printf("CRTL+C to stop\n"); + pause(); + + /* break down lpt1 */ + byte = inb(0x37A); + byte &= 0xEF; + outb(byte, 0x37A); +} diff --git a/mart/ex09/explanations.txt b/mart/ex09/explanations.txt index 54b14f3..de218af 100644 --- a/mart/ex09/explanations.txt +++ b/mart/ex09/explanations.txt @@ -1,7 +1,10 @@ 9a1. -The program just prints the number of keypresses +The program just prints the number of keyboard interrupts, these are interrupts for press, release and hold. 9a2. It happens that within the spinning the keyboard handler prints the number of keypresses. This is because the priority is set to 257 because it's an interrupt handler. + +9b. +The program prints all interrupts, so a different for press and release.