Skip to content

Commit f7b0281

Browse files
author
Louis Jenkins
committed
Merge branch 'development'
2 parents 63d3909 + 1c43c83 commit f7b0281

File tree

33 files changed

+1732
-655
lines changed

33 files changed

+1732
-655
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "src/C_Utils"]
2+
path = src/C_Utils
3+
url = https://github.com/LouisJenkinsCS/C_Utils

MoltarOS.sublime-workspace

Lines changed: 469 additions & 225 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,26 @@ The below depicts an early "schedule" or rather a path I will be taking in terms
1414
- [x] Keyboard Driver
1515
- [x] Memory Management (Physical + Virtual)
1616
- [x] Higher Half Kernel
17+
- [x] Multitasking and Scheduling
1718
- [ ] File System
1819
- [ ] Process Creation and Managements
19-
- [ ] Multitasking and Scheduling
2020
- [ ] Networking
2121
- [ ] ELF Binary Support
2222
- [ ] Interactive Shell
2323
- [ ] Graphical User Interfaces
2424

2525
#Progress Update & Changelog
2626

27+
## Version .002a
28+
29+
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.
30+
31+
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).
32+
33+
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!
34+
35+
![Screenshot](/multitasking.JPG)
36+
2737
## Version .002
2838

2939
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.

multitasking.JPG

55.5 KB
Loading

src/kernel/.sym

Whitespace-only changes.

src/kernel/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Include directories
2-
INCLUDE := kernel x86 drivers mm
2+
INCLUDE := kernel x86 drivers mm sched ds
33

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

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

3939
-include $(DEPENDENCIES)

src/kernel/drivers/kbd.c

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,10 @@ static const char *to_string(uint8_t code) {
212212
str = "NUMLOCK";
213213
break;
214214
case KBD_KP_KEY_ASTERISK:
215-
str = "(keypad) ASTERISK";
215+
str = "(KP) ASTERISK";
216216
break;
217217
case KBD_KP_KEY_MINUS:
218-
str = "(keypad) MINUS";
218+
str = "(KP) MINUS";
219219
break;
220220
case KBD_KEY_TAB:
221221
str = "TAB";
@@ -260,16 +260,16 @@ static const char *to_string(uint8_t code) {
260260
str = "BACK_SLASH";
261261
break;
262262
case KBD_KP_KEY_7:
263-
str = "(keypad) 7";
263+
str = "(KP) 7";
264264
break;
265265
case KBD_KP_KEY_8:
266-
str = "(keypad) 8";
266+
str = "(KP) 8";
267267
break;
268268
case KBD_KP_KEY_9:
269-
str = "(keypad) 9";
269+
str = "(KP) 9";
270270
break;
271271
case KBD_KP_KEY_PLUS:
272-
str = "(keypad) PLUS";
272+
str = "(KP) PLUS";
273273
break;
274274
case KBD_KEY_CAPS_LOCK:
275275
str = "CAPS_LOCK";
@@ -311,13 +311,13 @@ static const char *to_string(uint8_t code) {
311311
str = "ENTER";
312312
break;
313313
case KBD_KP_KEY_4:
314-
str = "(keypad) 4";
314+
str = "(KP) 4";
315315
break;
316316
case KBD_KP_KEY_5:
317-
str = "(keypad) 5";
317+
str = "(KP) 5";
318318
break;
319319
case KBD_KP_KEY_6:
320-
str = "(keypad) 6";
320+
str = "(KP) 6";
321321
break;
322322
case KBD_KEY_LSHIFT:
323323
str = "LSHIFT";
@@ -356,13 +356,13 @@ static const char *to_string(uint8_t code) {
356356
str = "RSHIFT";
357357
break;
358358
case KBD_KP_KEY_1:
359-
str = "(keypad) 1";
359+
str = "(KP) 1";
360360
break;
361361
case KBD_KP_KEY_2:
362-
str = "(keypad) 2";
362+
str = "(KP) 2";
363363
break;
364364
case KBD_KP_KEY_3:
365-
str = "(keypad) 3";
365+
str = "(KP) 3";
366366
break;
367367
case KBD_KEY_LCTRL:
368368
str = "LCTRL";
@@ -383,10 +383,10 @@ static const char *to_string(uint8_t code) {
383383
str = "SUPER";
384384
break;
385385
case KBD_KP_KEY_0:
386-
str = "(keypad) 0";
386+
str = "(KP) 0";
387387
break;
388388
case KBD_KP_KEY_PERIOD:
389-
str = "(keypad) PERIOD";
389+
str = "(KP) PERIOD";
390390
break;
391391
default:
392392
str = "(NULL)";
@@ -401,13 +401,13 @@ static const char *escaped_to_string(uint8_t code) {
401401
const char *str;
402402
switch (code) {
403403
case KBD_KP_KEY_ENTER:
404-
str = "(keypad) ENTER";
404+
str = "(KP) ENTER";
405405
break;
406406
case KBD_KEY_RCTRL:
407407
str = "RCTRL";
408408
break;
409409
case KBD_KP_KEY_SLASH:
410-
str = "(keypad) SLASH";
410+
str = "(KP) SLASH";
411411
break;
412412
case KBD_KEY_RALT:
413413
str = "RALT";
@@ -462,22 +462,50 @@ static void keyboard_irq_handler(struct registers *UNUSED(regs)) {
462462
bool released = scancode & 0x80;
463463
scancode &= ~0x80;
464464

465-
// On each key press, we write prettily to the same line.
466-
vga_clear();
467-
vga_set_x(0);
468-
printf("Scancode: %x, You %s: ", scancode, released ? "Released" : "Pressed");
469-
470465
// State-Based machine, which determines which scan table to decode from.
471466
switch (state) {
472467
// Waiting for first byte
473-
case 0:
474-
printf("%s", to_string(KBD_SCAN_TABLE[scancode]));
468+
case 0: {
469+
char *str = to_string(KBD_SCAN_TABLE[scancode]);
470+
uint32_t x = vga_get_x();
471+
uint32_t y = vga_get_y();
472+
vga_set_x(65);
473+
vga_set_y(1);
474+
for (int i = 0; i < 15 - strlen(str); i++) {
475+
vga_putc(' ');
476+
}
477+
printf("%s", str);
478+
vga_set_x(x);
479+
vga_set_y(y);
475480
return;
481+
}
476482
// Waiting for second byte of multibyte sequence
477483
case 1:
478-
printf("%s", escaped_to_string(KBD_ESCAPED_SCAN_TABLE[scancode]));
484+
switch (KBD_ESCAPED_SCAN_TABLE[scancode]) {
485+
case KBD_KEY_DOWN:
486+
vga_scroll_down();
487+
break;
488+
case KBD_KEY_UP:
489+
vga_scroll_up();
490+
break;
491+
default: {
492+
char *str = escaped_to_string(KBD_ESCAPED_SCAN_TABLE[scancode]);
493+
uint32_t x = vga_get_x();
494+
uint32_t y = vga_get_y();
495+
vga_set_x(65);
496+
vga_set_y(1);
497+
for (int i = 0; i < 15 - strlen(str); i++) {
498+
vga_putc(' ');
499+
}
500+
printf("%s", str);
501+
vga_set_x(x);
502+
vga_set_y(y);
503+
}
504+
}
479505
state = 0;
480506
}
507+
508+
481509
}
482510

483511
// Simple initializer that registers IRQ handler

src/kernel/drivers/rtc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,7 @@ void rtc_print() {
6161
if(hour < 0)
6262
hour += 12;
6363

64-
printf("%d:%d:%d %s", hour, rtc_get_minute(), rtc_get_second(), pm ? "PM" : "AM");
64+
uint8_t min = rtc_get_minute();
65+
uint8_t sec = rtc_get_second();
66+
printf("%d:%s%d:%s%d%s", hour, min < 10 ? "0" : "", min, sec < 10 ? "0" : "", sec, pm ? "PM" : "AM");
6567
}

0 commit comments

Comments
 (0)