Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


typo fix
[palacios.git] / palacios / src / devices / apic.c
index 44ca08d..9e636b6 100644 (file)
@@ -505,7 +505,7 @@ static void drain_irq_entries(struct apic_state * apic) {
 static int get_highest_isr(struct apic_state * apic) {
     int i = 0, j = 0;
 
-    // We iterate backwards to find the highest priority
+    // We iterate backwards to find the highest priority in-service request
     for (i = 31; i >= 0; i--) {
        uint8_t  * svc_major = apic->int_svc_reg + i;
     
@@ -527,14 +527,15 @@ static int get_highest_isr(struct apic_state * apic) {
 static int get_highest_irr(struct apic_state * apic) {
     int i = 0, j = 0;
 
-    // We iterate backwards to find the highest priority
+    // We iterate backwards to find the highest priority enabled requested interrupt
     for (i = 31; i >= 0; i--) {
        uint8_t  * req_major = apic->int_req_reg + i;
-    
+       uint8_t  * en_major = apic->int_en_reg + i;
+       
        if ((*req_major) & 0xff) {
            for (j = 7; j >= 0; j--) {
                uint8_t flag = 0x1 << j;
-               if ((*req_major) & flag) {
+               if ((*req_major & *en_major) & flag) {
                    return ((i * 8) + j);
                }
            }
@@ -1877,6 +1878,12 @@ static int apic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
     apic_dev = (struct apic_dev_state *)V3_Malloc(sizeof(struct apic_dev_state) + 
                                                  sizeof(struct apic_state) * vm->num_cores);
 
+
+    if (!apic_dev) {
+       PrintError("Failed to allocate space for APIC\n");
+       return -1;
+    }
+
     apic_dev->num_apics = vm->num_cores;
     v3_lock_init(&(apic_dev->state_lock));