This commit is contained in:
Julian Barathieu 2020-02-06 14:07:57 +01:00 committed by Adrien Bourmault
parent 3bd535e995
commit 551d9ccac3
2 changed files with 41 additions and 15 deletions

View File

@ -47,10 +47,11 @@ error_t KernLog(const char *fmt, ...)
// //
void DebugLog(const char *fmt, ...) void DebugLog(const char *fmt, ...)
{ {
ulong ticks = KeGetTicks();
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
BPrintOnBuf(BStdDbg, "[%d]\t", KeGetTicks()); BPrintOnBuf(BStdDbg, "[%d]\t", ticks);
BPrintOnBufV(BStdDbg, fmt, ap); BPrintOnBufV(BStdDbg, fmt, ap);
va_end(ap); va_end(ap);
} }

View File

@ -102,6 +102,30 @@ error_t CmdDate(int argc, char **argv, char *cmdline)
return EOK; return EOK;
} }
error_t CmdDmesg(int argc, char **argv, char *cmdline)
{
char *ptr;
size_t N = 0;
if (argc == 1) N = 999;
else if (argc == 2) N = atoi(argv[1]);
else {
KernLog("dmesg: no more than one argument\n");
return EINVAL;
}
BLockBuf(BStdDbg);
ptr = (char *)lmax((ulong)BStdDbg->buf,
(ulong)(BStdDbg->wp - BStdDbg->lastLF - (BStdDbg->lineLen * N)));
KernLog(ptr);
BUnlockBuf(BStdDbg);
return EOK;
}
error_t CmdHelp(int argc, char **argv, char *cmdline) error_t CmdHelp(int argc, char **argv, char *cmdline)
{ {
uint i, count = 0; uint i, count = 0;
@ -182,19 +206,20 @@ error_t CmdVersion(int argc, char **argv, char *cmdline)
Command_t shcmdtable[] = 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" },
{ "exit", CmdQuit, "Initiate shutdown" }, { "dmesg", CmdDmesg, "Print N lines of debug log" },
{ "help", CmdHelp, "Show this message" }, { "exit", CmdQuit, "Initiate shutdown" },
{ "march", CmdStarWars, "Play the Imperial March" }, { "help", CmdHelp, "Show this message" },
{ "mmap", CmdMemMap, "Show memory map" }, { "march", CmdStarWars, "Play the Imperial March" },
{ "musage", CmdMemUsage, "Show memory statistics" }, { "mmap", CmdMemMap, "Show memory map" },
{ "quit", CmdQuit, "Alias for 'exit'" }, { "musage", CmdMemUsage, "Show memory statistics" },
{ "sleep", CmdSleep, "Sleep x ms" }, { "quit", CmdQuit, "Alias for 'exit'" },
{ "time", CmdTime, "Print time" }, { "sleep", CmdSleep, "Sleep N ms" },
{ "test", CmdTest, "Launch the x test" }, { "time", CmdTime, "Print time" },
{ "ver", CmdVersion, "Version and legal infos" }, { "test", CmdTest, "Launch a test" },
{ "ver", CmdVersion, "Version and legal infos" },
{ NULL, NULL, NULL } { NULL, NULL, NULL }
}; };