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

📄 pci-library-reference.html

📁 有关ecos2。0介绍了实时嵌入式的结构以及线程调度的实现和内存的管理等
💻 HTML
📖 第 1 页 / 共 2 页
字号:
be used to access registers that are device specific. General PCIregisters are best accessed through <TTCLASS="FUNCTION">cyg_pci_get_device_info()</TT>.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">void cyg_pci_write_config_uint8(  cyg_pci_device_id devid,				  cyg_uint8 offset, cyg_uint8 val );void cyg_pci_write_config_uint16( cyg_pci_device_id devid,				  cyg_uint8 offset, cyg_uint16 val );void cyg_pci_write_config_uint32( cyg_pci_device_id devid,				  cyg_uint8 offset, cyg_uint32 val );</PRE></TD></TR></TABLE><P>These functions write registers of the appropriate size tothe configuration space of the given device. They should mainlybe used to access registers that are device specific. General PCIregisters are best accessed through <TTCLASS="FUNCTION">cyg_pci_get_device_info()</TT>. Writing the general registers this way may render the contents ofa <SPANCLASS="STRUCTNAME">cyg_pci_device</SPAN> structure invalid.</P></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="AEN12891">Resource allocation</H2><P>These routines allocate memory and I/O space to PCI devices.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">cyg_bool cyg_pci_configure_device( cyg_pci_device *dev_info )</PRE></TD></TR></TABLE><P>Allocate memory and IO space to all base address registersusing the current memory and IO base addresses in the library. Theallocated base addresses, translated into directly usable values,will be put into the matching <TTCLASS="VARNAME">base_map[]</TT> entriesin <TTCLASS="PARAMETER"><I>*dev_info</I></TT>. If <TTCLASS="PARAMETER"><I>*dev_info</I></TT> doesnot contain valid <TTCLASS="VARNAME">base_size[]</TT> entries, then the result is<TTCLASS="CONSTANT">false</TT>. This function will also call <TTCLASS="FUNCTION">cyg_pci_translate_interrupt()</TT> to put the interrupt vector into theHAL vector entry.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">cyg_bool cyg_pci_configure_bus( cyg_uint8 bus, cyg_uint8 *next_bus )</PRE></TD></TR></TABLE><P>Allocate memory and IO space to all base address registers on all deviceson the given bus and all subordinate busses. If a PCI-PCI bridge is found on<TTCLASS="PARAMETER"><I>bus</I></TT>, this function will call itself recursively in orderto configure the bus on the other side of the bridge. Because of the nature ofbridge devices, all devices on the secondary side of a bridge must be allocatedmemory and IO space before the memory and IO windows on the bridge device can beproperly configured. The <TTCLASS="PARAMETER"><I>next_bus</I></TT> argument points to thebus number to assign to the next subordinate bus found. The number will beincremented as new busses are discovered. If successful, <TTCLASS="CONSTANT">true</TT>is returned. Otherwise, <TTCLASS="CONSTANT">false</TT> is returned.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">cyg_bool cyg_pci_translate_interrupt( cyg_pci_device *dev_info,				      CYG_ADDRWORD *vec );</PRE></TD></TR></TABLE><P>Translate the device's PCI interrupt (INTA#-INTD#)to the associated HAL vector. This may also depend on which slotthe device occupies. If the device may generate interrupts, thetranslated vector number will be stored in <TTCLASS="PARAMETER"><I>vec</I></TT> and theresult is <TTCLASS="CONSTANT">true</TT>. Otherwise the result is <TTCLASS="CONSTANT">false</TT>.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">cyg_bool cyg_pci_allocate_memory( cyg_pci_device *dev_info,                                  cyg_uint32 bar,                                   CYG_PCI_ADDRESS64 *base );cyg_bool cyg_pci_allocate_io( cyg_pci_device *dev_info,                              cyg_uint32 bar,                               CYG_PCI_ADDRESS32 *base );</PRE></TD></TR></TABLE><P>These routines allocate memory or I/O space to the base addressregister indicated by <TTCLASS="PARAMETER"><I>bar</I></TT>. The base address in<TTCLASS="PARAMETER"><I>*base</I></TT> will be correctly aligned and the address of thenext free location will be written back into it if the allocation succeeds. Ifthe base address register is of the wrong type for this allocation, or<TTCLASS="PARAMETER"><I>dev_info</I></TT> does not contain valid <TTCLASS="VARNAME">base_size[]</TT> entries, the result is <TTCLASS="CONSTANT">false</TT>. These functionsallow a device driver to set up its own mappings if it wants. Most devicesshould probably use <TTCLASS="FUNCTION">cyg_pci_configure_device()</TT>.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">void cyg_pci_set_memory_base( CYG_PCI_ADDRESS64 base );void cyg_pci_set_io_base( CYG_PCI_ADDRESS32 base );</PRE></TD></TR></TABLE><P>These routines set the base addresses for memory and I/O mappingsto be used by the memory allocation routines. Normally these baseaddresses will be set to default values based on the platform. Theseroutines allow these to be changed by application code if necessary.</P></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="AEN12923">PCI Library Hardware API</H2><P>This API is used by the PCI library to access the PCI busconfiguration space. Although it should not normally be necessary,this API may also be used by device driver or application code toperform PCI bus operations not supported by the PCI library.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">void cyg_pcihw_init(void);</PRE></TD></TR></TABLE><P>Initialize the PCI hardware so that the configuration spacemay be accessed.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">void cyg_pcihw_read_config_uint8(  cyg_uint8 bus,               cyg_uint8 devfn, cyg_uint8 offset, cyg_uint8 *val);void cyg_pcihw_read_config_uint16( cyg_uint8 bus,               cyg_uint8 devfn, cyg_uint8 offset, cyg_uint16 *val);void cyg_pcihw_read_config_uint32( cyg_uint8 bus,               cyg_uint8 devfn, cyg_uint8 offset, cyg_uint32 *val);</PRE></TD></TR></TABLE><P>These functions read a register of the appropriate size fromthe PCI configuration space at an address composed from the <TTCLASS="PARAMETER"><I>bus</I></TT>, <TTCLASS="PARAMETER"><I>devfn</I></TT> and <TTCLASS="PARAMETER"><I>offset</I></TT>arguments.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">void cyg_pcihw_write_config_uint8(  cyg_uint8 bus,                cyg_uint8 devfn, cyg_uint8 offset, cyg_uint8 val);void cyg_pcihw_write_config_uint16( cyg_uint8 bus,                cyg_uint8 devfn, cyg_uint8 offset, cyg_uint16 val);void cyg_pcihw_write_config_uint32( cyg_uint8 bus,                cyg_uint8 devfn, cyg_uint8 offset, cyg_uint32 val);</PRE></TD></TR></TABLE><P>These functions write a register of the appropriate size tothe PCI configuration space at an address composed from the<TTCLASS="PARAMETER"><I>bus</I></TT>, <TTCLASS="PARAMETER"><I>devfn</I></TT> and<TTCLASS="PARAMETER"><I>offset</I></TT> arguments.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">cyg_bool cyg_pcihw_translate_interrupt( cyg_uint8 bus,					cyg_uint8 devfn,					CYG_ADDRWORD *vec);</PRE></TD></TR></TABLE><P>This function interrogates the device and determines whichHAL interrupt vector it is connected to.</P></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="AEN12940">HAL PCI support</H2><P>HAL support consists of a set of C macros that provide theimplementation of the low level PCI API.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">HAL_PCI_INIT()</PRE></TD></TR></TABLE><P>Initialize the PCI bus.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">HAL_PCI_READ_UINT8( bus, devfn, offset, val )HAL_PCI_READ_UINT16( bus, devfn, offset, val )HAL_PCI_READ_UINT32( bus, devfn, offset, val )</PRE></TD></TR></TABLE><P>Read a value from the PCI configuration space of the appropriatesize at an address composed from the <TTCLASS="PARAMETER"><I>bus</I></TT>, <TTCLASS="PARAMETER"><I>devfn</I></TT> and <TTCLASS="PARAMETER"><I>offset</I></TT>.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">HAL_PCI_WRITE_UINT8( bus, devfn, offset, val )HAL_PCI_WRITE_UINT16( bus, devfn, offset, val )HAL_PCI_WRITE_UINT32( bus, devfn, offset, val )</PRE></TD></TR></TABLE><P>Write a value to the PCI configuration space of the appropriatesize at an address composed from the <TTCLASS="PARAMETER"><I>bus</I></TT>, <TTCLASS="PARAMETER"><I>devfn</I></TT> and <TTCLASS="PARAMETER"><I>offset</I></TT>.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">HAL_PCI_TRANSLATE_INTERRUPT( bus, devfn, *vec, valid )</PRE></TD></TR></TABLE><P>Translate the device's interrupt line into a HALinterrupt vector.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">HAL_PCI_ALLOC_BASE_MEMORYHAL_PCI_ALLOC_BASE_IO</PRE></TD></TR></TABLE><P>These macros define the default base addresses used to initializethe memory and I/O allocation pointers.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">HAL_PCI_PHYSICAL_MEMORY_BASEHAL_PCI_PHYSICAL_IO_BASE</PRE></TD></TR></TABLE><P>PCI memory and IO range do not always correspond directlyto physical memory or IO addresses. Frequently the PCI address spacesare windowed into the processor's address range at someoffset. These macros define offsets to be added to the PCI baseaddresses to translate PCI bus addresses into physical memory addressesthat can be used to access the allocated memory or IO space.</P><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B>The chunk of PCI memory space directly addressable thoughthe window by the CPU may be smaller than the amount of PCI memoryactually provided. In that case drivers will have to access PCImemory space in segments. Doing this will be platform specific andis currently beyond the scope of the HAL.</P></BLOCKQUOTE></DIV><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">HAL_PCI_IGNORE_DEVICE( bus, dev, fn )</PRE></TD></TR></TABLE><P>This macro, if defined, may be used to limit the devices which arefound by the bus scanning functions. This is sometimes necessary fordevices which need special handling. If this macro evaluates to <TTCLASS="CONSTANT">true</TT>, the given device will not be found by <TTCLASS="FUNCTION">cyg_pci_find_next</TT> or other bus scanning functions.</P></DIV></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="ecos-pci-library.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="ecos-ref.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="posix-compatibility.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">The eCos PCI Library</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="ecos-pci-library.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">eCos POSIX compatibility layer</TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

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