mirror of
https://gitlab.os-k.eu/os-k-team/os-k.git
synced 2023-08-25 14:03:10 +02:00
Work on a test command
This commit is contained in:
parent
ed5482fd1d
commit
a4bf874276
@ -31,10 +31,6 @@
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------//
|
//----------------------------------------------------------------------------//
|
||||||
|
|
||||||
void ShStartShell(void);
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------//
|
|
||||||
|
|
||||||
#define CMDBUFSIZE 256
|
#define CMDBUFSIZE 256
|
||||||
|
|
||||||
typedef struct Command_t Command_t;
|
typedef struct Command_t Command_t;
|
||||||
@ -55,5 +51,9 @@ extern Command_t shcmdtable[];
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------//
|
//----------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
void ShStartShell(void);
|
||||||
|
void ExecuteCommand(char *cmdbuf, Command_t *cmdtable);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
#include <sh/shell.h>
|
#include <sh/shell.h>
|
||||||
#include <po/shtdwn.h>
|
#include <po/shtdwn.h>
|
||||||
|
|
||||||
|
static Command_t testcmdtable[];
|
||||||
|
|
||||||
static inline int ShAtoi(char* str)
|
static inline int ShAtoi(char* str)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
@ -182,6 +184,26 @@ error_t CmdHelp(int argc, char **argv, char *cmdline)
|
|||||||
return EOK;
|
return EOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error_t CmdHelpTest(int argc, char **argv, char *cmdline)
|
||||||
|
{
|
||||||
|
uint i, count = 0;
|
||||||
|
Command_t *cmd;
|
||||||
|
|
||||||
|
if (argc == 1) {
|
||||||
|
KernLog("List of all test built-ins:\n");
|
||||||
|
for (cmd = testcmdtable; cmd->name != NULL; cmd++, count++) {
|
||||||
|
KernLog("\t%s", cmd->name);
|
||||||
|
for (i = strlen(cmd->name)/4; i<3; i++) {
|
||||||
|
KernLog("\t");
|
||||||
|
}
|
||||||
|
KernLog("%C%s%C\n", VGA_COLOR_DARK_GREY, cmd->help, shcol);
|
||||||
|
}
|
||||||
|
KernLog("End of list; %u commands total\n", count);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EOK;
|
||||||
|
}
|
||||||
|
|
||||||
error_t CmdMemMap(int argc, char **argv, char *cmdline)
|
error_t CmdMemMap(int argc, char **argv, char *cmdline)
|
||||||
{
|
{
|
||||||
MmPrintMemoryMap();
|
MmPrintMemoryMap();
|
||||||
@ -259,12 +281,9 @@ error_t CmdStarWars(int argc, char **argv, char *cmdline)
|
|||||||
|
|
||||||
error_t CmdTest(int argc, char **argv, char *cmdline)
|
error_t CmdTest(int argc, char **argv, char *cmdline)
|
||||||
{
|
{
|
||||||
|
ExecuteCommand(cmdline+5, testcmdtable);
|
||||||
|
KernLog ("\n");
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
error_t CmdTest(int argc, char **argv, char *cmdline)
|
|
||||||
{
|
|
||||||
KernLog("%s\n", &KeFormatCurTime()[13]);
|
|
||||||
return EOK;
|
return EOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,30 +333,37 @@ error_t CmdVersion(int argc, char **argv, char *cmdline)
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------//
|
//----------------------------------------------------------------------------//
|
||||||
|
|
||||||
Command_t shcmdtable[] =
|
static Command_t testcmdtable[] =
|
||||||
{
|
{
|
||||||
{ "args", CmdArgs, "Print command line" },
|
{ "args", CmdArgs, "Print command line" },
|
||||||
|
{ "dmpsec", CmdDumpATASect, "Dump an ATA sector on screen" },
|
||||||
|
{ "help", CmdHelpTest, "Show this message" },
|
||||||
|
{ "pfault", CmdPF, "Provoke a PF. Usage: pfault <address>"},
|
||||||
|
{ "pstest", CmdPsTest, "Scheduler test routine" },
|
||||||
|
{ "rpag", CmdReloadPage, "Reload the pages directory" },
|
||||||
|
{ "shell", CmdShell, "Start a new shell (nested)", },
|
||||||
|
{ "stkov", CmdStackOverflow, "Provoke a stack overflow" },
|
||||||
|
{ "stkun", CmdStackUnderflow, "Provoke a stack underflow" },
|
||||||
|
{ "timer", CmdTimerTest, "test timer of x ms" },
|
||||||
|
{ NULL, NULL, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
Command_t shcmdtable[] =
|
||||||
|
{
|
||||||
{ "beep", CmdBeep, "Make a beep" },
|
{ "beep", CmdBeep, "Make a beep" },
|
||||||
{ "cls", CmdClear, "Clears standard output" },
|
{ "cls", CmdClear, "Clears standard output" },
|
||||||
{ "color", CmdColor, "Change shell text color" },
|
{ "color", CmdColor, "Change shell text color" },
|
||||||
{ "date", CmdDate, "Print date" },
|
{ "date", CmdDate, "Print date" },
|
||||||
{ "dmpsec", CmdDumpATASect, "Dump an ATA sector on screen" },
|
|
||||||
{ "exit", CmdQuit, "Initiate shutdown" },
|
{ "exit", CmdQuit, "Initiate shutdown" },
|
||||||
{ "help", CmdHelp, "Show this message" },
|
{ "help", CmdHelp, "Show this message" },
|
||||||
{ "march", CmdStarWars, "Play the Imperial March" },
|
{ "march", CmdStarWars, "Play the Imperial March" },
|
||||||
{ "mmap", CmdMemMap, "Show memory map" },
|
{ "mmap", CmdMemMap, "Show memory map" },
|
||||||
{ "musage", CmdMemUsage, "Show memory statistics" },
|
{ "musage", CmdMemUsage, "Show memory statistics" },
|
||||||
{ "pfault", CmdPF, "Provoke a PF. Usage: pfault <address>"},
|
|
||||||
{ "pstest", CmdPsTest, "Scheduler test routine" },
|
|
||||||
{ "quit", CmdQuit, "Alias for 'exit'" },
|
{ "quit", CmdQuit, "Alias for 'exit'" },
|
||||||
{ "rpag", CmdReloadPage, "Reload the pages directory" },
|
|
||||||
{ "shell", CmdShell, "Start a new shell (nested)", },
|
{ "shell", CmdShell, "Start a new shell (nested)", },
|
||||||
{ "stkov", CmdStackOverflow, "Provoke a stack overflow" },
|
|
||||||
{ "stkun", CmdStackUnderflow, "Provoke a stack underflow" },
|
|
||||||
{ "sleep", CmdSleep, "Sleep x ms" },
|
{ "sleep", CmdSleep, "Sleep x ms" },
|
||||||
{ "testimer", CmdTimerTest, "test timer of x ms" },
|
|
||||||
{ "time", CmdTime, "Print time" },
|
{ "time", CmdTime, "Print time" },
|
||||||
|
{ "test", CmdTest, "Launch the x test" },
|
||||||
{ "ver", CmdVersion, "Version and legal infos" },
|
{ "ver", CmdVersion, "Version and legal infos" },
|
||||||
{ NULL, NULL, NULL }
|
{ NULL, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ int shcol = VGA_COLOR_LIGHT_GREY;
|
|||||||
|
|
||||||
static char *argvbuf = 0;
|
static char *argvbuf = 0;
|
||||||
|
|
||||||
static void ExecuteCommand(char *cmdbuf)
|
void ExecuteCommand(char *cmdbuf, Command_t *cmdtable)
|
||||||
{
|
{
|
||||||
error_t rc;
|
error_t rc;
|
||||||
Command_t *cmd;
|
Command_t *cmd;
|
||||||
@ -49,7 +49,7 @@ static void ExecuteCommand(char *cmdbuf)
|
|||||||
rc = ShCmdLineToArgVec(cmdbuf, &shargc, argvbuf);
|
rc = ShCmdLineToArgVec(cmdbuf, &shargc, argvbuf);
|
||||||
if (rc) KeStartPanic("Shell: Couldn't parse command line: %d", rc);
|
if (rc) KeStartPanic("Shell: Couldn't parse command line: %d", rc);
|
||||||
|
|
||||||
for (cmd = shcmdtable; cmd->name != NULL; cmd++) {
|
for (cmd = cmdtable; cmd->name != NULL; cmd++) {
|
||||||
if (!strcmp(cmd->name, shargv[0])) {
|
if (!strcmp(cmd->name, shargv[0])) {
|
||||||
cmd->func(shargc, shargv, cmdbuf);
|
cmd->func(shargc, shargv, cmdbuf);
|
||||||
found = true;
|
found = true;
|
||||||
@ -86,7 +86,7 @@ void ShStartShell(void)
|
|||||||
if (!(BStdIn->flags & BF_ERR)) {
|
if (!(BStdIn->flags & BF_ERR)) {
|
||||||
*bufptr = 0;
|
*bufptr = 0;
|
||||||
bufptr = cmdbuf;
|
bufptr = cmdbuf;
|
||||||
ExecuteCommand(cmdbuf);
|
ExecuteCommand(cmdbuf, shcmdtable);
|
||||||
|
|
||||||
memzero(cmdbuf, CMDBUFSIZE);
|
memzero(cmdbuf, CMDBUFSIZE);
|
||||||
BFlushBuf(BStdIn);
|
BFlushBuf(BStdIn);
|
||||||
@ -148,7 +148,7 @@ void ShStartShell(void)
|
|||||||
|
|
||||||
*bufptr = 0;
|
*bufptr = 0;
|
||||||
bufptr = cmdbuf;
|
bufptr = cmdbuf;
|
||||||
ExecuteCommand(cmdbuf);
|
ExecuteCommand(cmdbuf, shcmdtable);
|
||||||
|
|
||||||
memzero(cmdbuf, CMDBUFSIZE);
|
memzero(cmdbuf, CMDBUFSIZE);
|
||||||
KernLog("%Cshell> %C", VGA_COLOR_WHITE, shcol);
|
KernLog("%Cshell> %C", VGA_COLOR_WHITE, shcol);
|
||||||
@ -161,4 +161,3 @@ void ShStartShell(void)
|
|||||||
}
|
}
|
||||||
KernLog("[EOI]\n");
|
KernLog("[EOI]\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user