next up previous contents index
Next: 10.2.2 spin_lock.h: Spin locks Up: 10.2 Machine-independent Facilities Previous: 10.2 Machine-independent Facilities

10.2.1 page.h: Page size definitions

   

SYNOPSIS

#include <oskit/machine/page.h>

DESCRIPTION

This file provides of following symbols, which define the architectural page size of the architecture for which the OSKit is configured:
PAGE_SIZE
The number of bytes on each page. It can always be assumed to be a power of two.
PAGE_SHIFT
The number of low address bits not translated by the MMU hardware. PAGE_SIZE is always tex2html_wrap_inline33279 .
PAGE_MASK
A bit mask with the low-order PAGE_SHIFT address bits set. Always equal to tex2html_wrap_inline33281 . WARNING: Some systems (like linux) define this to be tex2html_wrap_inline33283 , be careful that the definitions match what the code expects!

In addition, the following macros are provided for convenience in performing page-related manipulations of addresses:

atop(addr)
  Converts a byte address into a page frame number, by dividing by PAGE_SIZE.
ptoa(page)
  Converts a page frame number into an integer (oskit_addr_t) byte address, by multiplying by PAGE_SIZE.
round_page(addr)
  Returns addr rounded up to the next higher page boundary. If addr is already on a page boundary, it is returned unchanged.
trunc_page(addr)
  Returns addr rounded down to the next lower page boundary. If addr is already on a page boundary, it is returned unchanged.
page_aligned(addr)
  Evaluates to true (nonzero) if addr is page aligned, or false (zero) if it isn't.

Note that many modern architectures support multiple page sizes. On such architectures, the page size defined in this file is the minimum architectural page size, i.e., the finest granularity over which the MMU has control. Since there seems to be no sufficiently generic and useful way that this header file could provide symbols indicating which ``other'' page sizes the architecture supports, making good use of larger pages probably must be done in machine-dependent code.

Some operating systems on some architectures do not actually support the minimum architectural page size in software; instead, they aggregate multiple architectural pages together into larger ``logical pages'' managed by the OS software. On such operating systems, it would be inappropriate for general OS or application code to use the PAGE_SIZE value provided by oskit/page.h, since this value would be smaller (more fine-grained) than the OS software actually supports, and therefore inappropriate. However, this is purely a high-level OS issue; like other parts of the toolkit, no one is required to use this header file if it is inappropriate in a particular situation.

This file was originally derived from Mach's vm_param.h.


next up previous contents index
Next: 10.2.2 spin_lock.h: Spin locks Up: 10.2 Machine-independent Facilities Previous: 10.2 Machine-independent Facilities

University of Utah Flux Research Group