Date: Wed, 04 Oct 95 08:43:15 GMT From: "gj%pcs.dec.com@inet-gw-1.pa.dec.com" <garyj@rks32.pcs.dec.com> To: hackers%freebsd.org@inet-gw-1.pa.dec.com Cc: jkh%freebsd.org@inet-gw-1.pa.dec.com Subject: patches to kzipboot and kzip Message-ID: <m0t0PQ4-0005OqC@rks32.pcs.dec.com>
next in thread | raw e-mail | index | archive | help
appended are patches to kzipboot and kzip to allow uncompressing the
gzip'ed kernel image over itself.
I've tested this on a 4 MB machine using a MFSKERNEL provided to me by
Jordan and it worked. It was possible to finally do an install of a SNAP
on the machine.
Gary J.
++++ patches for /sys/i386/boot/kzipboot ++++
*** Makefile.orig Tue Oct 3 12:23:49 1995
--- Makefile Tue Oct 3 21:27:35 1995
***************
*** 2,8 ****
PROG= kzip.o
BINMODE = 444 # target is a relocatable object
! SRCS= head.S boot.c unzip.c misc.c malloc.c inflate.c
BINDIR= /usr/lib
.PATH: ${.CURDIR}/../../../kern
NOMAN= toobad
--- 2,11 ----
PROG= kzip.o
BINMODE = 444 # target is a relocatable object
! SRCS= kzhead.S head.S boot.c unzip.c misc.c malloc.c inflate.c
!
! KOBJS= head.o boot.o unzip.o misc.o malloc.o inflate.o
!
BINDIR= /usr/lib
.PATH: ${.CURDIR}/../../../kern
NOMAN= toobad
***************
*** 18,24 ****
CFLAGS+= -DKADDR=$(KADDR) -DCSEG=$(CSEG)
CFLAGS+= -DKZIP -DCOMCONSOLE=0x3F8
! kzip.o: ${OBJS}
! $(LD) -r -x -o kzip.o $(OBJS)
.include <bsd.prog.mk>
--- 21,31 ----
CFLAGS+= -DKADDR=$(KADDR) -DCSEG=$(CSEG)
CFLAGS+= -DKZIP -DCOMCONSOLE=0x3F8
! beforeinstall:
! install -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
! ${.CURDIR}/obj/kzhead.o ${DESTDIR}${BINDIR}/kzhead.o
!
! kzip.o: ${KOBJS}
! $(LD) -r -x -o kzip.o $(KOBJS)
.include <bsd.prog.mk>
*** head.S.orig Tue Oct 3 21:24:10 1995
--- head.S Tue Oct 3 22:06:42 1995
***************
*** 3,12 ****
* Copyright (C) Serge Vakulenko
*/
.text
start:
! cli # disable interrupts
pushl 4(%esp) # pass howto arg
call _boot # unpack the kernel image
popl %eax # discard howto arg
ljmp $CSEG, $KADDR # jump to unpacked kernel
- . = start + 0x500 # skip over warm boot shit
--- 3,12 ----
* Copyright (C) Serge Vakulenko
*/
.text
+ .globl start
start:
! popl %eax # discard return from kzstart
pushl 4(%esp) # pass howto arg
call _boot # unpack the kernel image
popl %eax # discard howto arg
ljmp $CSEG, $KADDR # jump to unpacked kernel
*** kzhead.S.orig Tue Oct 3 22:31:56 1995
--- kzhead.S Tue Oct 3 22:36:27 1995
***************
*** 0 ****
--- 1,11 ----
+ /*
+ * Boot unpacker startup routine.
+ * this just jumps around the gzip'ed kernel
+ * image to the real startup routine.
+ */
+ .text
+ kzstart:
+ cli
+ # it seems like this should be possible using a jmp
+ call start # unpack the kernel image
+ . = kzstart + 0x500 # skip over warm boot shit
++++ patches for /usr/src/usr.bin/kzip ++++
*** Makefile.orig Tue Oct 3 12:35:36 1995
--- Makefile Tue Oct 3 22:28:42 1995
***************
*** 3,9 ****
PROG= kzip
NOMAN= toobad
! # Where we load the compressed stuff to uncompress it
! CFLAGS+= -DKZBASE=\"0x300000\"
.include <bsd.prog.mk>
--- 3,9 ----
PROG= kzip
NOMAN= toobad
! # Where the kernel runs, used as a base to calculate the load address
! CFLAGS+= -DKZBASE=0x100000
.include <bsd.prog.mk>
*** kzip.c.orig Tue Oct 3 12:34:37 1995
--- kzip.c Tue Oct 3 22:27:43 1995
***************
*** 18,23 ****
--- 18,25 ----
#include <unistd.h>
#include <sys/file.h>
#include <sys/types.h>
+ #include <sys/stat.h>
+ #include <sys/param.h>
#include <sys/wait.h>
#include <a.out.h>
#include <string.h>
***************
*** 33,38 ****
--- 35,45 ----
pid_t Pext, Pgzip, Ppiggy, Pld;
int pipe1[2], pipe2[2];
int status,fdi,fdo;
+ int size;
+ struct exec hdr;
+ int zip_size, offset;
+ char addr [10];
+ struct stat st;
char obj[BUFSIZ];
char out[BUFSIZ];
***************
*** 59,64 ****
--- 66,86 ----
if (pipe(pipe2) < 0) { perror("pipe()"); return 1; }
+ /* figure out how big the uncompressed image will be */
+ if (read (fdi, (char *)&hdr, sizeof(hdr)) != sizeof(hdr)) {
+ perror(argv[1]);
+ exit(2);
+ }
+
+ size = N_SYMOFF (hdr) - N_TXTOFF (hdr);
+
+ lseek (fdi, 0, SEEK_SET);
+
Pext = fork();
if (Pext < 0) { perror("fork()"); return 1; }
if (!Pext) {
***************
*** 123,128 ****
--- 145,156 ----
return 3;
}
+ /* a kludge to dynamically figure out where to start it */
+ stat (obj, &st);
+ zip_size = (int)st.st_size;
+ offset = KZBASE + size - zip_size + 0x2000; /* fudge factor */
+ sprintf(addr, "0x%x", roundup(offset, 4096));
+
Pld = fork();
if (Pld < 0) { perror("fork()"); return 1; }
if (!Pld) {
***************
*** 131,141 ****
"-Bstatic",
"-Z",
"-T",
! KZBASE,
"-o",
out,
! "/usr/lib/kzip.o",
obj,
0);
exit(2);
}
--- 159,170 ----
"-Bstatic",
"-Z",
"-T",
! addr,
"-o",
out,
! "/usr/lib/kzhead.o",
obj,
+ "/usr/lib/kzip.o",
0);
exit(2);
}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?m0t0PQ4-0005OqC>
