Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Address_map Class Reference

An Address_map is a generalized two-level hierarchical map of virtual addresses to some corresponding values. More...

#include <addrmap.h>

Inherited by Block_map, Page_map, and Segment_map.

Inheritance diagram for Address_map:

Inheritance graph
[legend]
List of all members.

Public Methods

void init ()
unsigned int * virtual_to_dir_entry (void *virtual_addr) const
unsigned int virtual_to_dir_index (void *virtual_addr) const
void * table_entry_to_virtual (unsigned int *dir_entry, unsigned int *physical_table, unsigned int *physical_table_entry)
unsigned int * virtual_to_table_entry (void *virtual_addr)
unsigned int * clear_table (unsigned int *physical_table)
void set_table_block_number (unsigned int disk_dir_index, unsigned int block_number)
unsigned int get_table_block_number (unsigned int disk_dir_index)
void set_table_address (unsigned int dir_index, unsigned int *physical_table)

Static Public Methods

unsigned int * virtual_to_table_entry (void *virtual_addr, unsigned int *table)
unsigned int * dir_entry_to_table (unsigned int *dir_entry)

Public Attributes

unsigned int * directory
unsigned int * disk_directory

Static Public Attributes

const unsigned int ENTRY_PRESENT = 0x1
const unsigned int ENTRY_READ_WRITE = 0x2
const unsigned int ENTRY_DIRTY = 0x40
const unsigned int DIR_ENTRY_SHIFT = 22
const unsigned int TABLE_ENTRY_SHIFT = 12
const unsigned int ENTRY_INDEX_MASK = 0x3ff
const unsigned int ENTRIES_PER_TABLE = 1024
const unsigned int ENTRY_FRAME_ADDRESS = 0xfffff000
const unsigned int PAYLOAD_SHIFT = 1

Detailed Description

An Address_map is a generalized two-level hierarchical map of virtual addresses to some corresponding values.

Specific implementations of address maps include the page map (page directory and tables), the disk block map, etc. For a description of how this data structure works in a particular implementation, see section 5.2 (Page Translation) of the 80386 Programmer's Reference Manual.

An address map directory contains an entry for each address map table. For present (in-memory) tables, the directory entry is the page frame address of the table in virtual memory and various flags.

The disk directory of an address map contains an entry for each address map table. An entry is the block number of the table on disk. If the table is not yet on disk, the entry is zero.

The interpretation of the entries within the tables themselves is left up to specific implementations. Typical uses for the table entries is for them to contain virtual addresses, indexes, etc.


Member Function Documentation

unsigned int * Address_map::clear_table unsigned int *    physical_table
 

Temporarily map a table and clear its memory. This should be done before a table is used so that its entries are all properly invalidated (marked as non-present). Return the virtual address of the cleared table.

unsigned int* Address_map::dir_entry_to_table unsigned int *    dir_entry [inline, static]
 

Convert a directory entry into the physical table address it contains.

unsigned int Address_map::get_table_block_number unsigned int    disk_dir_index [inline]
 

Get the disk block number for a particular table.

void Address_map::init  
 

Allocate and zero the directory.

Reimplemented in Page_map.

void Address_map::set_table_address unsigned int    dir_index,
unsigned int *    physical_table
[inline]
 

Set the physical memory address for a particular table. Mark the table as present and read-write.

void Address_map::set_table_block_number unsigned int    disk_dir_index,
unsigned int    block_number
[inline]
 

Set the disk block number for a particular table, given an index into the disk_directory.

void* Address_map::table_entry_to_virtual unsigned int *    dir_entry,
unsigned int *    physical_table,
unsigned int *    physical_table_entry
[inline]
 

Given a page directory entry and a physical page table, convert a physical page table entry into the virtual address it maps.

unsigned int* Address_map::virtual_to_dir_entry void *    virtual_addr const [inline]
 

Convert a virtual address to its corresponding directory entry. (The directory itself has the same virtual and physical address, so the entry returned is both virtual and physical as well.) Create a new page table if necessary.

unsigned int Address_map::virtual_to_dir_index void *    virtual_addr const [inline]
 

unsigned int * Address_map::virtual_to_table_entry void *    virtual_addr
 

Convert a virtual address to its corresponding table entry (without supplying the table).

unsigned int* Address_map::virtual_to_table_entry void *    virtual_addr,
unsigned int *    table
[inline, static]
 

Convert a virtual address to its corresponding table entry. (Whether the entry is physical or virtual depends on the table supplied.).


Member Data Documentation

const unsigned int Address_map::DIR_ENTRY_SHIFT = 22 [static]
 

unsigned int* Address_map::directory
 

has addrs of present tables.

unsigned int* Address_map::disk_directory
 

has blocks of all tables.

const unsigned int Address_map::ENTRIES_PER_TABLE = 1024 [static]
 

const unsigned int Address_map::ENTRY_DIRTY = 0x40 [static]
 

const unsigned int Address_map::ENTRY_FRAME_ADDRESS = 0xfffff000 [static]
 

const unsigned int Address_map::ENTRY_INDEX_MASK = 0x3ff [static]
 

const unsigned int Address_map::ENTRY_PRESENT = 0x1 [static]
 

const unsigned int Address_map::ENTRY_READ_WRITE = 0x2 [static]
 

const unsigned int Address_map::PAYLOAD_SHIFT = 1 [static]
 

const unsigned int Address_map::TABLE_ENTRY_SHIFT = 12 [static]
 


The documentation for this class was generated from the following files:

Torsion Operating System, Copyright (C) 2000-2002 Dan Helfman