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

PORTING UNIX TO THE 386: A PRACTICAL APPROACH


William & Lynne Jolitz


Most popular microprocessors use either segmentation or paging to manage memory address space access. The 386 is rare in that it possesses both. In fact, since segmentation, (see Figure 3(a)), is placed on top of paging (see Figure 3(b)), you are expected to use segmentation in some form any time memory is paged. And, most important, BSD relies on paging.




386 Memory Management Vitals
Most popular microprocessor use either segmentation or paging to manage memory address space access. The 386 is rare in that it possesses both. In fact, since segmentation, (see Figure 3(a)), is placed on top of paging (see Figure 3(b)), you are expected to use segmentation in some form any time memory is paged. And, most important, BSD relies on paging.

Processor Memory Reference
(segment register and offset)
Descriptor Table Linear Address Space
LDT (or GDT)
DS(15:3)

descriptor


 
sd

DS:SA   sd.sd_base + SA
Figure 3(a) - 386 Memory Management Segmentation

All operand references on the 386 are tied to one of the segment registers. This segment register uses a 16-bit selector (low-order bits determine level of access) to find a descriptor. This descriptor then determines the location of underlying memory in linear address space. When segmentation alone is enabled (also known as protected mode), the linear address space corresponds to the physical address of the selected segment for the operand. However, when paging is implemented, the linear address space address must be run through a two-level paging mechanism to find the physical page frame number, the actual address of physical memory underneath the virtual address.

Linear Address
Space
Page Table Address Translation Physical
Memory
Page
Table
Directory
Page
Table
Page
ptd[VA(31:22)]

pde

pt[VA(21:12)]

pte

pg[VA(11:0)]

data

ptd = %cr3 pt = pde.pf_num pg = pte.pf_num
Figure 3(b) - 386 Memory Management Paging

One of the most powerful, yet confusing, features of the 386 is its segmented architecture. While the current trend in microprocessors has been oriented towards a single "flat" linear virtual address space, the 386 has continued the bias toward segments held by the entire 80x86 line. The two most important changes in the 386 from previous versions -- permitting 32-bit operations and expanding segments from 64 Kbytes to 4 gigabytes in size -- may turn some of the inherent disadvantages of 80x86 segments into an advantage. Segments once too small for many data items (such as arrays of real numbers) can now utilize alternative address spaces. This is of great interest to those working with specialized applications, such as 3-D to 2-D transformations.



<<BACK NEXT >>



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