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

📄 pci_serv.c

📁 基于ecos的redboot
💻 C
📖 第 1 页 / 共 5 页
字号:
        }
        printf("Revision ID           = 0x%02X     ",byte_data);
 
        /* get Programming Interface */
        offset = PROG_IF_OFFSET;
        if (sys_read_config_byte (busno,devno,function,offset,&byte_data)
                == ERROR)
        {
            printf("Error reading Programming Interface\n");
            return;
        }
        printf("Programming Interface = 0x%02X\n",byte_data);

		/* get Sub Class */
        offset = SUB_CLASS_OFFSET;
        if (sys_read_config_byte (busno,devno,function,offset,&byte_data)
                == ERROR)
        {
            printf("Error reading Sub Class\n");
            return;
        }
        printf("Sub Class             = 0x%02X     ",byte_data);
 
        /* get Base Class */
        offset = BASE_CLASS_OFFSET;
        if (sys_read_config_byte (busno,devno,function,offset,&byte_data)
                == ERROR)
        {
            printf("Error reading Base Class\n");
            return;
		}
        printf("Base Class            = 0x%02X\n",byte_data);

		/* get Cache Line Size */
        offset = CACHE_LINE_OFFSET;
        if (sys_read_config_byte (busno,devno,function,offset,&byte_data)
                == ERROR)
        {
            printf("Error reading Cache Line Size\n");
            return;
        }
        printf("Cache Line Size       = 0x%02X     ",byte_data);
 
        /* get Latency Timer */
        offset = LATENCY_TIMER_OFFSET;
        if (sys_read_config_byte (busno,devno,function,offset,&byte_data)
                == ERROR)
        {
            printf("Error reading Latency Timer\n");
            return;
		}
        printf("Latency Timer         = 0x%02X\n",byte_data);

		/* get Header Type */
        offset = HEADER_TYPE_OFFSET;
        if (sys_read_config_byte (busno,devno,function,offset,&byte_data)
                == ERROR)
        {
            printf("Error reading Header Type\n");
            return;
        }
        printf("Header Type           = 0x%02X     ",byte_data);
		header_type = (((int)byte_data) & 0x7f); /* strip multifunction bit */
        
		/* get BIST */
        offset = BIST_OFFSET;
        if (sys_read_config_byte (busno,devno,function,offset,&byte_data)
                == ERROR)
        {
            printf("Error reading BIST\n");
            return;
		}
        printf("BIST                  = 0x%02X\n",byte_data);

        /* get Interrupt Line info */
        offset = INT_LINE_OFFSET;
        if (sys_read_config_byte (busno,devno,function,offset,&byte_data)
                == ERROR)
        {
            printf("Error reading Interrupt Line\n");
            return;
        }
        printf("Interrupt Line        = 0x%02X     ",byte_data);
 
        /* get Interrupt Pin info */
        offset = INT_PIN_OFFSET;
        if (sys_read_config_byte (busno,devno,function,offset,&byte_data)
                == ERROR)
        {
            printf("Error reading Interrupt Pin\n");
            return;
        }
        printf("Interrupt Pin         = 0x%02X\n",byte_data);

        /* get Capabilities Pointer info */
        offset = CAP_PTR_OFFSET;
        if (sys_read_config_byte (busno,devno,function,offset,&byte_data)
                == ERROR)
        {
            printf("Error reading Capabilities Pointer register\n");
            return;
        }
        printf("Capabilities Pointer  = 0x%02X\n",byte_data);

		if (header_type == 0) /* type 0 header-specific info */ 
		{
			/* get Min Gnt info */
			offset = MIN_GNT_OFFSET;
			if (sys_read_config_byte (busno,devno,function,offset,&byte_data)
                == ERROR)
			{
				printf("Error reading Minimum Grant\n");
				return;
			}
			printf("Minimum Grant         = 0x%02X     ",byte_data);
 
			/* get Max Lat info */
			offset = MAX_LAT_OFFSET;
			if (sys_read_config_byte (busno,devno,function,offset,&byte_data)
                == ERROR)
			{
				printf("Error reading Maximum Latency\n");
				return;
			}
			printf("Maximum Latency       = 0x%02X\n",byte_data);

			/* get subsystem vendor ID */
			offset = SUB_VENDOR_ID_OFFSET;
			if (sys_read_config_word (busno,devno,function,offset,&short_data)
                == ERROR)
			{
				printf("Error reading Subsystem Vendor ID\n");
				return;
			}
			printf("Subsystem Vendor ID   = 0x%04X   ",short_data);
			subvendor_id = short_data;
		
			/* get subsystem device ID */
			offset = SUB_DEVICE_ID_OFFSET;
			if (sys_read_config_word (busno,devno,function,offset,&short_data)
                == ERROR)
			{
				printf("Error reading Subsystem Device ID\n");
				return;
			}
			printf("Subsystem Device ID   = 0x%04X\n",short_data);
			subdevice_id = short_data;

			/* get Region 0 Base Address */
			offset = REGION0_BASE_OFFSET;
			if (sys_read_config_dword (busno,devno,function,offset,&long_data)
                == ERROR)
			{
				printf("Error reading Region 0 Base\n");
				return;
			}
			printf("PCI Region 0 Base     = 0x%08X\n",long_data);

			/* get Region 1 Base Address */
			offset = REGION1_BASE_OFFSET;
			if (sys_read_config_dword (busno,devno,function,offset,&long_data)
                == ERROR)
			{
				printf("Error reading Region 1 Base\n");
				return;
			}
			printf("PCI Region 1 Base     = 0x%08X\n",long_data);

			/* get Region 2 Base Address */
			offset = REGION2_BASE_OFFSET;
			if (sys_read_config_dword (busno,devno,function,offset,&long_data)
                == ERROR)
			{
				printf("Error reading Region 2 Base\n");
				return;
			}
			printf("PCI Region 2 Base     = 0x%08X\n",long_data);

			/* get Region 3 Base Address */
			offset = REGION3_BASE_OFFSET;
			if (sys_read_config_dword (busno,devno,function,offset,&long_data)
                == ERROR)
			{
				printf("Error reading Region 3 Base\n");
				return;
			}
			printf("PCI Region 3 Base     = 0x%08X\n",long_data);

			/* get Region 4 Base Address */
			offset = REGION4_BASE_OFFSET;
			if (sys_read_config_dword (busno,devno,function,offset,&long_data)
                == ERROR)
			{
				printf("Error reading Region 4 Base\n");
				return;
			}
			printf("PCI Region 4 Base     = 0x%08X\n",long_data);

			/* get Region 5 Base Address */
			offset = REGION5_BASE_OFFSET;
			if (sys_read_config_dword (busno,devno,function,offset,&long_data)
                == ERROR)
			{
				printf("Error reading Region 5 Base\n");
				return;
			}
			printf("PCI Region 5 Base     = 0x%08X\n",long_data);

			/* get Expansion ROM Base Address */
			offset = EXP_ROM_OFFSET;
			if (sys_read_config_dword (busno,devno,function,offset,&long_data)
                == ERROR)
			{
				printf("Error reading Expansion ROM Base\n");
				return;
			}
			printf("Expansion ROM Base    = 0x%08X\n",long_data);

			/* get Cardbus CIS pointer */
			offset = CARDBUS_CISPTR_OFFSET;
			if (sys_read_config_dword (busno,devno,function,offset,&long_data)
                == ERROR)
			{
				printf("Error reading Cardbus CIS Pointer\n");
				return;
			}
			printf("Cardbus CIS Pointer   = 0x%08X\n",long_data);
		} /* end type 0 header */

		else /* type 1 header_specific info */
		{
			/* get Bridge Control */
			offset = BRIDGE_CTRL_OFFSET;
			if (sys_read_config_word (busno,devno,function,offset,&short_data)
                == ERROR)
			{
				printf("Error reading Bridge Control Register\n");
				return;
			}
			printf("Bridge Control Reg    = 0x%04X   ",short_data);
	
			/* get Secondary Status */
			offset = SECONDARY_STAT_OFFSET;
			if (sys_read_config_word (busno,devno,function,offset,&short_data)
                == ERROR)
			{
				printf("Error reading Secondary Status Register\n");
				return;
			}
			printf("Secondary Status Reg  = 0x%04X\n",short_data);
		
			/* get Primary Bus Number */
			offset = PRIMARY_BUSNO_OFFSET;
			if (sys_read_config_byte (busno,devno,function,offset,&byte_data)
                == ERROR)
			{
				printf("Error reading Primary Bus Number\n");
				return;
			}
			printf("Primary Bus No.       = 0x%02X     ",byte_data);
 	
			/* get Secondary Bus Number */
			offset = SECONDARY_BUSNO_OFFSET;
			if (sys_read_config_byte (busno,devno,function,offset,&byte_data)
                == ERROR)
			{
				printf("Error reading Secondary Bus Number\n");
				return;
			}
			printf("Secondary Bus No.     = 0x%02X\n",byte_data);
	
			/* get Subordinate Bus Number */
			offset = SUBORD_BUSNO_OFFSET;
			if (sys_read_config_byte (busno,devno,function,offset,&byte_data)
                == ERROR)
			{
				printf("Error reading Subordinate Bus Number\n");
				return;
			}
			printf("Subordinate Bus No.   = 0x%02X     ",byte_data);
	
			/* get Secondary Latency Timer */
			offset = SECONDARY_LAT_OFFSET;
			if (sys_read_config_byte (busno,devno,function,offset,&byte_data)
                == ERROR)
			{
				printf("Error reading Secondary Latency Timer\n");
				return;
			}
			printf("Secondary Latency Tmr = 0x%02X\n",byte_data);
 
			/* get IO Base */
			offset = IO_BASE_OFFSET;
			if (sys_read_config_byte (busno,devno,function,offset,&byte_data)
                == ERROR)
			{
				printf("Error reading IO Base\n");
				return;
			}
			printf("IO Base               = 0x%02X     ",byte_data);

			/* get IO Limit */
			offset = IO_LIMIT_OFFSET;
			if (sys_read_config_byte (busno,devno,function,offset,&byte_data)
                == ERROR)
			{
				printf("Error reading IO Limit\n");
				return;
			}
			printf("IO Limit              = 0x%02X\n",byte_data);
	
			/* get Memory Base */
			offset = MEMORY_BASE_OFFSET;
			if (sys_read_config_word (busno,devno,function,offset,&short_data)
                == ERROR)
			{
				printf("Error reading Memory Base\n");
				return;
			}
			printf("Memory Base           = 0x%04X   ",short_data);
		
			/* get Memory Limit */
			offset = MEMORY_LIMIT_OFFSET;
			if (sys_read_config_word (busno,devno,function,offset,&short_data)
                == ERROR)
			{
				printf("Error reading Memory Limit\n");
				return;
			}
			printf("Memory Limit          = 0x%04X\n",short_data);
	
			/* get Prefetchable Memory Base */
			offset = PREF_MEM_BASE_OFFSET;
			if (sys_read_config_word (busno,devno,function,offset,&short_data)
			    == ERROR)
			{
				printf("Error reading Prefetchable Memory Base\n");
				return;
			}
			printf("Pref. Memory Base     = 0x%04X   ",short_data);	

			/* get Prefetchable Memory Limit */
			offset = PREF_MEM_LIMIT_OFFSET;
			if (sys_read_config_word (busno,devno,function,offset,&short_data)
                == ERROR)
			{
				printf("Error reading Prefetchable Memory Limit\n");
				return;
			}
			printf("Pref. Memory Limit    = 0x%04X\n",short_data);

			/* get IO Base Upper 16 Bits */
			offset = IO_BASE_UPPER_OFFSET;
			if (sys_read_config_word (busno,devno,function,offset,&short_data)
                == ERROR)
			{
				printf("Error reading IO Base Upper 16 Bits\n");
				return;
			}
			printf("IO Base Upper 16 Bits = 0x%04X   ",short_data);	

			/* get IO Limit Upper 16 Bits */
			offset = IO_LIMIT_UPPER_OFFSET;
			if (sys_read_config_word (busno,devno,function,offset,&short_data)
                == ERROR)
			{
				printf("Error reading IO Limit Upper 16 Bits\n");
				return;
			}
			printf("IO Limit Upper 16 Bits= 0x%04X\n",short_data);        
	
			/* get Prefetchable Base Upper 32 Bits */
			offset = PREF_BASE_UPPER_OFFSET;
			if (sys_read_config_dword (busno,devno,function,offset,&long_data)
                == ERROR)
			{
				printf("Error reading Prefetchable Base Upper 32 Bits\n");
				return;
			}
			printf("Pref. Base Up. 32 Bits= 0x%08X\n",long_data);

			/* get Prefetchable Limit Upper 32 Bits */
			offset = PREF_LIMIT_UPPER_OFFSET;
			if (sys_read_config_dword (busno,devno,function,offset,&long_data)
                == ERROR)
			{
				printf("Error reading Prefetchable Limit Upper 32 Bits\n");
				return;
			}
			printf("Pref. Lmt. Up. 32 Bits= 0x%08X\n",long_data);
	

			/* get Region 0 Base Address */
			offset = REGION0_BASE_OFFSET;
			if (sys_read_config_dword (busno,devno,function,offset,&long_data)
                == ERROR)

⌨️ 快捷键说明

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