diff --git a/.gitignore b/.gitignore index c49ac75..9080a4e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,5 +11,7 @@ user/* user/*.o .idea +cmake-build-debug +CMakeLists.txt __pycache__ res.txt diff --git a/Makefile b/Makefile index 6a758c8..ad10ed3 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ endif CFLAGS = -fno-pic -ffreestanding -static -fno-builtin -fno-strict-aliasing \ -mno-sse \ -I. \ - -Wall -ggdb -m32 -Werror -fno-omit-frame-pointer -Os + -Wall -Wno-unused-result -ggdb -m32 -Werror -fno-omit-frame-pointer -Os CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector) ASMFLAGS = -m32 -ffreestanding -c -g -I. @@ -141,4 +141,4 @@ clean: rm -f *.elf *.img *.bin *.raw *.o */*.o tools/mkfs ejudge.sh tools/%: tools/%.c - gcc -Wall -Werror -g $^ -o $@ + gcc -Wall -Wno-unused-result -Werror -g $^ -o $@ diff --git a/drivers/port.h b/drivers/port.h index 5d2174a..ff032d7 100644 --- a/drivers/port.h +++ b/drivers/port.h @@ -20,6 +20,7 @@ static inline void port_word_out(unsigned short port, unsigned short data) { asm volatile("outw %%ax, %%dx" : : "a" (data), "d" (port)); } +/* assembler-long, not c-long */ static inline void port_long_out(unsigned short port, unsigned int data) { asm volatile("outl %%eax, %%dx" : : "a" (data), "d" (port)); } diff --git a/drivers/uart.c b/drivers/uart.c index 613567f..bd12573 100644 --- a/drivers/uart.c +++ b/drivers/uart.c @@ -37,6 +37,7 @@ uartputc(char c) if (!uart) return; + /* What is that *skeleton emoji*? */ for (i = 0; i < 128 && !(port_byte_in(COM1+5) & 0x20); i++) { asm("pause"); } diff --git a/drivers/vga.c b/drivers/vga.c index 8b70fde..c31dcea 100644 --- a/drivers/vga.c +++ b/drivers/vga.c @@ -4,7 +4,7 @@ static char* const video_memory = (char*) (KERNBASE + 0xb8000); -enum colors16 { +enum colors16 : unsigned char { black = 0, blue, green, diff --git a/fs/fs.h b/fs/fs.h index a67d569..a78d936 100644 --- a/fs/fs.h +++ b/fs/fs.h @@ -31,6 +31,7 @@ struct dirent { char name[20]; }; +/* This way we have 512 bytes (1 sector) per dir */ struct dir { char reserved[32]; struct dirent entries[ents_in_dir]; diff --git a/lib/bribki.h b/lib/bribki.h new file mode 100644 index 0000000..0e6354c --- /dev/null +++ b/lib/bribki.h @@ -0,0 +1,21 @@ +#pragma once + +#include + +/* Bribki are stored here */ + +typedef struct { + char chars[5]; +} DebugBribka; + +DebugBribka byte_to_string_bribka(uint8_t byte) { + DebugBribka res = {.chars = {' ', ' ', ' ', ' ', 0}}; + int p = 3; + while (byte > 0) { + uint8_t d = byte % 10; + byte /= 10; + res.chars[p] = (char)(d) + '0'; + p--; + } + return res; +} \ No newline at end of file diff --git a/mbr.S b/mbr.S index 9c3e018..1c42849 100644 --- a/mbr.S +++ b/mbr.S @@ -11,6 +11,7 @@ _start: mov %cr0, %eax or $1, %eax // 3. enable protected mode mov %eax, %cr0 + ljmp $SEG_KCODE << 3, $init_32bit // 4. far jump diff --git a/tasks/float_basic/fp16/run/output b/tasks/float_basic/fp16/run/output new file mode 100644 index 0000000..a5c986d --- /dev/null +++ b/tasks/float_basic/fp16/run/output @@ -0,0 +1,53 @@ +67FE +63FE +5FFE +5BFE +57FE +53FE +4FFE +4BFE +47FE +43FE +3FFE +3BFE +37FE +33FE +2FFE +2BFE +27FE +23FE +1FFE +1BFE +17FE +13FE +0FFE +0BFE +07FE +03FF +6680 +6280 +5E80 +5A80 +5680 +5280 +4E80 +4A80 +4680 +4280 +3E80 +3A80 +3680 +3280 +2E80 +2A80 +2680 +2280 +1E80 +1A80 +1680 +1280 +0E80 +0A80 +0680 +0340 +019F diff --git a/tasks/float_basic/fp16/solution b/tasks/float_basic/fp16/solution new file mode 100755 index 0000000..17609cc Binary files /dev/null and b/tasks/float_basic/fp16/solution differ diff --git a/tasks/float_basic/okay-1/solution b/tasks/float_basic/okay-1/solution new file mode 100755 index 0000000..c4c7a78 Binary files /dev/null and b/tasks/float_basic/okay-1/solution differ diff --git a/tasks/x86_review/anagram/solution b/tasks/x86_review/anagram/solution new file mode 100755 index 0000000..bb70485 Binary files /dev/null and b/tasks/x86_review/anagram/solution differ diff --git a/tasks/x86_review/count/solution b/tasks/x86_review/count/solution new file mode 100755 index 0000000..a935b7d Binary files /dev/null and b/tasks/x86_review/count/solution differ diff --git a/tasks/x86_review/ppm-magic/a.out b/tasks/x86_review/ppm-magic/a.out new file mode 100755 index 0000000..d899913 Binary files /dev/null and b/tasks/x86_review/ppm-magic/a.out differ diff --git a/tasks/x86_review/ppm-magic/solution b/tasks/x86_review/ppm-magic/solution new file mode 100755 index 0000000..c59210e Binary files /dev/null and b/tasks/x86_review/ppm-magic/solution differ diff --git a/tasks/x86_review/recursion/solution b/tasks/x86_review/recursion/solution new file mode 100755 index 0000000..f3d4ca5 Binary files /dev/null and b/tasks/x86_review/recursion/solution differ