diff -ru 845patch-old/845patch.c 845patch/845patch.c
--- 845patch-old/845patch.c	Wed Mar 10 21:35:13 2004
+++ 845patch/845patch.c	Mon Sep  6 21:11:04 2004
@@ -13,9 +13,59 @@
 
 /* Christian Zietz <czietz@gmx.net> */
 
+
+
+static __inline void
+outb (unsigned char value, unsigned short int port)
+{
+    __asm__ __volatile__ ("outb %b0,%w1"::"a" (value), "Nd" (port));
+}
+
+static __inline void
+outw (unsigned short int value, unsigned short int port)
+{
+  __asm__ __volatile__ ("outw %w0,%w1": :"a" (value), "Nd" (port));
+
+}
+
+static __inline void
+outl (unsigned int value, unsigned short int port)
+{
+  __asm__ __volatile__ ("outl %0,%w1": :"a" (value), "Nd" (port));
+}
+
+static __inline unsigned char
+inb (unsigned short int port)
+{
+    unsigned char _v;
+    
+    __asm__ __volatile__ ("inb %w1,%0":"=a" (_v):"Nd" (port));
+    return _v;
+}
+
+
+static __inline unsigned int
+inl (unsigned short int port)
+{
+  unsigned int _v;
+
+  __asm__ __volatile__ ("inl %w1,%0":"=a" (_v):"Nd" (port));
+  return _v;
+}
+
+static __inline unsigned short int
+inw (unsigned short int port)
+{
+  unsigned short _v;
+
+  __asm__ __volatile__ ("inw %w1,%0":"=a" (_v):"Nd" (port));
+  return _v;
+}
+
+
+#include <sys/types.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <sys/io.h>
 #include <unistd.h>
 #define __USE_GNU
 #include <string.h>
@@ -32,6 +82,10 @@
 #define idstring "Total time for VGA POST:"
 #define idoffset (-19)
 
+void *
+memmem (const void *const haystack, const size_t haystack_len,
+        const void *const needle, const size_t needle_len);
+
 int main (int argc, char *argv[]) {
   int newmemsize;
   int check;
@@ -62,10 +116,17 @@
   }
   
   // give me permission to access io ports
+#ifdef __FreeBSD__
+  if (open("/dev/io", O_RDWR) == -1) {
+    fprintf(stderr, "Could not set IO permissions!\n%s must be run as root\n", argv[0]);
+    return 1;
+  }
+#else
   if (iopl(3)<0) {
     fprintf(stderr, "Could not set IO permissions!\n%s must be run as root\n", argv[0]);
     return 1;
   }
+#endif
 
   // check for correct chipset
   outl(0x80000000, 0xcf8);
@@ -162,3 +223,111 @@
 
   return !result;
 }
+
+
+void *
+memmem (const void *const haystack, const size_t haystack_len,
+        const void *const needle, const size_t needle_len)
+{
+    const unsigned char *const haystack_endptr = (const unsigned char *)haystack + haystack_len;
+    const unsigned char *const needle_endptr = (const unsigned char *)needle + needle_len;
+    const unsigned char *haystack_shifting_ptr;
+
+    size_t *shift_good_suffix;
+    size_t shift_last_occurrence [256];
+
+
+
+    if (needle_len > haystack_len)
+        return 0;
+
+    haystack_shifting_ptr = (const unsigned char *)haystack + needle_len;
+
+
+    /* Compute good suffix function.  */
+    shift_good_suffix = malloc (2 * needle_len * sizeof *shift_good_suffix);
+    if (shift_good_suffix != 0)
+    {
+        const unsigned char *needle_ptr;
+        size_t i, j;
+
+        shift_good_suffix [0] = 0;
+        needle_ptr = (const unsigned char *)needle + 1;
+        for (i = 1, j = 0; i < needle_len; ++i)
+        {
+            while (j > 0 && ((const unsigned char *)needle) [j] != *needle_ptr)
+                j = shift_good_suffix [j - 1];
+            if (((const unsigned char *)needle) [j] == *needle_ptr)
+                ++j;
+            shift_good_suffix [i] = j;
+            ++needle_ptr;
+        }
+
+        shift_good_suffix [needle_len] = 0;
+        needle_ptr = (const unsigned char *)needle + needle_len - 1;
+        for (i = 1, j = 0; i < needle_len; ++i)
+        {
+            --needle_ptr;
+            while (j > 0 && ((const unsigned char *)needle) [needle_len - 1 - j] != *needle_ptr)
+                j = shift_good_suffix [needle_len - 1 + j];
+            if (((const unsigned char *)needle) [needle_len - 1 - j] == *needle_ptr)
+                ++j;
+            shift_good_suffix [needle_len + i] = j;
+        }
+
+        for (i = 0; i < needle_len; ++i)
+            shift_good_suffix [i] = needle_len - shift_good_suffix [i];
+
+        for (i = 0; i < needle_len; ++i)
+        {
+            j = needle_len - 1 - shift_good_suffix [needle_len + i];
+            if (shift_good_suffix [j] > i + 1 - shift_good_suffix [needle_len + i])
+                shift_good_suffix [j] = i + 1 - shift_good_suffix [needle_len + i];
+        }
+    }
+
+
+    /* Compute last occurence function.  */
+    {
+        const unsigned char *needle_ptr = needle;
+        size_t i;
+
+        for (i = 0; i < 256; ++i)
+            shift_last_occurrence [i] = 0;
+        for (i = 0; i < needle_len; ++i)
+            shift_last_occurrence [*needle_ptr++] = i + 1;
+    }
+
+
+    /* Matching algorithm.  */
+    while (haystack_shifting_ptr <= haystack_endptr)
+    {
+        const unsigned char *haystack_ptr = haystack_shifting_ptr;
+        const unsigned char *needle_ptr = needle_endptr;
+        size_t len = needle_len;
+
+        while (len > 0 && *--haystack_ptr == *--needle_ptr)
+            --len;
+
+        if (len == 0)
+        {
+            if (shift_good_suffix != 0)
+                free (shift_good_suffix);
+            return (void *)haystack_ptr;
+        }
+
+        {
+            const size_t shift1 = shift_good_suffix != 0 ? shift_good_suffix [len - 1] : 1;
+            const size_t shift2 = (len > shift_last_occurrence [*haystack_ptr]
+                                   ? len - shift_last_occurrence [*haystack_ptr] : 1);
+
+            haystack_shifting_ptr += shift1 > shift2 ? shift1 : shift2;
+        }
+    }
+
+
+    if (shift_good_suffix != 0)
+        free (shift_good_suffix);
+    return 0;
+}
+
Only in 845patch: 845patch.c.orig
diff -ru 845patch-old/Makefile 845patch/Makefile
--- 845patch-old/Makefile	Sat Sep 13 01:33:09 2003
+++ 845patch/Makefile	Mon Sep  6 20:57:33 2004
@@ -1,4 +1,4 @@
-CFLAGS = -Wall -Ilrmi-0.8
+CFLAGS = -Wall -Ilrmi-0.8 -O2 -W -pedantic
 
 sources = 845patch.c lrmi-0.8/lrmi.c
 objects = 845patch.o lrmi-0.8/lrmi.o
Only in 845patch: Makefile.orig
diff -ru 845patch-old/lrmi-0.8/lrmi.c 845patch/lrmi-0.8/lrmi.c
--- 845patch-old/lrmi-0.8/lrmi.c	Wed May 14 11:18:12 2003
+++ 845patch/lrmi-0.8/lrmi.c	Mon Sep  6 21:04:55 2004
@@ -45,6 +45,7 @@
 #include <machine/psl.h>
 #include <machine/vm86.h>
 #include <machine/sysarch.h>
+#include <sys/ucontext.h>
 
 #endif /* __NetBSD__ || __FreeBSD__ */
 
Only in 845patch/lrmi-0.8: lrmi.c~
Only in 845patch: out
