Generating a 12M kernel

Markus Wild wild at nessie.cs.id.ethz.ch
Sat Apr 20 05:50:51 AEST 1991


If you thought like I did, that 8M is rather tight when running X, and
16M is more you usually need, so if you missed a 12M-kernel like 
I did, read on.

The following two programs help you analize the differences of your
kernels (you don't need to analize the kernels if you're using
either Release Beta3j or 1.1, I checked with both) and generate a
12M-kernel out of these differences. Please read the instructions
at the beginning of the programs on how to generate the kernel.

PLEASE: keep in mind that you are manipulating the heart of your
system, if something goes wrong, you might have to reboot from floppy
to reinstall the old kernel, so please take care!

How it works: Well, first was 'cmpcmp', which shows that all differences
between the various kernels only differ in the highest two bits. Those
two bits are characteristic for the memory size of the kernel. So after
a few comparisons between different kernels, it was quite obvious, which
bit-combination was missing, the 12M combination. All that now has to
be done is feeding the list of differences (as obtained from cmp -l) to
a program, that changes those two bits to the size you want at the offsets
in the kernel obtained from cmp. A program that does this is 'kernelpatch'.

Good luck, my system now shows ~10M of RAM available, this is enough
for me;-)

-Markus


PS: sorry, the disk with "shar" is currently not mounted...

>-------------------- cmpcmp.c --------------------------------------------<

/*
 * cmpcmp.c
 *
 * V1.0 (C) 1991 by Markus Wild. Use or abuse, I don't care.
 *
 * DISCLAIMER: What ever happens to you, your hardware, or whatever by
 *             using this program, it's only your business, not mine!
 *
 * This program analizes the output of a "cmp -l" of two kernels for
 * different memory sizes. If you want to apply "kernelpatch" to your
 * kernel, you should first check with this program, whether the kernels
 * meet the criteria for kernelpatch to work. This is done as follows:
 * 1) cd /stand
 * 2) cmp -l A3000unix A3008unix | cmpcmp
 * cmpcmp should now output 2 or 3 lines. Lines starting with 7 and 8
 * can be ignored, this is the COFF-timestamp and will naturally differ
 * between kernels. There should (besides the mentioned timestamp diffs)
 * only be *one* line more, and this line should show a value of
 * 0000, 0100, 0200 or 0300, depending on which two kernels you used for
 * the comparison. If all is ok so far, you may try your luck with
 * kernelpatch ;-)
 *
 ***************************************************************************/

#include <stdio.h>

main()
{
  int off, val1, val2;
  int last_diff = -1, diff;

  while (!feof (stdin))
    {
      scanf ("%d %o %o\n", &off, &val1, &val2);
      diff = val1 ^ val2;
      
      if (diff != last_diff)
	{
	  printf ("$%lx: %d = $%x = 0%o\n", off, diff, diff, diff);
	  last_diff = diff;
	}
    }
}

      
>-------------------- kernelpatch.c ---------------------------------------<

/*
 * kernelpatch.c (generate a 12M-A3000-UX-kernel from the given ones)
 *
 * V1.0 (C) 1991 by Markus Wild. Use or abuse, I don't care.
 *
 * DISCLAIMER: What ever happens to you, your hardware, or whatever by
 *             using this program, it's only your business, not mine!
 *
 * Use as follows:
 * 1) Check with "cmpcmp", whether your kernel meets the criteria for this
 *    program to work
 * 2) Copy one of the A30??unix kernels to A3012unix (all in /stand)
 * 3) Issue (while running sh, ksh or bash, but not csh !):
 *    cd /stand
 *    cmp -l A3000unix A3008unix | (read a; read a; kernelpatch A3012unix 12)
 *    (the two "read a" skip the timestamp-cmp, you can omit them if you want)
 * 4) Copy the new kernel to your boot-partition:
 *    cat coffboot A3012unix >/dev/dsk/c{your-scsi-id}d0s{your-partition-num}
 *    eg: bootpartition is on scsi-unit 3, the 6th partition: /dev/dsk/c3d0s6
 * 5) Link /unix to the new kernel: ln /stand/A3012unix /unix
 * 6) Reboot, good luck!
 *
 ***************************************************************************/

#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <stdio.h>

typedef unsigned char ubyte;

main (int argc, char *argv[])
{
  int off, fd, meg, mask;
  struct stat stb;

  if (argc != 3)
    {
      printf ("%s kernel num_meg\n", *argv);
      exit(1);
    }

  meg = atoi(argv[2]);

  switch (meg)
    {
    case 4:
      mask = 0300;
      break;

    case 8:
      mask = 0200;
      break;

    case 12:
      mask = 0100;
      break;

    case 16:
      mask = 0000;
      break;

    default:
      printf ("Unsupported memory size!\n");
      exit (1);
    }

  if ((fd = open (argv[1], 2)) >= 0)
    {
      ubyte *kernel;

      if (fstat (fd, &stb) == -1)
	{
	  perror ("fstat");
	  exit (1);
	}

      if ((kernel = mmap (0, stb.st_size, PROT_READ|PROT_WRITE, 
		       MAP_SHARED, fd, 0)) != (ubyte *)-1)
	{
	  while (!feof (stdin))
	    {
	      int dummy1, dummy2;

	      scanf ("%d %o %o\n", &off, &dummy1, &dummy2);
	      off--;

	      kernel [off] &= ~0300;
	      kernel [off] |= mask;
	    }
	}
      else
	perror ("mmap");

      close (fd);
    }
  return 0;
}
-- 
Markus M. Wild    - mwild at iiic.ethz.ch  |  wild at nessie.cs.id.ethz.ch
--
Insert your favorite $(cooky) here...



More information about the Comp.unix.amiga mailing list