9front - general discussion about 9front
 help / color / mirror / Atom feed
* [PATCH] EeePC battery status
@ 2020-09-25  7:38 Peter Kosyh
  2020-09-25  8:30 ` [9front] " Sigrid Solveig Haflínudóttir
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Kosyh @ 2020-09-25  7:38 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 324 bytes --]

Hi all!

Here is the patch to make my EeePC 1000px show battery status via
aux/acpi. Hope it can be useful for someone.

P.S. The main problem with EeePC running 9front is that network
interfaces wifi/ethernet are not supported by 9front. I will try port
them from some BSD, but i am not sure how long time it can take. :)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: eeepc-battery.diff --]
[-- Type: text/x-patch, Size: 1126 bytes --]

diff -r 5ca47d85e288 sys/src/cmd/aux/acpi.c
--- a/sys/src/cmd/aux/acpi.c	Mon Sep 21 11:43:31 2020 -0700
+++ b/sys/src/cmd/aux/acpi.c	Fri Sep 25 10:16:52 2020 +0300
@@ -83,7 +83,39 @@
 	{{Qcputemp},		"cputemp",	0444,		tmpread,		nil},
 	{{Qctl},			"ctl",		0666,		ctlread,		ctlwrite},
 };
+static char*
+eisaid(void *v)
+{
+	static char id[8];
+	ulong b, l;
+	int i;
 
+	if(amltag(v) == 's')
+		return v;
+	b = amlint(v);
+	for(l = 0, i=24; i>=0; i -= 8, b >>= 8)
+		l |= (b & 0xFF) << i;
+	id[7] = 0;
+	for(i=6; i>=3; i--, l >>= 4)
+		id[i] = "0123456789ABCDEF"[l & 0xF];
+	for(i=2; i>=0; i--, l >>= 5)
+		id[i] = '@' + (l & 0x1F);
+	return id;
+}
+static int
+enumec(void *dot, void *)
+{
+	void *p;
+	char *id;
+	id = eisaid(amlval(amlwalk(dot, "^_HID")));
+	if (id == nil || strcmp(id, "PNP0C09") != 0)
+		return 1;
+	p = amlwalk(dot, "^_REG");
+	if (p != nil) {
+		amleval(p, "ii", 0x3, 1, nil);
+	}
+	return 1;
+}
 static int
 enumbat(void *dot, void *)
 {
@@ -501,6 +533,7 @@
 	}
 	close(fd);
 
+	amlenum(amlroot, "_HID", enumec, nil);
 	amlenum(amlroot, "_BIF", enumbat, nil);
 	amlenum(amlroot, "_PSL", enumtmp, nil);
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [9front] [PATCH] EeePC battery status
  2020-09-25  7:38 [PATCH] EeePC battery status Peter Kosyh
@ 2020-09-25  8:30 ` Sigrid Solveig Haflínudóttir
  0 siblings, 0 replies; 2+ messages in thread
From: Sigrid Solveig Haflínudóttir @ 2020-09-25  8:30 UTC (permalink / raw)
  To: 9front

applied/pushed, thanks!


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-25  8:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-25  7:38 [PATCH] EeePC battery status Peter Kosyh
2020-09-25  8:30 ` [9front] " Sigrid Solveig Haflínudóttir

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).