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

Sigma0 application class. More...

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

Classes

struct  ConsoleData
struct  DiskData
struct  PutcData

Public Types

enum  { MAXDISKS = 32, MAXDISKREQUESTS = DISKS_SIZE }
- Public Types inherited from Sigma0Base
enum  {
  REQUEST_STDIN_ATTACH = 0x1001, REQUEST_DISKS_ATTACH, REQUEST_NETWORK_ATTACH, REQUEST_DISK,
  REQUEST_CONSOLE, REQUEST_HOSTOP, REQUEST_NETWORK, REQUEST_PCICFG,
  REQUEST_ACPI
}

Public Member Functions

char * map_self (Utcb *utcb, unsigned long physmem, unsigned long size, unsigned rights, bool frame=false)
char * map_string (Utcb *utcb, unsigned long src)
 Command lines need to be mapped.
bool attach_irq (unsigned gsi, unsigned cap_sm, bool unlocked, phy_cpu_no cpunr, char const *_name=0)
void * get_config_space (uint16 rid)
 Returns a pointer to the memory-mapped config space of a PCI device.
unsigned attach_msi (MessageHostOp *msg, phy_cpu_no 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 long exception_handler_address (unsigned vector)
unsigned create_worker_threads (Hip *hip, phy_cpu_no cpunr)
 Create exception and startup handling portals.
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)
 assert (reserve and reserve->virt<=CLIENT_PT_OFFSET and reserve->size-(reserve->virt-CLIENT_PT_OFFSET) >=(1<< (CLIENT_PT_ORDER+1)))
_cap_region del (Region(CLIENT_PT_OFFSET, 1U<< (CLIENT_PT_ORDER+1)))
 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, DESC_CAP_ALL, ParentProtocol::CAP_PARENT_ID).fill_words(utcb->msg)
*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))
*utcb<< Crd(0, 0, 0);utcb-> reset ()
unsigned init_memmap (Utcb *utcb)
 Init the memory map from the Hip.
void free_module (ModuleInfo *modinfo)
ModuleInfo * get_module (unsigned id)
ModuleInfo * alloc_module (char const *cmdline, unsigned sigma0_cmdlen, bool s0_reserved=false)
unsigned boot_s0_services (Utcb *utcb)
unsigned start_config (Utcb *utcb, unsigned short which, unsigned &internal_id)
 Starts a configuration loaded during boottime.
unsigned start_config (Utcb *utcb, char const *mconfig, unsigned &internal_id, unsigned &sc_usage_cap, unsigned long &usage_mem, bool bswitch, bool part_of_s0=false)
 Start a configuration from a stable memory region (mconfig).
bool idle_sc_sanity_check (unsigned pt)
bool map_idle_scs (Utcb *utcb, unsigned pt)
bool map_exc_pts (const ModuleInfo *modinfo, unsigned pt)
unsigned _start_config (Utcb *utcb, char *elf, unsigned long mod_size, char const *client_cmdline, ModuleInfo *modinfo, unsigned &sc_usage_cap, bool bswitch)
unsigned kill_module (ModuleInfo *modinfo)
 Kill the given module.
bool assign_pci_device (unsigned pd_cap, unsigned bdf, unsigned hint)
 Assign a PCI device to a PD.
NORETURN void internal_error (unsigned pid, Utcb *utcb)
 PT_FUNC (do_breakpoint, if(consolesem) consolesem->up();Logging::printf(">>> Break EIP %08x ESP %08x EFLAGS %08x\n", utcb->eip, utcb->esp, utcb->efl);if(consolesem) consolesem->down();) PT_FUNC(do_singlestep
 if (consolesem) consolesem->up()
 Logging::printf (">>> Step EIP %08x ESP %08x EFLAGS %08x\n", utcb->eip, utcb->esp, utcb->efl)
 if (consolesem) consolesem->down()
 PT_FUNC (do_recall, utcb->efl^=0x100;Logging::printf("RECALL EFLAGS %08x EIP %08x\n", utcb->efl, utcb->eip);utcb->mtd=MTD_RFLAGS;) 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, 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];MessageIrq msg(shared?MessageIrq::ASSERT_NOTIFY:MessageIrq::ASSERT_IRQ, gsi);while(!(res=nova_semdownmulti(cap_irq))){COUNTER_INC("GSI");if(locked) _lock_gsi.down();_mb->bus_hostirq.send(msg);if(locked) _lock_gsi.up();}Logging::panic("s0: %s(%x, %x) request failed with %x\n", __func__, gsi, cap_irq, res);) PT_FUNC(do_startup
 Handle startup exception of spawned childs.
 assert (modinfo)
bool translate_client_fault (ModuleInfo *modinfo, mword fault, mword err, mword &translated, mword &begin, mword &size, unsigned &rights)
 Translate a page fault (given by fault and err) into a memory region [begin, begin+size).
 PT_FUNC (do_request, ModuleInfo *modinfo=get_module((pid-CLIENT_PT_OFFSET) >> CLIENT_PT_SHIFT);assert(modinfo);COUNTER_INC("request");if(utcb->head.untyped==EXCEPTION_WORDS){assert(MEM_OFFSET+modinfo->physsize<=CLIENT_BOOT_UTCB);LOG_VERBOSE("s0: [%2u, %02x] pagefault %x/%x for %llx err %llx at %x\n", modinfo->id, pid, utcb->head.untyped, utcb->head.typed, utcb->qual[1], utcb->qual[0], utcb->eip);mword fault=utcb->qual[1];mword begin;mword size;mword translated;unsigned rights;if(not translate_client_fault(modinfo, fault, utcb->qual[0], translated, begin, size, rights)){Logging::printf("s0: [%2u, %02x] pagefault %x/%x for %llx err %llx at %x\n", modinfo->id, pid, utcb->head.untyped, utcb->head.typed, utcb->qual[1], utcb->qual[0], utcb->eip);Logging::printf("s0: [%2u] unresolvable pagefault - killing client ...\n", modinfo->id);utcb->reset();kill_module(modinfo);return;}assert((begin<=translated)&&(translated< (begin+size)));const mword page_mask=((1UL<< Utcb::MINSHIFT)-1);assert((size >=0x1000) and((begin &page_mask)==0));unsigned order=Cpu::maxalign(translated-begin, begin, fault-(translated-begin), size);LOG_VERBOSE("s0: [%2u, %02x] %lx %lx+%lx -> order %u: %lx+%lx\n", modinfo->id, pid, translated, begin, size, order, translated &~((1UL<< order)-1), 1UL<< order);assert(order >=Utcb::MINSHIFT);assert((1UL<< order)<=size);mword aligned_begin=translated &~((1UL<< order)-1);const Crd region=Crd(aligned_begin >> Utcb::MINSHIFT, order-Utcb::MINSHIFT, rights);if(utcb->qual[0]&1){Logging::printf("s0: potential overmap. revoke!\n");nova_revoke(region, false);}utcb->reset();*utcb<< Utcb::TypedMapCap(region,(fault &~page_mask));utcb->set_header(0, 0);if((utcb->qual[1]&CLIENT_HIP)==CLIENT_HIP){unsigned long rest=utcb->add_mappings(reinterpret_cast< unsigned long >(modinfo->hip), 0x1000, CLIENT_HIP|MAP_MAP, DESC_MEM_ALL);assert(!rest);}else{unsigned long rest=utcb->add_mappings(reinterpret_cast< unsigned long >(modinfo->mem), modinfo->physsize, MEM_OFFSET|MAP_MAP, DESC_MEM_ALL);if(rest){utcb->set_header(0, 0);unsigned long offset=(utcb->qual[1]&~((1UL<< Utcb::MINSHIFT)-1))-MEM_OFFSET;rest=utcb->add_mappings(reinterpret_cast< unsigned long >(modinfo->mem)+offset, 1UL<< Utcb::MINSHIFT,(MEM_OFFSET+offset)|MAP_MAP, DESC_MEM_ALL);assert(!rest);}}LOG_VERBOSE("s0: [%2u, %02x] map %x/%x for %llx err %llx at %x\n", modinfo->id, pid, utcb->head.untyped, utcb->head.typed, utcb->qual[1], utcb->qual[0], utcb->eip);return;}SemaphoreGuard l(_lock_gsi);if(request_pcicfg(modinfo->id, utcb)) return;if(!request_disks(modinfo, utcb)&&!request_console(modinfo, utcb)&&!request_network(modinfo, utcb)) switch(utcb->msg[0]){case REQUEST_HOSTOP:{MessageHostOp *msg=reinterpret_cast< MessageHostOp * >(utcb->msg+1);if(utcb->head.untyped *sizeof(unsigned)< sizeof(unsigned)+sizeof(*msg)) goto fail;switch(msg->type){case MessageHostOp::OP_GET_MAC:msg->mac=get_mac(modinfo->mac++*MAXMODULES+modinfo->id);utcb->msg[0]=0;break;case MessageHostOp::OP_ASSIGN_PCI:if(modinfo->dma){if(assign_pci_device(NOVA_DEFAULT_PD_CAP+(modinfo->id<< CLIENT_PT_SHIFT)+CLIENT_PT_OFFSET, msg->value, msg->len)) utcb->msg[0]=0;else goto fail;}else{Logging::printf("s0: [%2u] DMA access denied.\n", modinfo->id);goto fail;}break;case MessageHostOp::OP_ATTACH_IRQ:if((msg->value &0xff)< _hip->cfg_gsi){unsigned gsi_cap=_irq_cap_base+(msg->value &0xff);unsigned res=nova_assign_gsi(gsi_cap, modinfo->cpunr);if(res!=NOVA_ESUCCESS) goto fail;Logging::printf("s0: [%2u] gsi %lx granted\n", modinfo->id, msg->value);utcb->set_header(1, 0);utcb->msg[0]=utcb->add_mappings(gsi_cap<< Utcb::MINSHIFT, 1<< Utcb::MINSHIFT, MAP_MAP, DESC_CAP_ALL);if(utcb->msg[0]) goto fail;}else{Logging::printf("s0: [%2u] irq request dropped %x nr %x\n", modinfo->id, utcb->msg[2], utcb->msg[2] >> Utcb::MINSHIFT);goto fail;}break;case MessageHostOp::OP_ATTACH_MSI:{if(msg->is_hpet){Logging::printf("s0: Client tried to map HPET MSI. He can do that himself!\n");goto fail;}unsigned cap=attach_msi(msg, modinfo->cpunr);if(!cap){Logging::printf("s0: [%2u] granting msi to cpu %u failed\n", modinfo->id, modinfo->cpunr);goto fail;}utcb->set_header(1+sizeof(*msg)/sizeof(unsigned), 0);unsigned long res=utcb->add_mappings(cap<< Utcb::MINSHIFT, 1<< Utcb::MINSHIFT, MAP_MAP, DESC_CAP_ALL);assert(res==0);utcb->msg[0]=0;Logging::printf("s0: [%2u] msi granted to cpu %u\n", modinfo->id, modinfo->cpunr);}break;case MessageHostOp::OP_ALLOC_IOIO_REGION:map_self(utcb,(msg->value >> 8)<< Utcb::MINSHIFT, 1<< (Utcb::MINSHIFT+msg->value &0xff), DESC_IO_ALL);utcb->set_header(1, 0);utcb->msg[0]=utcb->add_mappings((msg->value >> 8)<< Utcb::MINSHIFT,(1<< (Utcb::MINSHIFT+msg->value &0xff)), MAP_MAP, DESC_IO_ALL);if(utcb->msg[0]) goto fail;break;case MessageHostOp::OP_ALLOC_IOMEM:{unsigned long addr=msg->value &~0xffful;char *ptr=map_self(utcb, addr, msg->len, DESC_MEM_ALL);utcb->set_header(1, 0);utcb->msg[0]=utcb->add_mappings(reinterpret_cast< unsigned long >(ptr), msg->len, MAP_MAP, DESC_MEM_ALL);if(utcb->msg[0]==0) Logging::printf("s0: [%2u] iomem %lx+%lx granted from %p\n", modinfo->id, addr, msg->len, ptr);else{Logging::printf("s0: [%2u] iomem mapping failed.\n", modinfo->id);goto fail;}}break;case MessageHostOp::OP_ALLOC_SEMAPHORE:case MessageHostOp::OP_ALLOC_SERVICE_THREAD:case MessageHostOp::OP_ALLOC_SERVICE_PORTAL:case MessageHostOp::OP_GUEST_MEM:case MessageHostOp::OP_ALLOC_FROM_GUEST:case MessageHostOp::OP_VIRT_TO_PHYS:case MessageHostOp::OP_NOTIFY_IRQ:case MessageHostOp::OP_VCPU_CREATE_BACKEND:case MessageHostOp::OP_VCPU_BLOCK:case MessageHostOp::OP_VCPU_RELEASE:case MessageHostOp::OP_REGISTER_SERVICE:case MessageHostOp::OP_GET_MODULE:case MessageHostOp::OP_WAIT_CHILD:case MessageHostOp::OP_CREATE_EC4PT:default:Logging::printf("s0: [%2u] unknown request (%x,%x,%x) dropped \n", modinfo->id, utcb->msg[0], utcb->msg[1], utcb->msg[2]);goto fail;}}break;case REQUEST_ACPI:{MessageAcpi *msg=reinterpret_cast< MessageAcpi * >(utcb->msg+1);if(utcb->head.untyped *sizeof(unsigned)< sizeof(unsigned)+sizeof(*msg)) goto fail;if(msg->type==MessageAcpi::ACPI_GET_IRQ) utcb->msg[0]=!_mb->bus_acpi.send(*msg, true);}break;default:Logging::printf("s0: [%2u] unknown request (%x,%x,%x) dropped \n", modinfo->id, utcb->msg[0], utcb->msg[1], utcb->msg[2]);goto fail;}return;fail:utcb->msg[0]=~0x10u;utcb->set_header(1, 0);) bool receive(MessageHostOp &msg)
 Handle child page-faults and "legacy call interface" requests.
void init_network ()
bool request_network (ModuleInfo *modinfo, Utcb *utcb)
 Handle network requests from other PDs.
bool receive (MessageNetwork &msg)
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 bswitch)
void switch_view (Motherboard *mb, int view, unsigned short consoleid)
 Switch to our view.
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 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 run (Utcb *utcb, Hip *hip) NORETURN
 Sigma0 ()
- Public Member Functions inherited from NovaProgram
 NovaProgram ()
- Public Member Functions inherited from CapAllocator
 CapAllocator (unsigned long cap_, unsigned long cap_start, unsigned long cap_order)
unsigned alloc_cap (unsigned count=1)
void dealloc_cap (unsigned cap, unsigned count=1)
- Public Member Functions inherited from StaticReceiver< Sigma0 >
 StaticReceiver ()
- Public Member Functions inherited from Device
void debug_dump ()
 Device (const char *debug_name)

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)
 Convert client's virtual address (physoffset) to a physical address.
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 sigma0_memfree (void *ptr)
static void start (phy_cpu_no cpu, Utcb *utcb) asm("start") REGPARM(3) NORETURN
- Static Public Member Functions inherited from Sigma0Base
static unsigned request_stdin (Utcb *utcb, StdinConsumer *consumer, unsigned sem_nq)
static unsigned request_disks_attach (Utcb *utcb, DiskConsumer *consumer, unsigned sem_nq)
static unsigned request_network_attach (Utcb *utcb, NetworkConsumer *consumer, unsigned sem_nq)
static unsigned disk (MessageDisk &msg)
static unsigned console (MessageConsole &msg)
static unsigned hostop (MessageHostOp &msg)
static unsigned network (MessageNetwork &msg)
static unsigned pcicfg (MessagePciConfig &msg)
static unsigned acpi (MessageAcpi &msg)
- Static Public Member Functions inherited from BaseProgram
static Utcbmyutcb (unsigned long esp=0)
 Get the UTCB pointer from the top of the stack, which is laid out as follows:
static phy_cpu_no mycpu ()
 Return my CPU number.
static void revoke_all_mem (void *address, unsigned long size, unsigned rights, bool myself)
 Revoke all memory for a given virtual region.
static Crd request_mapping (char *start, unsigned long size, unsigned long hotspot)
 Request the mapping for a memory area.
- Static Public Member Functions inherited from NovaProgram
static void exit (const char *msg)
 Default exit function.
- Static Public Member Functions inherited from StaticReceiver< Sigma0 >
static bool receive_static (Device *o, M &msg)

Public Attributes

phy_cpu_no _cpunr [MAXCPUS]
unsigned _numcpus
unsigned _last_affinity
unsigned _irq_cap_base
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
bool initialized_console
bool initialized_s0_tasks
Hip__hip
unsigned _msivector
unsigned long long _gsi
unsigned _pcidirect [MAXPCIDIRECT]
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, DESC_MEM_ALL, true)
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
 _irq_cap_base = alloc_cap(hip->cfg_gsi)
 return
ModuleInfo * modinfo = get_module((pid - CLIENT_PT_OFFSET) >> CLIENT_PT_SHIFT)
utcb eax = modinfo->cpunr
utcb ecx = utcb->edx = utcb->ebx = 0
utcb eip = modinfo->rip
utcb esp = CLIENT_HIP
utcb mtd = MTD_RIP_LEN | MTD_RSP | MTD_GPR_ACDB
NetworkProducer _prod_network [MAXMODULES]
 Network data.
struct Sigma0::DiskData _disk_data [MAXMODULES]
struct Sigma0::ConsoleData _console_data [MAXMODULES]

Static Public Attributes

static Semaphore _lock_mem

Friends

class s0_ParentProtocol

Additional Inherited Members

- Protected Member Functions inherited from NovaProgram
Utcballoc_utcb ()
 Alloc a region of virtual memory to put an EC into.
template<class C >
 __attribute__ ((nonnull(6))) unsigned create_ec_helper(C *tls
 Create an EC and setup the stack.
void init_mem (Hip *hip)
 Init the memory map from the HIP as we get them from sigma0.
void __attribute__ ((noreturn)) block_forever()
 Block ourself.
- Static Protected Member Functions inherited from Sigma0Base
static unsigned request_portal ()
template<unsigned OP>
static unsigned request_attach (Utcb *utcb, void *consumer, unsigned sem_nq)
 Creates a producer in Sigma0 and attaches it to a consumer in the calling PD.
template<class MESSAGE , unsigned OP>
static unsigned sigma0_message (MESSAGE &msg)
- Protected Attributes inherited from NovaProgram
Hip_hip
unsigned _cap_block
RegionList< 512 > _free_virt
RegionList< 512 > _free_phys
RegionList< 512 > _virt_phys
phy_cpu_no cpunr
phy_cpu_no unsigned excbase
phy_cpu_no unsigned Utcb ** utcb_out
phy_cpu_no unsigned Utcb void * func
phy_cpu_no unsigned Utcb void
unsigned long 
cap = ~0UL
phy_cpu_no unsigned Utcb void
unsigned long bool 
local

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.

unsigned Sigma0::_start_config ( Utcb utcb,
char *  elf,
unsigned long  mod_size,
char const *  client_cmdline,
ModuleInfo *  modinfo,
unsigned &  sc_usage_cap,
bool  bswitch 
)
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 
)
inlinestatic

Convert client's virtual address (physoffset) to a physical address.

Also truncates size if it points behind memory allocated to the client.

Returns true on error. (Why?!)

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

Prepare UTCB for receiving a new cap.

ModuleInfo* Sigma0::alloc_module ( char const *  cmdline,
unsigned  sigma0_cmdlen,
bool  s0_reserved = false 
)
inline
Sigma0::assert ( _cap_start  = =0 &&_cap_order==16)
Sigma0::assert ( reserve and reserve->virt<=CLIENT_PT_OFFSET and reserve->size reserve->virt-CLIENT_PT_OFFSET) >=(1<< (CLIENT_PT_ORDER+1))
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 ( ~utcb->head.untyped &  1)
Sigma0::assert ( modinfo  )
bool Sigma0::assign_pci_device ( unsigned  pd_cap,
unsigned  bdf,
unsigned  hint 
)
inline

Assign a PCI device to a PD.

It makes sure only the first will get it.

Parameters
bdfBus/Device/Function
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,
phy_cpu_no  cpunr,
char const *  _name = 0 
)
inline
unsigned Sigma0::attach_msi ( MessageHostOp msg,
phy_cpu_no  cpunr 
)
inline
unsigned Sigma0::boot_s0_services ( Utcb utcb)
inline
Sigma0::check1 ( ,
init(hip)   
)
Sigma0::check1 ( ,
nova_create_sm(_lock_gsi.sm())||nova_create_sm(_lock_mem.sm())   
)
Sigma0::check1 ( ,
create_worker_threads(hip, utcb->head.nul_cpunr)   
)
Sigma0::check1 ( ,
nova_create_sm(putcd.sem.sm())   
)
Sigma0::check1 ( ,
nova_create_sm(CLIENT_PT_OFFSET+ParentProtocol::CAP_PARENT_ID  
)
Sigma0::check1 ( ,
nova_call(_percpu[utcb->head.nul_cpunr].cap_pt_echo  
)
template<typename T >
static bool Sigma0::convert_client_ptr ( ModuleInfo *  modinfo,
T *&  ptr,
unsigned  size 
)
inlinestatic

Converts client ptr to a pointer in our address space.

Returns true on error.

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,
phy_cpu_no  cpunr 
)
inline

Create exception and startup handling portals.

If cpunr is given, it only initializes this single CPU and assumes that this is the bootstrap CPU, i.e. exception handling portals start at capability index 0.

_cap_region Sigma0::del ( Region(CLIENT_PT_OFFSET, 1U<< (CLIENT_PT_ORDER+1))  )
unsigned long Sigma0::exception_handler_address ( unsigned  vector)
inline
static void Sigma0::fancy_output ( const char *  st,
unsigned  maxchars 
)
inlinestatic
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.

void* Sigma0::get_config_space ( uint16  rid)
inline

Returns a pointer to the memory-mapped config space of a PCI device.

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.

bool Sigma0::idle_sc_sanity_check ( unsigned  pt)
inline
Sigma0::if ( consolesem  )
Sigma0::if ( consolesem  )
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
NORETURN void Sigma0::internal_error ( unsigned  pid,
Utcb utcb 
)
inline
unsigned Sigma0::kill_module ( ModuleInfo *  modinfo)
inline

Kill the given module.

unsigned Hip* hip Sigma0::Logging::init ( putc  ,
 
)
Sigma0::Logging::init ( putc  ,
putcd 
)
Sigma0::Logging::printf ( "s0: preinit %p\n\n"  ,
hip   
)
Sigma0::Logging::printf ( "s0: create locks\n"  )
Sigma0::Logging::printf ( "s0: create pf echo+worker threads\n"  )
Sigma0::Logging::printf ( "s0: map vga memory\n"  )
Sigma0::Logging::printf ( ">>  ,
Step EIP%08x ESP%08x EFLAGS%08x\n"  ,
utcb->  eip,
utcb->  esp,
utcb->  efl 
)
bool Sigma0::map_exc_pts ( const ModuleInfo *  modinfo,
unsigned  pt 
)
inline
bool Sigma0::map_idle_scs ( Utcb utcb,
unsigned  pt 
)
inline
char* Sigma0::map_self ( Utcb utcb,
unsigned long  physmem,
unsigned long  size,
unsigned  rights,
bool  frame = false 
)
inline
char* Sigma0::map_string ( Utcb utcb,
unsigned long  src 
)
inline

Command lines need to be mapped.

Sigma0::memcpy ( _vga 0x1a000,
_vga 0x18000,
0x1000   
)
Sigma0::memmove ( utcb->  item_start(),
utcb->  msg,
sizeof(unsigned)*utcb->head.typed *  2 
)
void Sigma0::postinit ( Hip hip)
inline
Sigma0::PT_FUNC ( do_breakpoint  ,
if(consolesem) consolesem->up();Logging::printf(">>> Break EIP %08x ESP %08x EFLAGS %08x\n", utcb->eip, utcb->esp, utcb->efl);if(consolesem) consolesem->down();   
)
Sigma0::PT_FUNC ( do_recall  ,
utcb->efl^  = 0x100;  Logging::printf("RECALL EFLAGS %08x EIP %08x\n", utcb->efl, utcb->eip); utcb->mtd = MTD_RFLAGS; 
)
Sigma0::PT_FUNC ( do_request  )
inline

Handle child page-faults and "legacy call interface" requests.

Sigma0::PT_FUNC_NORETURN ( do_gsi  )

Handle startup exception of spawned childs.

static void Sigma0::putc ( void *  data,
int  value 
)
inlinestatic
bool Sigma0::receive ( MessageNetwork msg)
inline
bool Sigma0::receive ( MessageDiskCommit 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
* utcb<< Crd(0,0,0); utcb-> Sigma0::reset ( )
void Sigma0::run ( Utcb utcb,
Hip hip 
)
inline
static void Sigma0::serial_send ( long  value)
inlinestatic
* utcb<< Crd(0, 31, DESC_CAP_ALL); utcb-> Sigma0::set_header ( ,
 
)
utcb Sigma0::set_header ( ,
utcb->head.untyped/  2 
)
static void* Sigma0::sigma0_memalloc ( unsigned long  size,
unsigned long  align 
)
inlinestatic

Request memory from the memmap.

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

static void Sigma0::sigma0_memfree ( void *  ptr)
inlinestatic
void Sigma0::start ( phy_cpu_no  cpu,
Utcb utcb 
)
static
unsigned Sigma0::start_config ( Utcb utcb,
unsigned short  which,
unsigned &  internal_id 
)
inline

Starts a configuration loaded during boottime.

Configuration numbers start at zero.

unsigned Sigma0::start_config ( Utcb utcb,
char const *  mconfig,
unsigned &  internal_id,
unsigned &  sc_usage_cap,
unsigned long &  usage_mem,
bool  bswitch,
bool  part_of_s0 = false 
)
inline

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

Region has to be zero terminated.

void Sigma0::switch_view ( Motherboard mb,
int  view,
unsigned short  consoleid 
)
inline

Switch to our view.

bool Sigma0::translate_client_fault ( ModuleInfo *  modinfo,
mword  fault,
mword  err,
mword translated,
mword begin,
mword size,
unsigned &  rights 
)
inline

Translate a page fault (given by fault and err) into a memory region [begin, begin+size).

TODO Don't hardcode memory layout.

_lock_mem Sigma0::up ( )
putcd sem Sigma0::up ( )

Friends And Related Function Documentation

friend class s0_ParentProtocol
friend

Member Data Documentation

Hip* Sigma0::__hip
struct Sigma0::ConsoleData Sigma0::_console_data[MAXMODULES]
phy_cpu_no Sigma0::_cpunr[MAXCPUS]
struct Sigma0::DiskData Sigma0::_disk_data[MAXMODULES]
unsigned long long Sigma0::_gsi
unsigned Sigma0::_irq_cap_base
Sigma0::_irq_cap_base = alloc_cap(hip->cfg_gsi)
unsigned Sigma0::_last_affinity
Semaphore Sigma0::_lock_gsi
Sigma0::_lock_gsi = Semaphore(alloc_cap())
Semaphore Sigma0::_lock_mem
static
Sigma0::_lock_mem = Semaphore(alloc_cap())
unsigned Sigma0::_mac
Motherboard* Sigma0::_mb
ModuleInfo Sigma0::_modinfo[MAXMODULES]
unsigned Sigma0::_msivector
unsigned Sigma0::_numcpus
unsigned Sigma0::_pcidirect[MAXPCIDIRECT]
struct { ... } Sigma0::_percpu[MAXCPUS]
NetworkProducer Sigma0::_prod_network[MAXMODULES]

Network data.

char* Sigma0::_vga
Sigma0::_vga = map_self(utcb, 0xa0000, 1<<17, DESC_MEM_ALL, true)
VgaRegs Sigma0::_vga_regs
unsigned Sigma0::cap_ec_echo
unsigned Sigma0::cap_ec_worker
unsigned Sigma0::cap_pt_echo
Sigma0::consolesem = &putcd.sem
_vga_regs Sigma0::cursor_pos = 24*80*2
utcb Sigma0::eax = modinfo->cpunr
utcb Sigma0::ecx = utcb->edx = utcb->ebx = 0
utcb Sigma0::eip = modinfo->rip
utcb Sigma0::esp = CLIENT_HIP
unsigned Sigma0::exc_base
bool Sigma0::initialized_console
bool Sigma0::initialized_s0_tasks
ModuleInfo* Sigma0::modinfo = get_module((pid - CLIENT_PT_OFFSET) >> CLIENT_PT_SHIFT)
utcb Sigma0::mtd = MTD_RIP_LEN | MTD_RSP | MTD_GPR_ACDB
_vga_regs Sigma0::offset = 0
struct Sigma0::PutcData Sigma0::putcd
putcd Sigma0::regs = &_vga_regs
Region* Sigma0::reserve = _cap_region.find(CLIENT_PT_OFFSET)
Sigma0::return
putcd Sigma0::screen = reinterpret_cast<unsigned short *>(_vga + 0x18000)
putcd Sigma0::sem = Semaphore(alloc_cap())
s0_AdmissionProtocol* Sigma0::service_admission
s0_ParentProtocol* Sigma0::service_parent

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