|
PORTING UNIX TO THE 386: THE STANDALONE SYSTEM: Porting Unix to the 386: The Standalone SystemThis article, last of the original three done altogether in 1990, on getting the critical pieces functioning independantly that we needed to do the port. Once these we obtained, the kernel was inevitable. Watching for Land MinesAnticipating problems allowed us to find flaws in our work. We use the standalone system for bootstrap to load test programs that work machine-dependant portions of the kernel. The First StepWe stepwise proved out the running environment of program tools, program loading and execution, trap handling, stack, and support of high level language. Our project moved from fragile to substantive. Introducing the Standalone SystemOriginally the test framework to prove kernel parts work in the environment of an protected mode program running on the "raw" machine, this became the bootstrap environment to later load and start the kernel in system operation. Standalone Keyboard DriverSince we had a program running in an empty PC, we needed primative input with a keyboard driver for polled input. Used by standalone programs to boot and test parts of the kernel. Standalone Display Adapter DriverOutput from our standalone programs was done by a primative display driver to allow standalone programs to display results from bootstrap and test programs. We avoided the BIOS entirely. Prevaricating with the Standalone SystemWe didn't just load and debug the kernel; we chose to prove portions first. That way we learned the dependances first, and could try alternatives seperately. Later we used the same means to revise them later. Extending the Standalone SystemBooting a kernel didn't require all of this - but by extending support, we had a "mini kernel" like functionality. Dillemma - how much do you let the boostrap/loader actually do? We chose after the kernel was up to have it to the most - but this answer is subject to review. Processor Support -- i386.cWe initialized the processor with initial descriptor and page tables - one needs to run with the tables before activating memory/interrupt kernel functions. Initial Task State LoadHere's an oddity we had in the initial port. We first avoided the 386 TSS context switch because it was slow. With the 486 and later, it wasn't so we used it. But we needed at lead one to transit rings. Trap HandlingWe coded stub routines to connect trap handlers to descriptor table entry points, wiring the kernel to receive processor traps. Interrupt HandlingWe coded specialized trap handlers for interrupt traps, as these were initimate with the systems interrupt control hardware, not part of the processor. System Call HandlingSystem calls were handled by a call gate, a 386 peculiar mechanism which allowed for ring crossing into supervisor mode using a special segment descriptor call. We simulated user mode to test prior to running in the kernel. Page Fault HandlingWe coded trap handlers and simulated read and write faults to test out page faults with our processor support code. On a 2MB machine, we knew we'd get 1,000's. Where Do We Go From Here?We had put the plan of the first article into action, used the second articles tools to load test programs as the kernel, extending standalone operation. This created a base for the kernel and user environment. Porting Unix to the 386: Research and the Commercial SectorUnderstanding the boundary between research and development with BSD, and where a balance between commercial efforts can be struck. |