khypervisor  v1
gic/slotpirq.c
Go to the documentation of this file.
00001 #include <slotpirq.h>
00002 #include <k-hypervisor-config.h>
00003 #include <vgic.h>
00004 /* SLOT:PIRQ mapping */
00005 #include <log/print.h>
00006 
00007 static uint32_t _guest_pirqatslot[NUM_GUESTS_STATIC][VGIC_NUM_MAX_SLOTS];
00008 static uint32_t _guest_virqatslot[NUM_GUESTS_STATIC][VGIC_NUM_MAX_SLOTS];
00009 
00010 void slotpirq_init(void)
00011 {
00012     int i, j;
00013     for( i = 0; i < NUM_GUESTS_STATIC; i++ ) {
00014         for( j = 0; j < VGIC_NUM_MAX_SLOTS; j++ ) {
00015             _guest_pirqatslot[i][j] = PIRQ_INVALID;
00016             _guest_virqatslot[i][j] = VIRQ_INVALID;
00017         }
00018     }
00019 }
00020 
00021 void slotpirq_set( vmid_t vmid, uint32_t slot, uint32_t pirq )
00022 {
00023     if ( vmid < NUM_GUESTS_STATIC ) {
00024         printh( "vgic: setting vmid:%d slot:%d pirq:%d\n", vmid, slot, pirq );
00025         _guest_pirqatslot[vmid][slot] = pirq;
00026     }
00027 }
00028 
00029 uint32_t slotpirq_get(vmid_t vmid, uint32_t slot)
00030 {
00031     uint32_t pirq = PIRQ_INVALID;
00032 
00033     if ( vmid < NUM_GUESTS_STATIC ) {
00034         pirq = _guest_pirqatslot[vmid][slot];
00035         printh( "vgic: reading vmid:%d slot:%d pirq:%d\n", vmid, slot, pirq );
00036     }
00037     return pirq;
00038 }
00039 
00040 void slotpirq_clear(vmid_t vmid, uint32_t slot)
00041 {
00042     slotpirq_set(vmid, slot, PIRQ_INVALID);
00043 }
00044 
00045 void slotvirq_set( vmid_t vmid, uint32_t slot, uint32_t virq )
00046 {
00047     if ( vmid < NUM_GUESTS_STATIC ) {
00048         printh( "vgic: setting vmid:%d slot:%d virq:%d\n", vmid, slot, virq );
00049         _guest_virqatslot[vmid][slot] = virq;
00050     } else {
00051         printh( "vgic: not setting invalid vmid:%d slot:%d virq:%d\n", vmid, slot, virq );
00052     }
00053 }
00054 
00055 uint32_t slotvirq_getslot(vmid_t vmid, uint32_t virq)
00056 {
00057     uint32_t slot = SLOT_INVALID;
00058     int i;
00059 
00060     if ( vmid < NUM_GUESTS_STATIC ) {
00061         for ( i = 0; i < VGIC_NUM_MAX_SLOTS; i++ ) {
00062             if ( _guest_virqatslot[vmid][i] == virq ) {
00063                 slot = i;
00064                 printh( "vgic: reading vmid:%d slot:%d virq:%d\n", vmid, slot, virq );
00065                 break;
00066             }
00067         }
00068     }
00069     return slot;
00070 }
00071 
00072 void slotvirq_clear(vmid_t vmid, uint32_t slot)
00073 {
00074     slotvirq_set(vmid, slot, VIRQ_INVALID);
00075 }
00076 
00077 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines