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.


this will probably be a disaster...
[palacios.git] / palacios / src / devices / icc_bus.c
index c78190b..cfe3c05 100644 (file)
@@ -134,14 +134,14 @@ static int deliver(uint32_t src_apic, struct apic_data *dest_apic, struct int_cm
            // TODO: any APIC reset on dest core (shouldn't be needed, but not sure...)
 
            // Sanity check
-           if (core->cpu_mode!=INIT) { 
+           if (core->cpu_mode != INIT) { 
                PrintError("icc_bus: Warning: core %u is not in INIT state, ignored\n",core->cpu_id);
                // Only a warning, since INIT INIT SIPI is common
                break;
            }
 
            // We transition the target core to SIPI state
-           core->cpu_mode=SIPI;  // note: locking should not be needed here
+           core->cpu_mode = SIPI;  // note: locking should not be needed here
 
            // That should be it since the target core should be
            // waiting in host on this transition
@@ -201,6 +201,7 @@ static int deliver(uint32_t src_apic, struct apic_data *dest_apic, struct int_cm
 // icr_data contains interrupt vector *except* for ext_int
 // in which case it is given via irq
 //
+
 int v3_icc_send_ipi(struct vm_device * icc_bus, uint32_t src_apic, uint64_t icr_data, 
                    uint32_t dfr_data, uint32_t extirq) {
 
@@ -208,18 +209,29 @@ int v3_icc_send_ipi(struct vm_device * icc_bus, uint32_t src_apic, uint64_t icr_
 
     struct int_cmd_reg *icr = (struct int_cmd_reg *)&icr_data;
     struct dst_fmt_reg *dfr = (struct dst_fmt_reg*)&dfr_data;
+
     struct icc_bus_state * state = (struct icc_bus_state *)icc_bus->private_data;
+    struct apic_data * dest_apic = NULL;
+    PrintDebug("icc_bus: icc_bus=%p, src_apic=%u, icr_data=%llx, extirq=%u\n", 
+              icc_bus, src_apic, icr_data, extirq);
 
     // initial sanity checks
-    if (src_apic>=MAX_APICS || (!state->apics[src_apic].present && src_apic!=state->ioapic_id)) { 
+    if ((src_apic >= MAX_APICS) || 
+       ((state->apics[src_apic].present == 0) && 
+        (src_apic != state->ioapic_id))) { 
        PrintError("icc_bus: Apparently sending from unregistered apic id=%u\n",src_apic);
        return -1;
     }
-    if (icr->dst_mode==0  && !state->apics[icr->dst].present) { 
-       PrintError("icc_bus: Attempted send to unregistered apic id=%u\n",icr->dst);
+
+
+    if ((icr->dst_mode == 0) && (state->apics[icr->dst].present == 0)) { 
+       PrintError("icc_bus: Attempted send to unregistered apic id=%u\n", icr->dst);
        return -1;
     }
 
+    dest_apic =  &(state->apics[icr->dst]);
+
+
     PrintDebug("icc_bus: IPI %s %u from %s %u to %s %s %u (icr=0x%llx, dfr=0x%x) (extirq=%u)\n",
               deliverymode_str[icr->del_mode], icr->vec, 
               src_apic==state->ioapic_id ? "ioapic" : "apic",
@@ -241,6 +253,7 @@ int v3_icc_send_ipi(struct vm_device * icc_bus, uint32_t src_apic, uint64_t icr_
     switch (icr->dst_shorthand) {
 
        case 0:  // no shorthand
+
            if (icr->dst_mode==0) { 
                // physical delivery
                struct apic_data * dest_apic =  &(state->apics[icr->dst]);
@@ -311,11 +324,13 @@ int v3_icc_send_ipi(struct vm_device * icc_bus, uint32_t src_apic, uint64_t icr_
                    PrintError("icc_bus: unknown logical delivery model 0x%x\n", dfr->model);
                    return -1;
                }
+
            }
            
            break;
            
        case 1:  // self
+
            if (icr->dst_mode==0) { 
                // physical delivery
                if (icr->dst==state->ioapic_id) { 
@@ -329,12 +344,14 @@ int v3_icc_send_ipi(struct vm_device * icc_bus, uint32_t src_apic, uint64_t icr_
            } else {
                // logical delivery
                PrintError("icc_bus: use of logical delivery in self is not yet supported.\n");
+
                return -1;
            }
            break;
            
        case 2: 
-       case 3:  // all and all-but-me
+
+       case 3: { // all and all-but-me
            if (icr->dst_mode==0) { 
                // physical
                int i;
@@ -344,6 +361,7 @@ int v3_icc_send_ipi(struct vm_device * icc_bus, uint32_t src_apic, uint64_t icr_
                        if (deliver(src_apic,dest_apic,icr,state,extirq)) { 
                            return -1;
                        }
+
                    }
                }
            } else {
@@ -353,7 +371,11 @@ int v3_icc_send_ipi(struct vm_device * icc_bus, uint32_t src_apic, uint64_t icr_
                return -1;
            }
            break;
+       }
+       default:
+           return -1;
     }
+    
 
     return 0;
 }