oe_pagetable Class Reference

#include <mempage.h>

Collaboration diagram for oe_pagetable:

Collaboration graph
[legend]
List of all members.

Detailed Description

Memory page table used to simulate paged memory.

Note:
while the members are technically public, one should NEVER modify them in one's code except using member functions and the macros defined in this header file.

Definition at line 58 of file mempage.h.

Public Member Functions

 oe_pagetable (void)
 Construct empty page table.
 ~oe_pagetable (void)
 Destroy page table.
void init (void)
 Initialize page table.
void uninit (void)
 Deinitialize page table.
uint32 create_pagetable (uint32 numpages, uint32 page_size)
 Create page table.
int get_num_pages ()
 Return total number of accessible pages.
int alloc_page (int page_num)
 Allocate real memory from heap for given virtual memory page.
int deallocate_page (int page_num)
 Deallocate real memory for given page.
void set_page_flags (int page_num, OE_PT_FLAG added_flags)
 Sets given set of permission flags for the page.
void unset_page_flags (int page_num, OE_PT_FLAG removed_flags)
 Disables given set of permission flags for the page.
OE_INLINE uint8 read_mem8 (void *cpu_ref, uint32 paddr)
 Read 8-bit value from memory.
OE_INLINE uint16 read_mem16 (void *cpu_ref, uint32 paddr)
 Read 16-bit value from memory.
OE_INLINE uint32 read_mem32 (void *cpu_ref, uint32 paddr)
 Read 32-bit value from memory.
OE_INLINE void write_mem8 (void *cpu_ref, uint32 paddr, uint8 dat)
 Write 8-bit value to memory.
OE_INLINE void write_mem16 (void *cpu_ref, uint32 paddr, uint16 dat)
 Write 16-bit value to memory.
OE_INLINE void write_mem32 (void *cpu_ref, uint32 paddr, uint32 dat)
 Write 32-bit value to memory.
OE_INLINE uint8 forced_read_mem8 (void *cpu_ref, uint32 paddr)
 Read 8-bit value from memory without possibility for the user callback fallback.
OE_INLINE uint16 forced_read_mem16 (void *cpu_ref, uint32 paddr)
 Read 16-bit value from memory without possibility for the user callback fallback.
OE_INLINE uint32 forced_read_mem32 (void *cpu_ref, uint32 paddr)
 Read 32-bit value from memory without possibility for the user callback fallback.
OE_INLINE void forced_write_mem8 (void *cpu_ref, uint32 paddr, uint8 dat)
 Write 8-bit value to memory without possibility for the user callback fallback.
OE_INLINE void forced_write_mem16 (void *cpu_ref, uint32 paddr, uint16 dat)
 Write 16-bit value to memory without possibility for the user callback fallback.
OE_INLINE void forced_write_mem32 (void *cpu_ref, uint32 paddr, uint32 dat)
 Write 32-bit value to memory without possibility for the user callback fallback.

Public Attributes

oe_pagetable_ptrtablecalls
 Callback function pointers, should be set up by the user.
OE_PT_FLAGflags
uint8 ** mem
 Array of pointers to memory blocks, one block per page, if block is NULL - will cause "callback" to be called on access.
uint32 mask
uint32 shift
uint32 size
uint32 clamp


Constructor & Destructor Documentation

oe_pagetable::oe_pagetable ( void   ) 

Construct empty page table.

Definition at line 87 of file mempage.cpp.

oe_pagetable::~oe_pagetable ( void   ) 

Destroy page table.

Definition at line 92 of file mempage.cpp.


Member Function Documentation

void oe_pagetable::init ( void   ) 

Initialize page table.

Definition at line 97 of file mempage.cpp.

Referenced by CPU_RCA1802::init(), CPU_M65C02::init(), and oe_pagetable().

void oe_pagetable::uninit ( void   ) 

Deinitialize page table.

Definition at line 106 of file mempage.cpp.

Referenced by create_pagetable(), and ~oe_pagetable().

uint32 oe_pagetable::create_pagetable ( uint32  numpages,
uint32  page_size 
)

Create page table.

Number of pages * (page_size). Note that page_size has to be a power of 2 or the function will fail (with non-zero (error) return value)!

Returns:
ZERO means success, otherwise failure.

Definition at line 41 of file mempage.cpp.

Referenced by RCASTUDIO2::init(), HW_R6545::init(), NES::init(), Commodore64::init(), HW_MOS6567::init(), and PPU::setmapper().

int oe_pagetable::get_num_pages (  )  [inline]

Return total number of accessible pages.

Definition at line 89 of file mempage.h.

int oe_pagetable::alloc_page ( int  page_num  )  [inline]

Allocate real memory from heap for given virtual memory page.

Parameters:
page_num page number to allocate.
Returns:
0 on success (allocated or was already allocated), negative number on failure (out of memory).
Note:
can be called on-demand from callback when page fault occur to allocate memory pages only on first use.

Definition at line 96 of file mempage.h.

int oe_pagetable::deallocate_page ( int  page_num  )  [inline]

Deallocate real memory for given page.

Parameters:
page_num page number to allocate.
perm_flags - new permissions to add (will be ORed with current permissions).
Returns:
0 on success negative number on failure (trying to deallocate non-allocated page).

Definition at line 119 of file mempage.h.

void oe_pagetable::set_page_flags ( int  page_num,
OE_PT_FLAG  added_flags 
) [inline]

Sets given set of permission flags for the page.

Parameters:
page_num page number.
added_flags -- bitfield with one or more flag bits enabled. These will be enabled on the page.

Definition at line 137 of file mempage.h.

void oe_pagetable::unset_page_flags ( int  page_num,
OE_PT_FLAG  removed_flags 
) [inline]

Disables given set of permission flags for the page.

Parameters:
page_num page number.
removed_flags -- bitfield with one or more flag bits enabled. These will be disabled on the page.

Definition at line 147 of file mempage.h.

OE_INLINE uint8 oe_pagetable::read_mem8 ( void *  cpu_ref,
uint32  paddr 
) [inline]

Read 8-bit value from memory.

Parameters:
cpu_ref is opaque pointer which will be passed unchanged to the callback if called.
paddr flat address in memory.
Returns:
value read from memory, either directly or via callback.

Definition at line 158 of file mempage.h.

Referenced by CPU_RCA1802::cycle(), CPU_M65C02::cycle(), CPU_RCA1802::DMA_OUT(), PPU::readreg(), CPU_M65C02::reset(), and PPU::writereg().

OE_INLINE uint16 oe_pagetable::read_mem16 ( void *  cpu_ref,
uint32  paddr 
) [inline]

Read 16-bit value from memory.

Parameters:
cpu_ref is opaque pointer which will be passed unchanged to the callback if called.
paddr flat address in memory.
Returns:
value read from memory, either directly or via callback.

Definition at line 181 of file mempage.h.

OE_INLINE uint32 oe_pagetable::read_mem32 ( void *  cpu_ref,
uint32  paddr 
) [inline]

Read 32-bit value from memory.

Parameters:
cpu_ref is opaque pointer which will be passed unchanged to the callback if called.
paddr flat address in memory.
Returns:
value read from memory, either directly or via callback.

Definition at line 221 of file mempage.h.

OE_INLINE void oe_pagetable::write_mem8 ( void *  cpu_ref,
uint32  paddr,
uint8  dat 
) [inline]

Write 8-bit value to memory.

Parameters:
cpu_ref is opaque pointer which will be passed unchanged to the callback if called.
paddr flat address in memory.
dat data to write.

Definition at line 243 of file mempage.h.

Referenced by CPU_M65C02::cycle(), CPU_RCA1802::DMA_IN(), and PPU::writereg().

OE_INLINE void oe_pagetable::write_mem16 ( void *  cpu_ref,
uint32  paddr,
uint16  dat 
) [inline]

Write 16-bit value to memory.

Parameters:
cpu_ref is opaque pointer which will be passed unchanged to the callback if called.
paddr flat address in memory.
dat data to write.

Definition at line 266 of file mempage.h.

OE_INLINE void oe_pagetable::write_mem32 ( void *  cpu_ref,
uint32  paddr,
uint32  dat 
) [inline]

Write 32-bit value to memory.

Parameters:
cpu_ref is opaque pointer which will be passed unchanged to the callback if called.
paddr flat address in memory.
dat data to write.

Definition at line 306 of file mempage.h.

OE_INLINE uint8 oe_pagetable::forced_read_mem8 ( void *  cpu_ref,
uint32  paddr 
) [inline]

Read 8-bit value from memory without possibility for the user callback fallback.

Parameters:
cpu_ref is opaque pointer which will be passed unchanged to the callback if called.
paddr flat address in memory.
Returns:
value read from memory.
Note:
this is slightly faster than read_mem8(), but does not provide the callback mechanism in case of failure.

Definition at line 331 of file mempage.h.

OE_INLINE uint16 oe_pagetable::forced_read_mem16 ( void *  cpu_ref,
uint32  paddr 
) [inline]

Read 16-bit value from memory without possibility for the user callback fallback.

Parameters:
cpu_ref is opaque pointer which will be passed unchanged to the callback if called.
paddr flat address in memory.
Returns:
value read from memory.
Note:
this is slightly faster than read_mem16(), but does not provide the callback mechanism in case of failure.

Definition at line 349 of file mempage.h.

OE_INLINE uint32 oe_pagetable::forced_read_mem32 ( void *  cpu_ref,
uint32  paddr 
) [inline]

Read 32-bit value from memory without possibility for the user callback fallback.

Parameters:
cpu_ref is opaque pointer which will be passed unchanged to the callback if called.
paddr flat address in memory.
Returns:
value read from memory.
Note:
this is slightly faster than read_mem32(), but does not provide the callback mechanism in case of failure.

Definition at line 386 of file mempage.h.

OE_INLINE void oe_pagetable::forced_write_mem8 ( void *  cpu_ref,
uint32  paddr,
uint8  dat 
) [inline]

Write 8-bit value to memory without possibility for the user callback fallback.

Parameters:
cpu_ref is opaque pointer which will be passed unchanged to the callback if called.
paddr flat address in memory.
dat value to write to memory.
Note:
this is slightly faster than write_mem8(), but does not provide the callback mechanism in case of failure.

Definition at line 406 of file mempage.h.

OE_INLINE void oe_pagetable::forced_write_mem16 ( void *  cpu_ref,
uint32  paddr,
uint16  dat 
) [inline]

Write 16-bit value to memory without possibility for the user callback fallback.

Parameters:
cpu_ref is opaque pointer which will be passed unchanged to the callback if called.
paddr flat address in memory.
dat value to write to memory.
Note:
this is slightly faster than write_mem16(), but does not provide the callback mechanism in case of failure.

Definition at line 424 of file mempage.h.

OE_INLINE void oe_pagetable::forced_write_mem32 ( void *  cpu_ref,
uint32  paddr,
uint32  dat 
) [inline]

Write 32-bit value to memory without possibility for the user callback fallback.

Parameters:
cpu_ref is opaque pointer which will be passed unchanged to the callback if called.
paddr flat address in memory.
dat value to write to memory.
Note:
this is slightly faster than write_mem32(), but does not provide the callback mechanism in case of failure.

Definition at line 460 of file mempage.h.


Member Data Documentation

oe_pagetable_ptrtable* oe_pagetable::calls

Callback function pointers, should be set up by the user.

Definition at line 60 of file mempage.h.

Referenced by create_pagetable(), RCASTUDIO2::init(), NES::init(), init(), Commodore64::init(), read_mem16(), read_mem32(), read_mem8(), PPU::setmapper(), uninit(), write_mem16(), write_mem32(), and write_mem8().

uint8** oe_pagetable::mem

Array of pointers to memory blocks, one block per page, if block is NULL - will cause "callback" to be called on access.

Definition at line 62 of file mempage.h.

Referenced by alloc_page(), create_pagetable(), deallocate_page(), forced_read_mem16(), forced_read_mem32(), forced_read_mem8(), forced_write_mem16(), forced_write_mem32(), forced_write_mem8(), RCASTUDIO2::init(), NES::init(), init(), Commodore64::init(), read_mem16(), read_mem32(), read_mem8(), set_page_flags(), PPU::setmapper(), uninit(), unset_page_flags(), write_mem16(), write_mem32(), and write_mem8().


The documentation for this class was generated from the following files:
Generated on Sat Sep 9 03:50:53 2006 for Openem APIs by  doxygen 1.4.7