khypervisor  v1
Data Structures | Defines | Functions
virqmap.h File Reference
#include <arch_types.h>
#include <hvmm_trace.h>
#include <gic.h>
Include dependency graph for virqmap.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  virqmap_entry

Defines

#define VIRQMAP_ENTRY_NOTFOUND   0

Functions

struct virqmap_entryvirqmap_for_pirq (uint32_t pirq)
hvmm_status_t virqmap_init (void)
uint32_t virqmap_pirq (vmid_t vmid, uint32_t virq)
void virqmap_vgicd_changed_istatus_callback_handler (vmid_t vmid, uint32_t istatus, uint8_t word_offset)

Define Documentation

#define VIRQMAP_ENTRY_NOTFOUND   0

Definition at line 24 of file virqmap.h.


Function Documentation

struct virqmap_entry* virqmap_for_pirq ( uint32_t  pirq) [read]

Definition at line 47 of file virqmap.c.

{
    const struct virqmap_entry * result = VIRQMAP_ENTRY_NOTFOUND;

    if ( _virqmap[pirq].vmid != VMID_INVALID) {
        result = &_virqmap[pirq];
    }
    return result;
}

Definition at line 25 of file virqmap.c.

{
    // TODO(wonseok): read file and initialize the mapping.
    HVMM_TRACE_ENTER();
    int i;

    for (i = 0; i < GIC_NUM_MAX_IRQS; i++) {
        _virqmap[i].vmid = VMID_INVALID;
        _virqmap[i].virq = 0;
    }

    // NOTE(wonseok): referenced by https://github.com/kesl/khypervisor/wiki/Hardware-Resources-of-Guest-Linux-on-FastModels-RTSM_VE-Cortex-A15x1
    CFG_GUEST0_VIRQMAP(_virqmap);
    CFG_GUEST1_VIRQMAP(_virqmap);

    vgicd_set_callback_changed_istatus(&virqmap_vgicd_changed_istatus_callback_handler);

    HVMM_TRACE_EXIT();

    return HVMM_STATUS_SUCCESS;
}

Here is the call graph for this function:

uint32_t virqmap_pirq ( vmid_t  vmid,
uint32_t  virq 
)

Definition at line 57 of file virqmap.c.

{
    uint32_t pirq = PIRQ_INVALID;

    /* FIXME: This is ridiculously inefficient to loop up to GIC_NUM_MAX_IRQS */
    int i;
    for (i = 0; i < GIC_NUM_MAX_IRQS; i++) {
        if ( _virqmap[i].vmid == vmid && _virqmap[i].virq == virq ) {
            pirq = i;
            break;
        }
    }
    return pirq;
}
void virqmap_vgicd_changed_istatus_callback_handler ( vmid_t  vmid,
uint32_t  istatus,
uint8_t  word_offset 
)

Definition at line 73 of file virqmap.c.

{
    uint32_t cstatus;                          // changed bits only
    uint32_t minirq;
    int bit;

    minirq = word_offset * 32;                 /* irq range: 0~31 + word_offset * size_of_istatus_in_bits */
    cstatus = old_vgicd_status[vmid][word_offset] ^ istatus;   // find changed bits

    while(cstatus) {
        uint32_t virq;
        uint32_t pirq;
        bit = firstbit32(cstatus);

        virq = minirq + bit;
        pirq = virqmap_pirq(vmid, virq);

        if ( pirq != PIRQ_INVALID ) {
            /* changed bit */
            if ( istatus & (1 << bit) ) {
                printh("[%s : %d] enabled irq num is %d\n", __FUNCTION__, __LINE__, bit + minirq);
                gic_test_configure_irq(pirq, GIC_INT_POLARITY_LEVEL, gic_cpumask_current(), GIC_INT_PRIORITY_DEFAULT );
            } else {
                printh("[%s : %d] disabled irq num is %d\n",__FUNCTION__, __LINE__, bit + minirq);
                gic_disable_irq(pirq);
            }
        } else {
            printh( "WARNING: Ignoring virq %d for guest %d has no mapped pirq\n", virq, vmid );
        }
        cstatus &= ~(1<< bit);
    }
    old_vgicd_status[vmid][word_offset] = istatus;
}

Here is the call graph for this function:

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines