From 8651593758a94326ab8942a59ba6bd22db68a733 Mon Sep 17 00:00:00 2001 From: Marian Ohligs Date: Mon, 23 May 2011 13:42:26 +0200 Subject: [PATCH 1/2] bug fix in fb.c --- arch/x86/kernel/kb.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/kb.c b/arch/x86/kernel/kb.c index ce377862..7307852e 100644 --- a/arch/x86/kernel/kb.c +++ b/arch/x86/kernel/kb.c @@ -109,15 +109,14 @@ static void keyboard_handler(struct state *r) * you would add 128 to the scancode when you look for it */ kputchar(kbdus[scancode]); - if (kb_buffer.size <= kb_buffer.maxsize) { + if (kb_buffer.size <= kb_buffer.maxsize && kb_buffer.buffer != NULL) { memcpy(kb_buffer.buffer + kb_buffer.size, &kbdus[scancode], 1); kb_buffer.size++; + if (scancode == 28 || scancode == 15 || kb_buffer.size >= kb_buffer.maxsize) { + wakeup_task(kb_buffer.tid); + reschedule(); + } } - if (scancode == 28 || scancode == 15 || kb_buffer.size >= kb_buffer.maxsize) { - wakeup_task(kb_buffer.tid); - reschedule(); - } - } } From bae6e2df517a2f25b1ba4138cc0ae62d506c0b75 Mon Sep 17 00:00:00 2001 From: Marian Ohligs Date: Mon, 23 May 2011 13:47:05 +0200 Subject: [PATCH 2/2] add tiny hangman test --- .gitignore | 1 + kernel/tests.c | 4 ++-- newlib/examples/Makefile | 9 ++++++++- newlib/examples/hangman.c | 41 +++++++++++++++++++++++++++++++++++++++ newlib/examples/test | 4 +++- 5 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 newlib/examples/hangman.c diff --git a/.gitignore b/.gitignore index 7c04e4b0..1e9f25b6 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ newlib/examples/hello newlib/examples/jacobi newlib/examples/echo newlib/examples/tests +newlib/examples/hangman newlib/tmp/* newlib/x86/* metalsvm.elf diff --git a/kernel/tests.c b/kernel/tests.c index 4c0d87a9..4ba43b9f 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -119,7 +119,7 @@ static int STDCALL join_test(void* arg) int test_init(void) { - char* argv[] = {"/bin/hello", NULL}; + char* argv[] = {"/bin/hangman", NULL}; sem_init(&producing, 1); sem_init(&consuming, 0); @@ -131,7 +131,7 @@ int test_init(void) //create_kernel_task(NULL, consumer, NULL); //create_kernel_task(NULL, ping, NULL); //create_user_task(NULL, "/bin/hello", argv); - create_user_task(NULL, "/bin/hello", argv); + create_user_task(NULL, "/bin/hangman", argv); //create_user_task(NULL, "/bin/jacobi", argv); return 0; diff --git a/newlib/examples/Makefile b/newlib/examples/Makefile index e1a373f9..f63906cb 100644 --- a/newlib/examples/Makefile +++ b/newlib/examples/Makefile @@ -11,7 +11,7 @@ LDFLAGS = default: all -all: hello tests jacobi +all: hello tests jacobi hangman jacobi: jacobi.o $(CC_FOR_TARGET) -T link.ld -o $@ $(LDFLAGS) $< -lm @@ -31,6 +31,13 @@ hello: hello.o $(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@ chmod a-x $@.sym +hangman: hangman.o + $(CC_FOR_TARGET) -T link.ld -o $@ $(LDFLAGS) $< + $(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym + $(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@ + chmod a-x $@.sym + + clean: $(RM) hello tests *.sym *.o *~ diff --git a/newlib/examples/hangman.c b/newlib/examples/hangman.c new file mode 100644 index 00000000..e558b0ef --- /dev/null +++ b/newlib/examples/hangman.c @@ -0,0 +1,41 @@ +#include +#include +#include + +int Spiel () +{ + //Variablen + + char* Wort = malloc(100*sizeof(char)); + char* Raten = malloc(100*sizeof(char));; + int Versuche = 10; + + printf("Spieler 1 geben sie das Wort ein :"); + scanf("%s", Wort); + + printf("\n\nNun, Spieler 2 errate bitte das Wort\n"); + + while(Raten!=Wort && Versuche > 0){ + printf("Deine Antwort:"); + scanf("%s", Raten); + + + if(!strcmp(Raten,Wort)) + { + printf("ToLL! Das Wort ist richtig"); + return 0; + } + else + { + printf("Schade das Wort ist falsch"); + } + Versuche--; + } + return 0; +}//Spielen + +int main(int argc, char** argv) +{ + Spiel(); +} + diff --git a/newlib/examples/test b/newlib/examples/test index 28d14454..e7cf92e9 100644 --- a/newlib/examples/test +++ b/newlib/examples/test @@ -1 +1,3 @@ -123456789 +test +hallo +huso