LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-14-2008, 07:41 AM   #1
gthakur
LQ Newbie
 
Registered: Jul 2008
Posts: 1

Rep: Reputation: 0
Question Trouble in accessing device register using BAR


Hi all,

I am writing a driver for linux in which I want to access a device register.This register is at offset 0x60 and is behind a IO BAR register.This BAR register is at offset 0x68 and present in PCI space.Therefore it can be accessed directly.After lot of searching I found that the device register which i want to access is present in IO space and can be accessed using inw() and outw().Register location in IO space can be calulated by

Contents of BAR register(having base address) + offset of device register

BIOS writes the base address into BAR from bits8 to bit31 after PCI device is discovered.My problem is do I have to shift bits8:31 7 places right and add the offset or should I keep the contents of BAR register as it is (except bits 0:7which are used for getting info abt whether device register is mapped into IO space or memory space and maksed to zero) and add it to offset of device regiser directly.Let me make myself clear from a little example
offset of device register = 0x60
contents of BAR(i.e. base address) = 0x00002401
last bit is one which indicates device register is mapped into IO space.

For calculating absolute address first I'll make all other bits zero except bits8:31.which makes content of BAR 0x00002400

Now here I am confused
address of device register in IO space = 0x00002400 + 0x60 = 0x00002460

OR

may be is calculated this way = 0x00000024 + 0x60 = 0x84

Which is the correct method?
Anybody can help me out of this confusion?

Is there any user space utility in linux with which I can read/write deice register in IO space.

Last edited by gthakur; 07-14-2008 at 09:51 AM.
 
Old 07-14-2008, 12:32 PM   #2
resetreset
Senior Member
 
Registered: Mar 2008
Location: Cyberspace
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,340

Rep: Reputation: 62
Quote:
Originally Posted by gthakur View Post

Which is the correct method?
Anybody can help me out of this confusion?

Is there any user space utility in linux with which I can read/write deice register in IO space.


The only thing i can suggest is that you have to ask your BIOS manufacturer.

And as to the last question, *how* could that be possible, mister gthakur? Isnt Linux a protected mode OS? Although in the old days running "X" would lock the whole system as it probed ports, or *something* like that, although even then Linux was still a p-mode OS, running in pmode on an x86 CPU! (I still dont know what was going on).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in accessing register for at91rm9200 goelmanila Linux - Hardware 0 06-26-2008 03:24 AM
hw_random: misc device register failed jrdioko Linux - Software 5 09-14-2005 10:45 PM
Accessing register values in C... Elric of Grans Programming 6 05-09-2005 12:30 AM
Accessing the task bar without a mouse superztnt Linux - Newbie 2 06-08-2004 07:29 PM
ALSA unable to register device Griffon26 Linux - Software 3 11-27-2002 08:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration