Home    Prev Next    
Contents
Programming For PCI Device
Overview
Programmers Guide
Scenario
Access to PCI devices information
How to work with PCI header
Accessing PCI registers
Accessing BAR0-BAR5 areas
I/O Ports control
Single read/write operations
Data array read/write operations
Accessing Physical Memory Addresses
Memory Mapping
Additional Functions
Hardware interrupts handling at user level
Common Issues
Extended options of hardware interrupt handling
PCI Support Routines And Structures
Common Procedures
OpenRapidPci
IsRapidPciOpened
CloseRapidPci
GetHardwareConfiguration
GetPciLocation
PCI specific functions
PCI Header
GetPciHeader
SetPciHeader
ReadFromPci
WriteToPci
PCI BAR Areas
GetNumOfPciBars
GetPciBarLength
GetPciBarPhysicalAddress
GetPciBarLinearAddress
ReadPciBarByte
ReadPciBarWord
ReadPciBarLong
WritePciBarByte
WritePciBarWord
WritePciBarLong
PCI Registers
ReadPciCommandReg
WritePciCommandReg
ControlPciCommandRegBits
ReadPciStatusReg
Memory Access
MapPhysToLinear
UnmapMemory
GetMem
GetMemW
GetMemL
SetMem
SetMemW
SetMemL
Direct Port I/O
GetPortByte
GetPortWord
GetPortLong
SetPortByte
SetPortWord
SetPortLong
ReadPortBuffer
WritePortBuffer
Hardware Interrupts
UnmaskPciIrq
MaskPciIrq
GetInterruptCounter
Memory Mapping
Go to RapidDriver Main Page

To access specified physical memory address you have to map this physical address to a linear memory of the current process' address space. RapidPci includes the function MapPhysToLinear, which performs the above task and returns the pointer to the above linear memory defined by it's physical address and size. When the pointer is not needed by application any more, this physical memory area can and must be unmapped with the function UnmapMemory.
The following is an example how to get a pointer to the ROM BIOS area:

char *pBios;  
HANDLE hPci = NULL;  
hPci = OpenRapidPci( 0 );  
if (IsRapidPciOpened(hPci)) {  
 
  pBios = (char*)MapPhysToLinear(hPci,0xF8000,256); //256 bytes, starting from 0xF8000  
       
  //...pBIOS session...  
 
  UnmapMemory(hPci, 0xF8000,256); // undo mapping  
  hPci = CloseRapidPci(hPci);     //  close the driver  
}  
else   
  ... // failed