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-09 11:19:44 +02:00
parent 7d8253cf3e
commit f03a587337
5 changed files with 99 additions and 28 deletions

View File

@ -62,8 +62,6 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg)
IoGetRtcTimeChar(); IoGetRtcTimeChar();
IoPrintRtcTime(); IoPrintRtcTime();
KernLog("%d\n",realKernelEnd);
KeStartShell(); KeStartShell();
PoShutdown(); PoShutdown();

View File

@ -151,7 +151,7 @@ void RtcHandler(ISRFrame_t *regs)
void IoPrintRtcTime(void) void IoPrintRtcTime(void)
{ {
Time_t* RtcTime = IoGetRtcTime(); Time_t* RtcTime = IoGetRtcTime();
KernLog("[RTC Time] %02d/%02d/%04d ; %02d:%02d:%02d \n\n", KernLog("[RTC Time] %02d/%02d/%04d ; %02d:%02d:%02d \n",
RtcTime->day, RtcTime->day,
RtcTime->month, RtcTime->month,
RtcTime->year + RtcTime->century*100, RtcTime->year + RtcTime->century*100,

View File

@ -80,42 +80,114 @@ error_t CmdMemMap(int argc, char **argv, char *cmdline)
return EOK; return EOK;
} }
extern ulong realKernelEnd;
error_t CmdMemUsage(int argc, char **argv, char *cmdline) error_t CmdMemUsage(int argc, char **argv, char *cmdline)
{ {
size_t start, end; size_t stack_cur;
size_t diff, max; size_t img_diff, stack_diff;
size_t heap_start, heap_end;
size_t heap_diff, heap_max;
ulong flags = KePauseIRQs(); ulong flags = KePauseIRQs();
start = (size_t)_heap_start; heap_start = (size_t)_heap_start;
end = (size_t)_heap_end; heap_end = (size_t)_heap_end;
max = _heap_max; heap_max = _heap_max;
KeRestoreIRQs(flags); KeRestoreIRQs(flags);
diff = (size_t)end - (size_t)start; img_diff = realKernelEnd - (size_t)BtLoaderInfo.kernelAddr;
stack_diff = (size_t)BtLoaderInfo.kernelEndAddr - (realKernelEnd + 1);
heap_diff = (size_t)heap_end - (size_t)heap_start;
KernLog("Heap start:\t\t%p (%luMB + %luKB + %luB)\n", KernLog("Kernel image:\n");
start, _ADDR_TO_MB(start),
_ADDR_TO_KB(start),
_ADDR_TO_B(start));
KernLog("Heap end:\t\t%p (%luMB + %luKB + %luB)\n", KernLog("\tstarts at:\t\t%p (%04luMB + %04luKB + %04luB)\n",
end, _ADDR_TO_MB(end), BtLoaderInfo.kernelAddr,
_ADDR_TO_KB(end), _ADDR_TO_MB((size_t)BtLoaderInfo.kernelAddr),
_ADDR_TO_B(end)); _ADDR_TO_KB((size_t)BtLoaderInfo.kernelAddr),
_ADDR_TO_B((size_t)BtLoaderInfo.kernelAddr));
KernLog("Heap size:\t\t%luMB + %luKB + %luB (%#lx)\n", KernLog("\tends at:\t\t%p (%04luMB + %04luKB + %04luB)\n",
_ADDR_TO_MB(diff), realKernelEnd,
_ADDR_TO_KB(diff), _ADDR_TO_MB(realKernelEnd),
_ADDR_TO_B(diff), _ADDR_TO_KB(realKernelEnd),
diff); _ADDR_TO_B(realKernelEnd));
KernLog("Max heap size:\t%luMB + %luKB + %luB (%#lx)\n", KernLog("\tsize:\t\t\t%04luMB + %04luKB + %04luB (%p)\n",
_ADDR_TO_MB(max), _ADDR_TO_MB(img_diff),
_ADDR_TO_KB(max), _ADDR_TO_KB(img_diff),
_ADDR_TO_B(max), _ADDR_TO_B(img_diff),
max); img_diff);
KernLog("Kernel stack:\n");
KernLog("\tstarts at:\t\t%p (%04luMB + %04luKB + %04luB)\n",
BtLoaderInfo.kernelEndAddr,
_ADDR_TO_MB((size_t)BtLoaderInfo.kernelEndAddr),
_ADDR_TO_KB((size_t)BtLoaderInfo.kernelEndAddr),
_ADDR_TO_B((size_t)BtLoaderInfo.kernelEndAddr));
BARRIER();
char var;
(void)var;
stack_cur = (size_t)BtLoaderInfo.kernelEndAddr - (size_t)&var;
KernLog("\tends at:\t\t%p (%04luMB + %04luKB + %04luB)\n",
stack_cur,
_ADDR_TO_MB(stack_cur),
_ADDR_TO_KB(stack_cur),
_ADDR_TO_B(stack_cur));
KernLog("\tmin addr:\t\t%p (%04luMB + %04luKB + %04luB)\n",
realKernelEnd+1,
_ADDR_TO_MB(realKernelEnd+1),
_ADDR_TO_KB(realKernelEnd+1),
_ADDR_TO_B(realKernelEnd+1));
KernLog("\tsize (cur):\t\t%04luMB + %04luKB + %04luB (%p)\n",
_ADDR_TO_MB(stack_cur),
_ADDR_TO_KB(stack_cur),
_ADDR_TO_B(stack_cur),
stack_cur);
KernLog("\tsize (max):\t\t%04luMB + %04luKB + %04luB (%p)\n",
_ADDR_TO_MB(stack_diff),
_ADDR_TO_KB(stack_diff),
_ADDR_TO_B(stack_diff),
stack_diff);
KernLog("Kernel heap:\n");
KernLog("\tstarts at:\t\t%p (%04luMB + %04luKB + %04luB)\n",
heap_start, _ADDR_TO_MB(heap_start),
_ADDR_TO_KB(heap_start),
_ADDR_TO_B(heap_start));
KernLog("\tends at:\t\t%p (%04luMB + %04luKB + %04luB)\n",
heap_end, _ADDR_TO_MB(heap_end),
_ADDR_TO_KB(heap_end),
_ADDR_TO_B(heap_end));
KernLog("\tmax addr:\t\t%p (%04luMB + %04luKB + %04luB)\n",
heap_start + heap_max,
_ADDR_TO_MB(heap_start + heap_max),
_ADDR_TO_KB(heap_start + heap_max),
_ADDR_TO_B(heap_start + heap_max));
KernLog("\tsize (cur):\t\t%04luMB + %04luKB + %04luB (%p)\n",
_ADDR_TO_MB(heap_diff),
_ADDR_TO_KB(heap_diff),
_ADDR_TO_B(heap_diff),
heap_diff);
KernLog("\tsize (max):\t\t%04luMB + %04luKB + %04luB (%p)\n",
_ADDR_TO_MB(heap_max),
_ADDR_TO_KB(heap_max),
_ADDR_TO_B(heap_max),
heap_max);
return EOK; return EOK;
} }

View File

@ -26,6 +26,7 @@
#include <extras/argv.h> #include <extras/argv.h>
#include <kernel/mm.h> #include <kernel/mm.h>
#include <kernel/boot.h>
#include <kernel/heap.h> #include <kernel/heap.h>
#include <kernel/time.h> #include <kernel/time.h>
#include <kernel/speaker.h> #include <kernel/speaker.h>