Skip to content

Commit e18ec93

Browse files
authored
Merge pull request #27 from kushagra765/0.06
Fixed VGA and Keyboard Driver
2 parents ea036ec + c7012d0 commit e18ec93

File tree

8 files changed

+227
-158
lines changed

8 files changed

+227
-158
lines changed

build.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ sudo apt-get install nasm mtools
99
export PATH="./toolchain/compiler/bin:$PATH"
1010

1111
# Compile the OS
12-
i686-elf-as ./kernel/arch/i386/boot.S -o boot.o
12+
nasm -f elf32 ./kernel/arch/i386/boot.asm -o boot.o
1313
i686-elf-gcc -I./kernel/include/ -c ./kernel/drivers/vga/vga.c -o vga.o
1414
i686-elf-gcc -I./kernel/include/ -c ./kernel/drivers/ports/ports.c -o ports.o
1515
i686-elf-gcc -I./kernel/include/ -I./kernel/drivers/ -I./kernel/cpu/ -c ./kernel/drivers/keyboard/keyboard.c -o keyboard.o
16-
i686-elf-gcc -I./kernel/drivers/ -I./kernel/include/ -I./kernel/cpu/ -c ./init/init.c -o init.o
16+
i686-elf-gcc -I./kernel/drivers/ -I./kernel/include/ -I./kernel/cpu/ -c ./init/main.c -o init.o
1717
nasm -f elf32 ./kernel/cpu/load_gdt.asm -o load_gdt.o
1818
i686-elf-gcc -I./kernel/include/ -c ./kernel/cpu/gdt.c -o gdt.o
1919
nasm -f elf32 ./kernel/cpu/load_idt.asm -o load_idt.o

init/main.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
void kernel_main() {
99
/* Initialize the Terminal */
1010
terminal_initialize();
11-
writestr("Welcome to PlatypusOS!");
11+
writestr("Welcome to PlatypusOS!\n");
1212

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

1919
/* Load Drivers */
2020
init_keyboard();
21+
22+
__asm__ volatile("sti");
2123
}

kernel/arch/i386/boot.S

-34
This file was deleted.

kernel/arch/i386/boot.asm

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[BITS 32]
2+
3+
global start
4+
start:
5+
mov esp, sys_stack
6+
jmp stublet
7+
8+
ALIGN 4
9+
multiboot:
10+
11+
PAGE_ALIGN equ 1<<0
12+
MEMORY_INFO equ 1<<0
13+
KLUDGE_AOUT equ 1<<16
14+
MAGIC equ 0x1BADB002
15+
FLAGS equ PAGE_ALIGN | MEMORY_INFO | KLUDGE_AOUT
16+
CHECKSUM equ -(MAGIC + FLAGS)
17+
18+
EXTERN code, bss, end
19+
dd MAGIC
20+
dd FLAGS
21+
dd CHECKSUM
22+
23+
dd multiboot
24+
dd code
25+
dd bss
26+
dd end
27+
dd start
28+
29+
stublet:
30+
extern kernel_main
31+
call kernel_main
32+
jmp $
33+
34+
SECTION .bss
35+
resb 8192
36+
sys_stack:

kernel/arch/i386/linker.ld

+25-27
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,30 @@
1-
ENTRY(_start)
1+
ENTRY(start)
2+
3+
memory_address = 0x00100000;
24

35
SECTIONS
46
{
5-
. = 1M;
6-
7-
.text BLOCK(4K) : ALIGN(4K)
8-
{
9-
*(.multiboot)
10-
*(.text)
11-
}
12-
13-
14-
.rodata BLOCK(4K) : ALIGN(4K)
15-
{
16-
*(.rodata)
17-
}
18-
19-
20-
.data BLOCK(4K) : ALIGN(4K)
21-
{
22-
*(.data)
23-
}
24-
7+
.text memory_address : AT(memory_address) {
8+
code = .;
9+
*(.text)
10+
*(.rodata)
11+
. = ALIGN(4096);
12+
}
13+
14+
.data : AT(memory_address + (data - code))
15+
{
16+
data = .;
17+
*(.data)
18+
. = ALIGN(4096);
19+
}
20+
21+
.bss : AT(memory_address + (bss - code))
22+
{
23+
bss = .;
24+
*(.bss)
25+
. = ALIGN(4096);
26+
}
27+
28+
end = .;
2529

26-
.bss BLOCK(4K) : ALIGN(4K)
27-
{
28-
*(COMMON)
29-
*(.bss)
30-
}
31-
3230
}

kernel/drivers/keyboard/keyboard.c

+38-10
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,43 @@
55
#include <vga/vga.h>
66

77
uint8_t keyboard_layout[128] = {
8-
0, 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-',
9-
'=', '\b', '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p',
10-
'[', ']', '\n', 0, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l',
11-
';', '\'', '`', 0, '\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',',
12-
'.', '/', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0,
13-
0, 0, 0, 0, 0, 0, 0, 0, 0, '-', 0, 0, 0,
14-
'+', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
15-
};
8+
0, 27, '1', '2', '3', '4', '5', '6', '7', '8',
9+
'9', '0', '-', '=', '\b',
10+
'\t',
11+
'q', 'w', 'e', 'r',
12+
't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n',
13+
0,
14+
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';',
15+
'\'', '`', 0,
16+
'\\', 'z', 'x', 'c', 'v', 'b', 'n',
17+
'm', ',', '.', '/', 0,
18+
'*',
19+
0,
20+
' ',
21+
0,
22+
0,
23+
0, 0, 0, 0, 0, 0, 0, 0,
24+
0,
25+
0,
26+
0,
27+
0,
28+
0,
29+
0,
30+
'-',
31+
0,
32+
0,
33+
0,
34+
'+',
35+
0,
36+
0,
37+
0,
38+
0,
39+
0,
40+
0, 0, 0,
41+
0,
42+
0,
43+
0,
44+
};
1645

1746
void handler_keyboard() {
1847
uint8_t keyboard_key_scancode;
@@ -23,8 +52,7 @@ void handler_keyboard() {
2352
// Shift, Ctrl keys to be implemented
2453

2554
} else {
26-
char input = keyboard_layout[keyboard_key_scancode];
27-
terminal_putchar(input);
55+
putch(keyboard_layout[keyboard_key_scancode]);
2856
}
2957
}
3058

0 commit comments

Comments
 (0)