diff --git a/bootloader/bootloader.asm b/bootloader/bootloader.asm index 985f02ad..02d5db90 100644 --- a/bootloader/bootloader.asm +++ b/bootloader/bootloader.asm @@ -134,7 +134,7 @@ second_step: ; Loading the assembly kernel from floppy KERNEL_BASE equ 0x100 ; 0x100:0x0 = 0x1000 - sectors equ 0x40 ; sectors to read + sectors equ 0x42 ; sectors to read bootdev equ 0x0 mov ax, KERNEL_BASE diff --git a/fill.bash b/fill.bash index ecc8b574..555695c0 100644 --- a/fill.bash +++ b/fill.bash @@ -1,5 +1,5 @@ #!/bin/bash size=`stat -c%s kernel/kernel.bin` -let filler_size=16384-$size +let filler_size=17408-$size dd if=/dev/zero of=filler.bin bs=1 count=$filler_size diff --git a/kernel/include/keyboard.hpp b/kernel/include/keyboard.hpp index b44597f1..7ded6eeb 100644 --- a/kernel/include/keyboard.hpp +++ b/kernel/include/keyboard.hpp @@ -15,6 +15,7 @@ namespace keyboard { const char KEY_ENTER = 0x1C; const char KEY_BACKSPACE = 0x0E; const char KEY_UP = 0x48; +const char KEY_DOWN = 0x50; void install_driver(); char get_char(); diff --git a/kernel/include/vector.hpp b/kernel/include/vector.hpp index 0b3da91c..bcfbda93 100644 --- a/kernel/include/vector.hpp +++ b/kernel/include/vector.hpp @@ -60,6 +60,14 @@ public: return _capacity; } + const value_type& operator[](size_type pos) const { + return data[pos]; + } + + value_type& operator[](size_type pos){ + return data[pos]; + } + //Modifiers void push_back(value_type& element){ diff --git a/kernel/src/shell.cpp b/kernel/src/shell.cpp index 228f42d6..313d5527 100644 --- a/kernel/src/shell.cpp +++ b/kernel/src/shell.cpp @@ -88,8 +88,42 @@ void start_shell(){ } k_print("thor> "); - } else if(key == keyboard::KEY_UP){ - //TODO + } else if(key == keyboard::KEY_UP || key == keyboard::KEY_DOWN){ + if(history.size() > 0){ + if(key == keyboard::KEY_UP){ + if(history_index == 0){ + continue; + } + + --history_index; + } else { //KEY_DOWN + if(history_index == history.size()){ + continue; + } + + ++history_index; + } + + set_column(6); + + for(uint64_t i = 0; i < current_input_length; ++i){ + k_print(' '); + } + + set_column(6); + + current_input_length = 0; + + if(history_index < history.size()){ + auto saved = history[history_index]; + while(*saved){ + current_input[current_input_length++] = *saved; + k_print(*saved); + + ++saved; + } + } + } } else if(key == keyboard::KEY_BACKSPACE){ if(current_input_length > 0){ k_print('\b'); @@ -111,6 +145,13 @@ void start_shell(){ void exec_command(){ char buffer[50]; + auto saved = new char[current_input_length + 1]; + memcopy(saved, current_input, current_input_length); + saved[current_input_length] = '\0'; + + history.push_back(saved); + history_index = history.size(); + for(auto& command : commands){ const char* input_command = current_input; if(str_contains(current_input, ' ')){