ref: 94fd5b32e91645f98cec853c4282e4e2da5799ed
parent: 4593680a05190ac6eec5539ea1adccb42ad7c740
author: cinap_lenrek <cinap_lenrek@localhost>
date: Wed Aug 24 02:31:23 EDT 2011
make scram work on T23 (fix issue #85)
--- 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();
}