diff --git a/include/base/limits.h b/include/base/limits.h index b6d7769..57a5a35 100644 --- a/include/base/limits.h +++ b/include/base/limits.h @@ -35,6 +35,10 @@ #define CHAR_BIT 8 #define BITS_IN(T) (sizeof(T) * CHAR_BIT) +#define _ADDR_TO_MB(x) ((x)>>20) +#define _ADDR_TO_KB(x) (((x)>>10)&(KB-1)) +#define _ADDR_TO_B(x) ((x)&(KB-1)) + /* XXX find a generic way */ #define BYTES_TO_WORDS(B) ((B) >> 1) #define BYTES_TO_DWORDS(B) ((B) >> 2) diff --git a/kaleid/kernel/mm/map.c b/kaleid/kernel/mm/map.c index 33b816f..45334c7 100644 --- a/kaleid/kernel/mm/map.c +++ b/kaleid/kernel/mm/map.c @@ -193,10 +193,11 @@ void MmPrintMemoryMap(void) { default:; } - KernLog("Mem zone : %lp\t%s\twith length: %d Kio\n", - memoryMap.entry[i].addr, - avStr, - memoryMap.entry[i].length / KB + ulong len = memoryMap.entry[i].length; + + KernLog("Mem zone : %lp\t%s\twith length: %luMB + %luKB + %luB\n", + memoryMap.entry[i].addr, avStr, + _ADDR_TO_MB(len), _ADDR_TO_KB(len), _ADDR_TO_B(len) ); } } diff --git a/kaleid/kernel/ps/sched.c b/kaleid/kernel/ps/sched.c index 5e8e525..b7ab3dc 100644 --- a/kaleid/kernel/ps/sched.c +++ b/kaleid/kernel/ps/sched.c @@ -386,7 +386,9 @@ void pstest(void) int tick = 0; - while (tick < 14) { + KernLog("\n"); + + while (tick < 100) { //if (tick%25==0)ClearTerm(StdOut); if (tick > 0 && tick != 50 && tick % 10 == 0) { KernLog("Blocking current process\n"); diff --git a/kaleid/kernel/sh/shcmds.c b/kaleid/kernel/sh/shcmds.c index 2ca8df5..4f515ba 100644 --- a/kaleid/kernel/sh/shcmds.c +++ b/kaleid/kernel/sh/shcmds.c @@ -24,18 +24,6 @@ #include "shell.h" -Command_t cmdtable[] = -{ - { "beep", CmdBeep, "Make a beep" }, - { "date", CmdDate, "Print date" }, - { "exit", CmdQuit, "Initiate shutdown" }, - { "help", CmdHelp, "Show this message" }, - { "mmap", CmdMemMap, "Show memory map" }, - { "musage", CmdMemUsage, "Show memory statistics" }, - { "quit", CmdQuit, "Alias for 'exit'" }, - { NULL, NULL, NULL } -}; - error_t CmdBeep(int argc, char **argv, char *cmdline) { if (rand() % 64 == 0 || (argc > 1 && !strcmp(argv[1], "starwars"))) { @@ -81,10 +69,6 @@ error_t CmdMemMap(int argc, char **argv, char *cmdline) return EOK; } -#define ADDR_TO_MB(x) ((x)>>20) -#define ADDR_TO_KB(x) (((x)>>10)&(KB-1)) -#define ADDR_TO_B(x) ((x)&(KB-1)) - error_t CmdMemUsage(int argc, char **argv, char *cmdline) { size_t start, end; @@ -101,34 +85,50 @@ error_t CmdMemUsage(int argc, char **argv, char *cmdline) diff = (size_t)end - (size_t)start; KernLog("Heap start:\t\t%p (%luMB + %luKB + %luB)\n", - start, ADDR_TO_MB(start), - ADDR_TO_KB(start), - ADDR_TO_B(start)); + start, _ADDR_TO_MB(start), + _ADDR_TO_KB(start), + _ADDR_TO_B(start)); KernLog("Heap end:\t\t%p (%luMB + %luKB + %luB)\n", - end, ADDR_TO_MB(end), - ADDR_TO_KB(end), - ADDR_TO_B(end)); + end, _ADDR_TO_MB(end), + _ADDR_TO_KB(end), + _ADDR_TO_B(end)); - KernLog("Heap size:\t\t%p (%luMB + %luKB + %luB)\n", - diff, ADDR_TO_MB(diff), - ADDR_TO_KB(diff), - ADDR_TO_B(diff)); + KernLog("Heap size:\t\t%luMB + %luKB + %luB (%#lx)\n", + _ADDR_TO_MB(diff), + _ADDR_TO_KB(diff), + _ADDR_TO_B(diff), + diff); - KernLog("Max heap size:\t%luMB + %luKB + %luB\n", - ADDR_TO_MB(max), - ADDR_TO_KB(max), - ADDR_TO_B(max)); + KernLog("Max heap size:\t%luMB + %luKB + %luB (%#lx)\n", + _ADDR_TO_MB(max), + _ADDR_TO_KB(max), + _ADDR_TO_B(max), + max); return EOK; } +extern void pstest(void); +error_t CmdPsTest(int argc, char **argv, char *cmdline) +{ + pstest(); + return EOK; +} +//----------------------------------------------------------------------------// - - - - - +Command_t cmdtable[] = +{ + { "beep", CmdBeep, "Make a beep" }, + { "date", CmdDate, "Print date" }, + { "exit", CmdQuit, "Initiate shutdown" }, + { "help", CmdHelp, "Show this message" }, + { "mmap", CmdMemMap, "Show memory map" }, + { "musage", CmdMemUsage, "Show memory statistics" }, + { "pstest", CmdPsTest, "Scheduler test routine" }, + { "quit", CmdQuit, "Alias for 'exit'" }, + { NULL, NULL, NULL } +}; diff --git a/kaleid/kernel/sh/shell.c b/kaleid/kernel/sh/shell.c index 6aa1a83..8dcf6b9 100644 --- a/kaleid/kernel/sh/shell.c +++ b/kaleid/kernel/sh/shell.c @@ -33,6 +33,9 @@ void ExecuteCommand(char *cmdbuf) error_t rc; Command_t *cmd; bool found = false; + + if (!cmdbuf || !*cmdbuf) + return; memzero(*shargv, ARG_MAX); rc = KalCmdLineToArgVec(cmdbuf, &shargc, shargv); diff --git a/kaleid/kernel/sh/shell.h b/kaleid/kernel/sh/shell.h index 9a1d75a..591dd3b 100644 --- a/kaleid/kernel/sh/shell.h +++ b/kaleid/kernel/sh/shell.h @@ -51,14 +51,5 @@ struct Command_t const char *help; }; -#define DEC_CMD(name) error_t Cmd##name(int, char **, char *) - -DEC_CMD(Beep); -DEC_CMD(Quit); -DEC_CMD(Help); -DEC_CMD(Date); -DEC_CMD(MemMap); -DEC_CMD(MemUsage); - extern Command_t cmdtable[];