Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Mar 2009 19:49:27 +0200
From:      Andriy Gapon <avg@icyb.net.ua>
To:        freebsd-ports@FreeBSD.ORG
Subject:   request for a new port review [memtest86+]
Message-ID:  <49B6A827.50705@icyb.net.ua>

next in thread | raw e-mail | index | archive | help

Guys,

could you please review the below port for correctness, style and general approach
taken by me.
This is a port of memtest86+. Unlike existing sysutils/memtest86 this port is not
a download/extraction/version-tracking aid, rather it is designed to build a
stand-alone ELF image (bootable by boot2 or loader) and/or an ISO image from sources.
The first option does not need any additional justification, I think. The second
option can be useful if you want to add some local patches on top of vendor sources.

I am very grateful for the idea for this port and many technical details of it to
Stephan Eisvogel. I also thank Eygene Ryabinkin for teaching me some things about ld.

Alternatives for /boot/opt are welcome :)

P.S. Stephan, I plan to create a distinct port for your version very soon.
I am also considering making it a port option for this proposed port, the option
that would apply an extra patch.

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#        memtest86+
#        memtest86+/pkg-descr
#        memtest86+/files
#        memtest86+/files/pkg-message.in
#        memtest86+/files/patch-Makefile
#        memtest86+/files/patch-memtest.lds
#        memtest86+/files/patch-setup.S
#        memtest86+/files/patch-test.c
#        memtest86+/files/patch-error.c
#        memtest86+/distinfo
#        memtest86+/Makefile
#
echo c - memtest86+
mkdir -p memtest86+ > /dev/null 2>&1
echo x - memtest86+/pkg-descr
sed 's/^X//' >memtest86+/pkg-descr << '87f492dc64afaba6e391fa8cb6db43bf'
XStand alone memory test for x86 architecture computers
Xbased on the well-known original memtest86 written by
XChris Brady.
X
XWWW:    http://www.memtest.org/
87f492dc64afaba6e391fa8cb6db43bf
echo c - memtest86+/files
mkdir -p memtest86+/files > /dev/null 2>&1
echo x - memtest86+/files/pkg-message.in
sed 's/^X//' >memtest86+/files/pkg-message.in << 'd391f942bc4a3585ea4f4fd49ff3cc9c'
X===================================================
XThis port has installed ELF image of memtest86+ to
X%%BOOT_DIR%%/memtest86+
XYou can load it from from boot prompt by
Xinterrupting boot process and entering
XN:ad(M,a)%%BOOT_DIR%%/memtest86+
Xwhere N and M denote proper disk and slice numbers.
XSee boot(8) for details.
X
XAlternatively you can load the image from loader
Xprompt by escaping to it and entering the following
Xcommands:
Xunload
Xload %%BOOT_DIR%%/memtest86+
Xboot
XSee loader(8) for details.
X===================================================
d391f942bc4a3585ea4f4fd49ff3cc9c
echo x - memtest86+/files/patch-Makefile
sed 's/^X//' >memtest86+/files/patch-Makefile << '79e0f0dac01952c3c0aa5ae783c0c4a7'
X--- Makefile    2008-11-16 02:30:50.000000000 +0200
X+++ Makefile    2009-02-18 09:03:07.000000000 +0200
X@@ -23,15 +23,15 @@ all: memtest.bin memtest
X # symbols and then link it dynamically so I have full
X # relocation information
X memtest_shared: $(OBJS) memtest_shared.lds Makefile
X-       $(LD) --warn-constructors --warn-common -static -T memtest_shared.lds \
X+       $(LD) --warn-constructors --warn-common -static --oformat
elf32-i386-freebsd -T memtest_shared.lds \
X        -o $@ $(OBJS) && \
X-       $(LD) -shared -Bsymbolic -T memtest_shared.lds -o $@ $(OBJS)
X+       $(LD) -shared -Bsymbolic --oformat elf32-i386-freebsd -T
memtest_shared.lds -o $@ $(OBJS)
X
X memtest_shared.bin: memtest_shared
X        objcopy -O binary $< memtest_shared.bin
X
X memtest: memtest_shared.bin memtest.lds
X-       $(LD) -s -T memtest.lds -b binary memtest_shared.bin -o $@
X+       $(LD) -s --oformat elf32-i386-freebsd -T memtest.lds -b binary
memtest_shared.bin -o $@
X
X head.s: head.S config.h defs.h test.h
X        $(CC) -E -traditional $< -o $@
X@@ -58,7 +58,6 @@ clean:
X iso:
X        make all
X        ./makeiso.sh
X-       rm -f *.o *.s memtest.bin memtest memtest_shared memtest_shared.bin
X
X install: all
X        dd <memtest.bin >$(FDISK) bs=8192
79e0f0dac01952c3c0aa5ae783c0c4a7
echo x - memtest86+/files/patch-memtest.lds
sed 's/^X//' >memtest86+/files/patch-memtest.lds << 'ba00edfbd2b4dc4d36d3f4dce62a352d'
X--- memtest.lds 2008-11-16 02:18:14.000000000 +0200
X+++ memtest.lds 2009-02-18 00:24:22.000000000 +0200
X@@ -3,7 +3,7 @@
X
X ENTRY(_start);
X SECTIONS {
X-       . = 0x10000;
X+       . = 0xc0120000;
X        _start = . ;
X        .data : {
X                *(.data)
ba00edfbd2b4dc4d36d3f4dce62a352d
echo x - memtest86+/files/patch-setup.S
sed 's/^X//' >memtest86+/files/patch-setup.S << '1af268c970f623bfa2527da9052aa1d8'
X--- setup.S     2008-11-16 02:18:14.000000000 +0200
X+++ setup.S     2009-02-18 00:28:02.000000000 +0200
X@@ -42,7 +42,7 @@ start:
X        jz      alt_a20_done
X
X        /* set or clear bit1, the ALT_A20_GATE bit */
X-       movb    4(%esp), %ah
X+       addr32 movb     4(%esp), %ah
X        testb   %ah, %ah
X        jz      alt_a20_cont1
X        orb     $2, %al
1af268c970f623bfa2527da9052aa1d8
echo x - memtest86+/files/patch-test.c
sed 's/^X//' >memtest86+/files/patch-test.c << '868fad76cbe12388552b536bc2196eeb'
X--- test.c      2008-11-16 02:18:14.000000000 +0200
X+++ test.c      2009-02-18 00:27:11.000000000 +0200
X@@ -6,12 +6,11 @@
X  * ----------------------------------------------------
X  * MemTest86+ V2.01 Specific code (GPL V2.0)
X  * By Samuel DEMEULEMEESTER, sdemeule@memtest.org
X  * http://www.canardpc.com - http://www.memtest.org
X  */
X
X-#include "test.h"
X #include "config.h"
X-#include <sys/io.h>
X+#include "test.h"
X #include "dmi.h"
X
X extern int segs, bail;
X@@ -1400,6 +1399,20 @@ void sleep(int n, int sms)
X        }
X }
X
X+static inline unsigned char inb(unsigned int port)
X+{
X+        unsigned char data;
X+
X+        asm __volatile__("inb %1,%0" : "=a" (data) : "id" ((unsigned short)(port)));
X+        return (data);
X+}
X+
X+static inline void outb(unsigned int port, unsigned char data)
X+{
X+        asm __volatile__("outb %0,%1" : : "a" (data), "id" ((unsigned
short)(port)));
X+}
X+
X+
X /* Beep function */
X
X void beep(unsigned int frequency)
X@@ -1407,18 +1420,18 @@ void beep(unsigned int frequency)
X        unsigned int count = 1193180 / frequency;
X
X        // Switch on the speaker
X-       outb_p(inb_p(0x61)|3, 0x61);
X+       outb(inb(0x61)|3, 0x61);
X
X        // Set command for counter 2, 2 byte write
X-       outb_p(0xB6, 0x43);
X+       outb(0xB6, 0x43);
X
X        // Select desired Hz
X-       outb_p(count & 0xff, 0x42);
X+       outb(count & 0xff, 0x42);
X        outb((count >> 8) & 0xff, 0x42);
X
X        // Block for 100 microseconds
X        sleep(100, 1);
X
X        // Switch off the speaker
X-       outb(inb_p(0x61)&0xFC, 0x61);
X+       outb(inb(0x61)&0xFC, 0x61);
X }
868fad76cbe12388552b536bc2196eeb
echo x - memtest86+/files/patch-error.c
sed 's/^X//' >memtest86+/files/patch-error.c << 'a61494abd040e76825fee560b9abd7bd'
X--- error.c     2008-11-16 02:18:14.000000000 +0200
X+++ error.c     2009-02-18 00:27:40.000000000 +0200
X@@ -11,7 +11,6 @@
X
X #include "test.h"
X #include "config.h"
X-#include <sys/io.h>
X #include "dmi.h"
X
X extern int test_ticks, nticks, beepmode;
a61494abd040e76825fee560b9abd7bd
echo x - memtest86+/distinfo
sed 's/^X//' >memtest86+/distinfo << '7cd356ffd0fb9abb60e012f451021484'
XMD5 (memtest86+-2.11.tar.gz) = e457774139c0bfef899359df91f49b3e
XSHA256 (memtest86+-2.11.tar.gz) =
43876a7221e39cde791f20d04ecb071adfa08975cac2e511d04359619ce16c0e
XSIZE (memtest86+-2.11.tar.gz) = 165937
7cd356ffd0fb9abb60e012f451021484
echo x - memtest86+/Makefile
sed 's/^X//' >memtest86+/Makefile << '5bebcf008d84f9411fcb51a286638900'
X# New ports collection makefile for:    memtest86+
X# Date created:         2009-03-10
X# Whom:                 Andriy Gapon <avg@icyb.net.ua>
X#
X# $FreeBSD$
X#
X
XPORTNAME=               memtest86+
XPORTVERSION=            2.11
XCATEGORIES=             sysutils
XMASTER_SITES=           http://www.memtest.org/download/${PORTVERSION}/
X
XMAINTAINER=             avg@icyb.net.ua
XCOMMENT=                Stand-alone memory test for x86 architecture computers
X
XUSE_GMAKE=              yes
XALL_TARGET=             all
X
XONLY_FOR_ARCHS=         i386 amd64
X
XBOOT_DIR=               /boot/opt
X
XOPTIONS=                ISO     "Build bootable ISO image" off \
X                        BOOT    "Build ELF image loadable by boot2 and loader" on
X
X.include <bsd.port.pre.mk>
X
X.if defined(WITHOUT_ISO) && defined(WITHOUT_BOOT)
XIGNORE=                 nothing to build: neither ISO nor BOOT selected
X.endif
X
XPORTDOCS=               README
XSUB_FILES=              pkg-message
XSUB_LIST+=              BOOT_DIR=${BOOT_DIR}
X
X.if defined(WITH_ISO)
XALL_TARGET+=            iso
XPLIST_DIRS+=            %%DATADIR%%
XPLIST_FILES+=           %%DATADIR%%/mt${PORTVERSION:C/\.//}.iso
X.endif
X.if defined(WITH_BOOT)
XPLIST_DIRS+=            ${BOOT_DIR}
XPLIST_FILES+=           ${BOOT_DIR}/memtest86+
X.endif
X
Xpre-fetch:
X.if !defined(PACKAGE_BUILDING)
X        @${ECHO} "If you only need bootable ISO image of memtest86+,"
X        @${ECHO} "you can simply download it from http://www.memtest.org/."
X        @${ECHO} "Use this port if you need ELF image of memtest86+"
X        @${ECHO} "that can be loaded by boot2 or loader(8),"
X        @${ECHO} "or if you want to use this port to build ISO image"
X        @${ECHO} "with custom tweaks in memtest86+ code."
X.endif
X
Xdo-install:
X.if defined(WITH_ISO)
X        @${MKDIR} ${DATADIR}
X        ${INSTALL_DATA} ${WRKSRC}/mt${PORTVERSION:C/\.//}.iso ${DATADIR}/
X.endif
X.if defined(WITH_BOOT)
X        @${MKDIR} ${BOOT_DIR}
X        ${INSTALL_KLD} ${WRKSRC}/memtest ${BOOT_DIR}/memtest86+
X.endif
X.if !defined(NOPORTDOCS)
X        @${MKDIR} ${DOCSDIR}
X.for i in ${PORTDOCS}
X        ${INSTALL_DATA} ${WRKSRC}/${i} ${DOCSDIR}
X.endfor
X.endif
X
Xpost-install:
X.if defined(WITH_BOOT)
X        @${CAT} ${PKGMESSAGE}
X.endif
X
X.include <bsd.port.post.mk>
5bebcf008d84f9411fcb51a286638900
exit


-- 
Andriy Gapon



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?49B6A827.50705>