mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-09 04:22:04 -04:00
Cleanup
This commit is contained in:
parent
49f2fe30e5
commit
fdf93f927d
@ -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<partition_descriptor> partitions(disk_descriptor& disk);
|
||||
|
||||
}
|
||||
|
@ -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:
|
||||
|
@ -46,7 +46,6 @@ bool shift = false;
|
||||
|
||||
//Declarations of the different functions
|
||||
|
||||
void disks_command(const std::vector<std::string>& params);
|
||||
void exec_command(const std::vector<std::string>& params);
|
||||
|
||||
struct command_definition {
|
||||
@ -54,8 +53,7 @@ struct command_definition {
|
||||
void (*function)(const std::vector<std::string>&);
|
||||
};
|
||||
|
||||
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<std::string>& 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<ata::drive_descriptor*>(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<std::string>&){
|
||||
//Fake exec just to start() the scheduler
|
||||
std::vector<std::string> params;
|
||||
|
Loading…
x
Reference in New Issue
Block a user