mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-17 08:37:17 -04:00
Move STL stuff to stl folder
This commit is contained in:
parent
17abc063c5
commit
1e2bd865ff
@ -18,11 +18,13 @@ CPP_FLAGS_64=$(COMMON_CPP_FLAGS) -mno-sse3 -mno-sse4 -mno-sse4.1 -mno-sse4.2
|
||||
LINK_FLAGS=-lgcc -T linker.ld
|
||||
|
||||
KERNEL_CPP_FILES=$(wildcard src/*.cpp)
|
||||
KERNEL_CPP_STL_FILES=$(wildcard src/stl/*.cpp)
|
||||
|
||||
KERNEL_D_FILES=$(KERNEL_CPP_FILES:%.cpp=%.cpp.d)
|
||||
KERNEL_D_STL_FILES=$(KERNEL_CPP_STL_FILES:%.cpp=%.cpp.d)
|
||||
|
||||
#TODO Generate also the o files coming from s files automatically, ignoring crti and crtn
|
||||
KERNEL_O_FILES=boot_16_64.o boot_32_64.o $(KERNEL_CPP_FILES:src/%.cpp=%.cpp.o) isrs.s.o irqs.s.o arch.s.o
|
||||
|
||||
KERNEL_D_FILES=$(KERNEL_CPP_FILES:src/%.cpp=%.cpp.d)
|
||||
KERNEL_O_FILES=boot_16_64.o boot_32_64.o $(KERNEL_CPP_FILES:%.cpp=%.cpp.o) $(KERNEL_CPP_STL_FILES:%.cpp=%.cpp.o) isrs.s.o irqs.s.o arch.s.o
|
||||
|
||||
CRTBEGIN_OBJ:=$(shell $(CC) $(CFLAGS) -print-file-name=crtbegin.o)
|
||||
CRTEND_OBJ:=$(shell $(CC) $(CFLAGS) -print-file-name=crtend.o)
|
||||
@ -44,19 +46,33 @@ boot_32_64.o: boot_32.o
|
||||
%.s.o: src/%.s
|
||||
$(AS) -c $< -o $@
|
||||
|
||||
%.cpp.d: $(KERNEL_CPP_FILES)
|
||||
@ $(CC) $(CPP_FLAGS_64) $(THOR_FLAGS) $(WARNING_FLAGS) -MM -MT $*.cpp.o src/$*.cpp | sed -e 's@^\(.*\)\.o:@\1.d \1.o:@' > $@
|
||||
src/%.cpp.d: $(KERNEL_CPP_FILES)
|
||||
@ $(CC) $(CPP_FLAGS_64) $(THOR_FLAGS) $(WARNING_FLAGS) -MM -MT src/$*.cpp.o src/$*.cpp | sed -e 's@^\(.*\)\.o:@\1.d \1.o:@' > $@
|
||||
|
||||
%.cpp.o:
|
||||
src/stl/%.cpp.d: $(KERNEL_CPP_STL_FILES)
|
||||
@ $(CC) $(CPP_FLAGS_64) $(THOR_FLAGS) $(WARNING_FLAGS) -MM -MT src/stl/$*.cpp.o src/stl/$*.cpp | sed -e 's@^\(.*\)\.o:@\1.d \1.o:@' > $@
|
||||
|
||||
src/%.cpp.o:
|
||||
$(CC) $(CPP_FLAGS_64) $(THOR_FLAGS) $(WARNING_FLAGS) -c $< -o $@
|
||||
|
||||
src/stl/%.cpp.o:
|
||||
$(CC) $(CPP_FLAGS_64) $(THOR_FLAGS) $(WARNING_FLAGS) -c $< -o $@
|
||||
|
||||
-include $(KERNEL_D_FILES)
|
||||
-include $(KERNEL_D_STL_FILES)
|
||||
|
||||
kernel.bin: $(LINK_O_FILES)
|
||||
$(CC) $(LINK_FLAGS) $(CPP_FLAGS_64) -o kernel.bin.o $(LINK_O_FILES)
|
||||
$(OC) -R .note -R .comment -S -O binary kernel.bin.o kernel.bin
|
||||
|
||||
debug:
|
||||
echo $(KERNEL_CPP_STL_FILES)
|
||||
echo $(KERNEL_D_STL_FILES)
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
rm -f $(KERNEL_D_FILES)
|
||||
rm -f $(KERNEL_D_STL_FILES)
|
||||
rm -f $(KERNEL_O_FILES)
|
||||
rm -f crti.o
|
||||
rm -f crts.o
|
||||
rm -f *.bin
|
||||
rm -f *.d
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef ATA_H
|
||||
#define ATA_H
|
||||
|
||||
#include "types.hpp"
|
||||
#include "stl/types.hpp"
|
||||
|
||||
namespace ata {
|
||||
|
||||
|
@ -8,9 +8,9 @@
|
||||
#ifndef CONSOLE_H
|
||||
#define CONSOLE_H
|
||||
|
||||
#include "types.hpp"
|
||||
#include "enable_if.hpp"
|
||||
#include "string.hpp"
|
||||
#include "stl/types.hpp"
|
||||
#include "stl/enable_if.hpp"
|
||||
#include "stl/string.hpp"
|
||||
|
||||
void set_column(long column);
|
||||
long get_column();
|
||||
@ -23,7 +23,7 @@ void k_print(char key);
|
||||
void k_print(const char* string);
|
||||
void k_print(const char* string, uint64_t end);
|
||||
|
||||
void k_print(const string& s);
|
||||
void k_print(const std::string& s);
|
||||
|
||||
void k_print(uint8_t number);
|
||||
void k_print(uint16_t number);
|
||||
|
@ -8,10 +8,10 @@
|
||||
#ifndef DISKS_H
|
||||
#define DISKS_H
|
||||
|
||||
#include "types.hpp"
|
||||
#include "array.hpp"
|
||||
#include "vector.hpp"
|
||||
#include "string.hpp"
|
||||
#include "stl/types.hpp"
|
||||
#include "stl/array.hpp"
|
||||
#include "stl/vector.hpp"
|
||||
#include "stl/string.hpp"
|
||||
|
||||
namespace disks {
|
||||
|
||||
@ -38,7 +38,7 @@ struct partition_descriptor {
|
||||
};
|
||||
|
||||
struct file {
|
||||
string file_name;
|
||||
std::string file_name;
|
||||
bool directory;
|
||||
bool hidden;
|
||||
bool system;
|
||||
@ -66,13 +66,13 @@ void unmount();
|
||||
vector<file> ls();
|
||||
uint64_t free_size();
|
||||
|
||||
string read_file(const string& file);
|
||||
std::string read_file(const std::string& file);
|
||||
|
||||
const disk_descriptor* mounted_disk();
|
||||
const partition_descriptor* mounted_partition();
|
||||
|
||||
//TODO It is not a really good practice to directly expose the vector
|
||||
vector<string>& current_directory();
|
||||
vector<std::string>& current_directory();
|
||||
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
*/
|
||||
|
||||
#ifndef CODE_16
|
||||
#include "types.hpp"
|
||||
#include "stl/types.hpp"
|
||||
#endif
|
||||
|
||||
#ifndef E820_HPP
|
||||
|
@ -9,16 +9,17 @@
|
||||
#define FAT32_H
|
||||
|
||||
#include "disks.hpp"
|
||||
#include "vector.hpp"
|
||||
#include "string.hpp"
|
||||
|
||||
#include "stl/vector.hpp"
|
||||
#include "stl/string.hpp"
|
||||
|
||||
namespace fat32 {
|
||||
|
||||
typedef const disks::disk_descriptor& dd;
|
||||
|
||||
uint64_t free_size(dd disk, const disks::partition_descriptor& partition);
|
||||
vector<disks::file> ls(dd disk, const disks::partition_descriptor& partition, const vector<string>& path);
|
||||
string read_file(dd disk, const disks::partition_descriptor& partition, const vector<string>& path, const string& file);
|
||||
vector<disks::file> ls(dd disk, const disks::partition_descriptor& partition, const vector<std::string>& path);
|
||||
std::string read_file(dd disk, const disks::partition_descriptor& partition, const vector<std::string>& path, const std::string& file);
|
||||
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef INTERRUPTS_H
|
||||
#define INTERRUPTS_H
|
||||
|
||||
#include "types.hpp"
|
||||
#include "stl/types.hpp"
|
||||
|
||||
namespace interrupt {
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef KERNEL_UTILS_H
|
||||
#define KERNEL_UTILS_H
|
||||
|
||||
#include "types.hpp"
|
||||
#include "stl/types.hpp"
|
||||
|
||||
uint8_t in_byte(uint16_t _port);
|
||||
void out_byte(uint16_t _port, uint8_t _data);
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef KEYBOARD_H
|
||||
#define KEYBOARD_H
|
||||
|
||||
#include "types.hpp"
|
||||
#include "stl/types.hpp"
|
||||
|
||||
namespace keyboard {
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef MEMORY_H
|
||||
#define MEMORY_H
|
||||
|
||||
#include "types.hpp"
|
||||
#include "stl/types.hpp"
|
||||
|
||||
void init_memory_manager();
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef PAGING_H
|
||||
#define PAGING_H
|
||||
|
||||
#include "types.hpp"
|
||||
#include "stl/types.hpp"
|
||||
|
||||
namespace paging {
|
||||
|
||||
|
@ -5,10 +5,8 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//=======================================================================
|
||||
|
||||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
|
||||
#include "types.hpp"
|
||||
#ifndef ALGORITHMS_H
|
||||
#define ALGORITHMS_H
|
||||
|
||||
namespace std {
|
||||
|
||||
@ -90,14 +88,4 @@ bool equal_n(Iterator1 it1, Iterator2 it2, size_t n){
|
||||
|
||||
} //end of namespace std
|
||||
|
||||
template<typename CharT>
|
||||
struct basic_string;
|
||||
typedef basic_string<char> string;
|
||||
|
||||
uint64_t parse(const char* str);
|
||||
uint64_t parse(const char* str, const char* end);
|
||||
uint64_t parse(const string& str);
|
||||
|
||||
uint64_t str_len(const char* a);
|
||||
|
||||
#endif
|
@ -8,7 +8,7 @@
|
||||
#ifndef OPTIONAL_H
|
||||
#define OPTIONAL_H
|
||||
|
||||
#include "utils.hpp"
|
||||
#include "algorithms.hpp"
|
||||
|
||||
struct dummy_t {};
|
||||
|
@ -8,8 +8,13 @@
|
||||
#ifndef STRING_H
|
||||
#define STRING_H
|
||||
|
||||
#include "types.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "stl/types.hpp"
|
||||
#include "stl/algorithms.hpp"
|
||||
#include "stl/vector.hpp"
|
||||
|
||||
namespace std {
|
||||
|
||||
uint64_t str_len(const char* a);
|
||||
|
||||
template<typename CharT>
|
||||
struct basic_string {
|
||||
@ -208,4 +213,12 @@ public:
|
||||
|
||||
typedef basic_string<char> string;
|
||||
|
||||
uint64_t parse(const char* str);
|
||||
uint64_t parse(const char* str, const char* end);
|
||||
uint64_t parse(const string& str);
|
||||
|
||||
vector<string> split(const string& s);
|
||||
|
||||
} //end of namespace std
|
||||
|
||||
#endif
|
@ -8,15 +8,15 @@
|
||||
#ifndef VECTOR_H
|
||||
#define VECTOR_H
|
||||
|
||||
#include "types.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "stl/types.hpp"
|
||||
#include "stl/algorithms.hpp"
|
||||
|
||||
template<typename T>
|
||||
class vector {
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef value_type* pointer_type;
|
||||
typedef uint64_t size_type;
|
||||
typedef size_t size_type;
|
||||
typedef value_type* iterator;
|
||||
typedef const value_type* const_iterator;
|
||||
|
@ -8,9 +8,9 @@
|
||||
#ifndef SYSINFO_H
|
||||
#define SYSINFO_H
|
||||
|
||||
#include "string.hpp"
|
||||
#include "vector.hpp"
|
||||
#include "stl/string.hpp"
|
||||
#include "stl/vector.hpp"
|
||||
|
||||
void sysinfo_command(const vector<string>& params);
|
||||
void sysinfo_command(const vector<std::string>& params);
|
||||
|
||||
#endif
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef THOR_H
|
||||
#define THOR_H
|
||||
|
||||
#include "types.hpp"
|
||||
#include "stl/types.hpp"
|
||||
|
||||
void* operator new(uint64_t size);
|
||||
void operator delete(void* p);
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef TIMER_H
|
||||
#define TIMER_H
|
||||
|
||||
#include "types.hpp"
|
||||
#include "stl/types.hpp"
|
||||
|
||||
void install_timer();
|
||||
void sleep_ms(uint64_t delay);
|
||||
|
@ -6,13 +6,13 @@
|
||||
//=======================================================================
|
||||
|
||||
#include "acpi.hpp"
|
||||
#include "types.hpp"
|
||||
#include "kernel_utils.hpp"
|
||||
#include "timer.hpp"
|
||||
#include "paging.hpp"
|
||||
|
||||
#include "console.hpp"
|
||||
|
||||
#include "stl/types.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
uint32_t SMI_CMD; //ptr
|
||||
|
@ -1,30 +0,0 @@
|
||||
//=======================================================================
|
||||
// Copyright Baptiste Wicht 2013.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//=======================================================================
|
||||
|
||||
#include "algorithms.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
vector<string> split(const string& s){
|
||||
vector<string> parts;
|
||||
|
||||
string current(s.size());
|
||||
|
||||
for(char c : s){
|
||||
if(c == ' ' && !current.empty()){
|
||||
parts.push_back(current);
|
||||
current.clear();
|
||||
} else {
|
||||
current += c;
|
||||
}
|
||||
}
|
||||
|
||||
if(!current.empty()){
|
||||
parts.push_back(current);
|
||||
}
|
||||
|
||||
return std::move(parts);
|
||||
}
|
@ -8,8 +8,9 @@
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "console.hpp"
|
||||
#include "types.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
#include "stl/types.hpp"
|
||||
#include "stl/string.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -166,7 +167,7 @@ void k_print(const char* str){
|
||||
}
|
||||
}
|
||||
|
||||
void k_print(const string& s){
|
||||
void k_print(const std::string& s){
|
||||
for(auto c : s){
|
||||
k_print(c);
|
||||
}
|
||||
|
@ -5,15 +5,15 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//=======================================================================
|
||||
|
||||
#include "unique_ptr.hpp"
|
||||
#include "array.hpp"
|
||||
|
||||
#include "disks.hpp"
|
||||
#include "ata.hpp"
|
||||
#include "thor.hpp"
|
||||
#include "console.hpp"
|
||||
#include "fat32.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
#include "stl/unique_ptr.hpp"
|
||||
#include "stl/array.hpp"
|
||||
#include "stl/string.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -44,7 +44,7 @@ static_assert(sizeof(boot_record_t) == 512, "The boot record is 512 bytes long")
|
||||
const disks::disk_descriptor* _mounted_disk;
|
||||
const disks::partition_descriptor* _mounted_partition;
|
||||
|
||||
vector<string> pwd;
|
||||
vector<std::string> pwd;
|
||||
|
||||
} //end of anonymous namespace
|
||||
|
||||
@ -226,11 +226,11 @@ uint64_t disks::free_size(){
|
||||
return fat32::free_size(*_mounted_disk, *_mounted_partition);
|
||||
}
|
||||
|
||||
vector<string>& disks::current_directory(){
|
||||
vector<std::string>& disks::current_directory(){
|
||||
return pwd;
|
||||
}
|
||||
|
||||
string disks::read_file(const string& file){
|
||||
std::string disks::read_file(const std::string& file){
|
||||
if(!_mounted_disk || !_mounted_partition){
|
||||
return "";
|
||||
}
|
||||
|
@ -5,13 +5,13 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//=======================================================================
|
||||
|
||||
#include "unique_ptr.hpp"
|
||||
|
||||
#include "fat32.hpp"
|
||||
#include "types.hpp"
|
||||
#include "console.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "pair.hpp"
|
||||
|
||||
#include "stl/types.hpp"
|
||||
#include "stl/unique_ptr.hpp"
|
||||
#include "stl/algorithms.hpp"
|
||||
#include "stl/pair.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -197,7 +197,7 @@ size_t filename_length(char* filename){
|
||||
return 11;
|
||||
}
|
||||
|
||||
bool filename_equals(char* name, const string& path){
|
||||
bool filename_equals(char* name, const std::string& path){
|
||||
auto length = filename_length(name);
|
||||
|
||||
if(path.size() != length){
|
||||
@ -228,7 +228,7 @@ bool cache_disk_partition(fat32::dd disk, const disks::partition_descriptor& par
|
||||
return fat_bs && fat_is;
|
||||
}
|
||||
|
||||
pair<bool, unique_heap_array<cluster_entry>> find_cluster(fat32::dd disk, const vector<string>& path){
|
||||
pair<bool, unique_heap_array<cluster_entry>> find_cluster(fat32::dd disk, const vector<std::string>& path){
|
||||
auto cluster_addr = cluster_lba(fat_bs->root_directory_cluster_start);
|
||||
|
||||
unique_heap_array<cluster_entry> current_cluster(16 * fat_bs->sectors_per_cluster);
|
||||
@ -286,7 +286,7 @@ uint64_t fat32::free_size(dd disk, const disks::partition_descriptor& partition)
|
||||
return fat_is->free_clusters * fat_bs->sectors_per_cluster * 512;
|
||||
}
|
||||
|
||||
vector<disks::file> fat32::ls(dd disk, const disks::partition_descriptor& partition, const vector<string>& path){
|
||||
vector<disks::file> fat32::ls(dd disk, const disks::partition_descriptor& partition, const vector<std::string>& path){
|
||||
if(!cache_disk_partition(disk, partition)){
|
||||
return {};
|
||||
}
|
||||
@ -300,7 +300,7 @@ vector<disks::file> fat32::ls(dd disk, const disks::partition_descriptor& partit
|
||||
}
|
||||
}
|
||||
|
||||
string fat32::read_file(dd disk, const disks::partition_descriptor& partition, const vector<string>& path, const string& file){
|
||||
std::string fat32::read_file(dd disk, const disks::partition_descriptor& partition, const vector<std::string>& path, const std::string& file){
|
||||
if(!cache_disk_partition(disk, partition)){
|
||||
return {};
|
||||
}
|
||||
@ -327,7 +327,7 @@ string fat32::read_file(dd disk, const disks::partition_descriptor& partition, c
|
||||
fat_bs->sectors_per_cluster, sector.get())){
|
||||
found = true;
|
||||
|
||||
string content(entry.file_size + 1);
|
||||
std::string content(entry.file_size + 1);
|
||||
|
||||
for(size_t i = 0; i < entry.file_size; ++i){
|
||||
content += sector[i];
|
||||
|
@ -6,8 +6,6 @@
|
||||
//=======================================================================
|
||||
|
||||
#include "interrupts.hpp"
|
||||
#include "types.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "console.hpp"
|
||||
#include "kernel_utils.hpp"
|
||||
#include "gdt.hpp"
|
||||
@ -15,6 +13,8 @@
|
||||
#include "isrs.hpp"
|
||||
#include "irqs.hpp"
|
||||
|
||||
#include "stl/types.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
struct idt_entry {
|
||||
|
@ -6,11 +6,11 @@
|
||||
//=======================================================================
|
||||
|
||||
#include "paging.hpp"
|
||||
#include "types.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
#include "console.hpp"
|
||||
|
||||
#include "stl/types.hpp"
|
||||
#include "stl/algorithms.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
typedef uint64_t* page_entry;
|
||||
|
@ -5,25 +5,25 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//=======================================================================
|
||||
|
||||
#include "types.hpp"
|
||||
#include "keyboard.hpp"
|
||||
#include "kernel_utils.hpp"
|
||||
#include "console.hpp"
|
||||
#include "shell.hpp"
|
||||
#include "timer.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "memory.hpp"
|
||||
#include "disks.hpp"
|
||||
#include "string.hpp"
|
||||
#include "vector.hpp"
|
||||
#include "algorithms.hpp"
|
||||
#include "acpi.hpp"
|
||||
#include "e820.hpp"
|
||||
#include "optional.hpp"
|
||||
|
||||
//Commands
|
||||
#include "sysinfo.hpp"
|
||||
|
||||
#include "stl/types.hpp"
|
||||
#include "stl/algorithms.hpp"
|
||||
#include "stl/vector.hpp"
|
||||
#include "stl/string.hpp"
|
||||
#include "stl/optional.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
#ifdef CONFIG_HISTORY
|
||||
@ -32,37 +32,37 @@ static constexpr const bool History = true;
|
||||
static constexpr const bool History = false;
|
||||
#endif
|
||||
|
||||
vector<string> history;
|
||||
vector<std::string> history;
|
||||
uint64_t history_index = 0;
|
||||
|
||||
bool shift = false;
|
||||
|
||||
//Declarations of the different functions
|
||||
|
||||
void reboot_command(const vector<string>& params);
|
||||
void help_command(const vector<string>& params);
|
||||
void uptime_command(const vector<string>& params);
|
||||
void clear_command(const vector<string>& params);
|
||||
void date_command(const vector<string>& params);
|
||||
void sleep_command(const vector<string>& params);
|
||||
void echo_command(const vector<string>& params);
|
||||
void mmap_command(const vector<string>& params);
|
||||
void memory_command(const vector<string>& params);
|
||||
void memorydebug_command(const vector<string>& params);
|
||||
void disks_command(const vector<string>& params);
|
||||
void partitions_command(const vector<string>& params);
|
||||
void mount_command(const vector<string>& params);
|
||||
void unmount_command(const vector<string>& params);
|
||||
void ls_command(const vector<string>& params);
|
||||
void cd_command(const vector<string>& params);
|
||||
void pwd_command(const vector<string>& params);
|
||||
void free_command(const vector<string>& params);
|
||||
void cat_command(const vector<string>& params);
|
||||
void shutdown_command(const vector<string>& params);
|
||||
void reboot_command(const vector<std::string>& params);
|
||||
void help_command(const vector<std::string>& params);
|
||||
void uptime_command(const vector<std::string>& params);
|
||||
void clear_command(const vector<std::string>& params);
|
||||
void date_command(const vector<std::string>& params);
|
||||
void sleep_command(const vector<std::string>& params);
|
||||
void echo_command(const vector<std::string>& params);
|
||||
void mmap_command(const vector<std::string>& params);
|
||||
void memory_command(const vector<std::string>& params);
|
||||
void memorydebug_command(const vector<std::string>& params);
|
||||
void disks_command(const vector<std::string>& params);
|
||||
void partitions_command(const vector<std::string>& params);
|
||||
void mount_command(const vector<std::string>& params);
|
||||
void unmount_command(const vector<std::string>& params);
|
||||
void ls_command(const vector<std::string>& params);
|
||||
void cd_command(const vector<std::string>& params);
|
||||
void pwd_command(const vector<std::string>& params);
|
||||
void free_command(const vector<std::string>& params);
|
||||
void cat_command(const vector<std::string>& params);
|
||||
void shutdown_command(const vector<std::string>& params);
|
||||
|
||||
struct command_definition {
|
||||
const char* name;
|
||||
void (*function)(const vector<string>&);
|
||||
void (*function)(const vector<std::string>&);
|
||||
};
|
||||
|
||||
command_definition commands[21] = {
|
||||
@ -89,7 +89,7 @@ command_definition commands[21] = {
|
||||
{"shutdown", shutdown_command},
|
||||
};
|
||||
|
||||
string current_input(16);
|
||||
std::string current_input(16);
|
||||
|
||||
void exec_command();
|
||||
|
||||
@ -193,7 +193,7 @@ void start_shell(){
|
||||
void exec_command(){
|
||||
history_save();
|
||||
|
||||
auto params = split(current_input);;
|
||||
auto params = std::split(current_input);;
|
||||
|
||||
for(auto& command : commands){
|
||||
if(params[0] == command.name){
|
||||
@ -206,17 +206,17 @@ void exec_command(){
|
||||
k_printf("The command \"%s\" does not exist\n", current_input.c_str());
|
||||
}
|
||||
|
||||
void clear_command(const vector<string>&){
|
||||
void clear_command(const vector<std::string>&){
|
||||
wipeout();
|
||||
}
|
||||
|
||||
void __attribute__((noreturn)) reboot_command(const vector<string>&){
|
||||
void __attribute__((noreturn)) reboot_command(const vector<std::string>&){
|
||||
__asm__ __volatile__("mov al, 0x64; or al, 0xFE; out 0x64, al; mov al, 0xFE; out 0x64, al; " : : );
|
||||
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
void help_command(const vector<string>&){
|
||||
void help_command(const vector<std::string>&){
|
||||
k_print("Available commands:\n");
|
||||
|
||||
for(auto& command : commands){
|
||||
@ -225,7 +225,7 @@ void help_command(const vector<string>&){
|
||||
}
|
||||
}
|
||||
|
||||
void uptime_command(const vector<string>&){
|
||||
void uptime_command(const vector<std::string>&){
|
||||
k_printf("Uptime: %ds\n", timer_seconds());
|
||||
}
|
||||
|
||||
@ -243,7 +243,7 @@ uint8_t get_RTC_register(int reg) {
|
||||
return in_byte(cmos_data);
|
||||
}
|
||||
|
||||
void date_command(const vector<string>&){
|
||||
void date_command(const vector<std::string>&){
|
||||
uint64_t second;
|
||||
uint64_t minute;
|
||||
uint64_t hour;
|
||||
@ -321,11 +321,11 @@ void date_command(const vector<string>&){
|
||||
k_printf("%d.%d.%d %d:%.2d:%.2d\n", day, month, year, hour, minute, second);
|
||||
}
|
||||
|
||||
void sleep_command(const vector<string>& params){
|
||||
void sleep_command(const vector<std::string>& params){
|
||||
sleep_ms(parse(params[1]) * 1000);
|
||||
}
|
||||
|
||||
void echo_command(const vector<string>& params){
|
||||
void echo_command(const vector<std::string>& params){
|
||||
for(uint64_t i = 1; i < params.size(); ++i){
|
||||
k_print(params[i]);
|
||||
k_print(' ');
|
||||
@ -333,7 +333,7 @@ void echo_command(const vector<string>& params){
|
||||
k_print_line();
|
||||
}
|
||||
|
||||
void mmap_command(const vector<string>&){
|
||||
void mmap_command(const vector<std::string>&){
|
||||
if(e820::mmap_failed()){
|
||||
k_print_line("The mmap was not correctly loaded from e820");
|
||||
} else {
|
||||
@ -349,7 +349,7 @@ void mmap_command(const vector<string>&){
|
||||
}
|
||||
}
|
||||
|
||||
void memory_command(const vector<string>&){
|
||||
void memory_command(const vector<std::string>&){
|
||||
if(e820::mmap_failed()){
|
||||
k_print_line("The mmap was not correctly loaded from e820");
|
||||
} else {
|
||||
@ -360,11 +360,11 @@ void memory_command(const vector<string>&){
|
||||
}
|
||||
}
|
||||
|
||||
void memorydebug_command(const vector<string>&){
|
||||
void memorydebug_command(const vector<std::string>&){
|
||||
memory_debug();
|
||||
}
|
||||
|
||||
void disks_command(const vector<string>&){
|
||||
void disks_command(const vector<std::string>&){
|
||||
k_print_line("UUID Type");
|
||||
|
||||
for(uint64_t i = 0; i < disks::detected_disks(); ++i){
|
||||
@ -374,7 +374,7 @@ void disks_command(const vector<string>&){
|
||||
}
|
||||
}
|
||||
|
||||
void partitions_command(const vector<string>& params){
|
||||
void partitions_command(const vector<std::string>& params){
|
||||
auto uuid = parse(params[1]);
|
||||
|
||||
if(disks::disk_exists(uuid)){
|
||||
@ -394,7 +394,7 @@ void partitions_command(const vector<string>& params){
|
||||
}
|
||||
}
|
||||
|
||||
void mount_command(const vector<string>& params){
|
||||
void mount_command(const vector<std::string>& params){
|
||||
if(params.size() == 1){
|
||||
auto md = disks::mounted_disk();
|
||||
auto mp = disks::mounted_partition();
|
||||
@ -421,7 +421,7 @@ void mount_command(const vector<string>& params){
|
||||
}
|
||||
}
|
||||
|
||||
void unmount_command(const vector<string>& ){
|
||||
void unmount_command(const vector<std::string>& ){
|
||||
if(!disks::mounted_partition() || !disks::mounted_disk()){
|
||||
k_print_line("Nothing is mounted");
|
||||
|
||||
@ -431,7 +431,7 @@ void unmount_command(const vector<string>& ){
|
||||
disks::unmount();
|
||||
}
|
||||
|
||||
void ls_command(const vector<string>& params){
|
||||
void ls_command(const vector<std::string>& params){
|
||||
if(!disks::mounted_partition() || !disks::mounted_disk()){
|
||||
k_print_line("Nothing is mounted");
|
||||
|
||||
@ -477,7 +477,7 @@ void ls_command(const vector<string>& params){
|
||||
}
|
||||
}
|
||||
|
||||
void free_command(const vector<string>&){
|
||||
void free_command(const vector<std::string>&){
|
||||
if(!disks::mounted_partition() || !disks::mounted_disk()){
|
||||
k_print_line("Nothing is mounted");
|
||||
|
||||
@ -487,7 +487,7 @@ void free_command(const vector<string>&){
|
||||
k_printf("Free size: %m\n", disks::free_size());
|
||||
}
|
||||
|
||||
void pwd_command(const vector<string>&){
|
||||
void pwd_command(const vector<std::string>&){
|
||||
if(!disks::mounted_partition() || !disks::mounted_disk()){
|
||||
k_print_line("Nothing is mounted");
|
||||
|
||||
@ -506,7 +506,7 @@ void pwd_command(const vector<string>&){
|
||||
k_print_line();
|
||||
}
|
||||
|
||||
optional<disks::file> find_file(const string& name){
|
||||
optional<disks::file> find_file(const std::string& name){
|
||||
auto files = disks::ls();
|
||||
|
||||
for(auto& file : files){
|
||||
@ -518,7 +518,7 @@ optional<disks::file> find_file(const string& name){
|
||||
return {};
|
||||
}
|
||||
|
||||
void cd_command(const vector<string>& params){
|
||||
void cd_command(const vector<std::string>& params){
|
||||
if(!disks::mounted_partition() || !disks::mounted_disk()){
|
||||
k_print_line("Nothing is mounted");
|
||||
|
||||
@ -551,7 +551,7 @@ void cd_command(const vector<string>& params){
|
||||
}
|
||||
}
|
||||
|
||||
void cat_command(const vector<string>& params){
|
||||
void cat_command(const vector<std::string>& params){
|
||||
if(!disks::mounted_partition() || !disks::mounted_disk()){
|
||||
k_print_line("Nothing is mounted");
|
||||
|
||||
@ -578,7 +578,7 @@ void cat_command(const vector<string>& params){
|
||||
}
|
||||
}
|
||||
|
||||
void shutdown_command(const vector<string>&){
|
||||
void shutdown_command(const vector<std::string>&){
|
||||
if(!acpi::init()){
|
||||
k_print_line("Unable to init ACPI");
|
||||
}
|
||||
|
@ -4,13 +4,3 @@
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//=======================================================================
|
||||
|
||||
#ifndef ALGORITHMS_H
|
||||
#define ALGORITHMS_H
|
||||
|
||||
#include "string.hpp"
|
||||
#include "vector.hpp"
|
||||
|
||||
vector<string> split(const string& s);
|
||||
|
||||
#endif
|
@ -5,10 +5,9 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//=======================================================================
|
||||
|
||||
#include "utils.hpp"
|
||||
#include "string.hpp"
|
||||
#include "stl/string.hpp"
|
||||
|
||||
uint64_t parse(const char* it, const char* end){
|
||||
uint64_t std::parse(const char* it, const char* end){
|
||||
int i = end - it - 1;
|
||||
|
||||
uint64_t factor = 1;
|
||||
@ -22,7 +21,7 @@ uint64_t parse(const char* it, const char* end){
|
||||
return acc;
|
||||
}
|
||||
|
||||
uint64_t parse(const char* str){
|
||||
uint64_t std::parse(const char* str){
|
||||
int i = 0;
|
||||
|
||||
const char* it = str;
|
||||
@ -41,14 +40,35 @@ uint64_t parse(const char* str){
|
||||
return acc;
|
||||
}
|
||||
|
||||
uint64_t parse(const string& str){
|
||||
uint64_t std::parse(const string& str){
|
||||
return parse(str.begin(), str.end());
|
||||
}
|
||||
|
||||
uint64_t str_len(const char* a){
|
||||
uint64_t std::str_len(const char* a){
|
||||
uint64_t length = 0;
|
||||
while(*a++){
|
||||
++length;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
vector<std::string> std::split(const string& s){
|
||||
vector<string> parts;
|
||||
|
||||
string current(s.size());
|
||||
|
||||
for(char c : s){
|
||||
if(c == ' ' && !current.empty()){
|
||||
parts.push_back(current);
|
||||
current.clear();
|
||||
} else {
|
||||
current += c;
|
||||
}
|
||||
}
|
||||
|
||||
if(!current.empty()){
|
||||
parts.push_back(current);
|
||||
}
|
||||
|
||||
return std::move(parts);
|
||||
}
|
@ -341,7 +341,7 @@ void get_base_info(){
|
||||
|
||||
} //end of anonymous namespace
|
||||
|
||||
void sysinfo_command(const vector<string>&){
|
||||
void sysinfo_command(const vector<std::string>&){
|
||||
get_base_info();
|
||||
get_vendor_id();
|
||||
get_brand_string();
|
||||
|
Loading…
x
Reference in New Issue
Block a user