コード例 #1
0
ファイル: ata_init.c プロジェクト: imgits/rkanalyzer
static void ata_new(struct pci_device *pci_device)
{
	struct ata_host *host;

	/* initialize ata_host and ata_channel structures */
	host = alloc_ata_host();
	host->pci_device = pci_device;
	host->interrupt_line = pci_device->config_space.interrupt_line;
	host->channel[0] = ata_new_channel(host);
	host->channel[1] = ata_new_channel(host);
	pci_device->host = host;

	/* initialize primary and secondary channels */
	ata_set_cmdblk_handler(host, 0);
	ata_set_ctlblk_handler(host, 0);
	ata_set_cmdblk_handler(host, 1);
	ata_set_ctlblk_handler(host, 1);

	/* initialize bus master */
	ata_set_bm_handler(host);

	/* vendor specific init */
	ata_init_vendor(host);

#ifdef VTD_TRANS
	// printf("ATA : %x:%x:%x\n",pci_device->address.bus_no ,pci_device->address.device_no ,pci_device->address.func_no) ;

	if (iommu_detected) {
		u32 *phys ;
		  
		add_remap(pci_device->address.bus_no
			  ,pci_device->address.device_no
			  ,pci_device->address.func_no
			  ,host->channel[0]->shadow_prd_phys >> 12,1,PERM_DMA_RO) ;
		phys=(u32 *)host->channel[0]->shadow_prd ;
		add_remap(pci_device->address.bus_no
			  ,pci_device->address.device_no
			  ,pci_device->address.func_no
			  ,*phys >> 12,ATA_BM_TOTAL_BUFSIZE / PAGESIZE, PERM_DMA_RW) ;
		add_remap(pci_device->address.bus_no
			  ,pci_device->address.device_no
			  ,pci_device->address.func_no
			  ,host->channel[1]->shadow_prd_phys >> 12,1,PERM_DMA_RO) ;
		phys=(u32 *)host->channel[1]->shadow_prd ;
		add_remap(pci_device->address.bus_no
			  ,pci_device->address.device_no
			  ,pci_device->address.func_no
			  ,*phys >> 12,ATA_BM_TOTAL_BUFSIZE / PAGESIZE, PERM_DMA_RW) ;
	}
#endif // of VTD_TRANS
	
	return;
}
コード例 #2
0
ファイル: ata_init.c プロジェクト: anbangr/bitvisor-dev
static void ata_new(struct pci_device *pci_device, bool ahci_flag)
{
	struct ata_host *host;

	/* initialize ata_host and ata_channel structures */
	host = alloc_ata_host();
	host->pci_device = pci_device;
	host->interrupt_line = pci_device->config_space.interrupt_line;
	host->channel[0] = ata_new_channel(host);
	host->channel[1] = ata_new_channel(host);
	host->hc = NULL;
	host->ahci_enabled = false;
	STORAGE_HC_ADDR_PCI (host->hc_addr.addr, pci_device);
	host->hc_addr.type = STORAGE_HC_TYPE_ATA;
	host->hc_addr.num_ports = 2;
	host->hc_addr.ncq = false;
	spinlock_init (&host->ata_cmd_lock);
	LIST1_HEAD_INIT (host->ata_cmd_list);
	host->ata_cmd_thread = false;
	pci_device->host = host;

	/* initialize primary and secondary channels */
	ata_set_cmdblk_handler(host, 0);
	ata_set_ctlblk_handler(host, 0);
	ata_set_cmdblk_handler(host, 1);
	ata_set_ctlblk_handler(host, 1);
	if (ahci_flag)
		host->ahci_data = ahci_new (pci_device);
	else
		host->ahci_data = NULL;

	/* initialize bus master */
	ata_set_bm_handler(host);

	/* vendor specific init */
	ata_init_vendor(host);

	if (!host->ahci_enabled)
		ata_ahci_mode (pci_device, false);

#ifdef VTD_TRANS
	// printf("ATA : %x:%x:%x\n",pci_device->address.bus_no ,pci_device->address.device_no ,pci_device->address.func_no) ;

	if (iommu_detected) {
		u32 *phys ;
		  
		add_remap(pci_device->address.bus_no
			  ,pci_device->address.device_no
			  ,pci_device->address.func_no
			  ,host->channel[0]->shadow_prd_phys >> 12,1,PERM_DMA_RO) ;
		phys=(u32 *)host->channel[0]->shadow_prd ;
		add_remap(pci_device->address.bus_no
			  ,pci_device->address.device_no
			  ,pci_device->address.func_no
			  ,*phys >> 12,ATA_BM_TOTAL_BUFSIZE / PAGESIZE, PERM_DMA_RW) ;
		add_remap(pci_device->address.bus_no
			  ,pci_device->address.device_no
			  ,pci_device->address.func_no
			  ,host->channel[1]->shadow_prd_phys >> 12,1,PERM_DMA_RO) ;
		phys=(u32 *)host->channel[1]->shadow_prd ;
		add_remap(pci_device->address.bus_no
			  ,pci_device->address.device_no
			  ,pci_device->address.func_no
			  ,*phys >> 12,ATA_BM_TOTAL_BUFSIZE / PAGESIZE, PERM_DMA_RW) ;
	}
#endif // of VTD_TRANS
	
	return;
}