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

📄 pci.sgml

📁 开放源码实时操作系统源码.
💻 SGML
📖 第 1 页 / 共 3 页
字号:
                                       void *     user_data);
</PROGRAMLISTING>
<PARA>The <parameter>vendor</parameter>, <parameter>device</parameter>, and
<parameter>class</parameter> are from the device configuration space. The
<parameter>user_data</parameter> is the callback data passed to <function>
cyg_pci_find_matching</function>.
</PARA>
<PROGRAMLISTING>void cyg_pci_get_device_info ( cyg_pci_device_id devid,
			       cyg_pci_device *dev_info );</PROGRAMLISTING>
<PARA>This function gets the PCI configuration information for the
device indicated in <parameter>devid</parameter>. The common fields of the
<structname>cyg_pci_device</structname> structure, and the appropriate fields
of the relevant header union member are filled in from the device's
configuration space.
If the device has not been enabled, then this function will also fetch
the size and type information from the base address registers and
place it in the <varname>base_size[]</varname> array.</PARA>
<PROGRAMLISTING>void cyg_pci_set_device_info ( cyg_pci_device_id devid,
			       cyg_pci_device *dev_info );</PROGRAMLISTING>
<PARA>This function sets the PCI configuration information for the
device indicated in <parameter>devid</parameter>. Only the configuration space
registers that are writable are actually written. Once all the fields have
been written, the device info will be read back into <parameter>*dev_info
</parameter>, so that it reflects the true state of the hardware.</PARA>
<PROGRAMLISTING>
void cyg_pci_read_config_uint8(  cyg_pci_device_id devid,
				 cyg_uint8 offset, cyg_uint8 *val );
void cyg_pci_read_config_uint16( cyg_pci_device_id devid,
				 cyg_uint8 offset, cyg_uint16 *val );
void cyg_pci_read_config_uint32( cyg_pci_device_id devid,
				 cyg_uint8 offset, cyg_uint32 *val );
</PROGRAMLISTING>
<PARA>These functions read registers of the appropriate size from
the configuration space of the given device. They should mainly
be used to access registers that are device specific. General PCI
registers are best accessed through <function>cyg_pci_get_device_info()
</function>.</PARA>
<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 );
</PROGRAMLISTING>
<PARA>These functions write registers of the appropriate size to
the configuration space of the given device. They should mainly
be used to access registers that are device specific. General PCI
registers are best accessed through <function>cyg_pci_get_device_info()
</function>. Writing the general registers this way may render the contents of
a <structname>cyg_pci_device</structname> structure invalid.</PARA>
</SECT2>
<SECT2>
<TITLE>Resource allocation</TITLE>
<PARA>These routines allocate memory and I/O space to PCI devices.</PARA>
<PROGRAMLISTING>cyg_bool cyg_pci_configure_device( cyg_pci_device *dev_info )</PROGRAMLISTING>
<PARA>Allocate memory and IO space to all base address registers
using the current memory and IO base addresses in the library. The
allocated base addresses, translated into directly usable values,
will be put into the matching <varname>base_map[]</varname> entries
in <parameter>*dev_info</parameter>. If <parameter>*dev_info</parameter> does
not contain valid <varname>base_size[]</varname> entries, then the result is
<constant>false</constant>. This function will also call <function>
cyg_pci_translate_interrupt()</function> to put the interrupt vector into the
HAL vector entry.</PARA>
<PROGRAMLISTING>cyg_bool cyg_pci_configure_bus( cyg_uint8 bus, cyg_uint8 *next_bus )
</PROGRAMLISTING>
<PARA>Allocate memory and IO space to all base address registers on all devices
on the given bus and all subordinate busses. If a PCI-PCI bridge is found on
<parameter>bus</parameter>, this function will call itself recursively in order
to configure the bus on the other side of the bridge. Because of the nature of
bridge devices, all devices on the secondary side of a bridge must be allocated
memory and IO space before the memory and IO windows on the bridge device can be
properly configured. The <parameter>next_bus</parameter> argument points to the
bus number to assign to the next subordinate bus found. The number will be
incremented as new busses are discovered. If successful, <constant>true</constant>
is returned. Otherwise, <constant>false</constant> is returned.
</PARA>
<PROGRAMLISTING>
cyg_bool cyg_pci_translate_interrupt( cyg_pci_device *dev_info,
				      CYG_ADDRWORD *vec );
</PROGRAMLISTING>
<PARA>Translate the device's PCI interrupt (INTA#-INTD#)
to the associated HAL vector. This may also depend on which slot
the device occupies. If the device may generate interrupts, the
translated vector number will be stored in <parameter>vec</parameter> and the
result is <constant>true</constant>. Otherwise the result is <constant>false
</constant>.</PARA>
<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 );
</PROGRAMLISTING>
<PARA>These routines allocate memory or I/O space to the base address
register indicated by <parameter>bar</parameter>. The base address in
<parameter>*base</parameter> will be correctly aligned and the address of the
next free location will be written back into it if the allocation succeeds. If
the base address register is of the wrong type for this allocation, or
<parameter>dev_info</parameter> does not contain valid <varname>base_size[]
</varname> entries, the result is <constant>false</constant>. These functions
allow a device driver to set up its own mappings if it wants. Most devices
should probably use <function>cyg_pci_configure_device()</function>.</PARA>
<PROGRAMLISTING>void cyg_pci_set_memory_base( CYG_PCI_ADDRESS64 base );
void cyg_pci_set_io_base( CYG_PCI_ADDRESS32 base );</PROGRAMLISTING>
<PARA>These routines set the base addresses for memory and I/O mappings
to be used by the memory allocation routines. Normally these base
addresses will be set to default values based on the platform. These
routines allow these to be changed by application code if necessary.</PARA>
</SECT2>
<SECT2>
<TITLE>PCI Library Hardware API</TITLE>
<PARA>This API is used by the PCI library to access the PCI bus
configuration space. Although it should not normally be necessary,
this API may also be used by device driver or application code to
perform PCI bus operations not supported by the PCI library.</PARA>
<PROGRAMLISTING>void cyg_pcihw_init(void);</PROGRAMLISTING>
<PARA>Initialize the PCI hardware so that the configuration space
may be accessed.</PARA>
<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);
</PROGRAMLISTING>
<PARA>These functions read a register of the appropriate size from
the PCI configuration space at an address composed from the <parameter>bus
</parameter>, <parameter>devfn</parameter> and <parameter>offset</parameter>
arguments.</PARA>
<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);
</PROGRAMLISTING>
<PARA>These functions write a register of the appropriate size to
the PCI configuration space at an address composed from the
<parameter>bus</parameter>, <parameter>devfn</parameter> and
<parameter>offset</parameter> arguments.</PARA>
<PROGRAMLISTING>
cyg_bool cyg_pcihw_translate_interrupt( cyg_uint8 bus,
					cyg_uint8 devfn,
					CYG_ADDRWORD *vec);
</PROGRAMLISTING>
<PARA>This function interrogates the device and determines which
HAL interrupt vector it is connected to.</PARA>
</SECT2>
<SECT2>
<TITLE>HAL PCI support</TITLE>
<PARA>HAL support consists of a set of C macros that provide the
implementation of the low level PCI API.</PARA>
<PROGRAMLISTING>HAL_PCI_INIT()</PROGRAMLISTING>
<PARA>Initialize the PCI bus.</PARA>
<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 )</PROGRAMLISTING>
<PARA>Read a value from the PCI configuration space of the appropriate
size at an address composed from the <parameter>bus</parameter>, <parameter>
devfn</parameter> and <parameter>offset</parameter>.</PARA>
<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 )</PROGRAMLISTING>
<PARA>Write a value to the PCI configuration space of the appropriate
size at an address composed from the <parameter>bus</parameter>, <parameter>
devfn</parameter> and <parameter>offset</parameter>.</PARA>
<PROGRAMLISTING>HAL_PCI_TRANSLATE_INTERRUPT( bus, devfn, *vec, valid )</PROGRAMLISTING>
<PARA>Translate the device's interrupt line into a HAL
interrupt vector.</PARA>
<PROGRAMLISTING>HAL_PCI_ALLOC_BASE_MEMORY
HAL_PCI_ALLOC_BASE_IO</PROGRAMLISTING>
<PARA>These macros define the default base addresses used to initialize
the memory and I/O allocation pointers.</PARA>
<PROGRAMLISTING>HAL_PCI_PHYSICAL_MEMORY_BASE
HAL_PCI_PHYSICAL_IO_BASE</PROGRAMLISTING>
<PARA>PCI memory and IO range do not always correspond directly
to physical memory or IO addresses. Frequently the PCI address spaces
are windowed into the processor's address range at some
offset. These macros define offsets to be added to the PCI base
addresses to translate PCI bus addresses into physical memory addresses
that can be used to access the allocated memory or IO space.</PARA>
<NOTE>
<PARA>The chunk of PCI memory space directly addressable though
the window by the CPU may be smaller than the amount of PCI memory
actually provided. In that case drivers will have to access PCI
memory space in segments. Doing this will be platform specific and
is currently beyond the scope of the HAL.</PARA>
</NOTE>
<PROGRAMLISTING>HAL_PCI_IGNORE_DEVICE( bus, dev, fn )</PROGRAMLISTING
<PARA>This macro, if defined, may be used to limit the devices which are
found by the bus scanning functions. This is sometimes necessary for
devices which need special handling. If this macro evaluates to <constant>true
</constant>, the given device will not be found by <function>cyg_pci_find_next
</function> or other bus scanning functions.
</PARA>
<PROGRAMLISTING>HAL_PCI_IGNORE_BAR( dev_info, bar_num )</PROGRAMLISTING
<PARA>This macro, if defined, may be used to limit which BARs are discovered
and configured. This is sometimes necessary for platforms with limited PCI
windows. If this macro evaluates to <constant>true</constant>, the given BAR
will not be discovered by <function>cyg_pci_get_device_info</function> and
therefore not configured by <function>cyg_pci_configure_device</function>.
</PARA>
</SECT2>
</SECT1>
</CHAPTER>
</PART>

⌨️ 快捷键说明

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