memtest86+ on freebsd

Andriy Gapon avg at icyb.net.ua
Mon Dec 15 04:08:27 PST 2008


on 12/12/2008 13:17 Andriy Gapon said the following:
> Just in case anybody still remembers this issue.
> It seams that the main culprit here was the following line in the linker
> script:
> 
> OUTPUT_FORMAT("elf32-i386");
> 
> I was tipped just today that it should have read:
> OUTPUT_FORMAT("elf32-i386-freebsd", "elf32-i386-freebsd",
> "elf32-i386-freebsd");

In fact it was Stephan Eisvogel who provided me with this hint.
He has also kindly pointed me to his version of memtest86+ for FreeBSD
that not only has porting changes but also some functional
changes/enhancements as well:
http://seitics.de/pub/memtest/

Stephan has also offered/suggested the following:
> If there is sufficient interest I could be persuaded to donate
> our Forth triple boot menu code that we use in our own products
> (primary FreeBSD partition, secondary dito, memtest) to help
> FreeBSD gain memtest on boot.

I personally think that this sounds cool, especially for certain kinds
of applications.


And just for the reference I am attaching my minimal patch that allows
memtest86+ to compile on FreeBSD. I haven't tested the result though.
I have some doubts about .code32 change in setup.S.
Also I see that Stephan changed memtest.lds so that
. = 0x10000;
became
. = 0xc0120000;

-- 
Andriy Gapon
-------------- next part --------------
diff -rup memtest86+-2.01/error.c memtest86+-2.01/error.c
--- memtest86+-2.01/error.c	2008-02-21 13:26:05.000000000 +0200
+++ memtest86+-2.01/error.c	2008-12-12 13:15:00.943778766 +0200
@@ -11,7 +11,6 @@
  
 #include "test.h"
 #include "config.h"
-#include <sys/io.h>
 #include "dmi.h"
 
 extern int test_ticks, nticks, beepmode;
diff -rup memtest86+-2.01/memtest.lds memtest86+-2.01/memtest.lds
--- memtest86+-2.01/memtest.lds	2008-02-21 13:26:05.000000000 +0200
+++ memtest86+-2.01/memtest.lds	2008-12-12 13:09:07.993226296 +0200
@@ -1,4 +1,4 @@
-OUTPUT_FORMAT("elf32-i386");
+OUTPUT_FORMAT("elf32-i386-freebsd", "elf32-i386-freebsd", "elf32-i386-freebsd");
 OUTPUT_ARCH(i386);
 
 ENTRY(_start); 
diff -rup memtest86+-2.01/memtest_shared.lds memtest86+-2.01/memtest_shared.lds
--- memtest86+-2.01/memtest_shared.lds	2008-02-21 13:26:05.000000000 +0200
+++ memtest86+-2.01/memtest_shared.lds	2008-12-12 13:09:19.184938804 +0200
@@ -1,4 +1,4 @@
-OUTPUT_FORMAT("elf32-i386");
+OUTPUT_FORMAT("elf32-i386-freebsd", "elf32-i386-freebsd", "elf32-i386-freebsd");
 OUTPUT_ARCH(i386);
 
 ENTRY(startup_32); 
diff -rup memtest86+-2.01/setup.S memtest86+-2.01/setup.S
--- memtest86+-2.01/setup.S	2008-02-21 13:26:05.000000000 +0200
+++ memtest86+-2.01/setup.S	2008-12-12 13:16:48.404989746 +0200
@@ -42,7 +42,9 @@ start:
 	jz	alt_a20_done
 	
 	/* set or clear bit1, the ALT_A20_GATE bit */
+	.code32
 	movb	4(%esp), %ah
+	.code16
 	testb	%ah, %ah
 	jz	alt_a20_cont1
 	orb	$2, %al
diff -rup memtest86+-2.01/test.c memtest86+-2.01/test.c
--- memtest86+-2.01/test.c	2008-02-21 13:26:05.000000000 +0200
+++ memtest86+-2.01/test.c	2008-12-12 13:14:06.257361411 +0200
@@ -9,9 +9,10 @@
  * http://www.x86-secret.com - http://www.memtest.org
  */
 
+#include <sys/types.h>
+#include <machine/cpufunc.h>
 #include "test.h"
 #include "config.h"
-#include <sys/io.h>
 #include "dmi.h"
 
 extern int segs, bail;
@@ -1407,18 +1408,18 @@ void beep(unsigned int frequency)
 	unsigned int count = 1193180 / frequency;
 
 	// Switch on the speaker
-	outb_p(inb_p(0x61)|3, 0x61);
+	outb(0x61, inb(0x61)|3);
 
 	// Set command for counter 2, 2 byte write
-	outb_p(0xB6, 0x43);
+	outb(0x43, 0xB6);
 
 	// Select desired Hz
-	outb_p(count & 0xff, 0x42);
-	outb((count >> 8) & 0xff, 0x42);
+	outb(0x42, count & 0xff);
+	outb(0x42, (count >> 8) & 0xff);
 
 	// Block for 100 microseconds
 	sleep(100, 1);
 
 	// Switch off the speaker
-	outb(inb_p(0x61)&0xFC, 0x61);
+	outb(0x61, inb(0x61)&0xFC);
 }


More information about the freebsd-hackers mailing list