Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

Physical_memory Class Reference

The Physical_memory map keeps track of which physical memory pages are available for allocation. More...

#include <physmem.h>

Collaboration diagram for Physical_memory:

Collaboration graph
[legend]
List of all members.

Public Member Functions

Size get_mem_size () const
void init ()
void enable_allocator (unsigned &last_available_address)
void * alloc_page (Memory_class mem_class=MEM_CLASS_ABOVE_16MB, Size request_size=PAGE_SIZE)
void free_page (void *page)
void * resize (void *page, Memory_class mem_class, Size new_size)
void * get_allocator_metadata_start ()
void * get_allocator_max_metadata_start ()
void unit_test ()
void print ()

Public Attributes

Page_allocator page_allocator

Protected Member Functions

void calc_memory_size ()

Protected Attributes

Size mem_size
unsigned char * page_after_kernel
bool allocator_enabled

Detailed Description

The Physical_memory map keeps track of which physical memory pages are available for allocation.


Member Function Documentation

void * Physical_memory::alloc_page Memory_class  mem_class = MEM_CLASS_ABOVE_16MB,
Size  request_size = PAGE_SIZE
 

Allocate a page span of the given alignment.

Look for a page in the given memory class, and keep trying successive lower classes until one is found. If the allocator is not yet enabled, then single "allocated" pages are put right after the kernel in memory and page_after_kernel is incremented accordingly. request_size is the number of bytes to allocate, which will be rounded up to a whole page amount.

void Physical_memory::calc_memory_size  )  [protected]
 

Calculate how much physical memory is available on the system and store it in mem_size.

void Physical_memory::enable_allocator unsigned &  last_available_address  ) 
 

Enable the physical memory page allocator.

void Physical_memory::free_page void *  page  ) 
 

Free the given page.

Note that pages "allocated" before the allocator is enabled cannot be freed.

void* Physical_memory::get_allocator_max_metadata_start  )  [inline]
 

Return the start address of the allocator's metadata as if it managed the maximum number of pages allowed by this architecture.

void* Physical_memory::get_allocator_metadata_start  )  [inline]
 

Return the start address of the allocator's metadata.

Size Physical_memory::get_mem_size  )  const [inline]
 

Return physical system memory size in bytes.

void Physical_memory::init  ) 
 

Initialize the physical memory manager.

void Physical_memory::print  ) 
 

Print out information on physical memory.

void * Physical_memory::resize void *  page,
Memory_class  mem_class,
Size  new_size
 

Resize the existing allocated page to a new size.

void Physical_memory::unit_test  ) 
 

Perform some basic tests to make sure this works as it should.


Member Data Documentation

bool Physical_memory::allocator_enabled [protected]
 

is real page allocator enabled?

Size Physical_memory::mem_size [protected]
 

size of system memory in bytes

unsigned char* Physical_memory::page_after_kernel [protected]
 

page immediately after kernel

Page_allocator Physical_memory::page_allocator
 


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

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