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.


added error check to 8259
[palacios.git] / palacios / src / devices / 8259a.c
index 0d55349..0521c51 100644 (file)
@@ -159,6 +159,11 @@ struct pic_internal {
 
     struct guest_info * core;
 
+    struct {
+       int (*ack)(struct guest_info * core, uint32_t irq, void * private_data);
+       void * private_data;
+    } irq_ack_cbs[15];
+
 
     void * router_handle;
     void * controller_handle;
@@ -217,6 +222,9 @@ static int pic_raise_intr(struct v3_vm_info * vm, void * private_data, struct v3
        return -1;
     }
 
+    state->irq_ack_cbs[irq_num].ack = irq->ack;
+    state->irq_ack_cbs[irq_num].private_data = irq->private_data;
+
     if (V3_Get_CPU() != vm->cores[0].pcpu_id) {
        // guest is running on another core, interrupt it to deliver irq
        v3_interrupt_cpu(vm, 0, 0);
@@ -329,7 +337,7 @@ static int pic_begin_irq(struct guest_info * info, void * private_data, int irq)
                state->master_irr &= ~(0x1 << irq);
            }
        } else {
-          PrintDebug("8259 PIC: (master) Ignoring begin_irq for %d since I don't own it\n",irq);
+          PrintDebug("8259 PIC: (master) Ignoring begin_irq for %d since I don't own it\n", irq);
        }
 
     } else {
@@ -341,11 +349,12 @@ static int pic_begin_irq(struct guest_info * info, void * private_data, int irq)
               state->slave_irr &= ~(0x1 << (irq - 8));
           }
        } else {
-          PrintDebug("8259 PIC: (slave) Ignoring begin_irq for %d since I don't own it\n",irq);
+          PrintDebug("8259 PIC: (slave) Ignoring begin_irq for %d since I don't own it\n", irq);
        }
-
     }
 
+
+
     return 0;
 }
 
@@ -466,6 +475,15 @@ static int write_master_port1(struct guest_info * core, ushort_t port, void * sr
             if ((cw2->EOI) && (!cw2->R) && (cw2->SL)) {
                 // specific EOI;
                 state->master_isr &= ~(0x01 << cw2->level);
+
+
+               /*
+               // ack the irq if requested
+               if (state->irq_ack_cbs[irq].ack) {
+                   state->irq_ack_cbs[irq].ack(info, irq, state->irq_ack_cbs[irq].private_data);
+               }
+               */
+
             } else if ((cw2->EOI) & (!cw2->R) && (!cw2->SL)) {
                 int i;
                 // Non-specific EOI
@@ -475,7 +493,7 @@ static int write_master_port1(struct guest_info * core, ushort_t port, void * sr
                         state->master_isr &= ~(0x01 << i);
                         break;
                     }
-                }      
+                }
                 PrintDebug("8259 PIC: Post ISR = %x (wr_Master1)\n", state->master_isr);
             } else if (!(cw2->EOI) && (cw2->R) && (cw2->SL)) {
                 PrintDebug("8259 PIC: Ignoring set-priority, priorities not implemented (level=%d, wr_Master1)\n", cw2->level);
@@ -486,6 +504,13 @@ static int write_master_port1(struct guest_info * core, ushort_t port, void * sr
                 return -1;
             }
 
+           if (cw2->EOI) {
+               if (pic_get_intr_number(core,  state) != -1) {
+                   PrintError("Interrupt pending after EOI\n");
+               }
+           }
+
+
             state->master_ocw2 = cw;
         } else if (IS_OCW3(cw)) {
             PrintDebug("8259 PIC: Handling OCW3 = %x (wr_Master1)\n", cw);
@@ -609,6 +634,14 @@ static int write_slave_port1(struct guest_info * core, ushort_t port, void * src
                return -1;
            }
 
+           if (cw2->EOI) {
+               if (pic_get_intr_number(core,  state) != -1) {
+                   PrintError("Interrupt pending after EOI\n");
+               }
+           }
+
+
+
            state->slave_ocw2 = cw;
        } else if (IS_OCW3(cw)) {
            // Basically sets the IRR/ISR read flag
@@ -849,7 +882,10 @@ static int pic_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) {
        
     state = (struct pic_internal *)V3_Malloc(sizeof(struct pic_internal));
 
-    V3_ASSERT(state != NULL);
+    if (!state) {
+       PrintError("Cannot allocate in init\n");
+       return -1;
+    }
 
     struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, state);