shithub: riscv

Download patch

ref: 9c52f4d9d453e1fa4511478dcb09af03e4c37dfb
parent: 91e9d7466fbd23618c113672f0b379d63cf16f29
author: Matthew Veety <mveety@gmail.com>
date: Thu Dec 12 21:20:29 EST 2013

Added in /dev/cputemp for bcm kernel (Thanks Krystian!)

--- a/sys/src/9/bcm/devarch.c
+++ b/sys/src/9/bcm/devarch.c
@@ -156,8 +156,17 @@
 	return readstr(offset, a, n, str);
 }
 
+static long
+cputempread(Chan*, void *a, long n, vlong offset)
+{
+ 	char str[128];
+ 	snprint(str, sizeof str, "%d±%d\n", gettemp(0) / 1000, 1);
+	return readstr(offset, a, n, str);
+}
+
 void
 archinit(void)
 {
 	addarchfile("cputype", 0444, cputyperead, nil);
+	addarchfile("cputemp", 0444, cputempread, nil);
 }
--- a/sys/src/9/bcm/vcore.c
+++ b/sys/src/9/bcm/vcore.c
@@ -288,3 +288,14 @@
 		return 0;
 	return buf[1];
 }
+
+uint
+gettemp(int tempid)
+{
+	u32int buf[2];
+	buf[0] = tempid;
+	if(vcreq(0x00030006, buf, sizeof(buf[0]), sizeof(buf)) != sizeof buf)
+		return 0;
+
+	return buf[1];
+}
--