Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

Space Class Reference

An address space. More...

#include <space.h>

Inheritance diagram for Space:

Task List of all members.

Public Types

enum  Status {
  Insert_ok = 0, Insert_warn_exists, Insert_warn_attrib_upgrade, Insert_err_nomem,
  Insert_err_exists
}
 Return status of v_insert. More...
enum  Page_attrib {
  Page_no_attribs = 0, Page_writable = Pt_entry::Writable, Page_noncacheable = Pt_entry::Noncacheable | Pt_entry::Write_through, Page_user_accessible = Pt_entry::User,
  Page_all_attribs
}
 Attribute masks for page mappings. More...

Public Member Functions

bool is_privileged (void)
 Is this task a privileged one?
void make_current ()
void switchin_context ()
template<typename T>
T peek (T const *addr, bool user_space)
 Read integral type at any virtual address.
template<typename T>
T peek_user (T const *addr)
 Read integral type at virtual address in user space.
template<typename T>
void poke_user (T *addr, T value)
 Set integral type at virtual address in user space to value.
template<typename T>
void copy_from_user (T *kdst, T const *usrc, size_t n)
 Copy integral types from user space to kernel space.
template<typename T>
void copy_to_user (T *udst, T const *ksrc, size_t n)
 Copy integral types from kernel space to user space.
void page_map (Address phys, Address virt, Address size, unsigned page_attribs)
void page_unmap (Address virt, Address size)
void page_protect (Address virt, Address size, unsigned page_attribs)
Address kip_address () const
 Get KIP address.
void kmem_update (void *addr)
 Update this address space with an entry from the kernel's shared address space.
void remote_update (const Address, const Space *, const Address, size_t)
 Populate this address space with n PDEs from a remote address space.
void update_small (Address virt, bool flush)
 Update a page in the small space window from Kmem.
bool is_mappable (Address addr, size_t size)
 Check if an memory region may be unmapped or overmapped.
int mapped (Address addr, int need_writable) const
Address virt_to_phys (Address virt) const
 Simple page-table lookup.
const Pdir * dir () const
Space_index id () const
 Task number.
Space_index chief () const
 Chief Number.
void * operator new (size_t size)
void operator delete (void *block)
Address virt_to_phys_s0 (void *a) const
 Simple page-table lookup.
bool is_sigma0 (void) const
 Tests if a task is the sigma0 task.
unsigned get_io_counter (void)
bool io_lookup (Address)
 ~Space ()
 Destructor.
Space::Status v_insert (Address phys, Address virt, size_t size, unsigned page_attribs)
 Insert a page-table entry, or upgrade an existing entry with new attributes.
bool v_lookup (Address virt, Address *phys=0, Address *size=0, unsigned *page_attribs=0)
 Look up a page-table entry.
bool v_delete (Address virt, Address size, unsigned page_attribs=0)
 Delete page-table entries, or some of the entries' attributes.
void ldt_addr (void *addr)
Address ldt_addr () const
void ldt_size (Mword size)
Mword ldt_size () const
template<>
void copy_from_user (Mword *kdst, Mword const *usrc, size_t n)
template<>
void copy_to_user (Mword *udst, Mword const *ksrc, size_t n)

Static Public Member Functions

static Space * id_lookup (Task_num id)
 Lookup space belonging to a task number.
static Space * current ()

Protected Member Functions

void switchin_lipc_kip_pointer ()
 Space (unsigned number)
 Constructor.

Protected Attributes

Pdir _dir

Private Member Functions

 Space ()
 Space (const Space &)
void remove_from_space_index ()
 Remove space from space index.
void switch_ldt ()
void free_ldt_memory ()

Detailed Description

An address space.

Class Space extends Space_context with insertion and lookup functions.


Member Enumeration Documentation

enum Space::Page_attrib
 

Attribute masks for page mappings.

Enumeration values:
Page_no_attribs 
Page_writable  Page is writable.
Page_noncacheable  Page is noncacheable.
Page_user_accessible  it's a user page.
Page_all_attribs  A mask which contains all mask bits.

enum Space::Status
 

Return status of v_insert.

Enumeration values:
Insert_ok  Mapping was added successfully.
Insert_warn_exists  Mapping already existed.
Insert_warn_attrib_upgrade  Mapping already existed, attribs upgrade.
Insert_err_nomem  Couldn't alloc new page table.
Insert_err_exists  A mapping already exists at the target addr.


Constructor & Destructor Documentation

Space::Space (   )  [private]
 

Space::Space (  const Space &   )  [private]
 

Space::~Space (   ) 
 

Destructor.

Deletes the address space and unregisters it from Space_index.

Space::Space (  unsigned  number  )  [protected]
 

Constructor.

Creates a new address space and registers it with Space_index.

Registration may fail (if a task with the given number already exists, or if another thread creates an address space for the same task number concurrently). In this case, the newly-created address space should be deleted again.

Parameters:
new_number Task number of the new address space


Member Function Documentation

Space_index Space::chief (   )  const [inline]
 

Chief Number.

Returns:
Task number of this task's chief.

template<>
void Space::copy_from_user (  Mword *  kdst,
Mword const *  usrc,
size_t  n
)  [inline]
 

template<typename T>
void Space::copy_from_user (  T *  kdst,
T const *  usrc,
size_t  n
)  [inline]
 

Copy integral types from user space to kernel space.

Parameters:
kdst Virtual destination address in kernel space.
usrc Virtual source address in user space.
n Number of integral types to copy.

template<>
void Space::copy_to_user (  Mword *  udst,
Mword const *  ksrc,
size_t  n
)  [inline]
 

template<typename T>
void Space::copy_to_user (  T *  udst,
T const *  ksrc,
size_t  n
)  [inline]
 

Copy integral types from kernel space to user space.

Parameters:
udst Virtual destination address in user space.
ksrc Virtual source address in kernel space.
n Number of integral types to copy.

Space * Space::current (   )  [inline, static]
 

const Pdir * Space::dir (   )  const [inline]
 

void Space::free_ldt_memory (   )  [inline, private]
 

unsigned Space::get_io_counter (  void   )  [inline]
 

Space_index Space::id (   )  const [inline]
 

Task number.

Returns:
Number of the task to which this Space instance belongs.

Space * Space::id_lookup (  Task_num  id  )  [inline, static]
 

Lookup space belonging to a task number.

bool Space::io_lookup (  Address   )  [inline]
 

bool Space::is_mappable (  Address  addr,
size_t  size
)  [inline]
 

Check if an memory region may be unmapped or overmapped.

In V2-utcb, it returns false if the memory region overlaps the utcb area

bool Space::is_privileged (  void   )  [inline]
 

Is this task a privileged one?

bool Space::is_sigma0 (  void   )  const [inline]
 

Tests if a task is the sigma0 task.

Returns:
true if the task is sigma0, false otherwise.

Address Space::kip_address (   )  const [inline]
 

Get KIP address.

Returns:
Address there the KIP is mapped.

void Space::kmem_update (  void *  addr  )  [inline]
 

Update this address space with an entry from the kernel's shared address space.

The kernel maintains a 'master' page directory in class Kmem. Use this function when an entry from the master directory needs to be copied into this address space.

Parameters:
addr virtual address for which an entry should be copied from the shared page directory.

Address Space::ldt_addr (   )  const [inline]
 

void Space::ldt_addr (  void *  addr  )  [inline]
 

Mword Space::ldt_size (   )  const [inline]
 

void Space::ldt_size (  Mword  size  )  [inline]
 

void Space::make_current (   )  [inline]
 

int Space::mapped (  Address  addr,
int  need_writable
)  const [inline]
 

void Space::operator delete (  void *  block  ) 
 

void * Space::operator new (  size_t  size  ) 
 

void Space::page_map (  Address  phys,
Address  virt,
Address  size,
unsigned  page_attribs
)  [inline]
 

void Space::page_protect (  Address  virt,
Address  size,
unsigned  page_attribs
)  [inline]
 

void Space::page_unmap (  Address  virt,
Address  size
)  [inline]
 

template<typename T>
T Space::peek (  T const *  addr,
bool  user_space
)  [inline]
 

Read integral type at any virtual address.

Parameters:
addr Virtual address in user or kernel address space.
user_space Location of virtual address (user or kernel space).
Returns:
Integral value read from address.

template<typename T>
T Space::peek_user (  T const *  addr  )  [inline]
 

Read integral type at virtual address in user space.

Parameters:
addr Virtual address in user address space.
Returns:
Integral value read from address.

template<typename T>
void Space::poke_user (  T *  addr,
T  value
)  [inline]
 

Set integral type at virtual address in user space to value.

Parameters:
addr Virtual address in user address space.
value New value to be set.

void Space::remote_update (  const   Address,
const Space *  ,
const   Address,
size_t 
)  [inline]
 

Populate this address space with n PDEs from a remote address space.

Use this function when a part of another address space needs to be temporarily visible in the current address space (i.e., for long IPC). If one of the PDEs was valid, i.e. non-null, we need a TLB flush.

Parameters:
loc_addr virtual address where temporary should be established.
rem remote address space.
rem_addr virtual address in remote address space.
n number of PDEs to copy.

void Space::remove_from_space_index (   )  [inline, private]
 

Remove space from space index.

void Space::switch_ldt (   )  [inline, private]
 

void Space::switchin_context (   )  [inline]
 

void Space::switchin_lipc_kip_pointer (   )  [inline, protected]
 

void Space::update_small (  Address  virt,
bool  flush
)  [inline]
 

Update a page in the small space window from Kmem.

Parameters:
flush true if TLB-Flush necessary

bool Space::v_delete (  Address  virt,
Address  size,
unsigned  page_attribs = 0
) 
 

Delete page-table entries, or some of the entries' attributes.

This function works for one or multiple mappings (in contrast to v_insert!).

Parameters:
virt Virtual address of the memory region that should be changed.
size Size of the memory region that should be changed.
page_attribs If nonzero, delete only the given page attributes. Otherwise, delete the whole entries.
Returns:
False if an error occurs and some of the mappings could not be flushed. True if all goes well.

Space::Status Space::v_insert (  Address  phys,
Address  virt,
size_t  size,
unsigned  page_attribs
) 
 

Insert a page-table entry, or upgrade an existing entry with new attributes.

Parameters:
phys Physical address (page-aligned).
virt Virtual address for which an entry should be created.
size Size of the page frame -- 4KB or 4MB.
page_attribs Attributes for the mapping (see Space::Page_attrib).
Returns:
Insert_ok if a new mapping was created; Insert_warn_exists if the mapping already exists; Insert_warn_attrib_upgrade if the mapping already existed but attributes could be upgraded; Insert_err_nomem if the mapping could not be inserted because the kernel is out of memory; Insert_err_exists if the mapping could not be inserted because another mapping occupies the virtual-address range
Precondition:
phys and virt need to be size-aligned according to the size argument.

bool Space::v_lookup (  Address  virt,
Address *  phys = 0,
Address *  size = 0,
unsigned *  page_attribs = 0
) 
 

Look up a page-table entry.

Parameters:
virt Virtual address for which we try the look up.
phys Meaningful only if we find something (and return true). If not 0, we fill in the physical address of the found page frame.
page_attribs Meaningful only if we find something (and return true). If not 0, we fill in the page attributes for the found page frame (see Space::Page_attrib).
size If not 0, we fill in the size of the page-table slot. If an entry was found (and we return true), this is the size of the page frame. If no entry was found (and we return false), this is the size of the free slot. In either case, it is either 4KB or 4MB.
Returns:
True if an entry was found, false otherwise.

Address Space::virt_to_phys (  Address  virt  )  const [inline]
 

Simple page-table lookup.

Parameters:
virt Virtual address. This address does not need to be page-aligned.
Returns:
Physical address corresponding to a.

Address Space::virt_to_phys_s0 (  void *  a  )  const [inline]
 

Simple page-table lookup.

This method is similar to Space_context's virt_to_phys(). The difference is that this version handles Sigma0's address space with a special case: For Sigma0, we do not actually consult the page table -- it is meaningless because we create new mappings for Sigma0 transparently; instead, we return the logically-correct result of physical address == virtual address.

Parameters:
a Virtual address. This address does not need to be page-aligned.
Returns:
Physical address corresponding to a.


Member Data Documentation

Pdir Space::_dir [protected]
 


The documentation for this class was generated from the following files:
Generated on Mon Sep 26 14:20:17 2005 for Fiasco by  doxygen 1.4.2