PC Review


Reply
Thread Tools Rate Thread

Accessing registers on a PCI board

 
 
baical
Guest
Posts: n/a
 
      26th Nov 2005

Here is the situation:

I have a PCI board I use as a platform to train in NT driver
development. The board uses 3 resources:
1. IRQ;
2. Memory (Mem0 - contains 32-bit control registers )
3. Memory (Mem1 - contains data registers )

All the resources are processed smoothly in my StartDevice function
(below are debug messages from my AddDevice ):

MC431PCI - PNP Request (IRP_MN_START_DEVICE)
MC431PCI - Resources:
type CmResourceTypeMemory start 03FDFFF00 length 100
type CmResourceTypeMemory start 03FE00000 length 200000
type CmResourceTypeInterrupt level 16, vector 16, affinity
FFFFFFFF
MC431PCI - Translated Resources:
type CmResourceTypeMemory start 03FDFFF00 length 100
type CmResourceTypeMemory start 03FE00000 length 200000
type CmResourceTypeInterrupt level 8, vector 194, affinity 3
MC431PCI - Found control memory block. Physical base address -
3FDFFF00, length - 255
MC431PCI - Found data memory block. Physical base address - 3FE00000,
length - 2097152
MC431PCI - Got Interrupt Resource 2
MC431PCI - Mapping control memory ...
MC431PCI - Control memory virtual base address F7CD9F00
MC431PCI - Mapping data memory ...
MC431PCI - Data memory virtual base address A9687000


After that I probe my control registers (which called RUK#) using
READ_REGISTER_ULONG():
MC431PCI Reading ruk0: 0h
MC431PCI Reading ruk1: 0h
MC431PCI Reading ruk2: 0h
MC431PCI Reading ruk3: 1h
MC431PCI Reading ruk4: 0h
MC431PCI Reading ruk5: 0h
MC431PCI Reading ruk6: 0h
MC431PCI Reading ruk7: 0h
MC431PCI Reading ruk9: 12000012h
MC431PCI Reading ruk10: 0h
MC431PCI Reading ruk11: 0h
MC431PCI Reading ruk12: 0h
MC431PCI Reading ruk13: 0h

As we can see they are all read ok.

Bit 15 of RUK2 controls onboard LED. So just to make sure everything's
ok I set bit 15 high, writing 0x8000 to RUK2 and my LED goes bright
red.
MC431PCI Reading ruk2: 0x8000h.

After that I leave my HandleStartDevice routine feeling absolutely
confident my board is ready to accept control codes and actually
execute them. Device manager shows the board just the way i described
it in the inf file and resources pane shows the resources settings
correct.

I connect to my device via CreateFile and then use DeviceIoControl to
send the control code to turn off the LED (remember it's still on). The
code which I believed should be written was:
WRITE_REGISTER_ULONG((PULONG) (pdx->membase0 + p->RUK), p->buffer);,
where p is a pointer to my PARAMS structure that arrived with the IRP.
It simply contains address and data;


Here is what my DispatchControl says to me:
....
MC431PCI - DATA TO BE WRITTEN: 0h
MC431PCI - ADDR TO BE WRITTEN TO: 8h
MC431PCI - WRITING 0h TO RUK2 ....
MC431PCI - SEE WHAT'S IN RUK2: FFFFFFFFh
.....

Well as we can guess the LED is still on and I end up being unable to
write nor can i read from my device.
So the question is why once I leave HandleStartDevice routine I lose
contact with the PCI board. I can no longer read or write. I even
tried to address my register directly avoiding HAL :

first writing into RUK2 still hoping to turn off that LED:
*((PULONG)(pdx->membase0+RUK2)) = 0x00;
and then reading from it
*((PULONG) (pdx->membase0+RUK2)).
The result is still FFFFFFFFh . I of course can turn it off while still
in HandleStartDevice.

Any idea where to look? What happens once HandleStartDevice returns?



--
baical
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing 1394 PHY registers TonB Windows XP Drivers 0 26th Jul 2006 02:23 PM
Subject: WANTED: Singel CPU based board with 64bit PCI-X slot (NO PCI-e) MoRpHeUs Asus Motherboards 7 30th Jun 2005 04:02 PM
Asrock Asus Board K7S8X Board: K7S8XE on board sound Shepİ DIY PC 0 11th Dec 2003 03:27 AM
PCI Standard PCI-to-PCI Bridge Paul Microsoft Windows 2000 Hardware 1 10th Nov 2003 07:09 PM
PCI Standard PCI-to-PCI bridge Jon Windows XP Setup 1 12th Oct 2003 01:41 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:35 AM.