Beispiel #1
0
/* Remove a PA-POS-OC3 from the specified slot */
int dev_c7200_pa_pos_shutdown(vm_instance_t *vm,struct cisco_card *card)
{
   struct pos_oc3_data *d = card->drv_info;

   /* Remove the PA EEPROM */
   cisco_card_unset_eeprom(card);
   c7200_set_slot_eeprom(VM_C7200(vm),card->slot_id,NULL);

   /* Remove the PCI device */
   pci_dev_remove(d->pci_dev);

   /* Remove the PLX9060 chips */
   vm_object_remove(vm,d->rx_obj);
   vm_object_remove(vm,d->tx_obj);
   vm_object_remove(vm,d->cs_obj);

   /* Remove the devices from the CPU address space */
   vm_unbind_device(vm,&d->rx_dev);
   vm_unbind_device(vm,&d->tx_dev);
   vm_unbind_device(vm,&d->cs_dev);

   vm_unbind_device(vm,&d->dev);
   cpu_group_rebuild_mts(vm->cpu_group);

   /* Free the device structure itself */
   free(d);
   return(0);
}
Beispiel #2
0
/* Map a device at the specified physical address */
int vm_map_device(vm_instance_t *vm,struct vdevice *dev,m_uint64_t base_addr)
{
#if 0   
   /* Suspend VM activity */
   vm_suspend(vm);

   if (cpu_group_sync_state(vm->cpu_group) == -1) {
      fprintf(stderr,"VM%u: unable to sync with system CPUs.\n",
              vm->instance_id);
      return(-1);
   }
#endif

   /* Unbind the device if it was already active */
   vm_unbind_device(vm,dev);

   /* Map the device at the new base address and rebuild MTS */
   dev->phys_addr = base_addr;
   vm_bind_device(vm,dev);
   cpu_group_rebuild_mts(vm->cpu_group);

#if 0
   vm_resume(vm);
#endif
   return(0);
}
Beispiel #3
0
/* Remove a device */
void dev_remove (vm_instance_t * vm, struct vdevice *dev)
{
    if (dev == NULL)
        return;

    vm_unbind_device (vm, dev);

    vm_log (vm, "DEVICE",
        "Removal of device %s, fd=%d, host_addr=0x%" LL "x, flags=%d\n",
        dev->name, dev->fd, (m_uint64_t) dev->host_addr, dev->flags);

    if (dev->flags & VDEVICE_FLAG_REMAP) {
        dev_init (dev);
        return;
    }

    if (dev->fd != -1) {
        /* Unmap memory mapped file */
        if (dev->host_addr) {

            vm_log (vm, "MMAP", "unmapping of device '%s', "
                "fd=%d, host_addr=0x%" LL "x, len=0x%x\n",
                dev->name, dev->fd, (m_uint64_t) dev->host_addr,
                dev->phys_len);
            munmap ((void *) dev->host_addr, dev->phys_len);
        }

        close (dev->fd);
    } else {
        /* Use of malloc'ed host memory: free it */
        if (dev->host_addr)
            free ((void *) dev->host_addr);
    }

    /* reinitialize the device to a clean state */
    dev_init (dev);
}