Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
Louis Jenkins committed Feb 1, 2017
2 parents 63d3909 + 1c43c83 commit f7b0281
Show file tree
Hide file tree
Showing 33 changed files with 1,732 additions and 655 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "src/C_Utils"]
path = src/C_Utils
url = https://github.com/LouisJenkinsCS/C_Utils
694 changes: 469 additions & 225 deletions MoltarOS.sublime-workspace

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,26 @@ The below depicts an early "schedule" or rather a path I will be taking in terms
- [x] Keyboard Driver
- [x] Memory Management (Physical + Virtual)
- [x] Higher Half Kernel
- [x] Multitasking and Scheduling
- [ ] File System
- [ ] Process Creation and Managements
- [ ] Multitasking and Scheduling
- [ ] Networking
- [ ] ELF Binary Support
- [ ] Interactive Shell
- [ ] Graphical User Interfaces

#Progress Update & Changelog

## Version .002a

It took me a while, but finally, I've got it! Multitasking! Currently, the CPU may as well be a uniprocessor, but I do implement task switching that allows me to have a VERY simple and __minimal__ multitasking kernel! They are still only threads because they do not have their own page directory (and hence share the same virtual address space). This meant that to create these tasks I had to copy the 'parent' stack for the 'child', and do a ton of trickery to get it working.

As well, the time sharing has no current way to 'yield' to the 'scheduler' either, as I use the software context switching method (meaning, I only task switch from an interrupt handler).

Good news is that I have fixed the Real-Time Clock, and I have it update in the top right corner, and as well as have the last pressed key right below it. I've also taken the time to implement scrolling! Now it buffers each line of the VGA buffer so that scrolling up and down will save and restore them appropriately!

![Screenshot](/multitasking.JPG)

## Version .002

It is FINALLY here! I have implemented not only memory management (paging and a heap allocator), but even converted to a higher-half kernel approach, which was also easier, surprisingly, than a normal identity-mapped system. I've also fixed up the tests and their output format to better portray the significance of the initialization of the kernel thus far. I am very satisfied with what I have done, but unfortunately, I have to attend to another project for the time being.
Expand Down
Binary file added multitasking.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added src/kernel/.sym
Empty file.
6 changes: 3 additions & 3 deletions src/kernel/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Include directories
INCLUDE := kernel x86 drivers mm
INCLUDE := kernel x86 drivers mm sched ds

# List of all headers from the included directories
HEADERS := $(shell find $(INCLUDE) -type f -name \*.h)
Expand Down Expand Up @@ -32,8 +32,8 @@ COMPILER_WARNINGS := \
-Wall -Wextra -Wshadow -Wpointer-arith -Wcast-align \
-Wnested-externs -Wwrite-strings -Wredundant-decls -Winline -Wconversion

CFLAGS := -g -std=gnu11 $(COMPILER_WARNINGS) -fbuiltin -Iinclude -D__IS_MOLTAROS
LINKER_FLAGS := -ffreestanding -O2 -nostdlib -lgcc $(COMPILER_WARNINGS) -fbuiltin -D__IS_MOLTAROS
CFLAGS := -g -std=gnu11 $(COMPILER_WARNINGS) -fbuiltin -fno-omit-frame-pointer -Iinclude -D__IS_MOLTAROS
LINKER_FLAGS := -ffreestanding -O1 -nostdlib -lgcc $(COMPILER_WARNINGS) -fbuiltin -D__IS_MOLTAROS
LIBC := ../libc/libk.a

-include $(DEPENDENCIES)
Expand Down
76 changes: 52 additions & 24 deletions src/kernel/drivers/kbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ static const char *to_string(uint8_t code) {
str = "NUMLOCK";
break;
case KBD_KP_KEY_ASTERISK:
str = "(keypad) ASTERISK";
str = "(KP) ASTERISK";
break;
case KBD_KP_KEY_MINUS:
str = "(keypad) MINUS";
str = "(KP) MINUS";
break;
case KBD_KEY_TAB:
str = "TAB";
Expand Down Expand Up @@ -260,16 +260,16 @@ static const char *to_string(uint8_t code) {
str = "BACK_SLASH";
break;
case KBD_KP_KEY_7:
str = "(keypad) 7";
str = "(KP) 7";
break;
case KBD_KP_KEY_8:
str = "(keypad) 8";
str = "(KP) 8";
break;
case KBD_KP_KEY_9:
str = "(keypad) 9";
str = "(KP) 9";
break;
case KBD_KP_KEY_PLUS:
str = "(keypad) PLUS";
str = "(KP) PLUS";
break;
case KBD_KEY_CAPS_LOCK:
str = "CAPS_LOCK";
Expand Down Expand Up @@ -311,13 +311,13 @@ static const char *to_string(uint8_t code) {
str = "ENTER";
break;
case KBD_KP_KEY_4:
str = "(keypad) 4";
str = "(KP) 4";
break;
case KBD_KP_KEY_5:
str = "(keypad) 5";
str = "(KP) 5";
break;
case KBD_KP_KEY_6:
str = "(keypad) 6";
str = "(KP) 6";
break;
case KBD_KEY_LSHIFT:
str = "LSHIFT";
Expand Down Expand Up @@ -356,13 +356,13 @@ static const char *to_string(uint8_t code) {
str = "RSHIFT";
break;
case KBD_KP_KEY_1:
str = "(keypad) 1";
str = "(KP) 1";
break;
case KBD_KP_KEY_2:
str = "(keypad) 2";
str = "(KP) 2";
break;
case KBD_KP_KEY_3:
str = "(keypad) 3";
str = "(KP) 3";
break;
case KBD_KEY_LCTRL:
str = "LCTRL";
Expand All @@ -383,10 +383,10 @@ static const char *to_string(uint8_t code) {
str = "SUPER";
break;
case KBD_KP_KEY_0:
str = "(keypad) 0";
str = "(KP) 0";
break;
case KBD_KP_KEY_PERIOD:
str = "(keypad) PERIOD";
str = "(KP) PERIOD";
break;
default:
str = "(NULL)";
Expand All @@ -401,13 +401,13 @@ static const char *escaped_to_string(uint8_t code) {
const char *str;
switch (code) {
case KBD_KP_KEY_ENTER:
str = "(keypad) ENTER";
str = "(KP) ENTER";
break;
case KBD_KEY_RCTRL:
str = "RCTRL";
break;
case KBD_KP_KEY_SLASH:
str = "(keypad) SLASH";
str = "(KP) SLASH";
break;
case KBD_KEY_RALT:
str = "RALT";
Expand Down Expand Up @@ -462,22 +462,50 @@ static void keyboard_irq_handler(struct registers *UNUSED(regs)) {
bool released = scancode & 0x80;
scancode &= ~0x80;

// On each key press, we write prettily to the same line.
vga_clear();
vga_set_x(0);
printf("Scancode: %x, You %s: ", scancode, released ? "Released" : "Pressed");

// State-Based machine, which determines which scan table to decode from.
switch (state) {
// Waiting for first byte
case 0:
printf("%s", to_string(KBD_SCAN_TABLE[scancode]));
case 0: {
char *str = to_string(KBD_SCAN_TABLE[scancode]);
uint32_t x = vga_get_x();
uint32_t y = vga_get_y();
vga_set_x(65);
vga_set_y(1);
for (int i = 0; i < 15 - strlen(str); i++) {
vga_putc(' ');
}
printf("%s", str);
vga_set_x(x);
vga_set_y(y);
return;
}
// Waiting for second byte of multibyte sequence
case 1:
printf("%s", escaped_to_string(KBD_ESCAPED_SCAN_TABLE[scancode]));
switch (KBD_ESCAPED_SCAN_TABLE[scancode]) {
case KBD_KEY_DOWN:
vga_scroll_down();
break;
case KBD_KEY_UP:
vga_scroll_up();
break;
default: {
char *str = escaped_to_string(KBD_ESCAPED_SCAN_TABLE[scancode]);
uint32_t x = vga_get_x();
uint32_t y = vga_get_y();
vga_set_x(65);
vga_set_y(1);
for (int i = 0; i < 15 - strlen(str); i++) {
vga_putc(' ');
}
printf("%s", str);
vga_set_x(x);
vga_set_y(y);
}
}
state = 0;
}


}

// Simple initializer that registers IRQ handler
Expand Down
4 changes: 3 additions & 1 deletion src/kernel/drivers/rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,7 @@ void rtc_print() {
if(hour < 0)
hour += 12;

printf("%d:%d:%d %s", hour, rtc_get_minute(), rtc_get_second(), pm ? "PM" : "AM");
uint8_t min = rtc_get_minute();
uint8_t sec = rtc_get_second();
printf("%d:%s%d:%s%d%s", hour, min < 10 ? "0" : "", min, sec < 10 ? "0" : "", sec, pm ? "PM" : "AM");
}
Loading

0 comments on commit f7b0281

Please sign in to comment.