From 26fc668d74f67f45c0e7255532b2f000b3bdd686 Mon Sep 17 00:00:00 2001 From: Rose Date: Wed, 31 Jul 2024 21:03:29 -0500 Subject: [PATCH] kbd stuff needs volatile, start structure changes --- .gitignore | 2 ++ Makefile | 4 ++-- README.md | 5 +++-- handler.nasm | 1 + disk.h => include/disk.h | 0 file.h => include/file.h | 0 file_s.h => include/file_s.h | 0 fs.h => include/fs.h | 0 helper.h => include/helper.h | 0 interrupt.h => include/interrupt.h | 0 kbd.h => include/kbd.h | 2 +- paging.h => include/paging.h | 0 print.h => include/print.h | 0 progs.h => include/progs.h | 0 tests.h => include/tests.h | 0 tss.h => include/tss.h | 0 v86defs.h => include/v86defs.h | 0 interrupt.c | 1 + kbd.c | 11 +++++++---- kernel.c | 2 +- setenv.sh | 10 ++++++++++ 21 files changed, 28 insertions(+), 10 deletions(-) rename disk.h => include/disk.h (100%) rename file.h => include/file.h (100%) rename file_s.h => include/file_s.h (100%) rename fs.h => include/fs.h (100%) rename helper.h => include/helper.h (100%) rename interrupt.h => include/interrupt.h (100%) rename kbd.h => include/kbd.h (96%) rename paging.h => include/paging.h (100%) rename print.h => include/print.h (100%) rename progs.h => include/progs.h (100%) rename tests.h => include/tests.h (100%) rename tss.h => include/tss.h (100%) rename v86defs.h => include/v86defs.h (100%) create mode 100755 setenv.sh diff --git a/.gitignore b/.gitignore index e0b7168..e31eb50 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ *.lock *.com bx_enh_dbg.ini +.cache +compile_commands.json diff --git a/Makefile b/Makefile index 4e3b608..c3920a2 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ objects = entry.o kernel.o task.o handler.o interrupt.o v86.o print.o tss.o gdt.o\ paging.o fault.o tests.o kbd.o helper.o disk.o file.o fs.o dosfs/dosfs.o fs_dos.o\ progs.o hexedit.o textedit.o -CFLAGS = -target "i686-elf" -m32 -mgeneral-regs-only -ffreestanding\ - -march=i686 -fno-stack-protector -Wno-int-conversion -nostdlib -c -g +CFLAGS = -target "i386-elf" -m32 -mgeneral-regs-only -ffreestanding\ + -march=i386 -fno-stack-protector -Wno-int-conversion -nostdlib -c -Iinclude LFLAGS = -Wl,--gc-sections -Wl,--print-gc-sections -m32 -nostartfiles -nostdlib ifeq ($(OUTFILE),) diff --git a/README.md b/README.md index 2e8d089..8aa3aab 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ -# luciaos - +# ROSE +in progress toy OS +i work on stream at diff --git a/handler.nasm b/handler.nasm index 7598156..d9c6fdd 100644 --- a/handler.nasm +++ b/handler.nasm @@ -66,6 +66,7 @@ pop ds pop eax iret +; from linux 0.0.1 global picInit picInit: mov al, 0x11 ; initialization sequence diff --git a/disk.h b/include/disk.h similarity index 100% rename from disk.h rename to include/disk.h diff --git a/file.h b/include/file.h similarity index 100% rename from file.h rename to include/file.h diff --git a/file_s.h b/include/file_s.h similarity index 100% rename from file_s.h rename to include/file_s.h diff --git a/fs.h b/include/fs.h similarity index 100% rename from fs.h rename to include/fs.h diff --git a/helper.h b/include/helper.h similarity index 100% rename from helper.h rename to include/helper.h diff --git a/interrupt.h b/include/interrupt.h similarity index 100% rename from interrupt.h rename to include/interrupt.h diff --git a/kbd.h b/include/kbd.h similarity index 96% rename from kbd.h rename to include/kbd.h index 10db410..383bf04 100644 --- a/kbd.h +++ b/include/kbd.h @@ -15,7 +15,7 @@ __attribute((__no_caller_saved_registers__)) uint16_t get_scancode(); __attribute__ ((interrupt)) -void keyboardHandler(struct interrupt_frame *frame); +void keyboardHandler(struct interrupt_frame volatile *frame); typedef enum { KEY_ESCAPE=0x01, KEY_1=0x02, KEY_2=0x03, diff --git a/paging.h b/include/paging.h similarity index 100% rename from paging.h rename to include/paging.h diff --git a/print.h b/include/print.h similarity index 100% rename from print.h rename to include/print.h diff --git a/progs.h b/include/progs.h similarity index 100% rename from progs.h rename to include/progs.h diff --git a/tests.h b/include/tests.h similarity index 100% rename from tests.h rename to include/tests.h diff --git a/tss.h b/include/tss.h similarity index 100% rename from tss.h rename to include/tss.h diff --git a/v86defs.h b/include/v86defs.h similarity index 100% rename from v86defs.h rename to include/v86defs.h diff --git a/interrupt.c b/interrupt.c index a89c27e..515c998 100644 --- a/interrupt.c +++ b/interrupt.c @@ -90,6 +90,7 @@ void IRQ_clear_mask(char IRQline) { outb(port, value); } +// Mostly from https://web.archive.org/web/20090719085533/http://osdev.berlios.de/v86.html char v86_if = 0; extern uint16_t error_screen[80*50]; // defined in kernel.c extern uint16_t IVT[]; diff --git a/kbd.c b/kbd.c index 895edc5..5cf6a79 100644 --- a/kbd.c +++ b/kbd.c @@ -31,11 +31,13 @@ uint8_t scancodesToAsciiShift[0x3B] = "\0" // 0x38 " " // 0x39 "\0"; // 0x3A -uint8_t _KBDWAIT; -uint8_t _KEYCAPS = 0, _KEYSHIFT = 0; -uint8_t _LSTKEY_ASCII = 0, _LSTKEY_SCAN = 0; +volatile uint8_t _KBDWAIT; +volatile uint8_t _KEYCAPS = 0; +volatile uint8_t _KEYSHIFT = 0; +volatile uint8_t _LSTKEY_ASCII = 0; +volatile uint8_t _LSTKEY_SCAN = 0; __attribute__ ((interrupt)) -void keyboardHandler(struct interrupt_frame *frame) { +void keyboardHandler(struct interrupt_frame volatile *frame) { uint16_t old_ds; asm volatile( "mov %%ds, %%bx\n" @@ -43,6 +45,7 @@ void keyboardHandler(struct interrupt_frame *frame) { "mov %%ax, %%ds\n" :"=b"(old_ds)::"%ax" ); + asm volatile("xchg %bx,%bx"); uint8_t key; asm volatile("inb $0x60, %%al":"=a"(key)); if (key == 0x3A) { // caps lock press diff --git a/kernel.c b/kernel.c index 25eb48e..a5d98d7 100644 --- a/kernel.c +++ b/kernel.c @@ -504,7 +504,7 @@ extern void triple_fault(); uint32_t kernel_check = 0x12345678; void start() { word *vga_text = (word *)0xb8000; - char h[] = "LuciaOS"; + char h[] = "ROSE"; for (int i = 0; i < sizeof(h); i++) *(char *)&vga_text[i] = h[i]; vga_text = &vga_text[80]; diff --git a/setenv.sh b/setenv.sh new file mode 100755 index 0000000..b9f6c77 --- /dev/null +++ b/setenv.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +SOURCE=${BASH_SOURCE[0]} +while [ -L "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd ) + SOURCE=$(readlink "$SOURCE") + [[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located +done +DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd ) +export CPATH="${DIR}/include:${DIR}/lib/include"