next up previous
Next: Device Drivers Up: Machine-Dependent Code Previous: Interrupt structure

Noncontiguous System Memory

By default, the kernel assumes that memory is physically mapped as one contiguous block. Some machine architectures, though, have a non-contiguous physical memory mapping, and there is code in the BSD kernel to handle this. For example, the IBM PC has RAM starting at physical memory 0, but the ROM and I/O space are mapped at 640k. Consequently, additional memory must start after the ROM, at physical location 1024k.

If non-contiguous memory is to be supported, the preprocessor constant MACHINE_NONCONTIG must be defined, and three functions must be added to the pmap.c module. The function pmap_next_page() should return the physical starting address of the ``next'' page of memory. The first time this function is called, it should return the lowest physical memory location. The next time it is called, it should return the starting address of the next page (usually 4096 bytes higher), and so on, making sure to jump over holes in physical memory. pmap_page_index() should return a page number given its physical address and pmap_free_pages() should return how many free pages are left. See the i386 and Macintosh ports for example implementation of these three functions.



Lawrence Kesteloot
Fri Jan 20 16:29:52 EST 1995