@@ -1,51 +1,55 @@
-$NetBSD: patch-ab,v 1.9 2014/10/01 01:17:33 jmcneill Exp $
+$NetBSD: patch-ab,v 1.10 2015/01/04 18:42:50 jmcneill Exp $
--- estd.c.orig 2009-10-20 16:18:28.000000000 +0000
-+++ estd.c 2014-09-30 11:10:54.000000000 +0000
-@@ -55,7 +55,10 @@
++++ estd.c
+@@ -55,7 +55,11 @@
#define TECH_EST 1
#define TECH_POWERNOW 2
#define TECH_ACPI 3
-#define TECH_MAX 3
+#define TECH_INTREPID 4
+#define TECH_LOONGSON 5
-+#define TECH_GENERIC 6
-+#define TECH_MAX 6
++#define TECH_ROCKCHIP 6
++#define TECH_GENERIC 7
++#define TECH_MAX 7
/* this is ugly, but... <shrug> */
#define MAX_FREQS 32
-@@ -116,26 +119,35 @@ int ndomains;
+@@ -116,26 +120,38 @@ int ndomains;
static size_t cp_time_size = sizeof(cp_time[0]) * CPUSTATES;
#endif
-static char *techdesc[4] = {"Unknown",
-+static char *techdesc[7] = {"Unknown",
++static char *techdesc[8] = {"Unknown",
"Enhanced SpeedStep",
"PowerNow",
- "ACPI P-States"
+ "ACPI P-States",
+ "Intrepid",
+ "Loongson",
++ "Rockchip",
+ "Generic"
};
-static char *freqctl[4] = { "",
-+static char *freqctl[7] = { "",
++static char *freqctl[8] = { "",
"machdep.est.frequency.available",
"machdep.powernow.frequency.available",
- "hw.acpi.cpu.px_dom0.available"
+ "hw.acpi.cpu.px_dom0.available",
+ "machdep.intrepid.frequency.available",
+ "machdep.loongson.frequency.available",
++ "machdep.cpu.frequency.available",
+ "machdep.frequency.available"
};
-static char *setctl[4] = { "",
-+static char *setctl[7] = { "",
++static char *setctl[8] = { "",
"machdep.est.frequency.target",
"machdep.powernow.frequency.target",
- "hw.acpi.cpu.px_dom0.select"
+ "hw.acpi.cpu.px_dom0.select",
+ "machdep.intrepid.frequency.target",
+ "machdep.loongson.frequency.target",
++ "machdep.cpu.frequency.target",
+ "machdep.frequency.current"
};
@@ -53,11 +57,11 @@
usage()
{
- printf("usage: estd [-d] [-o] [-n] [-A] [-C] [-E] [-P] [-a] [-s] [-b] [-p poll interval in us] [-g grace period] [-l low watermark percentage] [-h high watermark percentage] [-m minimum MHz] [-M maximum MHz]\n");
-+ printf("usage: estd [-d] [-o] [-n] [-A] [-C] [-E] [-P] [-I] [-L] [-G] [-a] [-s] [-b] [-p poll interval in us] [-g grace period] [-l low watermark percentage] [-h high watermark percentage] [-m minimum MHz] [-M maximum MHz]\n");
++ printf("usage: estd [-d] [-o] [-n] [-A] [-C] [-E] [-P] [-I] [-L] [-R] [-G] [-a] [-s] [-b] [-p poll interval in us] [-g grace period] [-l low watermark percentage] [-h high watermark percentage] [-m minimum MHz] [-M maximum MHz]\n");
printf(" estd -v\n");
printf(" estd -f\n");
exit(1);
-@@ -367,7 +379,7 @@ main(int argc, char *argv[])
+@@ -367,7 +383,7 @@ main(int argc, char *argv[])
FILE *fexists;
/* get command-line options */
@@ -66,7 +70,7 @@
switch (ch) {
case 'v':
version();
-@@ -400,6 +412,16 @@ main(int argc, char *argv[])
+@@ -400,6 +416,19 @@ main(int argc, char *argv[])
break;
case 'P':
tech = TECH_POWERNOW;
@@ -77,9 +81,44 @@
+ case 'L':
+ tech = TECH_LOONGSON;
+ break;
++ case 'R':
++ tech = TECH_ROCKCHIP;
++ break;
+ case 'G':
+ tech = TECH_GENERIC;
+ break;
case 'a':
strategy = AGGRESSIVE;
break;
+@@ -434,8 +463,9 @@ main(int argc, char *argv[])
+
+ ndomains = 1;
+ domain = ecalloc(ndomains, sizeof(struct domain));
+-
+- #if defined(__DragonFly__)
++
++#if defined(__NetBSD__) || defined(__DragonFly__)
++# if defined(__DragonFly__)
+ if (kinfo_get_cpus(&ncpus)) {
+ fprintf(stderr, "estd: Cannot get number of cpus\n");
+ exit(1);
+@@ -443,11 +473,18 @@ main(int argc, char *argv[])
+ cp_time = ecalloc(ncpus, sizeof(struct kinfo_cputime));
+ cp_old = ecalloc(ncpus, sizeof(struct kinfo_cputime));
+ cp_time_len = ncpus * sizeof(struct kinfo_cputime);
++# elif defined(__NetBSD__)
++ size_t ncpus_len = sizeof(ncpus);
++ if (sysctlbyname("hw.ncpu", &ncpus, &ncpus_len, NULL, 0) != 0) {
++ fprintf(stderr, "estd: Cannot get number of cpus\n");
++ exit(1);
++ }
++# endif
+ domain[0].ncpus = ncpus;
+ domain[0].cpus = ecalloc(ncpus, sizeof(int));
+ for (i = 0; i < domain[0].ncpus; i++)
+ domain[0].cpus[i] = i;
+- #endif
++#endif
+
+ /* try to guess cpu-scaling technology */
+ if (tech == TECH_UNKNOWN) {