/* * dev_c7200_pa_mc8te1_init() * * Add a PA-MC-8TE1 port adapter into specified slot. */ int dev_c7200_pa_mc8te1_init(vm_instance_t *vm,struct cisco_card *card) { struct pa_mc_data *d; u_int slot = card->slot_id; /* Allocate the private data structure for PA-MC-8TE1 chip */ if (!(d = malloc(sizeof(*d)))) { vm_error(vm,"%s: out of memory\n",card->dev_name); return(-1); } memset(d,0,sizeof(*d)); d->name = card->dev_name; d->vm = vm; d->irq = c7200_net_irq_for_slot_port(slot,0); /* Set the PCI bus */ card->pci_bus = vm->slots_pci_bus[slot]; /* Set the EEPROM */ cisco_card_set_eeprom(vm,card,cisco_eeprom_find_pa("PA-MC-8TE1")); c7200_set_slot_eeprom(VM_C7200(vm),slot,&card->eeprom); /* Create the PM7380 */ d->pci_dev = pci_dev_add(card->pci_bus,card->dev_name, 0x11f8, 0x7380, 0,0,d->irq,d, NULL,pci_pos_read,pci_pos_write); /* Initialize SSRAM device */ d->ssram_name = dyn_sprintf("%s_ssram",card->dev_name); dev_init(&d->ssram_dev); d->ssram_dev.name = d->ssram_name; d->ssram_dev.priv_data = d; d->ssram_dev.handler = dev_ssram_access; /* Create the PLX9054 */ d->plx_name = dyn_sprintf("%s_plx",card->dev_name); d->plx_obj = dev_plx9054_init(vm,d->plx_name, card->pci_bus,1, &d->ssram_dev,NULL); /* Set callback function for PLX9054 PCI-To-Local doorbell */ dev_plx_set_pci2loc_doorbell_cbk(d->plx_obj->data, (dev_plx_doorbell_cbk) plx9054_doorbell_callback, d); /* Store device info into the router structure */ card->drv_info = d; return(0); }
/* Create a new MV64460 controller */ int dev_mv64460_init(vm_instance_t *vm,char *name, m_uint64_t paddr,m_uint32_t len) { struct mv64460_data *d; int i; if (!(d = malloc(sizeof(*d)))) { fprintf(stderr,"mv64460: unable to create device data.\n"); return(-1); } memset(d,0,sizeof(*d)); pthread_mutex_init(&d->lock,NULL); d->name = name; d->vm = vm; d->bus[0] = vm->pci_bus[0]; d->bus[1] = vm->pci_bus[1]; for(i=0;i<MV64460_SDMA_CHANNELS;i++) d->sdma[i].id = i; vm_object_init(&d->vm_obj); d->vm_obj.name = name; d->vm_obj.data = d; d->vm_obj.shutdown = (vm_shutdown_t)dev_mv64460_shutdown; dev_init(&d->dev); d->dev.name = name; d->dev.priv_data = d; d->dev.phys_addr = paddr; d->dev.phys_len = len; d->dev.handler = dev_mv64460_access; /* Create the SRAM device */ dev_init(&d->sram_dev); d->sram_dev.name = "mv64460_sram"; d->sram_dev.phys_len = MV64460_SRAM_SIZE; d->sram_dev.flags = VDEVICE_FLAG_CACHING; d->sram_dev.host_addr = (m_iptr_t)m_memalign(4096,d->sram_dev.phys_len); if (!d->sram_dev.host_addr) { fprintf(stderr,"mv64460: unable to create SRAM data.\n"); return(-1); } /* Add the controller as a PCI device */ if (!pci_dev_lookup(d->bus[0],0,0,0)) { d->pci_dev = pci_dev_add(d->bus[0],name, PCI_VENDOR_MARVELL,PCI_PRODUCT_MARVELL_MV64460, 0,0,-1,d,NULL,pci_mv64460_read,NULL); if (!d->pci_dev) { fprintf(stderr,"mv64460: unable to create PCI device.\n"); return(-1); } } /* TEST */ pci_dev_add(d->bus[1],name, PCI_VENDOR_MARVELL,PCI_PRODUCT_MARVELL_MV64460, 0,0,-1,d,NULL,pci_mv64460_read,NULL); /* Map this device to the VM */ vm_bind_device(vm,&d->dev); vm_object_add(vm,&d->vm_obj); return(0); }
/* * dev_c7200_pa_pos_init() * * Add a PA-POS port adapter into specified slot. */ int dev_c7200_pa_pos_init(vm_instance_t *vm,struct cisco_card *card) { struct pos_oc3_data *d; u_int slot = card->slot_id; /* Allocate the private data structure for PA-POS-OC3 chip */ if (!(d = malloc(sizeof(*d)))) { vm_error(vm,"%s: out of memory\n",card->dev_name); return(-1); } memset(d,0,sizeof(*d)); d->name = card->dev_name; d->vm = vm; /* Set the PCI bus */ card->pci_bus = vm->slots_pci_bus[slot]; /* Set the EEPROM */ cisco_card_set_eeprom(vm,card,cisco_eeprom_find_pa("PA-POS-OC3")); c7200_set_slot_eeprom(VM_C7200(vm),slot,&card->eeprom); /* Initialize RX device */ d->rx_name = dyn_sprintf("%s_RX",card->dev_name); dev_init(&d->rx_dev); d->rx_dev.name = d->rx_name; d->rx_dev.priv_data = d; d->rx_dev.handler = dev_pos_rx_access; /* Initialize TX device */ d->tx_name = dyn_sprintf("%s_TX",card->dev_name); dev_init(&d->tx_dev); d->tx_dev.name = d->tx_name; d->tx_dev.priv_data = d; d->tx_dev.handler = dev_pos_tx_access; /* Initialize CS device */ d->cs_name = dyn_sprintf("%s_CS",card->dev_name); dev_init(&d->cs_dev); d->cs_dev.name = d->cs_name; d->cs_dev.priv_data = d; d->cs_dev.handler = dev_pos_cs_access; /* Initialize PLX9060 for RX part */ d->rx_obj = dev_plx9060_init(vm,d->rx_name,card->pci_bus,0,&d->rx_dev); /* Initialize PLX9060 for TX part */ d->tx_obj = dev_plx9060_init(vm,d->tx_name,card->pci_bus,1,&d->tx_dev); /* Initialize PLX9060 for CS part (CS=card status, chip status, ... ?) */ d->cs_obj = dev_plx9060_init(vm,d->cs_name,card->pci_bus,2,&d->cs_dev); /* Unknown PCI device here (will be mapped at 0x30000) */ dev_init(&d->dev); d->dev.name = card->dev_name; d->dev.priv_data = d; d->dev.phys_len = 0x10000; d->dev.handler = dev_pos_access; d->pci_dev = pci_dev_add(card->pci_bus,card->dev_name,0,0,3,0, c7200_net_irq_for_slot_port(slot,0), d,NULL,pci_pos_read,pci_pos_write); /* Store device info into the router structure */ card->drv_info = d; return(0); }