DeskLib 2.90a:PCI.h


Contents


Introduction and Overview

Warning: This API has not yet been implemented. Do not use.

These declarations are essentially just wrappers for the PCI SWIs. In time, we might add more complex functionality.

The PCI Manager allocates IDs for each PCI device in the computer. You can find the maximum ID with PCI_ReturnNumber, and use values up to and including that for functions taking handles.


Functions


PCI_ReadID

void PCI_ReadID(pci_handle handle, unsigned int *ID, unsigned int *subID);

Return PCI IDs for a given device.

If ID is non-NULL, then bits 0-15 are set to vendor ID and bits 16-31 to device ID.

If subID is non-NULL, then bits 0-15 are set to subsystem vendor ID and bits 16-31 to subsystem ID.


PCI_ReadHeader

void PCI_ReadHeader(pci_handle handle, void *buffer, unsigned int buflen);

Read buflen bytes from the PCI header into the given buffer. buflen must be 4-256 and a multiple of 4.


PCI_ReturnNumber

pci_handle PCI_ReturnNumber(void );

Return number of allocated function handles. You can search from 1 to the result of this inclusive for PCI devices.


PCI_EnumerateFuntions

pci_handle PCI_EnumerateFuntions(pci_handle handle, unsigned int *ID, unsigned int *subID, unsigned int *classcode);

Similar to PCI_ReadID, but allows enumeration. Use 0 for the first value, then the value returned for succesive calls.


PCI_IORead

unsigned int PCI_IORead(unsigned int address, unsigned int size);

Read and write PCI I/O space. The address passed can be found with PCI_HardwareAddress. The size parameter is either 1, 2 or 4, indicating 8, 16 or 32-bit access.


PCI_IOWrite

void PCI_IOWrite(unsigned int address, unsigned int vaulue, unsigned int size);

PCI_MemoryRead

void PCI_MemoryRead(unsigned int address, unsigned int length, void *buffer, unsigned int flags);

Read and write PCI Memory space. A buffer and length is passed for the access. The only available flag is for reads - bit 3 when set indicates it is prefetchable.


PCI_MemoryWrite

void PCI_MemoryWrite(unsigned int address, unsigned int length, void *buffer, unsigned int flags);

PCI_ConfigurationRead

unsigned int PCI_ConfigurationRead(unsigned int address, unsigned int size, pci_handle handle);

Read and write PCI configuration space. The size parameter is either 1, 2 or 4, indicating 8, 16 or 32-bit access.


PCI_ConfigurationRead

void PCI_ConfigurationRead(unsigned int address, unsigned int value, unsigned int size, pci_handle handle);

PCI_HardwareAddress

unsigned int PCI_HardwareAddress(pci_address *address, pci_handle handle);

PCI_SpecialCycle

unsigned int PCI_SpecialCycle(unsigned int bus, unsigned int message);

PCI_FindByID

pci_handle PCI_FindByID(int vendor, int device, int subvendor, int subid);

PCI_FindBuClass

pci_handle PCI_FindBuClass(pci_handle handle, unsigned int class_code, unsigned int mask);

PCI_RAMAlloca

void * PCI_RAMAlloca(size_t size, unsigned int alignment, unsigned int boundary, unsigned int *pci_address);

PCI_RAMFree

void PCI_RAMFree(void *address);

PCI_LogicalAddress

exetern void * PCI_LogicalAddress(pci_aflags flags, unsigned int pci_address, unsigned int length);

Types


pci_handle

typedef unsigned int pci_handle;

pci_aflags

typedef struct
{
int access : 4;
int bufferable : 1;
int cacheable : 1;
int policy : 3;
int access_sp : 1;
int unused : 20;
int memory : 1;
int query : 1;

} pci_aflags;

pci_address

typedef struct
{
pci_aflags flags;
unsigned int index;
unsigned int flags;
unsigned int address;
unsigned int size;
void *laddress;

} pci_address;