summaryrefslogtreecommitdiff
path: root/lib/e_show_mem.c
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2017-08-30 08:25:59 +0000
committerYuval Adam <_@yuv.al>2017-08-30 08:25:59 +0000
commit8e4bff4cab0ddac6060645b0715210484d02ff40 (patch)
tree3a5c3024371a04692a3a6d9974d001cdff8ebf84 /lib/e_show_mem.c
Initial file dump from open source releaseHEADmaster
Diffstat (limited to 'lib/e_show_mem.c')
-rw-r--r--lib/e_show_mem.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/lib/e_show_mem.c b/lib/e_show_mem.c
new file mode 100644
index 00000000..863a8689
--- /dev/null
+++ b/lib/e_show_mem.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2015 Spreadtrum Communications Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/mm.h>
+#include <linux/notifier.h>
+#include <linux/swap.h>
+
+#ifdef CONFIG_E_SHOW_MEM
+
+static BLOCKING_NOTIFIER_HEAD(e_show_mem_notify_list);
+
+int register_e_show_mem_notifier(struct notifier_block *nb)
+{
+ return blocking_notifier_chain_register(&e_show_mem_notify_list, nb);
+}
+EXPORT_SYMBOL_GPL(register_e_show_mem_notifier);
+
+int unregister_e_show_mem_notifier(struct notifier_block *nb)
+{
+ return blocking_notifier_chain_unregister(&e_show_mem_notify_list, nb);
+}
+EXPORT_SYMBOL_GPL(unregister_e_show_mem_notifier);
+
+
+void enhanced_show_mem(enum e_show_mem_type type)
+{
+ /* Module used pages */
+ unsigned long used = 0;
+ struct sysinfo i;
+
+ printk("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
+ printk("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
+ printk("Enhanced Mem-Info:");
+ if (E_SHOW_MEM_BASIC == type)
+ printk("E_SHOW_MEM_BASIC\n");
+ else if (E_SHOW_MEM_CLASSIC == type)
+ printk("E_SHOW_MEM_CLASSIC\n");
+ else
+ printk("E_SHOW_MEM_ALL\n");
+ printk("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
+ printk("Enhanced Mem-info :SHOW MEM\n");
+ show_mem(SHOW_MEM_FILTER_NODES | SHOW_MEM_FILTER_PAGE_COUNT);
+ si_meminfo(&i);
+ printk("MemTotal: %8lu kB\n"
+ "Buffers: %8lu kB\n"
+ "SwapCached: %8lu kB\n",
+ (i.totalram) << (PAGE_SHIFT - 10),
+ (i.bufferram) << (PAGE_SHIFT - 10),
+ total_swapcache_pages() << (PAGE_SHIFT - 10));
+
+ blocking_notifier_call_chain(&e_show_mem_notify_list,
+ (unsigned long)type, &used);
+ printk("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
+ printk("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
+}
+#endif