khypervisor  v1
Data Structures | Defines | Functions | Variables
virq.c File Reference
#include "virq.h"
#include <k-hypervisor-config.h>
#include <hvmm_trace.h>
#include <vgic.h>
#include <gic.h>
#include <slotpirq.h>
#include <log/print.h>
Include dependency graph for virq.c:

Go to the source code of this file.

Data Structures

struct  virq_entry

Defines

#define VIRQ_MIN_VALID_PIRQ   16
#define VIRQ_NUM_MAX_PIRQS   1024
#define VALID_PIRQ(pirq)   (pirq >= VIRQ_MIN_VALID_PIRQ && pirq < VIRQ_NUM_MAX_PIRQS)
#define VIRQ_MAX_ENTRIES   128

Functions

hvmm_status_t virq_inject (vmid_t vmid, uint32_t virq, uint32_t pirq, uint8_t hw)
static void virq_flush (vmid_t vmid)
hvmm_status_t virq_init (void)

Variables

static struct virq_entry _guest_virqs [NUM_GUESTS_STATIC][VIRQ_MAX_ENTRIES+1]

Define Documentation

#define VALID_PIRQ (   pirq)    (pirq >= VIRQ_MIN_VALID_PIRQ && pirq < VIRQ_NUM_MAX_PIRQS)

Definition at line 13 of file virq.c.

#define VIRQ_MAX_ENTRIES   128

Definition at line 15 of file virq.c.

#define VIRQ_MIN_VALID_PIRQ   16

Definition at line 10 of file virq.c.

#define VIRQ_NUM_MAX_PIRQS   1024

Definition at line 11 of file virq.c.


Function Documentation

static void virq_flush ( vmid_t  vmid) [static]

Definition at line 51 of file virq.c.

{
    /* Actual injection of queued VIRQs takes place here */

    int i;
    int count = 0;
    struct virq_entry *entries = &_guest_virqs[vmid][0];

    for( i = 0; i < VIRQ_MAX_ENTRIES; i++) {
        if ( entries[i].valid ) {
            uint32_t slot;
            if ( entries[i].hw ) {
                slot = vgic_inject_virq_hw(entries[i].virq, VIRQ_STATE_PENDING, GIC_INT_PRIORITY_DEFAULT, entries[i].pirq);
                if ( slot != VGIC_SLOT_NOTFOUND ) {
                    slotpirq_set( vmid, slot, entries[i].pirq );
                }
            } else {
                slot = vgic_inject_virq_sw(entries[i].virq, VIRQ_STATE_PENDING, GIC_INT_PRIORITY_DEFAULT, smp_processor_id(), 1);
            }

            if (slot == VGIC_SLOT_NOTFOUND ) {
                break;
            }

            slotvirq_set( vmid, slot, entries[i].virq );    

            /* Forget */
            entries[i].valid = 0;

            count++;
        }
    }
    if ( count > 0 ) {
        printh( "virq: injected %d virqs to vmid %d \n", count, vmid );
    }
}

Here is the call graph for this function:

Definition at line 88 of file virq.c.

{
    int i, j;

    for( i = 0; i < NUM_GUESTS_STATIC; i++) {
        for( j = 0; j < (VIRQ_MAX_ENTRIES + 1); j++ ) {
            _guest_virqs[i][j].valid = 0;
        }
    }

    vgic_setcallback_virq_flush(&virq_flush);
    return HVMM_STATUS_SUCCESS;
}

Here is the call graph for this function:

hvmm_status_t virq_inject ( vmid_t  vmid,
uint32_t  virq,
uint32_t  pirq,
uint8_t  hw 
)

Definition at line 26 of file virq.c.

{
    hvmm_status_t result = HVMM_STATUS_BUSY;
    int i;
    struct virq_entry *q = &_guest_virqs[vmid][0];
    int slot = slotvirq_getslot(vmid, virq);
    if ( slot == SLOT_INVALID ) {
        /* Inject only the same virq is not present in a slot */
        for( i = 0; i < VIRQ_MAX_ENTRIES; i++ ) {
            if ( q[i].valid == 0 ) {
                q[i].pirq = pirq;
                q[i].virq = virq;   
                q[i].hw = hw;
                q[i].valid = 1;
                result = HVMM_STATUS_SUCCESS;
                break;
            }
        }
    printh( "virq: queueing virq %d pirq %d to vmid %d %s\n", virq, pirq, vmid, result == HVMM_STATUS_SUCCESS ? "done" : "failed");
    } else {
     printh( "virq: rejected queueing duplicated virq %d pirq %d to vmid %d %s\n", virq, pirq, vmid);    
    }
    return result;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 24 of file virq.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines