From 10783bd50e283ff3df93fbb40cb0cff1f81a455e Mon Sep 17 00:00:00 2001 From: Santiago Lo Coco Date: Mon, 1 Nov 2021 09:38:24 -0300 Subject: [PATCH] Add changes in makefile Co-authored-by: Ezequiel Bellver Co-authored-by: Juan Barmasch --- Kernel/Makefile | 5 +- Kernel/drivers/include/keyboard.h | 2 - Kernel/drivers/keyboard.c | 250 ++++++++++++++--------------- Kernel/interruptions/systemCalls.c | 2 +- Kernel/utils/memManagerBuddy.c | 8 +- Kernel/utils/sem.c | 2 +- Makefile | 21 ++- flags.txt | 1 + 8 files changed, 152 insertions(+), 139 deletions(-) create mode 100644 flags.txt diff --git a/Kernel/Makefile b/Kernel/Makefile index e672529..d447715 100644 --- a/Kernel/Makefile +++ b/Kernel/Makefile @@ -17,6 +17,7 @@ OBJECTS_INTERRUPTIONS=$(SOURCES_INTERRUPTIONS:.c=.o) OBJECTS_INTERRUPTIONS_ASM=$(SOURCES_INTERRUPTIONS_ASM:.asm=.o) OBJECTS_ASM=$(SOURCES_ASM:.asm=.o) LOADERSRC=loader.asm +FLAGS=../flags.txt LOADEROBJECT=$(LOADERSRC:.asm=.o) STATICLIBS= @@ -31,8 +32,8 @@ $(KERNEL): $(STATICLIBS) $(ALL_OBJECTS) $(KERNEL_ELF): $(STATICLIBS) $(ALL_OBJECTS) $(LD) $(LDFLAGS) -T kernel.ld --oformat=elf64-x86-64 -o $@ $^ -%.o: %.c - $(GCC) $(GCCFLAGS) -I./include -I./drivers/include -I./interruptions/include -I./utils/include -I./tests/include $(MFLAG) -c $< -o $@ +%.o: %.c $(FLAGS) + $(GCC) $(GCCFLAGS) -I./include -I./drivers/include -I./interruptions/include -I./utils/include -I./tests/include $(MFLAG) $(KFLAG) -c $< -o $@ %.o : %.asm $(ASM) $(ASMFLAGS) $< -o $@ diff --git a/Kernel/drivers/include/keyboard.h b/Kernel/drivers/include/keyboard.h index 184b06c..577d3b6 100644 --- a/Kernel/drivers/include/keyboard.h +++ b/Kernel/drivers/include/keyboard.h @@ -4,8 +4,6 @@ #include #include "../../utils/include/schedulerLib.h" -#define SIZE 1 - void keyboard_handler(); unsigned char getKeyFromBuffer(); unsigned char getCharInterrupt(); diff --git a/Kernel/drivers/keyboard.c b/Kernel/drivers/keyboard.c index ba3bfa8..bbc3226 100644 --- a/Kernel/drivers/keyboard.c +++ b/Kernel/drivers/keyboard.c @@ -1,9 +1,9 @@ #include "keyboard.h" -static unsigned char kbdus[250]; -static unsigned char kbdus_sh[250]; -// static unsigned char kbdsp_sh[250]; -// static unsigned char kbdsp[250]; +#define SIZE 1 + +static unsigned char kbd[250]; +static unsigned char kbd_sh[250]; unsigned char buffer[SIZE] = {0}; unsigned char *current = buffer; @@ -48,11 +48,11 @@ void testKeyboardInterrupt(unsigned char c) { } if (flag == 0) { - c = kbdus_sh[c]; + c = kbd_sh[c]; if (c != 0) saveChar(c); } else { - c = kbdus[c]; + c = kbd[c]; if (c != 0) saveChar(c); } @@ -74,46 +74,8 @@ void keyboard_handler() { testKeyboardInterrupt(c); } -// static unsigned char kbdsp[250] = { -// 0, 124, '1', '2', '3', '4', '5', '6', '7', '8', /* 9 */ -// '9', '0', '\'', 168, '\b', /* Backspace */ -// '\t', /* Tab */ -// 'q', 'w', 'e', 'r', /* 19 */ -// 't', 'y', 'u', 'i', 'o', 'p', 96, '+', '\n', /* Enter key */ -// 0, /* 29 - Control */ -// 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 164, /* ñ */ -// '{', '}', 0, /* Left shift */ -// '<', 'z', 'x', 'c', 'v', 'b', 'n', /* 49 */ -// 'm', ',', '.', '-', 0, /* Right shift */ -// '*', -// 0, /* Alt */ -// ' ', /* Space bar */ -// 0, /* Caps lock */ -// 0, /* 59 - F1 key ... > */ -// 0, 0, 0, 0, 0, 0, 0, 0, -// 0, /* < ... F10 */ -// 0, /* 69 - Num lock*/ -// 0, /* Scroll Lock */ -// 0, /* Home key */ -// 0, /* Up Arrow */ -// 0, /* Page Up */ -// '-', -// 0, /* Left Arrow */ -// 0, -// 0, /* Right Arrow */ -// '+', -// 0, /* 79 - End key*/ -// 0, /* Down Arrow */ -// 0, /* Page Down */ -// 0, /* Insert Key */ -// 0, /* Delete Key */ -// 0, 0, 0, -// 0, /* F11 Key */ -// 0, /* F12 Key */ -// 0, /* All other keys are undefined */ -// }; - -static unsigned char kbdus[250] = { +#ifndef SPANISH +static unsigned char kbd[250] = { 0, 27, '1', '2', '3', '4', '5', '6', '7', '8', /* 9 */ '9', '0', '-', '=', '\b', /* Backspace */ '\t', /* Tab */ @@ -151,83 +113,119 @@ static unsigned char kbdus[250] = { 0, /* F12 Key */ 0, /* All other keys are undefined */ }; - -// static unsigned char kbdsp_sh[250] = -// { -// 0, 167, 21, '\"', '#', '$', '%', '&', '/', '(', /* 9 */ -// ')', '=', '?', 173, '\b', /* Backspace */ -// '\t', /* Tab */ -// 'Q', 'W', 'E', 'R', /* 19 */ -// 'T', 'Y', 'U', 'I', 'O', 'P', 0, '*', '\n', /* Enter key */ -// 0, /* 29 - Control */ -// 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 165, /* 39 */ -// '[', ']', 0, /* Left shift */ -// '>', 'Z', 'X', 'C', 'V', 'B', 'N', /* 49 */ -// 'M', ';', ':', '_', 0, /* Right shift */ -// '*', -// 0, /* Alt */ -// ' ', /* Space bar */ -// 0, /* Caps lock */ -// 0, /* 59 - F1 key ... > */ -// 0, 0, 0, 0, 0, 0, 0, 0, -// 0, /* < ... F10 */ -// 0, /* 69 - Num lock*/ -// 0, /* Scroll Lock */ -// 0, /* Home key */ -// 0, /* Up Arrow */ -// 0, /* Page Up */ -// '-', -// 0, /* Left Arrow */ -// 0, -// 0, /* Right Arrow */ -// '+', -// 0, /* 79 - End key*/ -// 0, /* Down Arrow */ -// 0, /* Page Down */ -// 0, /* Insert Key */ -// 0, /* Delete Key */ -// 0, 0, '>', -// 0, /* F11 Key */ -// 0, /* F12 Key */ -// 0, /* All other keys are undefined */ -// }; - -static unsigned char kbdus_sh[250] = - { - 0, 27, '!', '\"', '#', 0 /* shift+4 */, '%', '&', '/', '(', /* 9 */ - ')', '=', '?', '`', '\b', /* Backspace */ - '\t', /* Tab */ - 'Q', 'W', 'E', 'R', /* 19 */ - 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '\n', /* Enter key */ - 0, /* 29 - Control */ - 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', /* 39 */ - '\'', '>', 0, /* Left shift */ - '|', 'Z', 'X', 'C', 'V', 'B', 'N', /* 49 */ - 'M', ';', ':', '_', 0, /* Right shift */ - '*', - 0, /* Alt */ - ' ', /* Space bar */ - 0, /* Caps lock */ - 0, /* 59 - F1 key ... > */ - 0, 0, 0, 0, 0, 0, 0, 0, - 0, /* < ... F10 */ - 0, /* 69 - Num lock*/ - 0, /* Scroll Lock */ - 0, /* Home key */ - 0, /* Up Arrow */ - 0, /* Page Up */ - '-', - 0, /* Left Arrow */ - 0, - 0, /* Right Arrow */ - '+', - 0, /* 79 - End key*/ - 0, /* Down Arrow */ - 0, /* Page Down */ - 0, /* Insert Key */ - 0, /* Delete Key */ - 0, 0, '>', - 0, /* F11 Key */ - 0, /* F12 Key */ - 0, /* All other keys are undefined */ - }; \ No newline at end of file +static unsigned char kbd_sh[250] = { + 0, 27, '!', '\"', '#', 0 /* shift+4 */, '%', '&', '/', '(', /* 9 */ + ')', '=', '?', '`', '\b', /* Backspace */ + '\t', /* Tab */ + 'Q', 'W', 'E', 'R', /* 19 */ + 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '\n', /* Enter key */ + 0, /* 29 - Control */ + 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', /* 39 */ + '\'', '>', 0, /* Left shift */ + '|', 'Z', 'X', 'C', 'V', 'B', 'N', /* 49 */ + 'M', ';', ':', '_', 0, /* Right shift */ + '*', + 0, /* Alt */ + ' ', /* Space bar */ + 0, /* Caps lock */ + 0, /* 59 - F1 key ... > */ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, /* < ... F10 */ + 0, /* 69 - Num lock*/ + 0, /* Scroll Lock */ + 0, /* Home key */ + 0, /* Up Arrow */ + 0, /* Page Up */ + '-', + 0, /* Left Arrow */ + 0, + 0, /* Right Arrow */ + '+', + 0, /* 79 - End key*/ + 0, /* Down Arrow */ + 0, /* Page Down */ + 0, /* Insert Key */ + 0, /* Delete Key */ + 0, 0, '>', + 0, /* F11 Key */ + 0, /* F12 Key */ + 0, /* All other keys are undefined */ +}; +#else +static unsigned char kbd[250] = { + 0, 124, '1', '2', '3', '4', '5', '6', '7', '8', /* 9 */ + '9', '0', '\'', 168, '\b', /* Backspace */ + '\t', /* Tab */ + 'q', 'w', 'e', 'r', /* 19 */ + 't', 'y', 'u', 'i', 'o', 'p', 96, '+', '\n', /* Enter key */ + 0, /* 29 - Control */ + 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 164, /* ñ */ + '{', '}', 0, /* Left shift */ + '<', 'z', 'x', 'c', 'v', 'b', 'n', /* 49 */ + 'm', ',', '.', '-', 0, /* Right shift */ + '*', + 0, /* Alt */ + ' ', /* Space bar */ + 0, /* Caps lock */ + 0, /* 59 - F1 key ... > */ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, /* < ... F10 */ + 0, /* 69 - Num lock*/ + 0, /* Scroll Lock */ + 0, /* Home key */ + 0, /* Up Arrow */ + 0, /* Page Up */ + '-', + 0, /* Left Arrow */ + 0, + 0, /* Right Arrow */ + '+', + 0, /* 79 - End key*/ + 0, /* Down Arrow */ + 0, /* Page Down */ + 0, /* Insert Key */ + 0, /* Delete Key */ + 0, 0, 0, + 0, /* F11 Key */ + 0, /* F12 Key */ + 0, /* All other keys are undefined */ +}; +static unsigned char kbd_sh[250] = { + 0, 167, 21, '\"', '#', '$', '%', '&', '/', '(', /* 9 */ + ')', '=', '?', 173, '\b', /* Backspace */ + '\t', /* Tab */ + 'Q', 'W', 'E', 'R', /* 19 */ + 'T', 'Y', 'U', 'I', 'O', 'P', 0, '*', '\n', /* Enter key */ + 0, /* 29 - Control */ + 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 165, /* 39 */ + '[', ']', 0, /* Left shift */ + '>', 'Z', 'X', 'C', 'V', 'B', 'N', /* 49 */ + 'M', ';', ':', '_', 0, /* Right shift */ + '*', + 0, /* Alt */ + ' ', /* Space bar */ + 0, /* Caps lock */ + 0, /* 59 - F1 key ... > */ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, /* < ... F10 */ + 0, /* 69 - Num lock*/ + 0, /* Scroll Lock */ + 0, /* Home key */ + 0, /* Up Arrow */ + 0, /* Page Up */ + '-', + 0, /* Left Arrow */ + 0, + 0, /* Right Arrow */ + '+', + 0, /* 79 - End key*/ + 0, /* Down Arrow */ + 0, /* Page Down */ + 0, /* Insert Key */ + 0, /* Delete Key */ + 0, 0, '>', + 0, /* F11 Key */ + 0, /* F12 Key */ + 0, /* All other keys are undefined */ +}; +#endif \ No newline at end of file diff --git a/Kernel/interruptions/systemCalls.c b/Kernel/interruptions/systemCalls.c index bd94a66..19184c7 100644 --- a/Kernel/interruptions/systemCalls.c +++ b/Kernel/interruptions/systemCalls.c @@ -36,7 +36,7 @@ uint64_t read(uint64_t fd, uint64_t buffer, uint64_t length) { blockIO(); } if (*bufferAux == '\v') { - return -1; + return 0; // break; } readBytes++; diff --git a/Kernel/utils/memManagerBuddy.c b/Kernel/utils/memManagerBuddy.c index 98d9270..89bc563 100644 --- a/Kernel/utils/memManagerBuddy.c +++ b/Kernel/utils/memManagerBuddy.c @@ -44,10 +44,10 @@ int ceil(float num) { return inum + 1; } -// unsigned int log2(unsigned int n) -// { -// return (n > 1) ? 1 + log2(n / 2) : 0; -// } +unsigned int log2(unsigned int n) +{ + return (n > 1) ? 1 + log2(n / 2) : 0; +} // /* Returns log base 2 of a double d */ // double log2(double d) { diff --git a/Kernel/utils/sem.c b/Kernel/utils/sem.c index f6b6e42..a70bc6e 100644 --- a/Kernel/utils/sem.c +++ b/Kernel/utils/sem.c @@ -170,7 +170,7 @@ char *getEntering(sem_t *sem) { } char *getSems() { - char *ans = pvPortMalloc(counter * SEM_DATA_MAX_SIZE); + char *ans = pvPortMalloc(1 + counter * SEM_DATA_MAX_SIZE); char *ret = ans; char *info = "name value pidsWaiting\n"; diff --git a/Makefile b/Makefile index 420ea53..b1f82c0 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,24 @@ - all: bootloader kernel userland image -buddy: bootloader kernelBuddy userland image +spanish: bootloader kernelSpanish userland imageSpanish +buddy: bootloader kernelBuddy userland imageBuddy bootloader: cd Bootloader; make all kernel: + @if ! grep -q "ke" flags.txt; then\ + echo "ke" > flags.txt;\ + fi cd Kernel; make all +kernelSpanish: + @if ! grep -q "ks" flags.txt; then\ + echo "ks" > flags.txt;\ + fi + cd Kernel; make all KFLAG=-DSPANISH kernelBuddy: + @if ! grep -q "be" flags.txt; then\ + echo "be" > flags.txt;\ + fi cd Kernel; make all MFLAG=-DBUDDY userland: @@ -15,6 +26,10 @@ userland: image: kernel bootloader userland cd Image; make all +imageSpanish: kernelSpanish bootloader userland + cd Image; make all +imageBuddy: kernelBuddy bootloader userland + cd Image; make all clean: cd Bootloader; make clean @@ -22,4 +37,4 @@ clean: cd Kernel; make clean cd Userland; make clean -.PHONY: bootloader image collections kernel userland all clean +.PHONY: bootloader image imageSpanish imageBuddy collections kernel kernelSpanish kernelBuddy userland all clean diff --git a/flags.txt b/flags.txt new file mode 100644 index 0000000..4e9b0ab --- /dev/null +++ b/flags.txt @@ -0,0 +1 @@ +ke