1
0
mirror of https://gitlab.os-k.eu/os-k-team/os-k.git synced 2023-08-25 14:03:10 +02:00
This commit is contained in:
Julian Barathieu 2019-05-08 20:45:28 +02:00
parent 8f4fd73de3
commit 0abbf67bc2
6 changed files with 50 additions and 49 deletions

View File

@ -35,6 +35,10 @@
#define CHAR_BIT 8 #define CHAR_BIT 8
#define BITS_IN(T) (sizeof(T) * CHAR_BIT) #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 */ /* XXX find a generic way */
#define BYTES_TO_WORDS(B) ((B) >> 1) #define BYTES_TO_WORDS(B) ((B) >> 1)
#define BYTES_TO_DWORDS(B) ((B) >> 2) #define BYTES_TO_DWORDS(B) ((B) >> 2)

View File

@ -193,10 +193,11 @@ void MmPrintMemoryMap(void) {
default:; default:;
} }
KernLog("Mem zone : %lp\t%s\twith length: %d Kio\n", ulong len = memoryMap.entry[i].length;
memoryMap.entry[i].addr,
avStr, KernLog("Mem zone : %lp\t%s\twith length: %luMB + %luKB + %luB\n",
memoryMap.entry[i].length / KB memoryMap.entry[i].addr, avStr,
_ADDR_TO_MB(len), _ADDR_TO_KB(len), _ADDR_TO_B(len)
); );
} }
} }

View File

@ -386,7 +386,9 @@ void pstest(void)
int tick = 0; int tick = 0;
while (tick < 14) { KernLog("\n");
while (tick < 100) {
//if (tick%25==0)ClearTerm(StdOut); //if (tick%25==0)ClearTerm(StdOut);
if (tick > 0 && tick != 50 && tick % 10 == 0) { if (tick > 0 && tick != 50 && tick % 10 == 0) {
KernLog("Blocking current process\n"); KernLog("Blocking current process\n");

View File

@ -24,18 +24,6 @@
#include "shell.h" #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) error_t CmdBeep(int argc, char **argv, char *cmdline)
{ {
if (rand() % 64 == 0 || (argc > 1 && !strcmp(argv[1], "starwars"))) { 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; 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) error_t CmdMemUsage(int argc, char **argv, char *cmdline)
{ {
size_t start, end; size_t start, end;
@ -101,34 +85,50 @@ error_t CmdMemUsage(int argc, char **argv, char *cmdline)
diff = (size_t)end - (size_t)start; diff = (size_t)end - (size_t)start;
KernLog("Heap start:\t\t%p (%luMB + %luKB + %luB)\n", KernLog("Heap start:\t\t%p (%luMB + %luKB + %luB)\n",
start, ADDR_TO_MB(start), start, _ADDR_TO_MB(start),
ADDR_TO_KB(start), _ADDR_TO_KB(start),
ADDR_TO_B(start)); _ADDR_TO_B(start));
KernLog("Heap end:\t\t%p (%luMB + %luKB + %luB)\n", KernLog("Heap end:\t\t%p (%luMB + %luKB + %luB)\n",
end, ADDR_TO_MB(end), end, _ADDR_TO_MB(end),
ADDR_TO_KB(end), _ADDR_TO_KB(end),
ADDR_TO_B(end)); _ADDR_TO_B(end));
KernLog("Heap size:\t\t%p (%luMB + %luKB + %luB)\n", KernLog("Heap size:\t\t%luMB + %luKB + %luB (%#lx)\n",
diff, ADDR_TO_MB(diff), _ADDR_TO_MB(diff),
ADDR_TO_KB(diff), _ADDR_TO_KB(diff),
ADDR_TO_B(diff)); _ADDR_TO_B(diff),
diff);
KernLog("Max heap size:\t%luMB + %luKB + %luB\n", KernLog("Max heap size:\t%luMB + %luKB + %luB (%#lx)\n",
ADDR_TO_MB(max), _ADDR_TO_MB(max),
ADDR_TO_KB(max), _ADDR_TO_KB(max),
ADDR_TO_B(max)); _ADDR_TO_B(max),
max);
return EOK; 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 }
};

View File

@ -34,6 +34,9 @@ void ExecuteCommand(char *cmdbuf)
Command_t *cmd; Command_t *cmd;
bool found = false; bool found = false;
if (!cmdbuf || !*cmdbuf)
return;
memzero(*shargv, ARG_MAX); memzero(*shargv, ARG_MAX);
rc = KalCmdLineToArgVec(cmdbuf, &shargc, shargv); rc = KalCmdLineToArgVec(cmdbuf, &shargc, shargv);
if (rc) KeStartPanic("Shell: Couldn't parse command line: %d", rc); if (rc) KeStartPanic("Shell: Couldn't parse command line: %d", rc);

View File

@ -51,14 +51,5 @@ struct Command_t
const char *help; 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[]; extern Command_t cmdtable[];