Use objcopy to build ramdisk object
. during build, uses much less memory, disk space, and time . lets us throw out bintoc
This commit is contained in:
parent
5a645f22a8
commit
ab0a67f7af
@ -1,6 +1,7 @@
|
|||||||
# Makefile for memory driver (MEMORY)
|
# Makefile for memory driver (MEMORY)
|
||||||
PROG= memory
|
PROG= memory
|
||||||
SRCS= memory.c imgrd.c
|
SRCS= memory.c imgrd.mfs
|
||||||
|
OBJS= ${SRCS:N*.h:R:S/$/.o/g}
|
||||||
|
|
||||||
DPADD+= ${LIBBLOCKDRIVER} ${LIBCHARDRIVER} ${LIBSYS}
|
DPADD+= ${LIBBLOCKDRIVER} ${LIBCHARDRIVER} ${LIBSYS}
|
||||||
LDADD+= -lblockdriver -lchardriver -lsys
|
LDADD+= -lblockdriver -lchardriver -lsys
|
||||||
@ -10,6 +11,22 @@ MAN=
|
|||||||
BINDIR?= /usr/sbin
|
BINDIR?= /usr/sbin
|
||||||
|
|
||||||
CPPFLAGS.memory.c+= -I${MINIXSRCDIR}
|
CPPFLAGS.memory.c+= -I${MINIXSRCDIR}
|
||||||
CPPFLAGS.imgrd.c+= -I${.CURDIR}/../ramdisk
|
|
||||||
|
imgrd.d: touch-genfiles
|
||||||
|
touch-genfiles:
|
||||||
|
[ -e ../ramdisk/image ] || touch -t 197001020000.00 ../ramdisk/image
|
||||||
|
|
||||||
|
|
||||||
|
.SUFFIXES: .mfs .c .o
|
||||||
|
|
||||||
|
# 'elf32-${ARCH}-minix' below should really be ${MACHINE_GNU_PLATFORM}
|
||||||
|
# but bsd.own.mk has to be upgraded for that.
|
||||||
|
.mfs.o:
|
||||||
|
${_MKTARGET_CREATE}
|
||||||
|
${OBJCOPY} -Ibinary -B${ARCH} -Oelf32-${ARCH}-minix $< $@
|
||||||
|
|
||||||
|
imgrd.mfs:
|
||||||
|
ln -s ../ramdisk/image $@
|
||||||
|
CLEANFILES+= imgrd.mfs
|
||||||
|
|
||||||
.include <minix.bootprog.mk>
|
.include <minix.bootprog.mk>
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
Ramdisk that is part of the image
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#include "local.h"
|
|
||||||
|
|
||||||
unsigned char imgrd[]=
|
|
||||||
{
|
|
||||||
#include "image.c"
|
|
||||||
};
|
|
||||||
|
|
||||||
size_t imgrd_size= sizeof(imgrd);
|
|
@ -2,5 +2,8 @@
|
|||||||
local defines and declarations
|
local defines and declarations
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern unsigned char imgrd[];
|
extern unsigned char _binary_imgrd_mfs_start[], *_binary_imgrd_mfs_end;
|
||||||
extern size_t imgrd_size;
|
|
||||||
|
#define imgrd _binary_imgrd_mfs_start
|
||||||
|
#define imgrd_size \
|
||||||
|
((size_t)(_binary_imgrd_mfs_end - _binary_imgrd_mfs_start))
|
||||||
|
@ -23,19 +23,11 @@ PROTO= proto.small
|
|||||||
EXTRA=system.conf master.passwd passwd pwd.db spwd.db rs.single
|
EXTRA=system.conf master.passwd passwd pwd.db spwd.db rs.single
|
||||||
|
|
||||||
CPPFLAGS+= -I${MINIXSRCDIR}/servers -I${MINIXSRCDIR}
|
CPPFLAGS+= -I${MINIXSRCDIR}/servers -I${MINIXSRCDIR}
|
||||||
CLEANFILES += $(PROGRAMS) $(SCRIPTS) $(EXTRA) bintoc image image.c t proto.gen
|
CLEANFILES += $(PROGRAMS) $(SCRIPTS) $(EXTRA) image image.c t proto.gen
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
|
|
||||||
realall: image.c
|
realall: image
|
||||||
|
|
||||||
image.c: bintoc image
|
|
||||||
./bintoc -o $@ image
|
|
||||||
|
|
||||||
# Note for cross compilation: this executable has to be compiled for the
|
|
||||||
# host system
|
|
||||||
bintoc: bintoc.c
|
|
||||||
$(CC) -o $@ bintoc.c
|
|
||||||
|
|
||||||
image: proto.gen mtab rc $(EXTRA)
|
image: proto.gen mtab rc $(EXTRA)
|
||||||
mkfs.mfs image proto.gen || { rm -f image; false; }
|
mkfs.mfs image proto.gen || { rm -f image; false; }
|
||||||
|
@ -1,129 +0,0 @@
|
|||||||
/*
|
|
||||||
bintoc.c
|
|
||||||
|
|
||||||
Convert a (binary) file to a series of comma separated hex values suitable
|
|
||||||
for initializing a character array in C.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define _POSIX_C_SOURCE 2
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
static char *progname;
|
|
||||||
static unsigned char buf[1024];
|
|
||||||
|
|
||||||
static void fatal(char *fmt, ...);
|
|
||||||
static void usage(void);
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
int c, i, r, first;
|
|
||||||
FILE *file_in, *file_out;
|
|
||||||
char *in_name;
|
|
||||||
char *o_arg;
|
|
||||||
|
|
||||||
(progname=strrchr(argv[0],'/')) ? progname++ : (progname=argv[0]);
|
|
||||||
|
|
||||||
o_arg= NULL;
|
|
||||||
while (c= getopt(argc, argv, "?o:"), c != -1)
|
|
||||||
{
|
|
||||||
switch(c)
|
|
||||||
{
|
|
||||||
case '?': usage();
|
|
||||||
case 'o': o_arg= optarg; break;
|
|
||||||
default: fatal("getopt failed: '%c'\n", c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (o_arg)
|
|
||||||
{
|
|
||||||
file_out= fopen(o_arg, "w");
|
|
||||||
if (file_out == NULL)
|
|
||||||
{
|
|
||||||
fatal("unable to create '%s': %s\n",
|
|
||||||
o_arg, strerror(errno));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
file_out= stdout;
|
|
||||||
|
|
||||||
if (optind < argc)
|
|
||||||
{
|
|
||||||
in_name= argv[optind];
|
|
||||||
optind++;
|
|
||||||
file_in= fopen(in_name, "r");
|
|
||||||
if (file_in == NULL)
|
|
||||||
{
|
|
||||||
fatal("unable to open '%s': %s",
|
|
||||||
in_name, strerror(errno));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
in_name= "(stdin)";
|
|
||||||
file_in= stdin;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (optind != argc)
|
|
||||||
usage();
|
|
||||||
|
|
||||||
first= 1;
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
r= fread(buf, 1, sizeof(buf), file_in);
|
|
||||||
if (r == 0)
|
|
||||||
break;
|
|
||||||
for (i= 0; i<r; i++)
|
|
||||||
{
|
|
||||||
if ((i % 8) == 0)
|
|
||||||
{
|
|
||||||
if (first)
|
|
||||||
{
|
|
||||||
fprintf(file_out, "\t");
|
|
||||||
first= 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
fprintf(file_out, ",\n\t");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
fprintf(file_out, ", ");
|
|
||||||
fprintf(file_out, "0x%02x", buf[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ferror(file_in))
|
|
||||||
{
|
|
||||||
fatal("read error on %s: %s\n",
|
|
||||||
in_name, strerror(errno));
|
|
||||||
}
|
|
||||||
fprintf(file_out, "\n");
|
|
||||||
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void fatal(char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
fprintf(stderr, "%s: ", progname);
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vfprintf(stderr, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
fprintf(stderr, "\n");
|
|
||||||
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void usage(void)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Usage: bintoc [-o <out-file>] [<in-file>]\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
@ -90,11 +90,12 @@ hdboot: image
|
|||||||
cp $$i $$newname; \
|
cp $$i $$newname; \
|
||||||
if [ -d /boot/image ]; \
|
if [ -d /boot/image ]; \
|
||||||
then ln -f $$newname /boot/`basename $$i`; \
|
then ln -f $$newname /boot/`basename $$i`; \
|
||||||
else gzip $$newname; \
|
else strip -s $$newname; \
|
||||||
|
gzip $$newname; \
|
||||||
fi \
|
fi \
|
||||||
done
|
done
|
||||||
cp ../kernel/kernel /boot/minix/.temp/
|
cp ../kernel/kernel /boot/minix/.temp/
|
||||||
strip -s /boot/minix/.temp/*
|
strip -s /boot/minix/.temp/kernel
|
||||||
[ -d /boot/image ] && ln -f /boot/minix/.temp/kernel /boot/kernel || true
|
[ -d /boot/image ] && ln -f /boot/minix/.temp/kernel /boot/kernel || true
|
||||||
sh mkboot $@ minix
|
sh mkboot $@ minix
|
||||||
exec sh update_bootcfg.sh
|
exec sh update_bootcfg.sh
|
||||||
|
Loading…
x
Reference in New Issue
Block a user