summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@localhost>2011-08-24 06:31:23 +0200
committercinap_lenrek <cinap_lenrek@localhost>2011-08-24 06:31:23 +0200
commit94fd5b32e91645f98cec853c4282e4e2da5799ed (patch)
tree717cc98c19bc21c9c006d748475d892a13502925
parent4593680a05190ac6eec5539ea1adccb42ad7c740 (diff)
downloadplan9front-94fd5b32e91645f98cec853c4282e4e2da5799ed.tar.xz
make scram work on T23 (fix issue #85)
-rw-r--r--sys/src/cmd/scram.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/sys/src/cmd/scram.c b/sys/src/cmd/scram.c
index f61a08841..7bd2299fe 100644
--- a/sys/src/cmd/scram.c
+++ b/sys/src/cmd/scram.c
@@ -1,20 +1,36 @@
#include <u.h>
#include </386/include/ureg.h>
-typedef struct Ureg Ureg;
#include <libc.h>
+struct Ureg u;
+int fd;
+
+void
+apm(void)
+{
+ seek(fd, 0, 0);
+ if(write(fd, &u, sizeof u) < 0)
+ sysfatal("write: %r");
+ seek(fd, 0, 0);
+ if(read(fd, &u, sizeof u) < 0)
+ sysfatal("read: %r");
+ if(u.flags & 1)
+ sysfatal("apm: %lux", (u.ax>>8) & 0xFF);
+}
+
void
main()
{
- Ureg ureg;
- int fd;
-
- fd = open("/dev/apm", OWRITE);
- if(fd < 0) sysfatal("%r");
- memset(&ureg, 0, sizeof ureg);
- ureg.ax = 0x5307;
- ureg.bx = 0x0001;
- ureg.cx = 0x0003;
- ureg.trap = 0x15;
- write(fd, &ureg, sizeof ureg);
+ if((fd = open("/dev/apm", ORDWR)) < 0)
+ if((fd = open("#P/apm", ORDWR)) < 0)
+ sysfatal("open: %r");
+
+ u.ax = 0x530E;
+ u.bx = 0x0000;
+ u.cx = 0x0102;
+ apm();
+ u.ax = 0x5307;
+ u.bx = 0x0001;
+ u.cx = 0x0003;
+ apm();
}