2021-12-29 15:15:18 +00:00
|
|
|
#include "superVisorTerminal.h"
|
2023-02-21 20:43:14 +00:00
|
|
|
#include "../storage/ata pio/ATAPIO.h"
|
|
|
|
#include "../storage/partitiontables/mbr/MasterBootRecord.h"
|
2023-02-23 22:54:02 +00:00
|
|
|
#include "../storage/filesystems/FAT/FAT.h"
|
2023-02-21 13:36:20 +00:00
|
|
|
|
2023-02-03 20:47:05 +00:00
|
|
|
bool isRunning = true;
|
2023-02-17 13:46:44 +00:00
|
|
|
extern "C" void startSuperVisorTerminal()
|
|
|
|
{
|
2023-02-26 23:34:30 +00:00
|
|
|
|
|
|
|
|
2023-02-17 13:46:44 +00:00
|
|
|
/*
|
|
|
|
* Show a little banner for cuteness
|
|
|
|
*/
|
|
|
|
printf("|=== BarinkOS ===|\n");
|
|
|
|
|
2022-03-12 15:56:50 +00:00
|
|
|
while (isRunning){
|
2021-12-29 15:15:18 +00:00
|
|
|
|
|
|
|
printf("SUPERVISOR:>$ " );
|
|
|
|
int characterCount = 0;
|
|
|
|
char command[10] = "";
|
|
|
|
|
|
|
|
// NOTE: lets just show a kernel prompt
|
|
|
|
uint8_t ScanCode = getKey();
|
|
|
|
while( ScanCode != 0x1C )
|
|
|
|
{
|
|
|
|
char character = getASCIIKey();
|
|
|
|
kterm_put(character );
|
|
|
|
// wHAT THE HELL
|
|
|
|
|
|
|
|
if( characterCount < 10 ){
|
|
|
|
command[characterCount] = character;
|
|
|
|
characterCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
ScanCode = getKey();
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
KeyHandled();
|
2023-02-08 13:07:44 +00:00
|
|
|
|
2021-12-29 15:15:18 +00:00
|
|
|
|
|
|
|
if ( strncmp("DATE", command , characterCount ) == 0 )
|
|
|
|
{
|
|
|
|
read_rtc();
|
|
|
|
printf("======= Time & Date ==========\n");
|
|
|
|
printf(" - Date: %02d-%02d-%02d\n",day, month, year);
|
|
|
|
printf(" - Time: %02d:%02d:%02d\n" , hour, minute, second);
|
|
|
|
printf(" - Ticks: %09d\n", pit_tick);
|
|
|
|
}
|
2023-02-08 13:07:44 +00:00
|
|
|
if( strncmp ("MEMORY" , command , characterCount) == 0 )
|
2021-12-29 15:15:18 +00:00
|
|
|
{
|
|
|
|
// Show memory layout
|
2023-02-11 11:22:45 +00:00
|
|
|
printf("========= Memory (very inaccurate) ==========\n");
|
2021-12-29 15:15:18 +00:00
|
|
|
printf("Kernel MemoryMap:\n");
|
|
|
|
printf("kernel: 0x%x - 0x%x\n", &kernel_begin , &kernel_end);
|
2023-02-11 11:22:45 +00:00
|
|
|
printf("Frames used: %d blocks of 4 KiB\n", GetUsedBlocks());
|
2021-12-29 15:15:18 +00:00
|
|
|
|
|
|
|
}
|
2023-02-08 13:07:44 +00:00
|
|
|
if(strncmp("TEST", command, characterCount) == 0)
|
2021-12-29 15:15:18 +00:00
|
|
|
{
|
|
|
|
// TEST #DE exception
|
|
|
|
asm volatile ("MOV $4, %AX ; MOV $0, %BX ; DIV %BX"); // IRS 0
|
|
|
|
}
|
2023-02-08 13:07:44 +00:00
|
|
|
if (strncmp("VERSION", command , characterCount) == 0)
|
2021-12-29 15:15:18 +00:00
|
|
|
{
|
|
|
|
// Show version information
|
|
|
|
printf("========= Version ========\n");
|
2023-02-26 23:34:30 +00:00
|
|
|
|
|
|
|
asm volatile ("movl $0x666, %eax; int $0x50");
|
2021-12-29 15:15:18 +00:00
|
|
|
|
|
|
|
}
|
2023-02-08 13:07:44 +00:00
|
|
|
if(strncmp("CLEAR", command, characterCount) == 0)
|
2021-12-29 15:15:18 +00:00
|
|
|
{
|
|
|
|
kterm_init();
|
|
|
|
printf("|=== BarinkOS ===|\n");
|
|
|
|
}
|
2023-02-19 13:17:47 +00:00
|
|
|
if(strncmp("LIST", command, 4) == 0)
|
2023-02-08 13:07:44 +00:00
|
|
|
{
|
2023-02-19 13:17:47 +00:00
|
|
|
|
|
|
|
// slice off the command part
|
|
|
|
char args[characterCount - 4];
|
|
|
|
for(int i = 5 ; i < characterCount; i++) {
|
|
|
|
args[i] = command[i];
|
|
|
|
}
|
|
|
|
|
2023-02-17 20:52:03 +00:00
|
|
|
printf("=============== DIRECTORY LISTING =================\n");
|
2023-02-19 13:17:47 +00:00
|
|
|
printf("Path to show %s\n", args);
|
2022-03-12 15:56:50 +00:00
|
|
|
}
|
2023-02-08 13:07:44 +00:00
|
|
|
|
2023-02-11 11:22:45 +00:00
|
|
|
if(strncmp("DEVICES", command, characterCount) == 0){
|
|
|
|
printf("================ CONNECTED DEVICES ===============\n");
|
|
|
|
|
2021-12-29 15:15:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-02-08 13:07:44 +00:00
|
|
|
printf("executed command: %s\n", command);
|
|
|
|
|
|
|
|
|
2021-12-29 15:15:18 +00:00
|
|
|
delay(1000);
|
|
|
|
}
|
|
|
|
}
|