⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pci_init.c

📁 详细介绍了一篇关于pci开发的接口芯片
💻 C
字号:
/*
	pci_init.c

	pci_init()
*/

#include <stdtypes.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#include <amcclib.h>
#include <lib.h>

extern CHAR errstring[];

UINT8 pci_init( struct _chip *chip, UINT16 index, UINT16 dev_id, UINT16 ven_id )
/*	Locate a chip and set up a chip structure, including base addresses 
	BUT NOT region sizes (must be done by call to "parse()" ).
	This is because pci_init may be called by code that is testing
	nvRAM, and parse() needs to read nvRAM to get region sizes
	from the nvRAM.

	Only matches device ID and vendor ID. If you want to also match	
	the subsystem vendor ID and subsystem ID, use "findchip()".

	Return: 0 if OK and chip structure updated...
				base address registers
				index
			1 = PCI BIOS not found
			2 = device not found

	Caller should probably also set up chip.type as AMCC_5920/5933
	Fatal exit if PCI BIOS call fails.
*/
{
UINT8 ch;
int i, status;

	if (pciBiosPresent(&ch,NULL,NULL)) 
    {
       	if (pciFindDevice(dev_id, ven_id, index, &chip->bus, &chip->device) == PCI_SUCCESSFUL) 
        {
			chip->index = index;
			// stuff base addresses...
			for( i = 0; i < NUM_BASE_REGIONS; i++ )
			{
				status = pci_config_read32( chip, \
					PCI_CS_BASE_ADDRESS_0 + (i*4), \
					&chip->reg[i].base );
				if ( status != PCI_SUCCESSFUL )
				{
					pci_bios_fail( status );
					printf( errstring );
					exit(1);
				}
         	}
         	return 0;
		}

		return 2;	// device not found
    }

    return 1;		// no PCI BIOS
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -