Add support for Rockchip 'machdep.cpu.frequency' interface. Use hw.ncpu to

detect number of CPUs on non-ACPI NetBSD systems.
This commit is contained in:
jmcneill 2015-01-04 18:42:49 +00:00
parent bfa07c5d16
commit 6bc0eecd54
3 changed files with 55 additions and 16 deletions

View file

@ -1,8 +1,8 @@
# $NetBSD: Makefile,v 1.22 2014/10/01 01:17:33 jmcneill Exp $
# $NetBSD: Makefile,v 1.23 2015/01/04 18:42:49 jmcneill Exp $
DISTNAME= estd-r7
PKGNAME= estd-0.7
PKGREVISION= 1
PKGREVISION= 2
CATEGORIES= sysutils
MASTER_SITES= http://www.ecademix.com/JohannesHofmann/

View file

@ -1,7 +1,7 @@
$NetBSD: distinfo,v 1.15 2014/10/01 01:17:33 jmcneill Exp $
$NetBSD: distinfo,v 1.16 2015/01/04 18:42:49 jmcneill Exp $
SHA1 (estd-r7.tar.gz) = 41186b82fe2a71a4436e01805522b60d100f84d4
RMD160 (estd-r7.tar.gz) = c91dad3c74ef099d54e546ac0cdf7a4a29c4a4f3
Size (estd-r7.tar.gz) = 8712 bytes
SHA1 (patch-aa) = 539b1bdcfab5815edec76277ee1be9fa9c762323
SHA1 (patch-ab) = 1fc49206f6a9add634bb7ab1d363d9318530e1e9
SHA1 (patch-ab) = 5dce228d8b2bb52db8dee45f48e0d4702d4358ed

View file

@ -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 @@ $NetBSD: patch-ab,v 1.9 2014/10/01 01:17:33 jmcneill Exp $
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 @@ $NetBSD: patch-ab,v 1.9 2014/10/01 01:17:33 jmcneill Exp $
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 @@ $NetBSD: patch-ab,v 1.9 2014/10/01 01:17:33 jmcneill Exp $
+ 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) {