diff --git a/Makefile b/Makefile index 57bc7eb..2617155 100644 --- a/Makefile +++ b/Makefile @@ -99,7 +99,7 @@ KernSources = kernel/cpu/cpuid.c \ kernel/init/info.c kernel/init/ssp.c \ kernel/io/rtc.c kernel/io/keyb.c \ kernel/io/spkr.c kernel/po/shtdwn.c \ - kernel/ke/shell.c kernel/ke/shcmds.c + kernel/sh/shell.c kernel/sh/shcmds.c LibCObj=$(patsubst %.c,$(KOBJDIR)/%.o,$(LibCSources)) diff --git a/include/kernel/keyboard.h b/include/kernel/keyboard.h index 7c51903..8fd6f58 100644 --- a/include/kernel/keyboard.h +++ b/include/kernel/keyboard.h @@ -38,6 +38,7 @@ void IoChangeCodePage(char *CodePage); //----------------------------------------------------------------------------// #define KEY_ESC 27 +#define KEY_BS 8 #define KEY_BEL 7 #define KEY_DC1 17 #define KEY_DC2 18 diff --git a/kaleid/kernel/ke/shcmds.c b/kaleid/kernel/sh/shcmds.c similarity index 63% rename from kaleid/kernel/ke/shcmds.c rename to kaleid/kernel/sh/shcmds.c index 164efd1..2ca8df5 100644 --- a/kaleid/kernel/ke/shcmds.c +++ b/kaleid/kernel/sh/shcmds.c @@ -27,8 +27,11 @@ 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 } }; @@ -58,10 +61,74 @@ error_t CmdHelp(int argc, char **argv, char *cmdline) if (argc == 1) { KernLog("List of all shell built-ins:\n"); for (cmd = cmdtable; cmd->name != NULL; cmd++, count++) { - KernLog("\t%s\t%s\n", cmd->name, cmd->help); + KernLog("\t%s\t\t%s\n", cmd->name, cmd->help); } - KernLog("End of list; %u commands total\n\n", count); + KernLog("End of list; %u commands total\n", count); } return EOK; } + +error_t CmdDate(int argc, char **argv, char *cmdline) +{ + IoPrintRtcTime(); + return EOK; +} + +error_t CmdMemMap(int argc, char **argv, char *cmdline) +{ + MmPrintMemoryMap(); + 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; + size_t diff, max; + + ulong flags = KePauseIRQs(); + + start = (size_t)_heap_start; + end = (size_t)_heap_end; + max = _heap_max; + + KeRestoreIRQs(flags); + + 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)); + + KernLog("Heap end:\t\t%p (%luMB + %luKB + %luB)\n", + 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("Max heap size:\t%luMB + %luKB + %luB\n", + ADDR_TO_MB(max), + ADDR_TO_KB(max), + ADDR_TO_B(max)); + + return EOK; +} + + + + + + + + + + diff --git a/kaleid/kernel/ke/shell.c b/kaleid/kernel/sh/shell.c similarity index 96% rename from kaleid/kernel/ke/shell.c rename to kaleid/kernel/sh/shell.c index dc2438a..6aa1a83 100644 --- a/kaleid/kernel/ke/shell.c +++ b/kaleid/kernel/sh/shell.c @@ -64,7 +64,7 @@ void KeStartShell(void) memzero(argv0, ARG_MAX); shargv = &argv0; - KernLog("\nshell> "); + KernLog("shell> "); BFlushBuf(BStdOut); while ((rc = BGetFromBuf(BStdIn, &ch)) == EOK || rc == EENDF) { @@ -85,6 +85,13 @@ void KeStartShell(void) switch (ch) { + case KEY_BS: + *bufptr = 0; + if (bufptr > cmdbuf) { + bufptr--; + } + break; + case KEY_BEL: if (rand() % 64 == 0) { IoDoStarWars(); diff --git a/kaleid/kernel/ke/shell.h b/kaleid/kernel/sh/shell.h similarity index 96% rename from kaleid/kernel/ke/shell.h rename to kaleid/kernel/sh/shell.h index d2d40f7..9a1d75a 100644 --- a/kaleid/kernel/ke/shell.h +++ b/kaleid/kernel/sh/shell.h @@ -24,6 +24,9 @@ #include #include + +#include +#include #include #include #include @@ -53,6 +56,9 @@ struct Command_t DEC_CMD(Beep); DEC_CMD(Quit); DEC_CMD(Help); +DEC_CMD(Date); +DEC_CMD(MemMap); +DEC_CMD(MemUsage); extern Command_t cmdtable[];