Tiberiu Chibici
913e65b856
==================================================== + Changed 'align 0x4' line above multiboot header in loader.asm to 'align 4' + Removed -e option for echo in build.sh + Modified build.sh for linux + Fixed triple fault when enabling paging + Fixed page faults at memory manager initialization + Fixed 'mem' console function + Added more info about page fault at crash screen + Added Panic() macro + Added verbose mode for memory manager [ BAD] BUILD 0.1.0.390 DATE 8/27/2011 AT 10:54 PM ==================================================== + Added stdlib routines, separated in different files + Rewritten physical memory manager + Added virtual mem manager + Added memory allocation/freeing + Added memory library + Added temporary allocation (at end of kernel), until paging is started - Removed functionality from debug console function 'mem' - Removed system.h, the one remaining function now in stdio.h
94 lines
2.1 KiB
C
94 lines
2.1 KiB
C
#include <debugio.h>
|
|
#include <stdlib.h>
|
|
#include <ctype.h>
|
|
#include "commands.c"
|
|
|
|
void _process_command (string params[16], int32 count);
|
|
void _command_does_not_exist(string command);
|
|
|
|
void ConsoleMain()
|
|
{
|
|
char buffer[512];
|
|
string params[CONSOLE_MAX_PARAMS];
|
|
|
|
CommandOsver();
|
|
|
|
for (;;)
|
|
{
|
|
// Read a string
|
|
ConsoleWrite("\n%#] ", Color(ColorBlack, ColorYellow));
|
|
ConsoleReadString(buffer, 512, '\n');
|
|
|
|
// Split buffer in params
|
|
params[0] = buffer;
|
|
|
|
int32 i=0, len = strlen(buffer), param_count = 0;
|
|
|
|
while (i < len && param_count < CONSOLE_MAX_PARAMS)
|
|
{
|
|
// Skip spaces before
|
|
while (i < len && isspace(buffer[i])) buffer[i++] = 0;
|
|
if (i == len) break;
|
|
|
|
params[param_count++] = &buffer[i];
|
|
|
|
// Skip non-spaces
|
|
while (i < len && !isspace(buffer[i])) i++;
|
|
}
|
|
|
|
// Send command to processing
|
|
_process_command(params, param_count);
|
|
}
|
|
|
|
}
|
|
|
|
void _process_command (string params[CONSOLE_MAX_PARAMS], int32 count)
|
|
{
|
|
int32 Cmd = -1;
|
|
|
|
if (count == 0)
|
|
{
|
|
ConsoleWrite ("%#! You must enter a command!\n", Color(0, ColorLightRed));
|
|
return;
|
|
}
|
|
|
|
// Lookup command in list
|
|
int32 i;
|
|
for (i = 0; i < ConsoleCommandsCount && Cmd == -1; i++)
|
|
if (strcmp(params[0], ConsoleCommands[i]) == 0) Cmd = i;
|
|
|
|
switch (Cmd)
|
|
{
|
|
case -1: _command_does_not_exist(params[0]); break;
|
|
case 0: CommandOsver(); break;
|
|
case 1: CommandTime(); break;
|
|
case 2: ConsoleClear(); break;
|
|
case 3: CommandHelp(params, count); break;
|
|
case 4: CommandDump (params, count); break;
|
|
case 5: CommandMem(params, count); break;
|
|
case 6: CommandCrash(); break;
|
|
case 7: CommandMouse(); break;
|
|
case 8: CommandRead(params, count); break;
|
|
case 9:
|
|
case 10: SystemReboot(); break;
|
|
|
|
default: ConsoleWrite ("%#! Command %#%s%# was not implemented (yet)!\n",
|
|
Color(0,ColorLightRed), Color(0,ColorWhite), params[0], Color(0,ColorLightRed)); break;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
void _command_does_not_exist(string command)
|
|
{
|
|
if (strlen(command) > 20)
|
|
{
|
|
command[18] = command[19] = command[20] = '.';
|
|
command[21] = null;
|
|
}
|
|
|
|
ConsoleWrite ("%#! Command %#%s%# does not exist!\n",
|
|
Color(0,ColorLightRed), Color(0,ColorWhite), command, Color(0,ColorLightRed));
|
|
|
|
}
|