pkgsrc/sysutils/vbetool/patches/patch-ab
joerg 5c0f407982 Don't expect the OS to provide inb/outb, just define the assembler
functions directly. Fixes build on NetBSD current. Add DESTDIR support.
2007-10-29 18:41:24 +00:00

106 lines
2.1 KiB
Text

$NetBSD: patch-ab,v 1.4 2007/10/29 18:41:24 joerg Exp $
--- vbetool.c.orig 2006-07-26 03:27:21.000000000 +0200
+++ vbetool.c
@@ -8,19 +8,39 @@ This program is released under the terms
version 2
*/
-#include <pci/pci.h>
#include <assert.h>
+#include <pciutils/pci.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/types.h>
+#ifdef __linux__
#include <sys/io.h>
#include <sys/kd.h>
+#endif
#include <sys/stat.h>
#include <errno.h>
+#ifdef __NetBSD__
+#include <machine/sysarch.h>
+#endif
+
+static uint8_t
+asm_inb(unsigned port)
+{
+ uint8_t data;
+ __asm volatile("inb %w1,%0" : "=a" (data) : "d" (port));
+ return data;
+}
+
+static __inline void
+asm_outb(uint8_t data, unsigned port)
+{
+ __asm volatile("outb %0,%w1" : : "a" (data), "d" (port));
+}
+
#include "include/lrmi.h"
#include "vbetool.h"
@@ -42,8 +62,16 @@ int vbetool_init (void) {
exit(1);
}
+#ifdef __NetBSD__
+# ifdef __i386__
+ i386_iopl(3);
+# else
+ x86_64_iopl(3);
+# endif
+#else
ioperm(0, 1024, 1);
iopl(3);
+#endif
pacc = pci_alloc();
pacc->numeric_ids = 1;
@@ -256,7 +284,9 @@ void restore_state_from(char *data)
LRMI_free_real(data);
+#ifdef __linux__
ioctl(0, KDSETMODE, KD_TEXT);
+#endif
}
@@ -476,23 +506,25 @@ int check_console()
return 11;
}
+#ifdef __linux__
ioctl(0, KDSETMODE, KD_GRAPHICS);
+#endif
return 0;
}
int enable_vga() {
- outb(0x03 | inb(0x3CC), 0x3C2);
- outb(0x01 | inb(0x3C3), 0x3C3);
- outb(0x08 | inb(0x46e8), 0x46e8);
- outb(0x01 | inb(0x102), 0x102);
+ asm_outb(0x03 | asm_inb(0x3CC), 0x3C2);
+ asm_outb(0x01 | asm_inb(0x3C3), 0x3C3);
+ asm_outb(0x08 | asm_inb(0x46e8), 0x46e8);
+ asm_outb(0x01 | asm_inb(0x102), 0x102);
return 0;
}
int disable_vga() {
- outb(~0x03 & inb(0x3CC), 0x3C2);
- outb(~0x01 & inb(0x3C3), 0x3C3);
- outb(~0x08 & inb(0x46e8), 0x46e8);
- outb(~0x01 & inb(0x102), 0x102);
+ asm_outb(~0x03 & asm_inb(0x3CC), 0x3C2);
+ asm_outb(~0x01 & asm_inb(0x3C3), 0x3C3);
+ asm_outb(~0x08 & asm_inb(0x46e8), 0x46e8);
+ asm_outb(~0x01 & asm_inb(0x102), 0x102);
return 0;
}