diff options
Diffstat (limited to 'gpxe/contrib/mkQNXnbi')
-rw-r--r-- | gpxe/contrib/mkQNXnbi/Makefile | 10 | ||||
-rw-r--r-- | gpxe/contrib/mkQNXnbi/README | 36 | ||||
-rw-r--r-- | gpxe/contrib/mkQNXnbi/examples/bootptab | 29 | ||||
-rw-r--r-- | gpxe/contrib/mkQNXnbi/examples/ws.etherboot | 22 | ||||
-rw-r--r-- | gpxe/contrib/mkQNXnbi/examples/ws.etherboot.on-the-fly | 22 | ||||
-rw-r--r-- | gpxe/contrib/mkQNXnbi/mkQNXnbi.c | 196 |
6 files changed, 315 insertions, 0 deletions
diff --git a/gpxe/contrib/mkQNXnbi/Makefile b/gpxe/contrib/mkQNXnbi/Makefile new file mode 100644 index 00000000..4f6c0f2a --- /dev/null +++ b/gpxe/contrib/mkQNXnbi/Makefile @@ -0,0 +1,10 @@ +# Makefile for the mkQNXnbi filter + +all: mkQNXnbi + +mkQNXnbi: mkQNXnbi.o + +mkQNXnbi.o: mkQNXnbi.c + +clean: + rm -f mkQNXnbi *.o diff --git a/gpxe/contrib/mkQNXnbi/README b/gpxe/contrib/mkQNXnbi/README new file mode 100644 index 00000000..1522df31 --- /dev/null +++ b/gpxe/contrib/mkQNXnbi/README @@ -0,0 +1,36 @@ +mkQNXnbi is a quick hack to generate tagged images from QNX boot images. + +To boot a QNX client with Etherboot you have to consider the following: +1. You MUST have another QNX box running in the network to provide the + root filesystem and the license info to the client. QNX cannot use + e.g. NFS for its root filesystem, as it needs to load a valid license + from a file on the root fs before being able to start TCP/IP. This + would lead to a chicken-and-egg problem. +2. The Net task normally determines the size of its internal tables from + the actual number of licensed nodes. Since this information is not + available at boot time when booting from the network, you will have + to set the max. number of nodes as well as a valid netmap entry for + the node providing the root filesystem as an option to Net in the + build file. + See examples/ws.etherboot and fill in the <blanks>. +3. The client does not need a TCP/IP license in order to boot. +4. You can use the boot-server OS of your choice. If you choose to use + QNX as boot server, the server of course needs a TCP/IP run-time + license. In this case you have the option of creating the boot image + on-the-fly and use the macro $(netmap) instead of a hard-coded MAC + address. + See examples/ws.etherboot.on-the-fly and fill in the <blanks>. + A template bootptab for the QNX bootp server is placed in the + examples directory. +5. mkQNXnbi expects the QNX image to be supplied on stdin and generates + the tagged image to stdout. This can be overridden on the command line + using the options -i <input-file> and -o <output-file>. + +mkQNXnbi can be compiled using e.g. Linux/gcc or on QNX using Watcom C +(or gcc, if you have it - see http://w3c.teaser.fr/~jcmichot/) + +Bug-reports to <al@alarsen.net> + +2002-01-25 +Anders Larsen +<al@alarsen.net> diff --git a/gpxe/contrib/mkQNXnbi/examples/bootptab b/gpxe/contrib/mkQNXnbi/examples/bootptab new file mode 100644 index 00000000..2077fa94 --- /dev/null +++ b/gpxe/contrib/mkQNXnbi/examples/bootptab @@ -0,0 +1,29 @@ +# /etc/bootptab: database for QNX bootp server (/etc/bootpd) + +# First, we define a global entry which specifies the stuff every host uses. +global:\ + :hd=/boot:\ + :ht=ethernet:\ + :sm=<your netmask here>:\ + :bf=|cd /boot; buildqnx -b 0x10000 build/<your build-file here> | mkQNXnbi:\ + :hn: + +# node 2 uses the default build-file +node2:\ + :tc=global:\ + :ha=<your MAC here>:\ + :ip=<your IP address here>: + +# node 3 uses its own build-file +node3:\ + :tc=global:\ + :ha=<your MAC here>:\ + :ip=<your IP address here>:\ + :bf=|cd /boot; buildqnx -b 0x10000 build/<your build-file here> | mkQNXnbi: + +# node 4 uses a pre-built boot image +node3:\ + :tc=global:\ + :ha=<your MAC here>:\ + :ip=<your IP address here>:\ + :bf=images/<your image-file here>: diff --git a/gpxe/contrib/mkQNXnbi/examples/ws.etherboot b/gpxe/contrib/mkQNXnbi/examples/ws.etherboot new file mode 100644 index 00000000..d8120bc8 --- /dev/null +++ b/gpxe/contrib/mkQNXnbi/examples/ws.etherboot @@ -0,0 +1,22 @@ +# /boot/build/ws.etherboot + +sys/boot +$ boot -v + +sys/Proc32 +$ Proc32 -l <target node number> + +sys/Slib32 +$ Slib32 + +sys/Slib16 +$ Slib16 + +/bin/Net +$ Net -n <highest QNX node number in network> -m "<node number of boot server> 1 <MAC of boot server node here>" + +/bin/Net.<network driver> +$ Net.<network driver> + +/bin/sinit +$ sinit -r //<node number of boot server>/ TERM=<your terminal emulation {QNX|qansi}> diff --git a/gpxe/contrib/mkQNXnbi/examples/ws.etherboot.on-the-fly b/gpxe/contrib/mkQNXnbi/examples/ws.etherboot.on-the-fly new file mode 100644 index 00000000..3058c450 --- /dev/null +++ b/gpxe/contrib/mkQNXnbi/examples/ws.etherboot.on-the-fly @@ -0,0 +1,22 @@ +# /boot/build/ws.etherboot.on-the-fly + +sys/boot +$ boot -v + +sys/Proc32 +$ Proc32 -l $(lnode) + +sys/Slib32 +$ Slib32 + +sys/Slib16 +$ Slib16 + +/bin/Net +$ Net -n <highest QNX node number in network> -m $(netmap) + +/bin/Net.<network driver> +$ Net.<network driver> + +/bin/sinit +$ sinit -r //$(bnode)/ TERM=<your terminal emulation {QNX|qansi}> diff --git a/gpxe/contrib/mkQNXnbi/mkQNXnbi.c b/gpxe/contrib/mkQNXnbi/mkQNXnbi.c new file mode 100644 index 00000000..2ec2dc4b --- /dev/null +++ b/gpxe/contrib/mkQNXnbi/mkQNXnbi.c @@ -0,0 +1,196 @@ +//***************************************************************************** +// +// Purpose: Make a boot-image for EtherBoot +// +// +// Compiler: This source can be compiled with gcc and Watcom C +// +// +// Note: The QNX boot image can be build with any reasonable +// start address, e.g. 0x1000 (default) or 0x10000 +// (widespread Boot-Rom address) +// +// +// Author: Anders Larsen +// +// +// Copyright: (C) 1999 by +// +// Anders Larsen +// systems engineer +// Gutleuthausstr. 3 +// D-69469 Weinheim +// Germany +// phone: +49-6201-961717 +// fax: +49-6201-961718 +// e-mail: al@alarsen.net +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// +//----------------------------------------------------------------------------- +// +// Change Log: +// V0.2: Sun 1999-12-13 Anders Larsen <al@alarsen.net> +//***************************************************************************** + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <sys/types.h> + + +// max. size of QNX OS boot image is 512K +#define MAXSIZE (512*1024) + +typedef unsigned short ushort_t; +typedef unsigned long ulong_t; + + +// global header of tagged image: +struct initial_t +{ + ulong_t magic; + ulong_t length; + ulong_t location; + ulong_t start; +}; + + +// header of each image: +struct header_t +{ + ulong_t flags; + ulong_t loadaddr; + ulong_t imgsize; + ulong_t memsize; +}; + + +// global header of the QNX EtherBoot image: +struct qnx_loader_t +{ + struct initial_t setup; + struct header_t qnx; +}; + + +// global header: +union +{ + struct qnx_loader_t h; + char filler[512]; +} header; + + +char buffer[MAXSIZE]; + + +int usage( char* const* argv ) +{ + fprintf( stderr, "%s - make a tagged boot image for EtherBoot\n", *argv ); + fprintf( stderr, "\nuse:\n" ); + fprintf( stderr, "%s [ -<option> ]*\n", *argv ); + fprintf( stderr, "\noptions:\n" ); + fprintf( stderr, " i <input file> : QNX boot file (default: stdin)\n" ); + fprintf( stderr, " o <output file> : tagged image file (default: stdout)\n" ); + fprintf( stderr, " v : be verbose\n" ); + return EXIT_FAILURE; +} + +#ifdef __USAGE +%C - make a tagged boot image for EtherBoot + +use: +%C [ -<option> ]* + +options: + i <input file> : QNX boot file (default: stdin) + o <output file> : tagged image file (default: stdout) + v : be verbose +#endif + + +int main( int argc, char* const* argv ) +{ + int ch, l; + int verbose = 0; + + while ( ( ch = getopt( argc, argv, "hi:o:v" ) ) != EOF ) + switch ( ch ) + { + case 'i': + if ( !freopen( optarg, "r", stdin ) ) + { + perror( "can't open input file" ); + return EXIT_FAILURE; + } + break; + + case 'o': + if ( !freopen( optarg, "w", stdout ) ) + { + perror( "can't create output file" ); + return EXIT_FAILURE; + } + break; + + case 'v': + verbose++; + break; + + case 'h': + default: + return usage( argv ); + } + if ( optind != argc ) + return usage( argv ); + + memset( &header, 0, sizeof header ); + header.h.setup.magic = 0x1b031336; // magic number + header.h.setup.length = 4; + header.h.setup.location = 0x93e00000; // just below the EtherBoot rom + header.h.setup.start = 0; // filled in dynamically + header.h.qnx.flags = 0x04000004; // single image only + header.h.qnx.loadaddr = 0; // filled in dynamically + header.h.qnx.imgsize = 0; // filled in dynamically + header.h.qnx.memsize = 0; // filled in dynamically + + // read the QNX image from stdin: + for ( ; ( l = fread( buffer + header.h.qnx.imgsize, 1, 1024, stdin ) ) > 0; + header.h.qnx.imgsize += l + ) + ; + header.h.qnx.memsize = header.h.qnx.imgsize; + + // fill in the real load-address of the QNX boot image: + header.h.setup.start = *(ushort_t*)&buffer[10] << 16; + header.h.qnx.loadaddr = *(ushort_t*)&buffer[10] << 4; + + // write the tagged image file to stdout: + fwrite( &header, 1, 512, stdout ); + fwrite( buffer, 1, header.h.qnx.imgsize, stdout ); + + if ( verbose ) + { + // print diagnostic information: + fprintf( stderr, "QNX image size: %d bytes (%dK), load addr: 0x%05X\n", + header.h.qnx.imgsize, + header.h.qnx.imgsize / 1024, + header.h.qnx.loadaddr + ); + } + return EXIT_SUCCESS; +} |