info->used = mem_available ? (info->total - mem_available) : (info->total - info->free - info->cache);
info->swap = kBtoKiB(((swap_total > swap_free) ? (int)(swap_total - swap_free) : 0));
- /*
- * Get total memory size from zoneinfo
- *
- * meminfo show the total memory size
- * except kernel reserved memory
- *
- * Therefore, we will use (the number of page * page size)
- */
- fp = fopen("/proc/zoneinfo", "r");
- if (fp == NULL) {
- _E("IO_ERROR(0x%08x) : failed to open file to read memory size",
- RUNTIME_INFO_ERROR_IO_ERROR);
- return RUNTIME_INFO_ERROR_IO_ERROR;
- }
-
- info->total = 0;
- while (fgets(buf, sizeof(buf), fp) != NULL)
- if (sscanf(buf, " spanned %lu", &value) == 1)
- info->total += value;
- info->total = pagetoKiB(info->total);
-
- fclose(fp);
-
return RUNTIME_INFO_ERROR_NONE;
}
return RUNTIME_INFO_ERROR_NONE;
}
+
+API int runtime_info_get_physical_memory_size(int *size)
+{
+ char buf[256];
+ unsigned long value;
+ int sum;
+ FILE *fp = fopen("/proc/zoneinfo", "r");
+ if (!fp) {
+ _E("IO_ERROR(0x%08x) : failed to open file to read memory size",
+ RUNTIME_INFO_ERROR_IO_ERROR);
+ return RUNTIME_INFO_ERROR_IO_ERROR;
+ }
+
+ if (!size) {
+ _E("INVALID PARAMETER(0x%08x) : invalid output parameter",
+ RUNTIME_INFO_ERROR_INVALID_PARAMETER);
+ fclose(fp);
+ return RUNTIME_INFO_ERROR_INVALID_PARAMETER;
+ }
+
+ sum = 0;
+ while (fgets(buf, sizeof(buf), fp) != NULL)
+ if (sscanf(buf, " spanned %lu", &value) == 1)
+ sum += value;
+ *size = pagetoKiB(sum);
+
+ fclose(fp);
+
+ return RUNTIME_INFO_ERROR_NONE;
+}