9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Peter Kosyh <p.kosyh@gmail.com>
To: 9front@9front.org
Subject: [PATCH] EeePC battery status
Date: Fri, 25 Sep 2020 10:38:13 +0300	[thread overview]
Message-ID: <8736362tne.fsf@factor-ts.ru> (raw)

[-- 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);
 

             reply	other threads:[~2020-09-25  7:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-25  7:38 Peter Kosyh [this message]
2020-09-25  8:30 ` [9front] " Sigrid Solveig Haflínudóttir

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8736362tne.fsf@factor-ts.ru \
    --to=p.kosyh@gmail.com \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).