2022-08-15 01:34:15 +02:00
|
|
|
#include <stdint.h>
|
2022-06-19 19:54:09 +02:00
|
|
|
#include "shell.h"
|
|
|
|
#include "lib/stdio.h"
|
|
|
|
#include "lib/string.h"
|
2022-06-20 16:52:25 +02:00
|
|
|
#include "lib/memory.h"
|
2022-08-15 01:34:15 +02:00
|
|
|
#include "lib/time.h"
|
|
|
|
#include "arch/i686/fdc.h"
|
2022-06-19 19:54:09 +02:00
|
|
|
|
|
|
|
int shell_run(char *cmd){
|
2022-06-20 14:17:13 +02:00
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
puts("\x1b[32m");
|
2022-06-20 18:06:05 +02:00
|
|
|
if(!strcmp(cmd, "hello")){
|
2022-06-19 19:54:09 +02:00
|
|
|
printf("Hello!\n");
|
|
|
|
}
|
2022-06-20 18:06:05 +02:00
|
|
|
else if(!strcmp(cmd, "version")){
|
2022-06-20 14:17:13 +02:00
|
|
|
printf("%s\n", OS_VERSION);
|
|
|
|
}
|
2022-06-20 18:06:05 +02:00
|
|
|
else if(!strcmp(cmd, "clear")){
|
2022-06-20 16:54:00 +02:00
|
|
|
clear_screen();
|
|
|
|
}
|
2022-08-07 21:58:36 +02:00
|
|
|
else if(!strcmp(cmd, "serial")){
|
|
|
|
serial_printf("Hello world!\n");
|
2022-06-22 15:12:17 +02:00
|
|
|
}
|
2022-08-15 01:34:15 +02:00
|
|
|
else if(!strcmp(cmd, "sleep")){
|
|
|
|
printf("Sleeping...\n");
|
|
|
|
sleep(25);
|
|
|
|
printf("Done!\n");
|
|
|
|
}
|
|
|
|
else if(!strcmp(cmd, "readsect")){
|
|
|
|
puts("Sector number: ");
|
|
|
|
char secn_str[4];
|
|
|
|
gets(secn_str, 3);
|
|
|
|
int secn = atoi(secn_str);
|
|
|
|
|
|
|
|
uint8_t *sector = i686_fdc_read_sector(secn);
|
|
|
|
|
|
|
|
if(sector){
|
|
|
|
int i = 0;
|
|
|
|
for(int c = 0; c < 4; c++){
|
|
|
|
for(int j = 0; j < 128; j++){
|
|
|
|
printf("0x%x ", sector[i+j]);
|
|
|
|
}
|
|
|
|
i += 128;
|
|
|
|
printf("\nPress enter to continue\n");
|
2022-08-15 02:12:30 +02:00
|
|
|
gets(NULL, 0);
|
2022-08-15 01:34:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
printf("ERROR reading sector %i from disk", secn);
|
|
|
|
}
|
|
|
|
printf("Done!\n");
|
|
|
|
}
|
2022-06-19 19:54:09 +02:00
|
|
|
else{
|
|
|
|
printf("SHELL: Unknown command \"%s\"\n", cmd);
|
2022-06-20 14:17:13 +02:00
|
|
|
ret = 127;
|
2022-06-19 19:54:09 +02:00
|
|
|
}
|
2022-06-20 14:17:13 +02:00
|
|
|
puts("\x1b[0m");
|
|
|
|
|
|
|
|
return ret;
|
2022-06-19 19:54:09 +02:00
|
|
|
}
|
2022-08-15 01:34:15 +02:00
|
|
|
|
|
|
|
void shell(){
|
|
|
|
puts("\x1b[33mWelcome to quark!\x1b[0m\n\n");
|
|
|
|
|
|
|
|
for(;;){
|
|
|
|
static char cmd_buffer[256];
|
|
|
|
puts("$>");
|
|
|
|
gets(cmd_buffer, 255);
|
|
|
|
shell_run(cmd_buffer);
|
|
|
|
}
|
|
|
|
}
|