Sie sind auf Seite 1von 7

Library Description:

CoDeSys V 3.x
SysPci.library

Document Version 1.0


libdoc_e.dot / V1.0

3S - Smart Software Solutions GmbH page 1 of 8


SysPci_V3x_E.doc
Library SysPci.library

CONTENT

1 OVERVIEW 4

2 LIBRARY MODULES 5
2.1 SysPciGetCardInfo 5
2.2 SysPciGetConfigEntry 5
2.3 SysPciReadValue 6
2.4 SysPciSetConfigEntry 6
2.5 SysPciWriteValue 6
2.6 Structure PCI_INFO 7

CHANGE HISTORY 8
libdoc_e.dot / V1.0

3S - Smart Software Solutions GmbH page 3 of 8


SysPci_V3x_E.doc
Library SysPci.library

1 Overview

Note: It depends on the target system, which system libraries can be used in the application program.

This library support the access to PCI cards being connected to the system.

If the target system supports this functionality, information on the card can be retrieved and
values can be read from or written to the card.

Each function of this library will return the value 1 (ERR_FAILED) in case of an error occurred
and the value 0 otherwise.

The following functions are available:

SysPciGetCardInfo
SysPciGetConfigEntry
SysPciReadValue
SysPciSetConfigEntry
SysPciWriteValue

Information on the card is stored within the structure:

PCI_INFO
libdoc_e.dot / V1.0

3S - Smart Software Solutions GmbH page 4 of 8


SysPci_V3x_E.doc
Library SysPci.library

2 Library Modules

2.1 SysPciGetCardInfo
This function retrieves information on a PCI card that is identified by its vendor ID, its device
ID and its card index. Therefore, SysPciGetCardInfo returns a pointer to a variable of type
PCI_INFO containing the information on the PCI card.

The return value of type UDINT is an error code indicating success or failure of the operation
(see chapter 1).
Input variable Data type Description

usVendorId WORD Vendor ID (assigned by PCI SIG) of card to be


requested
usDeviceId WORD Device ID (assigned by manufacturer) of card to be
requested
usCardIndex WORD Index of card with combination of vendor and device
ID given
The index is based on 0. If there are multiple cards
corresponding to the combination of vendor and
device ID, you may switch from one card to the next
by incrementing the index and recalling the function.
pPciInfo POINTER TO Pointer to structure PCI_INFO containing information
PCI_INFO on the PCI card (see structure PCI_INFO, 2.6).

2.2 SysPciGetConfigEntry
This function allows to read the configuration data of a PCI card. The data is stored in a
structure of type PCI_INFO and filled into the PCI bus. By means of the bus, device and
function number SysPciGetConfigEntry identifies the associated bus entry and returns a
pointer to it.

The return value of type UDINT is an error code indicating success or failure of the operation
(see chapter 1).
Input variable Data type Description

usBus WORD PCI bus number

usDevice WORD PCI device number

usFunction WORD PCI function number

pPciInfo POINTER TO Pointer to structure PCI_INFO containing information


PCI_INFO on the PCI card (see structure PCI_INFO, 2.6).
libdoc_e.dot / V1.0

3S - Smart Software Solutions GmbH page 5 of 8


SysPci_V3x_E.doc
Library SysPci.library

2.3 SysPciReadValue
This function allows to read single configuration values of a PCI card by returning a pointer on
the associated memory address (pbyData). Thereby the associated bus entry is identified via
the bus, device and function number. The component to be read out is indicated by the
PciOffset.

The return value of type UDINT is an error code indicating success or failure of the operation
(see chapter 1).
Input variable Data type Description

usBus WORD PCI bus number

usDevice WORD PCI device number

usFunction WORD PCI function number

usPciOffset WORD Offset of configuration value to be read out

pbyData POINTER TO BYTE Pointer to memory address, where information can be


retrieved
usSize WORD Size of data to be read out (in byte)

2.4 SysPciSetConfigEntry
This function allows to write an entry to the PCI bus. The entry is a structure of type PCI-INFO
and is transmitted to the function SysPciSetConfigEntry via a pointer on it. The structure
contains the configuration data of the PCI card being identified by the bus, device and
function number.

The return value of type UDINT is an error code indicating success or failure of the operation
(see chapter 1).
Input variable Data type Description

usBus WORD PCI bus number

usDevice WORD PCI device number

usFunction WORD PCI function number

pPciInfo POINTER TO Pointer to structure PCI_INFO containing information


PCI_INFO on the PCI card (see structure PCI_INFO, 2.6).

2.5 SysPciWriteValue
This function allows to set single configuration values of a PCI card via a pointer on the
corresponding memory address (pbyData). Therefore the bus entry associated to the PCI
card is identified via the bus, device and function number. The bus entry is a structure of type
PCI_INFO. The component to be read out is indicated by PciOffset.

The return value of type UDINT is an error code indicating success or failure of the operation
libdoc_e.dot / V1.0

(see chapter 1).


Input variable Data type Description

usBus WORD PCI bus number

usDevice WORD PCI device number

3S - Smart Software Solutions GmbH page 6 of 8


SysPci_V3x_E.doc
Library SysPci.library

Input variable Data type Description

usFunction WORD PCI function number

usPciOffset WORD Offset of configuration value to be written

pbyData POINTER TO BYTE Pointer to memory address to be written in

usSize WORD Size of data to be written (in byte)

2.6 Structure PCI_INFO


This structure contains information on design, behavior and memory requirement of the PCI
card. The components are filled in by the card itself or by the PCI bus.

The example contains the identifying information of an Hilscher PCI card.


Structure component Data type Description

usVendorId WORD Registered Vendor ID of card assigned by PCI SIG


Example:
VENDOR_ID : WORD := 16#10B5;
(* PLX technology *)
usDeviceId WORD Device ID of card assigned by manufacturer
Example:
DEVICE_ID_PCI : WORD := 16#9050;
(* PCI card *)
usSubVendorID WORD Registered subsystem vendor ID assigned by PCI
SIG
Example:
SUBVENDOR_ID : WORD := 16#10B5;
(* PLX-PCI chip *)
usSubSystemID WORD Subsystem device ID assigned by manufacturer, if
there are multiple subsystems on card. The value 0
indicates that there are no subsystems.
Example:
SUBSYSTEM_ID_CIF50 : WORD := 16#1080;
(* Defines a HILSCHER CIF 50 PCI board *)
SUBSYSTEM_ID_CIF80 : WORD := 16#2695;
(* Defines a HILSCHER CIF 80 PCI board *)

ulBusNr DWORD Number of bus the PCI card is member of

SlotNr DWORD Number of slot (within bus) the PCI card is plugged in

ulFunction DWORD PCI function number

ulBaseAddresses ARRAY[0..5] OF Basis address register for reservation of z I/O port


DWORD addresses or I/O memory areas (Memory Mapped
I/O);
Specific for particular card.
libdoc_e.dot / V1.0

byInterrupt BYTE Identifies the interrupt vector on the particular system.

DeviceSpecific ARRAY[0..191] According to Pci specification the 192 manufacture


OF BYTE specific data bytes

3S - Smart Software Solutions GmbH page 7 of 8


SysPci_V3x_E.doc
Library SysPci.library

Change History
Version Description Date

0.1 Creation according to German version 1.0 19.02.2008


1.0 Release after formal review 20.02.2008
libdoc_e.dot / V1.0

3S - Smart Software Solutions GmbH page 8 of 8


SysPci_V3x_E.doc

Das könnte Ihnen auch gefallen