From fdf93f927d30c340d432e2566841245ab91cb5dc Mon Sep 17 00:00:00 2001 From: Baptiste Wicht Date: Thu, 6 Mar 2014 22:09:38 +0100 Subject: [PATCH] Cleanup --- kernel/include/disks.hpp | 8 +------- kernel/src/disks.cpp | 36 ------------------------------------ kernel/src/shell.cpp | 40 +--------------------------------------- 3 files changed, 2 insertions(+), 82 deletions(-) diff --git a/kernel/include/disks.hpp b/kernel/include/disks.hpp index b60d9241..2829e0b2 100644 --- a/kernel/include/disks.hpp +++ b/kernel/include/disks.hpp @@ -40,18 +40,12 @@ struct partition_descriptor { void detect_disks(); -uint64_t detected_disks(); - -bool disk_exists(uint64_t uuid); - disk_descriptor& disk_by_index(uint64_t index); disk_descriptor& disk_by_uuid(uint64_t uuid); -const char* disk_type_to_string(disk_type type); -const char* partition_type_to_string(vfs::partition_type type); - bool read_sectors(const disk_descriptor& disk, uint64_t start, uint8_t count, void* destination); bool write_sectors(const disk_descriptor& disk, uint64_t start, uint8_t count, void* destination); + std::unique_heap_array partitions(disk_descriptor& disk); } diff --git a/kernel/src/disks.cpp b/kernel/src/disks.cpp index f7e9802f..527988b2 100644 --- a/kernel/src/disks.cpp +++ b/kernel/src/disks.cpp @@ -90,10 +90,6 @@ void disks::detect_disks(){ } } -uint64_t disks::detected_disks(){ - return number_of_disks; -} - disks::disk_descriptor& disks::disk_by_index(uint64_t index){ return _disks[index]; } @@ -108,38 +104,6 @@ disks::disk_descriptor& disks::disk_by_uuid(uint64_t uuid){ __builtin_unreachable(); } -bool disks::disk_exists(uint64_t uuid){ - for(uint64_t i = 0; i < number_of_disks; ++i){ - if(_disks[i].uuid == uuid){ - return true; - } - } - - return false; -} - -const char* disks::disk_type_to_string(disk_type type){ - switch(type){ - case disk_type::ATA: - return "ATA"; - case disk_type::ATAPI: - return "ATAPI"; - default: - return "Invalid Type"; - } -} - -const char* disks::partition_type_to_string(vfs::partition_type type){ - switch(type){ - case vfs::partition_type::FAT32: - return "FAT32"; - case vfs::partition_type::UNKNOWN: - return "Unknown"; - default: - return "Invalid Type"; - } -} - bool disks::read_sectors(const disk_descriptor& disk, uint64_t start, uint8_t count, void* destination){ switch(disk.type){ case disk_type::ATA: diff --git a/kernel/src/shell.cpp b/kernel/src/shell.cpp index 1c13abf8..646b83af 100644 --- a/kernel/src/shell.cpp +++ b/kernel/src/shell.cpp @@ -46,7 +46,6 @@ bool shift = false; //Declarations of the different functions -void disks_command(const std::vector& params); void exec_command(const std::vector& params); struct command_definition { @@ -54,8 +53,7 @@ struct command_definition { void (*function)(const std::vector&); }; -command_definition commands[2] = { - {"disks", disks_command}, +command_definition commands[1] = { {"exec", exec_command}, }; @@ -170,42 +168,6 @@ void exec_shell_command(){ k_printf("The command \"%s\" does not exist\n", current_input.c_str()); } -void disks_command(const std::vector& params){ - bool verbose = false; - - //Read options if any - if(params.size() > 1){ - for(size_t i = 1; i < params.size(); ++i){ - if(params[i] == "-v"){ - verbose = true; - } - } - } - - if(verbose){ - k_print_line("UUID Type Model Serial Firmware"); - } else { - k_print_line("UUID Type"); - } - - for(uint64_t i = 0; i < disks::detected_disks(); ++i){ - auto& descriptor = disks::disk_by_index(i); - - if(verbose){ - if(descriptor.type == disks::disk_type::ATA || descriptor.type == disks::disk_type::ATAPI){ - auto sub = static_cast(descriptor.descriptor); - - k_printf("%10d %5s %20s %15s %s\n", descriptor.uuid, disks::disk_type_to_string(descriptor.type), - sub->model.c_str(), sub->serial.c_str(), sub->firmware.c_str()); - } else { - k_printf("%10d %s\n", descriptor.uuid, disks::disk_type_to_string(descriptor.type)); - } - } else { - k_printf("%10d %s\n", descriptor.uuid, disks::disk_type_to_string(descriptor.type)); - } - } -} - void exec_command(const std::vector&){ //Fake exec just to start() the scheduler std::vector params;