ptos: pm: Print usable memory in pretty units
Signed-off-by: Chloe M <chloe@yiffware.org>
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include <ke/bpal.h>
|
||||
#include <ex/trace.h>
|
||||
#include <string.h>
|
||||
#include <units.h>
|
||||
|
||||
#define DTRACE(Fmt, ...) \
|
||||
TRACE("[ PM ]: " Fmt, ##__VA_ARGS__)
|
||||
@@ -66,6 +67,30 @@ typedef struct {
|
||||
/* Standard usable memory list */
|
||||
static MM_PFD_LIST AvlList;
|
||||
|
||||
/* Memory statistics */
|
||||
static USIZE UsableMemory;
|
||||
|
||||
/*
|
||||
* Used to convert bytes into human readable units
|
||||
*/
|
||||
static inline VOID
|
||||
PmZoneSize(const CHAR *TypeName, USIZE Length)
|
||||
{
|
||||
if (TypeName == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Length >= UNIT_GIB) {
|
||||
DTRACE("%s : %d GiB\n", TypeName, Length / UNIT_GIB);
|
||||
} else if (Length >= UNIT_MIB) {
|
||||
DTRACE("%s : %d MiB\n", TypeName, Length / UNIT_MIB);
|
||||
} else if (Length >= UNIT_KIB) {
|
||||
DTRACE("%s : %d KiB\n", TypeName, Length / UNIT_KIB);
|
||||
} else {
|
||||
DTRACE("%s : %d bytes\n", TypeName, Length);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Appends a page frame descriptor to a page frame descriptor
|
||||
* list.
|
||||
@@ -179,9 +204,12 @@ PmProbe(VOID)
|
||||
}
|
||||
|
||||
++ZoneCount;
|
||||
UsableMemory += Entry.Length;
|
||||
}
|
||||
|
||||
/* Log some statistics */
|
||||
DTRACE("%d pfds, %d zones\n", PfdCount, ZoneCount);
|
||||
PmZoneSize("usable", UsableMemory);
|
||||
}
|
||||
|
||||
MM_PFN
|
||||
|
||||
Reference in New Issue
Block a user