Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Friends

Sigma0 Struct Reference

Sigma0 application class. More...

Inheritance diagram for Sigma0:
Sigma0Base NovaProgram StaticReceiver< Sigma0 > BaseProgram BaseProgram CapAllocator< NovaProgram > Device _CapAllocator

List of all members.

Classes

struct  ConsoleData
struct  DiskData
struct  PutcData

Public Types

enum  { MAXDISKS = 32, MAXDISKREQUESTS = DISKS_SIZE }

Public Member Functions

char * map_self (Utcb *utcb, unsigned long physmem, unsigned long size, unsigned rights=DESC_MEM_ALL)
char * map_string (Utcb *utcb, unsigned long src)
 Command lines need to be mapped.
bool attach_irq (unsigned gsi, unsigned cap_sm, bool unlocked, unsigned cpunr)
unsigned attach_msi (MessageHostOp *msg, unsigned cpunr)
template<class CONSUMER , class PRODUCER >
void handle_attach (ModuleInfo *modinfo, PRODUCER &res, Utcb *utcb)
 Handle an attach request.
void postinit (Hip *hip)
unsigned create_host_devices (Utcb *utcb, Hip *hip)
 Create the needed host devices aka instantiate the drivers.
unsigned alloc_crd ()
 Prepare UTCB for receiving a new cap.
unsigned create_worker_threads (Hip *hip, int cpunr)
unsigned __attribute__ ((noinline)) preinit(Utcb *utcb
 Init the pager, console and map initial resources.
unsigned Hip *hip Logging::init (putc, 0)
 Logging::printf ("s0: preinit %p\n\n", hip)
 check1 (1, init(hip))
 assert (_cap_start==0 &&_cap_order==16 &&CLIENT_PT_OFFSET==0x20000U)
 assert (reserve &&reserve->virt<=CLIENT_PT_OFFSET &&reserve->size-(reserve->virt-CLIENT_PT_OFFSET) >=(2<< CLIENT_PT_ORDER))
_cap_region del (Region(CLIENT_PT_OFFSET, 2U<< CLIENT_PT_ORDER))
 assert (!_cap_region.find(CLIENT_PT_OFFSET)&&!_cap_region.find(CLIENT_PT_OFFSET+(1U<< CLIENT_PT_ORDER)-1U))
 assert (!_cap_region.find(CLIENT_PT_OFFSET+(2U<< CLIENT_PT_ORDER)-1U))
 assert (!_cap_region.find(0))
 assert (!_cap_region.find(ParentProtocol::CAP_PT_PERCPU-1U))
 assert (!_cap_region.find(ParentProtocol::CAP_PT_PERCPU+Config::MAX_CPUS-1U))
 Logging::printf ("s0: create locks\n")
 check1 (2, nova_create_sm(_lock_gsi.sm())||nova_create_sm(_lock_mem.sm()))
_lock_mem up ()
 Logging::printf ("s0: create pf echo+worker threads\n")
 check1 (3, create_worker_threads(hip, utcb->head.nul_cpunr))
 Logging::printf ("s0: map vga memory\n")
 memcpy (_vga+0x1a000, _vga+0x18000, 0x1000)
putcd sem up ()
 check1 (6, nova_create_sm(putcd.sem.sm()))
 Logging::init (putc,&putcd)
 check1 (7, nova_create_sm(CLIENT_PT_OFFSET+ParentProtocol::CAP_PARENT_ID))
 Utcb::TypedMapCap (CLIENT_PT_OFFSET+ParentProtocol::CAP_PARENT_ID).fill_words(utcb->msg
 Crd (ParentProtocol::CAP_PARENT_ID, 0, MAP_MAP).value())
*utcb<< Crd(0,
31, DESC_CAP_ALL);utcb-> 
set_header (2, 0)
 for (unsigned gsi=0;gsi< hip->cfg_gsi;gsi++)
 check1 (8, nova_call(_percpu[utcb->head.nul_cpunr].cap_pt_echo))
unsigned init_memmap (Utcb *utcb)
 Init the memory map from the Hip.
void free_module (ModuleInfo *modinfo)
ModuleInfoget_module (unsigned id)
ModuleInfoalloc_module (char const *cmdline, unsigned sigma0_cmdlen)
unsigned start_config (Utcb *utcb, unsigned which, unsigned &internal_id)
 Starts a configuration loaded during boottime.
unsigned start_config (Utcb *utcb, char const *mconfig, unsigned &internal_id)
 Start a configuration from a stable memory region (mconfig).
unsigned _start_config (Utcb *utcb, char *elf, unsigned long mod_size, char const *mconfig, char const *client_cmdline, unsigned sigma0_cmdlen, unsigned &internal_id)
unsigned kill_module (ModuleInfo *modinfo)
 Kill the given module.
unsigned assign_pci_device (unsigned pd_cap, unsigned bdf, unsigned vfbdf)
 Assign a PCI device to a PD.
NORETURN void internal_error (unsigned pid, Utcb *utcb)
 PT_FUNC (do_map, assert(~utcb->head.untyped &1);utcb->set_header(0, utcb->head.untyped/2);memmove(utcb->item_start(), utcb->msg, sizeof(unsigned)*utcb->head.typed *2);) PT_FUNC_NORETURN(do_gsi
 Logging::printf ("s0: %s(%x) vec %x %s\n", __func__, cap_irq, gsi, locked?"locked":"unlocked")
MessageIrq msg (shared?MessageIrq::ASSERT_NOTIFY:MessageIrq::ASSERT_IRQ, gsi)
 while (!(res=nova_semdownmulti(cap_irq)))
 Logging::panic ("s0: %s(%x, %x) request failed with %x\n", __func__, gsi, cap_irq, res)
 PT_FUNC (do_startup, ModuleInfo *modinfo=get_module((pid-CLIENT_PT_OFFSET) >> CLIENT_PT_SHIFT);assert(modinfo);utcb->eip=modinfo->rip;utcb->esp=CLIENT_HIP;utcb->mtd=MTD_RIP_LEN|MTD_RSP;) PT_FUNC(do_request
 assert (modinfo)
 COUNTER_INC ("request")
 if (utcb->head.untyped==EXCEPTION_WORDS)
 if (request_pcicfg(modinfo->id, utcb)) return
SemaphoreGuard l (_lock_gsi)
 if (!request_vnet(modinfo, utcb)&&!request_disks(modinfo, utcb)&&!request_console(modinfo, utcb)&&!request_network(modinfo, utcb)) switch(utcb->msg[0])
utcb set_header (1, 0)
bool receive (MessageHostOp &msg)
void init_network ()
bool request_network (ModuleInfo *modinfo, Utcb *utcb)
 Handle network requests from other PDs.
bool receive (MessageNetwork &msg)
void init_vnet ()
bool receive (MessageVirtualNetPing &msg)
bool request_vnet (ModuleInfo *modinfo, Utcb *utcb)
void init_disks ()
 Global init.
void attach_drives (char const *cmdline, unsigned long cmdlen, unsigned client)
 Attach drives to a module.
unsigned long find_free_tag (unsigned short client, unsigned char disknr, unsigned long usertag, unsigned long &tag)
 Find a free disk tag for a client.
bool request_disks (ModuleInfo *modinfo, Utcb *utcb)
 Handle disk requests from other PDs.
bool receive (MessageDiskCommit &msg)
void init_console ()
 Init the console subsystem.
void alloc_console (ModuleInfo const *modinfo, const char *cmdline)
bool request_console (ModuleInfo *modinfo, Utcb *utcb)
 Handle console requests from other PDs.
bool receive (MessageConsole &msg)
bool request_pcicfg (unsigned client, Utcb *utcb)
unsigned hash (unsigned state, unsigned value)
 A very simple hash function.
unsigned generate_hostmac ()
 Generate a pseudo-random but persistent hostmac by hashing all PCI device IDs, their BDFs and the serial numbers of devices.
unsigned long long get_mac (unsigned clientnr)
 Return a MAC by adding the MAC-prefix, the host-MAC and a client specific number.
void __attribute__ ((noreturn)) run(Utcb *utcb
 Sigma0 ()

Static Public Member Functions

template<typename T >
static bool convert_client_ptr (ModuleInfo *modinfo, T *&ptr, unsigned size)
 Converts client ptr to a pointer in our address space.
static bool adapt_ptr_map (ModuleInfo *modinfo, unsigned long &physoffset, unsigned long &physsize)
 Returns true on error.
static void serial_send (long value)
static void putc (void *data, int value)
static void fancy_output (const char *st, unsigned maxchars)
static void * sigma0_memalloc (unsigned long size, unsigned long align)
 Request memory from the memmap.
static void switch_view (Motherboard *mb, int view=0, unsigned short consoleid=console_id)
 Switch to our view.

Public Attributes

unsigned _cpunr [MAXCPUS]
unsigned _numcpus
unsigned _last_affinity
struct {
   unsigned   cap_ec_worker
   unsigned   cap_ec_echo
   unsigned   cap_pt_echo
   unsigned   exc_base
_percpu [MAXCPUS]
Semaphore _lock_gsi
char * _vga
VgaRegs _vga_regs
struct Sigma0::PutcData putcd
Motherboard_mb
ModuleInfo _modinfo [MAXMODULES]
unsigned _mac
Hip__hip
unsigned _msivector
unsigned long long _gsi
unsigned _pcidirect [MAXPCIDIRECT]
bool admission
s0_AdmissionProtocolservice_admission
s0_ParentProtocolservice_parent
Regionreserve = _cap_region.find(CLIENT_PT_OFFSET)
 _lock_gsi = Semaphore(alloc_cap())
 _lock_mem = Semaphore(alloc_cap())
 _vga = map_self(utcb, 0xa0000, 1<<17)
putcd screen = reinterpret_cast<unsigned short *>(_vga + 0x18000)
putcd regs = &_vga_regs
putcd sem = Semaphore(alloc_cap())
 consolesem = &putcd.sem
_vga_regs cursor_pos = 24*80*2
_vga_regs offset = 0
 return
unsigned char res
unsigned gsi = utcb->msg[1] & 0xff
bool shared = (utcb->msg[1] >> 8) & 1
bool locked = !(utcb->msg[1] & 0x200)
unsigned cap_irq = utcb->msg[0]
ModuleInfomodinfo = get_module((pid - CLIENT_PT_OFFSET) >> CLIENT_PT_SHIFT)
fail __pad0__: utcb->msg[0] = ~0x10u
NetworkProducer _prod_network [MAXMODULES]
 Network data.
unsigned vnet_sm [MAXMODULES]
struct Sigma0::DiskData _disk_data [MAXMODULES]
struct Sigma0::ConsoleData _console_data [MAXMODULES]

Static Public Attributes

static Semaphore _lock_mem

Friends

class s0_ParentProtocol

Detailed Description

Sigma0 application class.


Member Enumeration Documentation

anonymous enum
Enumerator:
MAXDISKS 
MAXDISKREQUESTS 

Constructor & Destructor Documentation

Sigma0::Sigma0 (  )  [inline]

Member Function Documentation

unsigned Sigma0::__attribute__ ( (noinline)   ) 

Init the pager, console and map initial resources.

void Sigma0::__attribute__ ( (noreturn)   ) 
unsigned Sigma0::_start_config ( Utcb utcb,
char *  elf,
unsigned long  mod_size,
char const *  mconfig,
char const *  client_cmdline,
unsigned  sigma0_cmdlen,
unsigned &  internal_id 
) [inline]

We memset the client memory to make sure we get an deterministic run and not leak any information between clients.

static bool Sigma0::adapt_ptr_map ( ModuleInfo modinfo,
unsigned long &  physoffset,
unsigned long &  physsize 
) [inline, static]

Returns true on error.

(Why?!)

void Sigma0::alloc_console ( ModuleInfo const *  modinfo,
const char *  cmdline 
) [inline]
unsigned Sigma0::alloc_crd (  )  [inline]

Prepare UTCB for receiving a new cap.

ModuleInfo* Sigma0::alloc_module ( char const *  cmdline,
unsigned  sigma0_cmdlen 
) [inline]
Sigma0::assert ( _cap_start  = =0 &&_cap_order==16 &&CLIENT_PT_OFFSET==0x20000U  ) 
Sigma0::assert ( reserve &&reserve->virt<=CLIENT_PT_OFFSET &&reserve->size-  reserve->virt-CLIENT_PT_OFFSET) >=(2<< CLIENT_PT_ORDER  ) 
Sigma0::assert ( !_cap_region.  findCLIENT_PT_OFFSET)&&!_cap_region.find(CLIENT_PT_OFFSET+(1U<< CLIENT_PT_ORDER)-1U  ) 
Sigma0::assert ( !_cap_region.  findCLIENT_PT_OFFSET+(2U<< CLIENT_PT_ORDER)-1U  ) 
Sigma0::assert ( !_cap_region.  find0  ) 
Sigma0::assert ( !_cap_region.  findParentProtocol::CAP_PT_PERCPU-1U  ) 
Sigma0::assert ( !_cap_region.  findParentProtocol::CAP_PT_PERCPU+Config::MAX_CPUS-1U  ) 
Sigma0::assert ( modinfo   ) 
unsigned Sigma0::assign_pci_device ( unsigned  pd_cap,
unsigned  bdf,
unsigned  vfbdf 
) [inline]

Assign a PCI device to a PD.

It makes sure only the first will get it.

Returns 0 on success.

void Sigma0::attach_drives ( char const *  cmdline,
unsigned long  cmdlen,
unsigned  client 
) [inline]

Attach drives to a module.

bool Sigma0::attach_irq ( unsigned  gsi,
unsigned  cap_sm,
bool  unlocked,
unsigned  cpunr 
) [inline]
unsigned Sigma0::attach_msi ( MessageHostOp msg,
unsigned  cpunr 
) [inline]
Sigma0::check1 ( ,
nova_create_sm(putcd.sem.sm())   
)
Sigma0::check1 ( ,
init(hip)   
)
Sigma0::check1 ( ,
nova_create_sm(CLIENT_PT_OFFSET+ParentProtocol::CAP_PARENT_ID)   
)
Sigma0::check1 ( ,
nova_call(_percpu[utcb->head.nul_cpunr].cap_pt_echo  
)
Sigma0::check1 ( ,
nova_create_sm(_lock_gsi.sm())||nova_create_sm(_lock_mem.sm())   
)
Sigma0::check1 ( ,
create_worker_threads(hip, utcb->head.nul_cpunr)   
)
template<typename T >
static bool Sigma0::convert_client_ptr ( ModuleInfo modinfo,
T *&  ptr,
unsigned  size 
) [inline, static]

Converts client ptr to a pointer in our address space.

Returns true on error.

Sigma0::COUNTER_INC ( "request"   ) 
Sigma0::Crd ( ParentProtocol::CAP_PARENT_ID  ,
,
MAP_MAP   
)
unsigned Sigma0::create_host_devices ( Utcb utcb,
Hip hip 
) [inline]

Create the needed host devices aka instantiate the drivers.

unsigned Sigma0::create_worker_threads ( Hip hip,
int  cpunr 
) [inline]
_cap_region Sigma0::del ( Region(CLIENT_PT_OFFSET, 2U<< CLIENT_PT_ORDER)   ) 
static void Sigma0::fancy_output ( const char *  st,
unsigned  maxchars 
) [inline, static]
unsigned long Sigma0::find_free_tag ( unsigned short  client,
unsigned char  disknr,
unsigned long  usertag,
unsigned long &  tag 
) [inline]

Find a free disk tag for a client.

Sigma0::for ( unsigned  gsi = 0; gsi < hip->cfg_gsi; gsi++  )  [inline]
void Sigma0::free_module ( ModuleInfo modinfo  )  [inline]
unsigned Sigma0::generate_hostmac (  )  [inline]

Generate a pseudo-random but persistent hostmac by hashing all PCI device IDs, their BDFs and the serial numbers of devices.

unsigned long long Sigma0::get_mac ( unsigned  clientnr  )  [inline]

Return a MAC by adding the MAC-prefix, the host-MAC and a client specific number.

ModuleInfo* Sigma0::get_module ( unsigned  id  )  [inline]
template<class CONSUMER , class PRODUCER >
void Sigma0::handle_attach ( ModuleInfo modinfo,
PRODUCER &  res,
Utcb utcb 
) [inline]

Handle an attach request.

unsigned Sigma0::hash ( unsigned  state,
unsigned  value 
) [inline]

A very simple hash function.

Sigma0::if ( request_vnetmodinfo, utcb)&&!request_disks(modinfo, utcb)&&!request_console(modinfo, utcb)&&!request_network(modinfo, utcb  )  [inline]
Sigma0::if ( utcb->head.  untyped = = EXCEPTION_WORDS  )  [inline]
Sigma0::if ( request_pcicfg(modinfo->id, utcb)   ) 
void Sigma0::init_console (  )  [inline]

Init the console subsystem.

void Sigma0::init_disks (  )  [inline]

Global init.

unsigned Sigma0::init_memmap ( Utcb utcb  )  [inline]

Init the memory map from the Hip.

void Sigma0::init_network (  )  [inline]
void Sigma0::init_vnet (  )  [inline]
NORETURN void Sigma0::internal_error ( unsigned  pid,
Utcb utcb 
) [inline]
unsigned Sigma0::kill_module ( ModuleInfo modinfo  )  [inline]

Kill the given module.

SemaphoreGuard Sigma0::l ( _lock_gsi   ) 
unsigned Hip* hip Sigma0::Logging::init ( putc  ,
 
)
Sigma0::Logging::init ( putc  ,
putcd 
)
Sigma0::Logging::panic ( "s0: %s(%x, %x) request failed with %x\n"  ,
__func__  ,
gsi  ,
cap_irq  ,
res   
)
Sigma0::Logging::printf ( "s0: map vga memory\n"   ) 
Sigma0::Logging::printf ( "s0: preinit %p\n\n"  ,
hip   
)
Sigma0::Logging::printf ( "s0: %s(%x) vec %x %s\n"  ,
__func__  ,
cap_irq  ,
gsi  ,
locked?"locked":"unlocked"   
)
Sigma0::Logging::printf ( "s0: create locks\n"   ) 
Sigma0::Logging::printf ( "s0: create pf echo+worker threads\n"   ) 
char* Sigma0::map_self ( Utcb utcb,
unsigned long  physmem,
unsigned long  size,
unsigned  rights = DESC_MEM_ALL 
) [inline]
char* Sigma0::map_string ( Utcb utcb,
unsigned long  src 
) [inline]

Command lines need to be mapped.

Sigma0::memcpy ( _vga 0x1a000,
_vga 0x18000,
0x1000   
)
MessageIrq Sigma0::msg ( shared?MessageIrq::ASSERT_NOTIFY:MessageIrq::ASSERT_IRQ  ,
gsi   
)
void Sigma0::postinit ( Hip hip  )  [inline]
Sigma0::PT_FUNC ( do_map  ,
assert(~utcb->head.untyped &1);utcb->set_header(0, utcb->head.untyped/2);memmove(utcb->item_start(), utcb->msg, sizeof(unsigned)*utcb->head.typed *2);   
)
Sigma0::PT_FUNC ( do_startup  ,
ModuleInfo modinfo = get_module((pid - CLIENT_PT_OFFSET) >> CLIENT_PT_SHIFT); assert(modinfo);   utcb->eip = modinfo->rip; utcb->esp = CLIENT_HIP; utcb->mtd = MTD_RIP_LEN | MTD_RSP; 
)
static void Sigma0::putc ( void *  data,
int  value 
) [inline, static]
bool Sigma0::receive ( MessageNetwork msg  )  [inline]
bool Sigma0::receive ( MessageHostOp msg  )  [inline]
bool Sigma0::receive ( MessageDiskCommit msg  )  [inline]
bool Sigma0::receive ( MessageVirtualNetPing msg  )  [inline]
bool Sigma0::receive ( MessageConsole msg  )  [inline]
bool Sigma0::request_console ( ModuleInfo modinfo,
Utcb utcb 
) [inline]

Handle console requests from other PDs.

bool Sigma0::request_disks ( ModuleInfo modinfo,
Utcb utcb 
) [inline]

Handle disk requests from other PDs.

bool Sigma0::request_network ( ModuleInfo modinfo,
Utcb utcb 
) [inline]

Handle network requests from other PDs.

bool Sigma0::request_pcicfg ( unsigned  client,
Utcb utcb 
) [inline]
bool Sigma0::request_vnet ( ModuleInfo modinfo,
Utcb utcb 
) [inline]
static void Sigma0::serial_send ( long  value  )  [inline, static]
* utcb<< Crd(0, 31, DESC_CAP_ALL); utcb-> Sigma0::set_header ( ,
 
)
utcb Sigma0::set_header ( ,
 
)
static void* Sigma0::sigma0_memalloc ( unsigned long  size,
unsigned long  align 
) [inline, static]

Request memory from the memmap.

Minimum alignment is 16-bytes (for SSE stuff).

unsigned Sigma0::start_config ( Utcb utcb,
char const *  mconfig,
unsigned &  internal_id 
) [inline]

Start a configuration from a stable memory region (mconfig).

Region has to be zero terminated.

unsigned Sigma0::start_config ( Utcb utcb,
unsigned  which,
unsigned &  internal_id 
) [inline]

Starts a configuration loaded during boottime.

Configuration numbers start at zero.

static void Sigma0::switch_view ( Motherboard mb,
int  view = 0,
unsigned short  consoleid = console_id 
) [inline, static]

Switch to our view.

putcd sem Sigma0::up (  ) 
_lock_mem Sigma0::up (  ) 
Sigma0::Utcb::TypedMapCap ( CLIENT_PT_OFFSET+ParentProtocol::CAP_PARENT_ID   ) 
Sigma0::while ( res=nova_semdownmulti(cap_irq)  )  [inline]

Friends And Related Function Documentation

friend class s0_ParentProtocol [friend]

Member Data Documentation

unsigned Sigma0::_cpunr[MAXCPUS]
unsigned long long Sigma0::_gsi
Sigma0::_lock_gsi = Semaphore(alloc_cap())
Sigma0::_lock_mem = Semaphore(alloc_cap())
unsigned Sigma0::_mac
unsigned Sigma0::_numcpus
unsigned Sigma0::_pcidirect[MAXPCIDIRECT]
struct { ... } Sigma0::_percpu[MAXCPUS]

Network data.

char* Sigma0::_vga
Sigma0::_vga = map_self(utcb, 0xa0000, 1<<17)
unsigned Sigma0::cap_irq = utcb->msg[0]
Sigma0::consolesem = &putcd.sem
unsigned Sigma0::exc_base
unsigned Sigma0::gsi = utcb->msg[1] & 0xff
bool Sigma0::locked = !(utcb->msg[1] & 0x200)
ModuleInfo* Sigma0::modinfo = get_module((pid - CLIENT_PT_OFFSET) >> CLIENT_PT_SHIFT)
unsigned char Sigma0::res
Region* Sigma0::reserve = _cap_region.find(CLIENT_PT_OFFSET)
putcd Sigma0::screen = reinterpret_cast<unsigned short *>(_vga + 0x18000)
putcd Sigma0::sem = Semaphore(alloc_cap())
bool Sigma0::shared = (utcb->msg[1] >> 8) & 1
unsigned Sigma0::vnet_sm[MAXMODULES]

The documentation for this struct was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines