|
khypervisor
v1
|
#include <k-hypervisor-config.h>#include "virqmap.h"#include "context.h"#include "hvmm_types.h"#include "vdev/vdev_gicd.h"#include <asm-arm_inline.h>#include <config/cfg_platform.h>#include <log/print.h>
Go to the source code of this file.
Defines | |
| #define | firstbit32(word) ( 31 - asm_clz(word) ) |
| #define | NUM_MAX_VIRQS 128 |
| #define | NUM_STATUS_WORDS (NUM_MAX_VIRQS / 32) |
Functions | |
| hvmm_status_t | virqmap_init (void) |
| struct virqmap_entry * | virqmap_for_pirq (uint32_t pirq) |
| 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) |
Variables | |
| static struct virqmap_entry | _virqmap [GIC_NUM_MAX_IRQS] |
| static uint32_t | old_vgicd_status [NUM_GUESTS_STATIC][NUM_STATUS_WORDS] = {{0,}, } |
| #define firstbit32 | ( | word | ) | ( 31 - asm_clz(word) ) |
| #define NUM_MAX_VIRQS 128 |
| #define NUM_STATUS_WORDS (NUM_MAX_VIRQS / 32) |
| 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;
}
| hvmm_status_t virqmap_init | ( | void | ) |
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;
}

| 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 | ||
| ) |
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;
}

struct virqmap_entry _virqmap[GIC_NUM_MAX_IRQS] [static] |
uint32_t old_vgicd_status[NUM_GUESTS_STATIC][NUM_STATUS_WORDS] = {{0,}, } [static] |
1.7.6.1