v3_host_dev_t v3_host_dev_open(char *impl,
v3_bus_class_t bus,
v3_guest_dev_t gdev,
+ v3_guest_dev_intr_t intr,
struct v3_vm_info *vm)
{
- V3_ASSERT(host_dev_hooks != NULL);
- V3_ASSERT(host_dev_hooks->open != NULL);
+ V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks != NULL);
+ V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks->open != NULL);
- return host_dev_hooks->open(impl,bus,gdev,vm->host_priv_data);
+ return host_dev_hooks->open(impl,bus,gdev,intr,vm->host_priv_data);
}
int v3_host_dev_close(v3_host_dev_t hdev)
{
- V3_ASSERT(host_dev_hooks);
- V3_ASSERT(host_dev_hooks->close);
+ V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks);
+ V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks->close);
return host_dev_hooks->close(hdev);
}
void *dst,
uint64_t len)
{
- V3_ASSERT(host_dev_hooks != NULL);
- V3_ASSERT(host_dev_hooks->read_io != NULL);
+ V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks != NULL);
+ V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks->read_io != NULL);
return host_dev_hooks->read_io(hdev,port,dst,len);
}
void *src,
uint64_t len)
{
- V3_ASSERT(host_dev_hooks != NULL);
- V3_ASSERT(host_dev_hooks->write_io != NULL);
+ V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks != NULL);
+ V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks->write_io != NULL);
return host_dev_hooks->write_io(hdev,port,src,len);
}
void *dst,
uint64_t len)
{
- V3_ASSERT(host_dev_hooks != NULL);
- V3_ASSERT(host_dev_hooks->read_mem != NULL);
+ V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks != NULL);
+ V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks->read_mem != NULL);
return host_dev_hooks->read_mem(hdev,(void*)gpa,dst,len);
}
void *src,
uint64_t len)
{
- V3_ASSERT(host_dev_hooks != NULL);
- V3_ASSERT(host_dev_hooks->write_mem != NULL);
+ V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks != NULL);
+ V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks->write_mem != NULL);
return host_dev_hooks->write_mem(hdev,(void*)gpa,src,len);
}
void *dst,
uint64_t len)
{
- V3_ASSERT(host_dev_hooks != NULL);
- V3_ASSERT(host_dev_hooks->read_config);
+ V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks != NULL);
+ V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks->read_config);
return host_dev_hooks->read_config(hdev,offset,dst,len);
}
void *src,
uint64_t len)
{
- V3_ASSERT(host_dev_hooks != NULL);
- V3_ASSERT(host_dev_hooks->write_config);
+ V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks != NULL);
+ V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks->write_config);
return host_dev_hooks->write_config(hdev,offset,src,len);
int v3_host_dev_ack_irq(v3_host_dev_t hdev, uint8_t irq)
{
- V3_ASSERT(host_dev_hooks != NULL);
- V3_ASSERT(host_dev_hooks->ack_irq);
+ V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks != NULL);
+ V3_ASSERT(VM_NONE, VCORE_NONE, host_dev_hooks->ack_irq);
return host_dev_hooks->ack_irq(hdev,irq);
}
int v3_host_dev_raise_irq(v3_host_dev_t hostdev,
v3_guest_dev_t guest_dev,
+ v3_guest_dev_intr_t intr,
uint8_t irq)
{
- // Make this smarter later...
+ if (intr) {
+ intr(hostdev,guest_dev,irq,1);
+ return 0;
+ } else {
+ struct vm_device *dev = (struct vm_device *) guest_dev;
+ if (dev && dev->vm) {
+ return v3_raise_irq(dev->vm,irq);
+ } else {
+ return -1;
+ }
+ }
+}
+
+int v3_host_dev_lower_irq(v3_host_dev_t hostdev,
+ v3_guest_dev_t guest_dev,
+ v3_guest_dev_intr_t intr,
+ uint8_t irq)
+{
struct vm_device *dev = (struct vm_device *) guest_dev;
if (dev && dev->vm) {
- return v3_raise_irq(dev->vm,irq);
+ if (intr) {
+ intr(hostdev,guest_dev,irq,0);
+ return 0;
+ } else {
+ return v3_lower_irq(dev->vm,irq);
+ }
} else {
return -1;
}
void V3_Init_Host_Device_Support(struct v3_host_dev_hooks * hooks) {
host_dev_hooks = hooks;
- PrintDebug("V3 host device interface inited\n");
+ PrintDebug(VM_NONE, VCORE_NONE, "V3 host device interface inited\n");
return;
}