Main Page | Class Hierarchy | Class List | File List | Class 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 Member Functions

void init ()
unsigned * virtual_to_dir_entry (void *virtual_addr) const
unsigned virtual_to_dir_index (void *virtual_addr) const
unsigned get_table_entry (void *virtual_addr)
bool set_table_entry (void *virtual_addr, unsigned entry_value)
void * table_entry_to_virtual (unsigned *dir_entry, unsigned *physical_table, unsigned *physical_table_entry)
unsigned * dir_index_to_table (unsigned dir_index)
unsigned * virtual_to_table_entry (void *virtual_addr)
unsigned * get_table (unsigned dir_index)
unsigned * clear_table (unsigned *physical_table)
void get_dirty_dir_entries (Array< unsigned * > &dirty_dir_entries)
void set_table_block_number (unsigned disk_dir_index, unsigned block_number)
unsigned get_table_block_number (unsigned disk_dir_index)
void set_table_address (unsigned dir_index, unsigned *physical_table)

Static Public Member Functions

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

Public Attributes

unsigned * directory
unsigned * disk_directory

Static Public Attributes

const unsigned ENTRY_PRESENT = 0x1
const unsigned ENTRY_READ_WRITE = 0x2
const unsigned ENTRY_DIRTY = 0x40
const unsigned DIR_ENTRY_SHIFT = 22
const unsigned TABLE_ENTRY_SHIFT = 12
const unsigned ENTRY_INDEX_MASK = 0x3ff
const unsigned ENTRIES_PER_TABLE = 1024
const unsigned ENTRY_FRAME_ADDRESS = 0xfffff000
const unsigned 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 * Address_map::clear_table unsigned *  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. It is the caller's responsibility to call unmap_temp_page() on the returned virtual address when done using it.

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

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

unsigned* Address_map::dir_index_to_table unsigned  dir_index  )  [inline]
 

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

void Address_map::get_dirty_dir_entries Array< unsigned * > &  dirty_dir_entries  ) 
 

Get a list of dirty entries in the directory.

unsigned * Address_map::get_table unsigned  dir_index  ) 
 

Given an index into the directory, return the corresponding table, loading it from disk if necessary.

It is the caller's responsibility to call unmap_temp_page() on the returned table when done using it.

unsigned Address_map::get_table_block_number unsigned  disk_dir_index  )  [inline]
 

Get the disk block number for a particular table.

unsigned Address_map::get_table_entry void *  virtual_addr  ) 
 

Return the value of the table entry corresponding to the given virtual address.

void Address_map::init  ) 
 

Allocate and zero the directory and disk directory.

void Address_map::set_table_address unsigned  dir_index,
unsigned *  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  disk_dir_index,
unsigned  block_number
[inline]
 

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

bool Address_map::set_table_entry void *  virtual_addr,
unsigned  entry_value
 

Set the table entry corresponding to the given virtual address.

Return true if the entry was altered at all, and false otherwise.

void* Address_map::table_entry_to_virtual unsigned *  dir_entry,
unsigned *  physical_table,
unsigned *  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* 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.

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

Convert a virtual address to its corresponding directory index.

unsigned * Address_map::virtual_to_table_entry void *  virtual_addr  ) 
 

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

It is the caller's responsibility to call unmap_temp_page() on the returned table entry when done using it, thereby freeing the temporarily mapped page containing it.

unsigned* Address_map::virtual_to_table_entry void *  virtual_addr,
unsigned *  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 Address_map::DIR_ENTRY_SHIFT = 22 [static]
 

unsigned* Address_map::directory
 

has addrs of present tables

unsigned* Address_map::disk_directory
 

has blocks of all tables

const unsigned Address_map::ENTRIES_PER_TABLE = 1024 [static]
 

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

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

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

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

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

const unsigned Address_map::PAYLOAD_SHIFT = 1 [static]
 

const unsigned Address_map::TABLE_ENTRY_SHIFT = 12 [static]
 


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

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