Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kernel/app/programs.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void load_program(void *adr, int size)
}


void run_program(void *adr, int size)
void run_program(void *adr)
{
char pointeur[11];
int_to_char((uint32_t)adr, pointeur);
Expand Down
2 changes: 1 addition & 1 deletion kernel/app/programs.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
#include "../mem/mem.h"

void load_program(void *adr, int size);
void run_program(void *adr, int size);
void run_program(void *adr);
110 changes: 104 additions & 6 deletions kernel/app/shell.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "shell.h"
#include "../mem/mem.h"
#include "../sys/hex.h"
#include "../sys/struct.h"
#include "../disque/disk.h"
#include "programs.h"

Expand All @@ -22,6 +23,20 @@ void detect_command()

int reconnu = 0;

if (compare_word_buff("man", argv[0]))
{
reconnu = 1;
free(argv);
vga_putchar("\n");
system_functions_descriptions(argc, argv);
return;
Comment on lines +28 to +32
}
if (compare_word_buff("shutdown", argv[0]))
{
outw(0x604, 0x2000);//qemu
outw(0x4004, 0x3400);//virtualbox
}
Comment on lines +34 to +38

if (compare_word_buff("clear", argv[0]))
{
clear_screen();
Expand Down Expand Up @@ -87,7 +102,7 @@ void detect_command()
//affiche les ressources de l'ordinateur

//les ressources
uint64_t total_mem = (get_total_ram()/1024/1024);
uint64_t total_mem = (get_total_ram());
int heap_mem = get_heap_ram_usage();
int stack_mem = get_stack_ram_usage();
int heap_total_mem = get_heap_ram_usage_and_non_use();
Expand Down Expand Up @@ -127,20 +142,18 @@ void detect_command()
load_program((uint32_t *)hex_to_int(argv[1]), char_to_int(argv[2]));
free(argv);
reconnu = 1;


}

if (compare_word_buff("run", argv[0]))
{
if (argc < 3)
if (argc < 2)
{
free(argv);
return;
}
//recuperer l adresse
vga_putchar("\n");
run_program((uint32_t *)hex_to_int(argv[1]), char_to_int(argv[2]));
run_program((uint32_t *)hex_to_int(argv[1]));
free(argv);
reconnu = 1;

Expand All @@ -149,7 +162,7 @@ void detect_command()
if (compare_word_buff("ata", argv[0]))
{
if (argc < 5)
{
{
free(argv);
return;
}
Expand Down Expand Up @@ -220,4 +233,89 @@ char *del_prefix(char *buffer)
return &buffer[i];


}

/// @brief detail les commandes -> commande man
/// @param argv la commande split en liste de mots
void system_functions_descriptions(int argc, char **argv)
{
if (argc >= 2)
{
//demande le detail d'une fonction
if (compare_word_buff("man", argv[1]))
{
vga_putchar("INCEPTION\n");
vga_putchar("affiche les details d'une fonction systeme\n");
}
else if (compare_word_buff("clear", argv[1]))
{
vga_putchar("efface l'ecran\n");
}else if(compare_word_buff("info", argv[1]))
{
vga_putchar("affiche les infos systeme\n");
}else if(compare_word_buff("echo", argv[1]))
{
vga_putchar("affiche du texte a l'ecran\n");
vga_putchar("les parametres sont tous affiches\n");
}else if(compare_word_buff("allocate", argv[1]))
{
vga_putchar("alloue une certaine quantite de memoire en octet dans la heap\n");
vga_putchar("prend un parametre qui est un nombre en octet\n");
vga_putchar("affiche \"done\" quand il a fini\n");
}else if(compare_word_buff("allocate", argv[1]))
{
Comment on lines +265 to +266
vga_putchar("reserve une quantite de memoire dans la heap\n");
vga_putchar("prend en parametre la quantite en octet de ram a allouer\n");
}else if(compare_word_buff("free", argv[1]))
{
vga_putchar("libere la ram alloue avec allocate\n");
vga_putchar("prend l adresse de la donnee\n");
}else if(compare_word_buff("dump", argv[1]))
{
vga_putchar("affiche les blocs memoire alloue libre ou non\n");
vga_putchar("permet de connaitre l'adresse des blocs\n");
}else if(compare_word_buff("monitor", argv[1]))
{
vga_putchar("affiche les ressources de l'ordinateur\n");
}else if(compare_word_buff("load", argv[1]))
{
vga_putchar("charge depuis le primary disque dans la heap\n");
vga_putchar("1er parametre: adresse sur le disque");
vga_putchar("2eme parametre: taille de la donnee en octet");
vga_putchar("affiche l'adresse dansizes la heap du debut de la donnee\n");
vga_putchar("affiche en hexadecimal les donnees stockes\n");
Comment on lines +282 to +286
}else if(compare_word_buff("run", argv[1]))
{
vga_putchar("lance un programme qui se trouve dans la heap\n");
vga_putchar("1er parametre: adresse du programme dans la heap\n");
vga_putchar("saute au programme comme une fonction standart\n");
}else if(compare_word_buff("ata", argv[1]))
{
vga_putchar("affiche des donnees dans le disque / les charges dans la ram\n");
vga_putchar("1er param -> read or load\n");
vga_putchar("2eme param -> numero du disque (1 pour le slave et 0 pour le primaire)\n");
vga_putchar("3eme param -> adresse lba\n");
vga_putchar("4eme param -> quantite de secteur a lire ou charger\n");
}else if(compare_word_buff("shutdown", argv[1])){
vga_putchar("eteint l'ordinateur\n");
vga_putchar("fonctionne sur VirtualBox et Qemu\n");
}else{
vga_putchar("la commande n'existe pas\n");
}
}else{
//detail de toutes les fonctions systèmes
vga_putchar("man -> donne les details des programmes\n");
vga_putchar("clear -> efface l'ecran\n");
vga_putchar("info -> infos systeme\n");
vga_putchar("echo -> affiche du texte\n");
vga_putchar("allocate -> alloue de la memoire\n");
vga_putchar("free -> libere de la memoire\n");
vga_putchar("dump -> affiche le contenu de la memoire\n");
vga_putchar("monitor -> affiche les ressources\n");
vga_putchar("load -> charge depuis le primary disque dans la heap\n");
vga_putchar("run -> lance un programme situe dans la ram\n");
vga_putchar("ata -> lit un disque ou charge un disque en memoire\n");
vga_putchar("shutdown -> arret de l'ordinateur\n");
}

}
1 change: 1 addition & 0 deletions kernel/app/shell.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ void detect_command();
int compare_word_buff(char *, char *);
int compare_first_word_buffer(char *, char *);
char *del_prefix(char *);
void system_functions_descriptions(int argc, char **argv);
10 changes: 10 additions & 0 deletions kernel/sys/struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ void outb(uint16_t port, uint8_t val)
* The outb %al, %dx encoding is the only option for all other cases.
* %1 expands to %dx because port is a uint16_t. %w1 could be used if we had the port number a wider C type */
}

void outw(uint16_t port, uint16_t value)
{
__asm__ volatile (
"outw %0, %1"
:
: "a"(value), "Nd"(port)
);
Comment on lines +14 to +18
}

uint8_t inb(uint16_t port)
{
uint8_t ret;
Expand Down
1 change: 1 addition & 0 deletions kernel/sys/struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ typedef signed long int32_t;
typedef signed long long int64_t;

void outb(uint16_t, uint8_t);
void outw(uint16_t port, uint16_t value);
uint8_t inb(uint16_t);
uint16_t inw(uint16_t port);
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ xxd Binaries/os.bin > os.hex

qemu-system-x86_64 \
-enable-kvm -cpu host \
-m 1G \
-m 2M \
-monitor stdio \
-drive format=raw,file=Binaries/os.bin \
-drive format=raw,file=disk.bin,if=ide