summaryrefslogtreecommitdiff
path: root/sys/src/9/pc/devarch.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2014-11-10 00:04:37 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2014-11-10 00:04:37 +0100
commitbcb67353c1ae559d6f91ab0669a06db52000b15d (patch)
treee2e6e9b26b7f13e234315c5753982bca4100dd22 /sys/src/9/pc/devarch.c
parentb18a6413975a0a8d06e6d310072a0ff90b1ed541 (diff)
pc, pc64: provide access to embedded controller with #P/ec file
Diffstat (limited to 'sys/src/9/pc/devarch.c')
-rw-r--r--sys/src/9/pc/devarch.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/sys/src/9/pc/devarch.c b/sys/src/9/pc/devarch.c
index 9265e2696..3d3ef0c1b 100644
--- a/sys/src/9/pc/devarch.c
+++ b/sys/src/9/pc/devarch.c
@@ -34,6 +34,7 @@ enum {
Qiow,
Qiol,
Qmsr,
+ Qec,
Qbase,
Qmax = 16,
@@ -62,7 +63,8 @@ static Dirtab archdir[Qmax] = {
"iob", { Qiob, 0 }, 0, 0660,
"iow", { Qiow, 0 }, 0, 0660,
"iol", { Qiol, 0 }, 0, 0660,
- "msr", { Qmsr, 0}, 0, 0660,
+ "msr", { Qmsr, 0 }, 0, 0660,
+ "ec", { Qec, 0 }, 0, 0660,
};
Lock archwlock; /* the lock is only for changing archdir */
int narchdir = Qbase;
@@ -361,7 +363,7 @@ static long
archread(Chan *c, void *a, long n, vlong offset)
{
char *buf, *p;
- int port;
+ int port, v;
ushort *sp;
ulong *lp;
vlong *vp;
@@ -407,6 +409,19 @@ archread(Chan *c, void *a, long n, vlong offset)
error(Ebadarg);
return n;
+ case Qec:
+ if(offset >= 256)
+ error(Ebadarg);
+ if(offset+n > 256)
+ n = 256 - offset;
+ p = a;
+ for(port = offset; port < offset+n; port++){
+ if((v = ecread(port)) < 0)
+ error(Eio);
+ *p++ = v;
+ }
+ return n;
+
case Qioalloc:
break;
@@ -486,6 +501,15 @@ archwrite(Chan *c, void *a, long n, vlong offset)
error(Ebadarg);
return n;
+ case Qec:
+ if(offset+n > 256)
+ error(Ebadarg);
+ p = a;
+ for(port = offset; port < offset+n; port++)
+ if(ecwrite(port, *p++) < 0)
+ error(Eio);
+ return n;
+
default:
if(c->qid.path < narchdir && (fn = writefn[c->qid.path]))
return fn(c, a, n, offset);