summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2012-08-09 12:06:08 +0000
committerDimitri Sokolyuk <demon@dim13.org>2012-08-09 12:06:08 +0000
commitc318dfa1af4cc70e2f9ea48965288bb7d1a630b1 (patch)
treed673046439041c22761340842d4e6e007d825c37
parent8e2dd3f47025a66e7b57e04df1a75c0d0ac0e53f (diff)
enable only ports we need
-rw-r--r--src/sp12.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/sp12.c b/src/sp12.c
index ef4fd97..c415394 100644
--- a/src/sp12.c
+++ b/src/sp12.c
@@ -803,6 +803,9 @@ int main(int argc, char *argv[])
char *dataPtr; /* for separating address:data */
int exitFlag = 0;
char binary[9] = "76543210"; /* Stores conversion num to binary */
+#if defined(__OpenBSD__)
+ u_long iomap[32];
+#endif
device.initPerformed = 0;
flashPath[0] = '\0';
@@ -821,8 +824,23 @@ int main(int argc, char *argv[])
if (ioperm(0x378,3,1)) {perror("ioperm error at 0x378");exit(1);}
if (ioperm(0x3BC,3,1)) {perror("ioperm error at 0x3BC");exit(1);}
#elif defined(__OpenBSD__)
- if (i386_iopl(1) == -1) {
- perror("i386_iopl error");
+#define enable(a, i) do { \
+ ((a)[((i) + 0) >> 5] &= ~(1 << (((i) + 0) & 0x1F))); \
+ ((a)[((i) + 1) >> 5] &= ~(1 << (((i) + 1) & 0x1F))); \
+ ((a)[((i) + 2) >> 5] &= ~(1 << (((i) + 2) & 0x1F))); \
+} while (0)
+
+ if (i386_get_ioperm(iomap) != 0) {
+ perror("i386_get_ioperm error");
+ exit(1);
+ }
+
+ enable(iomap, 0x278);
+ enable(iomap, 0x378);
+ enable(iomap, 0x3BC);
+
+ if (i386_set_ioperm(iomap) != 0) {
+ perror("i386_set_ioperm error");
exit(1);
}
#endif