Skip to content

Commit

Permalink
Fix crash on deleting characters when none in buffer, Minor cleanup, …
Browse files Browse the repository at this point in the history
…Rename kernel_main() to kmain()
  • Loading branch information
jonpas committed Jan 20, 2018
1 parent 427a850 commit c49febc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/boot.asm
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ mboot:
dd start

; Reserve space for stack
section .bss align=16
section .bss
resb 8192
stack_end:

section .text

[GLOBAL start] ; Kernel entry point
[EXTERN kernel_main] ; C code entry point
[EXTERN kmain] ; C code entry point

start:
; Load multiboot information
push ebx ; Save mboot information structure
cli ; Disable interrupts
mov esp, stack_end ; Set stack pointer to end of stack
call kernel_main ; Call 'kernel_main()' C function
push ebx ; Save mboot information structure
call kmain ; Call 'kernel_main()' C function
jmp $ ; Continue loop
2 changes: 1 addition & 1 deletion src/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ static void keyboard_handler(registers_t *regs) {
memset(input_buffer, 0, sizeof(input_buffer));
} else if (ascii == BKSP) {
// Try to delete last inputted character
if (monitor_delete() != -1) {
if (monitor_delete() != -1 && strlen(input_buffer) > 0) {
// Delete last character from input buffer
char tmp[INPUT_BUFFER_LEN] = {0};
memcpy(tmp, input_buffer, strlen(input_buffer) - 1);
Expand Down
10 changes: 7 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

struct multiboot;

int kernel_main(struct multiboot *mboot_ptr) {
int kmain(struct multiboot *mboot_ptr) {
// Initialize descriptor tables
init_descriptor_tables();

Expand All @@ -30,7 +30,11 @@ int kernel_main(struct multiboot *mboot_ptr) {

// TODO Multitasking
//switch_to_user_mode();
//syscall_monitor_write("Hello, user world!\n");

// System Call test
/*
syscall_monitor_write("Hello, user world!\n$ ");
*/

// Paging and Heap test (comment 'init_paging()' above!)
/*
Expand All @@ -51,7 +55,7 @@ int kernel_main(struct multiboot *mboot_ptr) {
monitor_write_hex(d);
*/

// Page fault test
// Panic test
/*
uint *ptr = (uint*)0xA0000000;
uint do_page_fault = *ptr;
Expand Down

0 comments on commit c49febc

Please sign in to comment.