NOVA User-Level Environment  Version testbox/changed-memory-timing-317-g320d8b5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Utcb Struct Reference

#include <utcb.h>

Inheritance diagram for Utcb:
CpuState

Classes

struct  Descriptor
class  Frame
 A smaller frame on the UTCB. More...
struct  head
struct  String
struct  TypedIdentifyCap
 Used with << operator to set up "translate" typed item in UTCB. More...
struct  TypedMapCap
 Used with << operator to set up "delegate" typed item in UTCB. More...
struct  TypedTranslateMem
 Used with << operator to set up "translate" typed item in UTCB for memory. More...

Public Types

enum  { STACK_START = 512 }
enum  { MINSHIFT = 12 }
enum  { HEADER_SIZE = sizeof(struct head), MAX_DATA_WORDS = sizeof(msg) / sizeof(msg[0]), MAX_FRAME_WORDS = MAX_DATA_WORDS - STACK_START - 1 }
typedef struct Utcb::Descriptor Descriptor

Public Member Functions

unsigned ind2fp (unsigned ofs)
 Converts index to UTCB data to UTCB "frame pointers".
unsigned fp2ind (unsigned fp)
 Converts UTCB "frame pointer" to index to UTCB data area.
unsigned get_stack_top ()
 Returns the index to UTCB data area of the first empty word above the UTCB stack area.
void set_stack_top (unsigned ofs)
 Sets the "top pointer" of the UTCB stack area.
Frame get_nested_frame ()
unsigned frame_words ()
 Returns the number of words needed for storing the current UTCB content to a UTCB frame as implemented in add_frame().
Utcbadd_frame ()
 Push UTCB header and data to a stack area in the UTCB.
void skip_frame ()
void drop_frame ()
 Restore UTCB to the state saved by the last add_frame() and remove the restored state from the stack area.
void set_header (unsigned untyped, unsigned typed)
unsigned * item_start ()
Utcboperator<< (unsigned value)
bool validate_send_bounds ()
bool validate_recv_bounds ()
template<typename T >
Utcboperator<< (T &value)
Utcboperator<< (String string)
Utcboperator<< (TypedMapCap value)
Utcboperator<< (TypedIdentifyCap value)
Utcboperator<< (Crd value)
template<typename T >
bool operator>> (T &value)
WARN_UNUSED unsigned long add_mappings (unsigned long addr, unsigned long size, unsigned long hotspot, unsigned rights, bool frame=false, unsigned max_items=sizeof(msg)/sizeof(msg[0])/2)
 Add mappings to a UTCB.
void reset ()
 If you mixing code which manipulates the utcb by its own and you use this Utcb/Frame code, you have to fix up your utcb after the code manipulated the utcb by its own.

Public Attributes

struct Utcb::head head
union {
   struct {
      unsigned   mtd
      unsigned   inst_len
      unsigned   eip
      unsigned   efl
      unsigned   intr_state
      unsigned   actv_state
      unsigned   inj_info
      unsigned   inj_error
      union {
         struct {
         } 
         unsigned   gpr [8]
      } 
      unsigned long long   qual [2]
      unsigned   ctrl [2]
      long long   reserved
      unsigned   cr0
      unsigned   cr2
      unsigned   cr3
      unsigned   cr4
      unsigned   dr7
      unsigned   sysenter_cs
      unsigned   sysenter_esp
      unsigned   sysenter_eip
      Descriptor   es
      Descriptor   cs
      Descriptor   ss
      Descriptor   ds
      Descriptor   fs
      Descriptor   gs
      Descriptor   ld
      Descriptor   tr
      Descriptor   gd
      Descriptor   id
      long long   tsc_value
      long long   tsc_off
   } 
   unsigned   msg [(4096-sizeof(struct head))/sizeof(unsigned)]
}; 

Member Typedef Documentation

Member Enumeration Documentation

anonymous enum
Enumerator:
STACK_START 

Index where we store a "frame pointer" to the top of the stack.

anonymous enum
Enumerator:
MINSHIFT 
anonymous enum
Enumerator:
HEADER_SIZE 
MAX_DATA_WORDS 
MAX_FRAME_WORDS 

Member Function Documentation

Utcb& Utcb::add_frame ( )
inline

Push UTCB header and data to a stack area in the UTCB.

Later, UTCB can be fully restored by drop_frame() or partially restored by skip_frame().

TODO: put error code at some fixed point

WARN_UNUSED unsigned long Utcb::add_mappings ( unsigned long  addr,
unsigned long  size,
unsigned long  hotspot,
unsigned  rights,
bool  frame = false,
unsigned  max_items = sizeof(msg) / sizeof(msg[0]) / 2 
)
inline

Add mappings to a UTCB.

Parameters
addrStart of the memory area to be delegated/translated
sizeSize of the memory area to be delegated/translated
hotspotZero for translation or hotspot | flags | MAP_MAP for delegation.
rightsPermission mask and type Crd type bits.
frameSet this to true if the receiver uses Utcb::Frame and you want him to pass bound checks.
max_itemsThe maximum number of typed items to be put in UTCB.
Returns
Size of memory left which couldn't be put on the utcb because no space is left. If this is not zero, the caller has to handle this case! See sigma0.cc map_self for inspiration.
void Utcb::drop_frame ( )
inline

Restore UTCB to the state saved by the last add_frame() and remove the restored state from the stack area.

unsigned Utcb::fp2ind ( unsigned  fp)
inline

Converts UTCB "frame pointer" to index to UTCB data area.

unsigned Utcb::frame_words ( )
inline

Returns the number of words needed for storing the current UTCB content to a UTCB frame as implemented in add_frame().

Frame Utcb::get_nested_frame ( )
inline
unsigned Utcb::get_stack_top ( )
inline

Returns the index to UTCB data area of the first empty word above the UTCB stack area.

unsigned Utcb::ind2fp ( unsigned  ofs)
inline

Converts index to UTCB data to UTCB "frame pointers".

unsigned* Utcb::item_start ( )
inline
Utcb& Utcb::operator<< ( unsigned  value)
inline
template<typename T >
Utcb& Utcb::operator<< ( T &  value)
inline
Utcb& Utcb::operator<< ( String  string)
inline
Utcb& Utcb::operator<< ( TypedMapCap  value)
inline
Utcb& Utcb::operator<< ( TypedIdentifyCap  value)
inline
Utcb& Utcb::operator<< ( Crd  value)
inline
template<typename T >
bool Utcb::operator>> ( T &  value)
inline
void Utcb::reset ( )
inline

If you mixing code which manipulates the utcb by its own and you use this Utcb/Frame code, you have to fix up your utcb after the code manipulated the utcb by its own.

Otherwise some of the assertion in the Frame code will trigger because the Utcb/Frame code assumes it's the only one who manipulates the utcb. In general avoid this mixing, however in sigma0 it's not done everywhere.

void Utcb::set_header ( unsigned  untyped,
unsigned  typed 
)
inline
void Utcb::set_stack_top ( unsigned  ofs)
inline

Sets the "top pointer" of the UTCB stack area.

void Utcb::skip_frame ( )
inline
bool Utcb::validate_recv_bounds ( )
inline
bool Utcb::validate_send_bounds ( )
inline

Member Data Documentation

union { ... }
unsigned Utcb::actv_state
unsigned Utcb::cr0
unsigned Utcb::cr2
unsigned Utcb::cr3
unsigned Utcb::cr4
Descriptor Utcb::cs
unsigned Utcb::ctrl[2]
unsigned Utcb::dr7
Descriptor Utcb::ds
unsigned Utcb::efl
unsigned Utcb::eip
Descriptor Utcb::es
Descriptor Utcb::fs
Descriptor Utcb::gd
unsigned Utcb::gpr[8]
Descriptor Utcb::gs
Descriptor Utcb::id
unsigned Utcb::inj_error
unsigned Utcb::inj_info
unsigned Utcb::inst_len
unsigned Utcb::intr_state
Descriptor Utcb::ld
unsigned Utcb::msg[(4096-sizeof(struct head))/sizeof(unsigned)]
unsigned Utcb::mtd
unsigned long long Utcb::qual[2]
long long Utcb::reserved
Descriptor Utcb::ss
unsigned Utcb::sysenter_cs
unsigned Utcb::sysenter_eip
unsigned Utcb::sysenter_esp
Descriptor Utcb::tr
long long Utcb::tsc_off
long long Utcb::tsc_value

The documentation for this struct was generated from the following file: