From c318dfa1af4cc70e2f9ea48965288bb7d1a630b1 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Thu, 9 Aug 2012 12:06:08 +0000 Subject: enable only ports we need --- src/sp12.c | 22 ++++++++++++++++++++-- 1 file 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 -- cgit v1.2.3