return RESOURCED_ERROR_NONE;
}
+static int parse_spanned_pages(const char *s, regmatch_t *match,
+ unsigned int parse_tag, void *data)
+{
+ char *e;
+ unsigned long v;
+ unsigned long *parse_v = (unsigned long *)data;
+
+ v = strtoul(s + match[1].rm_so, &e, 0);
+ *parse_v += v;
+
+ return 0;
+}
+
+int proc_get_ram_total(unsigned int *total)
+{
+ unsigned long total_spanned = 0;
+ static unsigned int total_ram = 0;
+ int ret;
+ const struct parse_arg args[] = {
+ PARSE_TAG("spanned[[:blank:]]+([0-9]+)\n",
+ parse_spanned_pages, SPANNED),
+ PARSE_TAG_EMPTY(),
+ };
+
+ if (total_ram > 0) {
+ *total = total_ram;
+ return RESOURCED_ERROR_NONE;
+ }
+
+ ret = proc_parse_zoneinfo(args, &total_spanned);
+ if (ret != RESOURCED_ERROR_NONE)
+ return RESOURCED_ERROR_NO_DATA;
+
+ total_ram = (unsigned int)BYTE_TO_KBYTE(total_spanned << PAGE_SHIFT);
+ *total = total_ram;
+
+ return RESOURCED_ERROR_NONE;
+}
+
static inline char *proc_skip_blanks(const char *s)
{
while (s && (isblank(*s) || !isalnum(*s)))
unsigned int tag;
};
+#define PARSE_TAG(exp, fn, id) \
+{ \
+ .re_exp = exp, \
+ .callback = fn, \
+ .tag = PARSE_TAG_##id, \
+}
+
+#define PARSE_TAG_EMPTY() {0,}
+
+enum {
+ PARSE_TAG_ZONE = 1,
+ PARSE_TAG_PAGE_COUNT,
+ PARSE_TAG_WM_MIN,
+ PARSE_TAG_WM_LOW,
+ PARSE_TAG_WM_HIGH,
+ PARSE_TAG_MANAGED,
+ PARSE_TAG_SPANNED,
+ PARSE_TAG_MAX,
+};
+
+
/**
* @desc get command line from /proc/{pid}/cmdline
* @return negative value if error
int proc_get_uptime(unsigned long *uptime);
/**
+ * @desc get total ram size including reserved memory
+ * @param[out] total Ram size in kilobytes
+ * @return negative value if error
+ */
+int proc_get_ram_total(unsigned int *total);
+
+/**
* @brief print uss and memtotal for showing brief memory information
*/
void proc_print_meninfo(FILE *fp);
#define PROC_COMPACT_ENTRY "/proc/sys/vm/compact_memory"
#define MEM_CONF_FILE RD_CONFIG_FILE(memory)
-enum {
- PARSE_TAG_ZONE = 1,
- PARSE_TAG_PAGE_COUNT,
- PARSE_TAG_WM_MIN,
- PARSE_TAG_WM_LOW,
- PARSE_TAG_WM_HIGH,
- PARSE_TAG_MANAGED,
- PARSE_TAG_MAX,
-};
-
#define COMPACT_CONFIG_SECTION "Compaction"
#define COMPACT_CONFIG_ENABLE "CompactEnable"
#define COMPACT_CONFIG_FRAG "Fraglevel"
#define TIZEN_DEBUG_MODE_FILE RD_SYS_ETC"/.debugmode"
#define DEFAULT_APPID "NULL"
+#define DEFAULT_RAMSIZE 512
#define INIT_PID 1
#define POWER_OFF_DIRECT 2
D_BUS_REPLY_NULL(invocation);
}
+static void dbus_get_get_ram_size(GDBusMethodInvocation *invocation, GVariant *params)
+{
+ unsigned int total = MBYTE_TO_KBYTE(DEFAULT_RAMSIZE);
+ int ret;
+
+ ret = proc_get_ram_total(&total);
+ if (ret)
+ _E("can't get ram total size. use default size");
+
+ g_dbus_method_invocation_return_value(invocation, g_variant_new("(u)", total));
+}
+
static void proc_dbus_exclude_signal_handler(GVariant *params)
{
const char *str = NULL;
" <arg type='i' name='Detect' direction='out'/>"
" <arg type='s' name='Appid' direction='out'/>"
" </method>"
+" <method name='GetRamSize'>"
+" <arg type='u' name='TotalSizeKB' direction='out'/>"
+" </method>"
" </interface>"
"</node>";
{ "ProcMemoryUsage", dbus_proc_memory_usage },
{ "ProcCpuUsage", dbus_proc_cpu_usage },
{ "CheckAppStatus", dbus_get_checkappstatus },
+ { "GetRamSize", dbus_get_get_ram_size },
/* Add methods here */
};