Skip to content

Commit

Permalink
Merge pull request #27 from kushagra765/0.06
Browse files Browse the repository at this point in the history
Fixed VGA and Keyboard Driver
  • Loading branch information
DamieFC authored May 24, 2021
2 parents ea036ec + c7012d0 commit e18ec93
Show file tree
Hide file tree
Showing 8 changed files with 227 additions and 158 deletions.
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ sudo apt-get install nasm mtools
export PATH="./toolchain/compiler/bin:$PATH"

# Compile the OS
i686-elf-as ./kernel/arch/i386/boot.S -o boot.o
nasm -f elf32 ./kernel/arch/i386/boot.asm -o boot.o
i686-elf-gcc -I./kernel/include/ -c ./kernel/drivers/vga/vga.c -o vga.o
i686-elf-gcc -I./kernel/include/ -c ./kernel/drivers/ports/ports.c -o ports.o
i686-elf-gcc -I./kernel/include/ -I./kernel/drivers/ -I./kernel/cpu/ -c ./kernel/drivers/keyboard/keyboard.c -o keyboard.o
i686-elf-gcc -I./kernel/drivers/ -I./kernel/include/ -I./kernel/cpu/ -c ./init/init.c -o init.o
i686-elf-gcc -I./kernel/drivers/ -I./kernel/include/ -I./kernel/cpu/ -c ./init/main.c -o init.o
nasm -f elf32 ./kernel/cpu/load_gdt.asm -o load_gdt.o
i686-elf-gcc -I./kernel/include/ -c ./kernel/cpu/gdt.c -o gdt.o
nasm -f elf32 ./kernel/cpu/load_idt.asm -o load_idt.o
Expand Down
4 changes: 3 additions & 1 deletion init/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
void kernel_main() {
/* Initialize the Terminal */
terminal_initialize();
writestr("Welcome to PlatypusOS!");
writestr("Welcome to PlatypusOS!\n");

/* Load GDT, IDT, ISR and IRQ */
init_gdt();
Expand All @@ -18,4 +18,6 @@ void kernel_main() {

/* Load Drivers */
init_keyboard();

__asm__ volatile("sti");
}
34 changes: 0 additions & 34 deletions kernel/arch/i386/boot.S

This file was deleted.

36 changes: 36 additions & 0 deletions kernel/arch/i386/boot.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[BITS 32]

global start
start:
mov esp, sys_stack
jmp stublet

ALIGN 4
multiboot:

PAGE_ALIGN equ 1<<0
MEMORY_INFO equ 1<<0
KLUDGE_AOUT equ 1<<16
MAGIC equ 0x1BADB002
FLAGS equ PAGE_ALIGN | MEMORY_INFO | KLUDGE_AOUT
CHECKSUM equ -(MAGIC + FLAGS)

EXTERN code, bss, end
dd MAGIC
dd FLAGS
dd CHECKSUM
dd multiboot
dd code
dd bss
dd end
dd start

stublet:
extern kernel_main
call kernel_main
jmp $

SECTION .bss
resb 8192
sys_stack:
52 changes: 25 additions & 27 deletions kernel/arch/i386/linker.ld
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
ENTRY(_start)
ENTRY(start)

memory_address = 0x00100000;

SECTIONS
{
. = 1M;

.text BLOCK(4K) : ALIGN(4K)
{
*(.multiboot)
*(.text)
}


.rodata BLOCK(4K) : ALIGN(4K)
{
*(.rodata)
}


.data BLOCK(4K) : ALIGN(4K)
{
*(.data)
}

.text memory_address : AT(memory_address) {
code = .;
*(.text)
*(.rodata)
. = ALIGN(4096);
}

.data : AT(memory_address + (data - code))
{
data = .;
*(.data)
. = ALIGN(4096);
}

.bss : AT(memory_address + (bss - code))
{
bss = .;
*(.bss)
. = ALIGN(4096);
}

end = .;

.bss BLOCK(4K) : ALIGN(4K)
{
*(COMMON)
*(.bss)
}

}
48 changes: 38 additions & 10 deletions kernel/drivers/keyboard/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,43 @@
#include <vga/vga.h>

uint8_t keyboard_layout[128] = {
0, 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-',
'=', '\b', '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p',
'[', ']', '\n', 0, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l',
';', '\'', '`', 0, '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',',
'.', '/', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, '-', 0, 0, 0,
'+', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
0, 27, '1', '2', '3', '4', '5', '6', '7', '8',
'9', '0', '-', '=', '\b',
'\t',
'q', 'w', 'e', 'r',
't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n',
0,
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';',
'\'', '`', 0,
'\\', 'z', 'x', 'c', 'v', 'b', 'n',
'm', ',', '.', '/', 0,
'*',
0,
' ',
0,
0,
0, 0, 0, 0, 0, 0, 0, 0,
0,
0,
0,
0,
0,
0,
'-',
0,
0,
0,
'+',
0,
0,
0,
0,
0,
0, 0, 0,
0,
0,
0,
};

void handler_keyboard() {
uint8_t keyboard_key_scancode;
Expand All @@ -23,8 +52,7 @@ void handler_keyboard() {
// Shift, Ctrl keys to be implemented

} else {
char input = keyboard_layout[keyboard_key_scancode];
terminal_putchar(input);
putch(keyboard_layout[keyboard_key_scancode]);
}
}

Expand Down
Loading

0 comments on commit e18ec93

Please sign in to comment.