Jolix
/joh'liks/ n.,adj. 386BSD

PORTING UNIX TO THE 386: A PRACTICAL APPROACH


William & Lynne Jolitz


Its not enough just to load the kernel and go, you need to insure its the kernel bit-for-bit by the time you run it.




Consistency Checks
Loading this large array of data containing the programs to be executed is a complex task, because many different 64K segments may be used. A "fence-post" error arising from incorrectly maintained far pointers can lead to unpredictable results when the protected mode program runs. Therefore, to verify that the program contents are loaded correctly, we use a simple checksum just before we dispatch to it in protected mode (see "Unix Kernel Load Program", boot.c).

Checksum section of Listing 1, Unix Kernel Load Utility: 'boot.exe' (file: boot.c)
...
/* 16 bit checksum of program. */
far_cksum(base, len) long len; char far *base; {
    char far *tmp;
    unsigned seg,offs ;
    long nbytes,sum, tlen;
    tmp = base;
    sum = 0;
    nbytes = 0;
    while (len) {
               /* normalize far pointer to handle segment rollover case */
          tmp = normalize(tmp);

               /* Do a page at a time */
           tlen = (len > PGSIZE)? PGSIZE : len;
          len -= tlen ;
          while (tlen--) {
         nbytes++;
         if (sum&01)
            sum = (sum>>1) + 0x8000;
         else
            sum >>= 1;
         sum += *tmp++ ;
         sum &= 0xFFFF;
           }
   }
    printf("\nChecksum %05lu%6ld ", sum, (nbytes+CLSIZE)/PGSIZE);
}
...

[ Learned a lesson with the 2BSD kernel back in the early 80's - be careful with bootstrap artifacts. Let someone else develop a new bootstrap which "seemed to work", but months later after the bootstrap was forgotten, the kernel started acting up. Had assumed that the problem was the new features and radical changes underway, so we withdrew them relentlessly. Sometimes it would work, sometimes not.

Burned out on this with regression tests, and ended up going off to a Unix Conference in Texas telling the audience the release was delayed. Months later, I find out that it was a bootstrap artifact, where portions of the kernel were overwritten by the bootstrap loading it.

In every port this would come up. Software systems are fragile, especially at the beginning. -wfj ]



<<BACK NEXT >>



Copyright 1989, 1990, 2006 TeleMuse Partners, William Jolitz and Lynne Jolitz