kbd stuff needs volatile, start structure changes

This commit is contained in:
Rose 2024-07-31 21:03:29 -05:00
parent 56152c6d20
commit 26fc668d74
21 changed files with 28 additions and 10 deletions

2
.gitignore vendored
View File

@ -4,3 +4,5 @@
*.lock
*.com
bx_enh_dbg.ini
.cache
compile_commands.json

View File

@ -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),)

View File

@ -1,2 +1,3 @@
# luciaos
<https://ceionia.com/resources/v86.html>
# ROSE
in progress toy OS
i work on stream at <https://twitch.tv/mcrrox>

View File

@ -66,6 +66,7 @@ pop ds
pop eax
iret
; from linux 0.0.1
global picInit
picInit:
mov al, 0x11 ; initialization sequence

View File

View File

@ -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,

View File

@ -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[];

11
kbd.c
View File

@ -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

View File

@ -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];

10
setenv.sh Executable file
View File

@ -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"