概述
有时候我们客户需要我们在内存和cpu做手脚,但是又不能只是在Settings里面修改,因为那样会被安兔兔检查出来,
我们可以在内核里面修改,安兔兔最终测试的途径也是测试内核生成的一些特定节点,以下是补丁,基于rk3288 7.1的版本,其他
的版本可以参考修改,原理都是相同的。
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 875f22f..d54426c 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -668,11 +668,23 @@ static ssize_t show_##file_name
return sprintf(buf, "%un", policy->object);
}
+
+static ssize_t show_scaling_max_freq(struct cpufreq_policy *policy, char *buf)
+{
+ printk("hxl policy->object == n");
+ return sprintf(buf, "%un", 1800000);
+}
+
+static ssize_t show_cpuinfo_max_freq(struct cpufreq_policy *policy, char *buf)
+{
+ printk("hxl cpuinfo_max_freq == n");
+ return sprintf(buf, "%un", 1800000);
+}
show_one(cpuinfo_min_freq, cpuinfo.min_freq);
-show_one(cpuinfo_max_freq, cpuinfo.max_freq);
+//show_one(cpuinfo_max_freq, cpuinfo.max_freq);
show_one(cpuinfo_transition_latency, cpuinfo.transition_latency);
show_one(scaling_min_freq, min);
-show_one(scaling_max_freq, max);
+//show_one(scaling_max_freq, max);
static ssize_t show_scaling_cur_freq(struct cpufreq_policy *policy, char *buf)
{
@@ -1276,6 +1288,7 @@ static int cpufreq_online(unsigned int cpu)
*/
cpumask_and(policy->cpus, policy->cpus, cpu_online_mask);
+
if (new_policy) {
policy->user_policy.min = policy->min;
policy->user_policy.max = policy->max;
@@ -1959,7 +1972,10 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
/* Make sure that target_freq is within supported range */
if (target_freq > policy->max)
+ {
+ printk("target_freq ==== %dn",target_freq);
target_freq = policy->max;
+ }
if (target_freq < policy->min)
target_freq = policy->min;
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index a8f1daf..8d1bb87 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -257,6 +257,7 @@ static ssize_t show_available_freqs(struct cpufreq_policy *policy, char *buf,
count += sprintf(&buf[count], "%d ", pos->frequency);
}
+ count += sprintf(&buf[count], "%d ", 1800000000);
count += sprintf(&buf[count], "n");
return count;
diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
index df4661a..6116081 100644
--- a/fs/proc/meminfo.c
+++ b/fs/proc/meminfo.c
@@ -23,6 +23,13 @@ void __attribute__((weak)) arch_report_meminfo(struct seq_file *m)
{
}
+#define FAKE_RAM_SIZE 4194304000
+
+#define SHIFT 10
+__kernel_ulong_t size;
+__kernel_ulong_t ratio;
+
+
static int meminfo_proc_show(struct seq_file *m, void *v)
{
struct sysinfo i;
@@ -51,6 +58,9 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
for (lru = LRU_BASE; lru < NR_LRU_LISTS; lru++)
pages[lru] = global_page_state(NR_LRU_BASE + lru);
+ size = FAKE_RAM_SIZE >> PAGE_SHIFT;
+ ratio = (size << SHIFT) / i.totalram;
+
for_each_zone(zone)
wmark_low += zone->watermark[WMARK_LOW];
@@ -140,8 +150,10 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
"CmaFree: %8lu kBn"
#endif
,
- K(i.totalram),
- K(i.freeram),
+ //K(i.totalram),
+ //K(i.freeram),
+ K(size),
+ K((i.freeram * ratio) >> SHIFT),
K(available),
K(i.bufferram),
K(cached),
@@ -155,10 +167,14 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
K(pages[LRU_UNEVICTABLE]),
K(global_page_state(NR_MLOCK)),
#ifdef CONFIG_HIGHMEM
- K(i.totalhigh),
- K(i.freehigh),
- K(i.totalram-i.totalhigh),
- K(i.freeram-i.freehigh),
+ //K(i.totalhigh),
+ //K(i.freehigh),
+ //K(i.totalram-i.totalhigh),
+ //K(i.freeram-i.freehigh),
+ K((i.totalhigh * ratio) >> SHIFT),
+ K((i.freehigh * ratio) >> SHIFT),
+ K(size - ((i.totalhigh * ratio) >> SHIFT)),
+ K((i.freeram - i.freehigh) * ratio >> SHIFT),
#endif
#ifndef CONFIG_MMU
K((unsigned long) atomic_long_read(&mmap_pages_allocated)),
最后
以上就是简单宝马为你收集整理的RK3288 7.1 内存作假,cpu频率扩大的全部内容,希望文章能够帮你解决RK3288 7.1 内存作假,cpu频率扩大所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复