tags 241239 patch thanks Redemption, at last! Well, sort of :-)
I implemented support for Multiboot in Memtest86. The upstream patch has already been forwarded to them. Since other bootloaders such as LILO still need to rely on the zImage version, I propose that the package includes both builds. See the attached debian patch. Btw, notice the increase in grub2's versioned dependency. Indeed, when this patch is applied the version of grub2 in lenny won't be able to load memtest86, only the one in experimental (which will be uploaded to sid as soon as lenny is released). -- Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."
diff -x '*.s' -Nur memtest86-3.4.old/head.S memtest86-3.4/head.S --- memtest86-3.4.old/head.S 2007-08-18 23:22:48.000000000 +0200 +++ memtest86-3.4/head.S 2008-09-05 13:52:55.000000000 +0200 @@ -37,6 +37,13 @@ cld cli + /* Store MBI pointer */ + xorl %ecx, %ecx + cmpl $0x2BADB002, %eax + jne 0f + movl %ebx, %ecx +0: + /* Ensure I have a stack pointer */ testl %esp, %esp jnz 0f @@ -49,6 +56,20 @@ 0: popl %ebx addl $_GLOBAL_OFFSET_TABLE_+[.-0b], %ebx + /* Move MBI pointer to a safe place */ + testl %ecx, %ecx + je 0f + movl %ecx, [EMAIL PROTECTED](%ebx) +0: + + jmp 0f + /* Multiboot header */ +.align 4 + .long 0x1BADB002 + .long 0 + .long -0x1BADB002 +0: + /* Pick the appropriate stack address */ leal [EMAIL PROTECTED](%ebx), %esp @@ -953,6 +974,9 @@ movl $1, %eax ret +.globl mbiptr +mbiptr: + .long 0 realptr: .word real - RSTART .word 0x0000 diff -x '*.s' -Nur memtest86-3.4.old/init.c memtest86-3.4/init.c --- memtest86-3.4.old/init.c 2007-09-04 09:40:39.000000000 +0200 +++ memtest86-3.4/init.c 2008-09-05 13:53:25.000000000 +0200 @@ -83,7 +83,10 @@ /* Determine the memory map */ if ((firmware == FIRMWARE_UNKNOWN) && (memsz_mode != SZ_MODE_PROBE)) { - if (query_linuxbios()) { + if (query_multiboot()) { + firmware = FIRMWARE_MULTIBOOT; + } + else if (query_linuxbios()) { firmware = FIRMWARE_LINUXBIOS; } else if (query_pcbios()) { diff -x '*.s' -Nur memtest86-3.4.old/Makefile memtest86-3.4/Makefile --- memtest86-3.4.old/Makefile 2008-09-05 13:19:02.000000000 +0200 +++ memtest86-3.4/Makefile 2008-09-05 13:52:15.000000000 +0200 @@ -14,7 +14,7 @@ -ffreestanding -fPIC OBJS= head.o reloc.o main.o test.o init.o lib.o patn.o screen_buffer.o \ - config.o linuxbios.o memsize.o pci.o controller.o random.o extra.o \ + config.o multiboot.o linuxbios.o memsize.o pci.o controller.o random.o extra.o \ spd.o error.o dmi.o all: memtest.bin memtest diff -x '*.s' -Nur memtest86-3.4.old/memsize.c memtest86-3.4/memsize.c --- memtest86-3.4.old/memsize.c 2007-07-17 05:10:08.000000000 +0200 +++ memtest86-3.4/memsize.c 2008-09-05 14:30:18.000000000 +0200 @@ -26,7 +26,7 @@ static void memsize_801(void); static int sanitize_e820_map(struct e820entry *orig_map, struct e820entry *new_bios, short old_nr, short res); -static void memsize_linuxbios(); +static void memsize_generic(); static void memsize_probe(void); static int check_ram(void); @@ -83,7 +83,10 @@ memsize_820(res); } else if (firmware == FIRMWARE_LINUXBIOS) { - memsize_linuxbios(); + memsize_generic("LinuxBIOS"); + } + else if (firmware == FIRMWARE_MULTIBOOT) { + memsize_generic("Multiboot"); } } @@ -111,7 +114,7 @@ } } } -static void memsize_linuxbios(void) +static void memsize_generic(char *origin) { int i, n; /* Build the memory map for testing */ @@ -129,7 +132,7 @@ n++; } v->msegs = n; - cprint(LINE_INFO, COL_MMAP, "LinuxBIOS"); + cprint(LINE_INFO, COL_MMAP, origin); } static void memsize_820(int res) { diff -x '*.s' -Nur memtest86-3.4.old/multiboot.c memtest86-3.4/multiboot.c --- memtest86-3.4.old/multiboot.c 1970-01-01 01:00:00.000000000 +0100 +++ memtest86-3.4/multiboot.c 2008-09-05 14:30:44.000000000 +0200 @@ -0,0 +1,65 @@ +/* multiboot.c - MemTest-86 Version 3.3 + * + * Copyright (C) 2008 Robert Millan + * + * Loosely based on linuxbios.c, which is: + * + * Released under version 2 of the Gnu Public License. + * By Eric Biederman + */ + +#include <stdint.h> +#include "test.h" + +struct mbi +{ + uint32_t flags; + uint32_t dummy[10]; + uint32_t mmap_length; + uint32_t mmap_addr; +}; + +struct multiboot_mmap_entry +{ + uint32_t size; + uint64_t addr; + uint64_t len; + uint32_t type; +} __attribute__((packed)); + +extern struct mbi *mbiptr; + +int query_multiboot(void) +{ + struct multiboot_mmap_entry *mem; + int i; + + if (!mbiptr) { + return 0; + } + if (!mbiptr->mmap_addr) { + return 1; + } + if ((mbiptr->flags & 0x00000040) == 0) { + return 1; + } + + mem = (struct multiboot_mmap_entry *) mbiptr->mmap_addr; + mem_info.e820_nr = 0; + + for (i = 0; i < E820MAX; i++) { + if ((uint32_t) mem >= (mbiptr->mmap_addr + mbiptr->mmap_length)) { + break; + } + + mem_info.e820[mem_info.e820_nr].addr = mem->addr; + mem_info.e820[mem_info.e820_nr].size = mem->len; + /* Multiboot spec defines available / reserved types to match with E820. */ + mem_info.e820[mem_info.e820_nr].type = mem->type; + mem_info.e820_nr++; + + mem = (struct multiboot_mmap_entry *) ((uint32_t) mem + mem->size + sizeof (mem->size)); + } + + return 1; +} diff -x '*.s' -Nur memtest86-3.4.old/test.h memtest86-3.4/test.h --- memtest86-3.4.old/test.h 2007-09-08 12:38:25.000000000 +0200 +++ memtest86-3.4/test.h 2008-09-05 13:57:02.000000000 +0200 @@ -96,6 +96,7 @@ void *memmove(void *dest, const void *src, ulong n); int query_linuxbios(void); int query_pcbios(void); +int query_multiboot(void); int insertaddress(ulong); void printpatn(void); void printpatn(void); @@ -318,6 +319,7 @@ #define FIRMWARE_UNKNOWN 0 #define FIRMWARE_PCBIOS 1 #define FIRMWARE_LINUXBIOS 2 +#define FIRMWARE_MULTIBOOT 3 extern struct vars * const v; extern unsigned char _start[], _end[], startup_32[];
diff -x '*.s' -Nur memtest86-3.4.old/debian/control memtest86-3.4/debian/control --- memtest86-3.4.old/debian/control 2008-09-05 13:19:02.000000000 +0200 +++ memtest86-3.4/debian/control 2008-09-05 14:45:14.000000000 +0200 @@ -7,7 +7,7 @@ Package: memtest86 Architecture: i386 amd64 kfreebsd-i386 kfreebsd-amd64 -Suggests: hwtools, memtester, kernel-patch-badram, memtest86+, grub2 (>=1.95+20070515-1) | grub (>= 0.95+cvs20040624), mtools +Suggests: hwtools, memtester, kernel-patch-badram, memtest86+, grub2 (>= 1.96+20080831-1) | grub (>= 0.95+cvs20040624), mtools Description: thorough real-mode memory tester Memtest86 scans your RAM for errors. . diff -x '*.s' -Nur memtest86-3.4.old/debian/grub memtest86-3.4/debian/grub --- memtest86-3.4.old/debian/grub 2008-09-05 13:19:02.000000000 +0200 +++ memtest86-3.4/debian/grub 2008-09-05 14:48:49.000000000 +0200 @@ -1,11 +1,11 @@ #!/bin/bash set -e -if test -e /boot/memtest86.bin ; then - echo "Found memtest86 image: /boot/memtest86.bin" >&2 +if test -e /boot/memtest86_multiboot.bin ; then + echo "Found memtest86 image: /boot/memtest86_multiboot.bin" >&2 cat << EOF menuentry "Memory test (memtest86)" { - linux ${GRUB_DRIVE_BOOT}/memtest86.bin + multiboot ${GRUB_DRIVE_BOOT}/memtest86_multiboot.bin } EOF fi diff -x '*.s' -Nur memtest86-3.4.old/debian/lilo.conf memtest86-3.4/debian/lilo.conf --- memtest86-3.4.old/debian/lilo.conf 2008-09-05 13:19:02.000000000 +0200 +++ memtest86-3.4/debian/lilo.conf 2008-09-05 14:48:09.000000000 +0200 @@ -1,5 +1,5 @@ # sample /etc/lilo.conf entry for memtest86 -image = /boot/memtest86.bin +image = /boot/memtest86_zimage.bin label = memtest diff -x '*.s' -Nur memtest86-3.4.old/debian/make-memtest86-boot-floppy memtest86-3.4/debian/make-memtest86-boot-floppy --- memtest86-3.4.old/debian/make-memtest86-boot-floppy 2008-09-05 13:19:02.000000000 +0200 +++ memtest86-3.4/debian/make-memtest86-boot-floppy 2008-09-05 14:43:26.000000000 +0200 @@ -16,7 +16,7 @@ set -e -MEMTEST=/boot/memtest86.bin +MEMTEST=/boot/memtest86_zimage.bin FLOPPYIMAGE=/dev/fd0 error() diff -x '*.s' -Nur memtest86-3.4.old/debian/make-memtest86-boot-floppy.1 memtest86-3.4/debian/make-memtest86-boot-floppy.1 --- memtest86-3.4.old/debian/make-memtest86-boot-floppy.1 2008-09-05 13:19:02.000000000 +0200 +++ memtest86-3.4/debian/make-memtest86-boot-floppy.1 2008-09-05 14:48:22.000000000 +0200 @@ -20,7 +20,7 @@ .SH OPTIONS .IP "\-\-memtest <path to the memtest-image>" -Path to the memtest86-image, default is /boot/memtest86.bin. +Path to the memtest86-image, default is /boot/memtest86_zimage.bin. .IP "\-\-floppyimage <path to the floppyimage or device>" File or device where the boot-image should be written to, default is /dev/fd0. diff -x '*.s' -Nur memtest86-3.4.old/debian/postinst memtest86-3.4/debian/postinst --- memtest86-3.4.old/debian/postinst 2008-09-05 13:19:02.000000000 +0200 +++ memtest86-3.4/debian/postinst 2008-09-05 14:48:31.000000000 +0200 @@ -5,7 +5,7 @@ # (adapted from snippet by [EMAIL PROTECTED]) if [ -x /sbin/lilo ] && [ -r /etc/lilo.conf ] && [ "${DEBIAN_FRONTEND}" != "noninteractive" ] && - grep "image.*=.*/boot/memtest86.bin" /etc/lilo.conf >/dev/null + grep "image.*=.*/boot/memtest86_zimage.bin" /etc/lilo.conf >/dev/null then echo "You seem to have an entry for memtest86 in /etc/lilo.conf." printf "Run lilo now [y/N]? " diff -x '*.s' -Nur memtest86-3.4.old/debian/README.Debian memtest86-3.4/debian/README.Debian --- memtest86-3.4.old/debian/README.Debian 2008-09-05 13:19:02.000000000 +0200 +++ memtest86-3.4/debian/README.Debian 2008-09-05 14:47:53.000000000 +0200 @@ -1,13 +1,22 @@ memtest86 for Debian -------------------- -Binary image is /boot/memtest86.bin +Two binary images are provided: + + - A legacy /boot/memtest86_zimage.bin that uses Linux zImage boot + protocol. + + - A Multiboot /boot/memtest86_multiboot.bin image that follows the + Multiboot specification. To run the tester you'll need to setup your bootloader (see examples/lilo.conf for LILO), or to make a boot-floppy, and reboot on -this image. +the zImage. The make-memtest86-boot-floppy utility will help you to create a boot floppy or floppy image. +The Multiboot image is the recommended option if you want to use GRUB, and +in platforms other than PC/BIOS (such as coreboot), it is the only option. + -- Yann Dirson <[EMAIL PROTECTED]>, Tue May 25 15:45:37 2004 diff -x '*.s' -Nur memtest86-3.4.old/debian/rules memtest86-3.4/debian/rules --- memtest86-3.4.old/debian/rules 2008-09-05 13:19:02.000000000 +0200 +++ memtest86-3.4/debian/rules 2008-09-05 14:43:07.000000000 +0200 @@ -31,7 +31,8 @@ install -d debian/memtest86/usr/bin install -m755 debian/make-memtest86-boot-floppy debian/memtest86/usr/bin/ - install -D -m644 memtest.bin debian/memtest86/boot/memtest86.bin + install -D -m644 memtest.bin debian/memtest86/boot/memtest86_zimage.bin + install -D -m644 memtest debian/memtest86/boot/memtest86_multiboot.bin install -D -m755 debian/grub debian/memtest86/etc/grub.d/20_memtest86 dh_installman debian/make-memtest86-boot-floppy.1