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

PORTING UNIX TO THE 386: A PRACTICAL APPROACH


William & Lynne Jolitz


Requirements for a DOS PC Utility to boot a 386BSD UNIX kernel.




The First PC Utility: boot.exe

The First PC Utility: boot.exe

main() {
int fi;
struct exec hdr;

    fi = open ("pgm", O_RDONLY);
    read (fi, &hdr, sizeof (hdr));
    read (fi, (char *) 0, hdr.a_text +  hdr.a_data);
    (* (void * () 0) ();
    /* NOTREACHED */
}
Example 1: Mock code that loads a GCC executable into memory
boot.exe is quite simple in theory, as our mock code fragment in Example 1 demonstrates. It just loads a GCC executable into memory at location 0, enters into protected mode, and then executes it. Simple, huh?

There are some niggling little gotchas, however:

Bill Gates thought 640KB would be big enough for anyone - well, its not for us.

  • Programs are frequently larger than is considered "convenient" in the PC world. On the PC, 64K or less is considered adequate, while the UNIX kernel we must load averages about 280 Kbytes in size, so we will have to manage the so-called "far" pointers in a large model 8086 program.
  • The bottom (address 0) of PC memory contains a critical portion of the MS-DOS operating system. We will need to use MS-DOS itself to load the program, so we can't touch this area until after we read in the entire program. We will therefore have to allocate a pool of memory space large enough to temporarily hold a copy of the program we are loading until it is safe to overwrite location 0.
  • Once we enter into protected mode, we can't easily go back and enter MS-DOS again, so we must do all our checks and anticipate needs prior to taking that last giant step.
  • Now we can implement the utility:




    <<BACK NEXT >>



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