LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-21-2010, 09:06 PM   #1
jamesbon
Member
 
Registered: Jun 2010
Posts: 147

Rep: Reputation: 9
how does macro to get base address register in configuration space works


I am trying to understand working of pci_resource_start function
So I browsed code via cscope and searched for string pci_resource_start
and got following in pci.h

Code:
 #define pci_resource_start(dev, bar)    ((dev)->resource[(bar)].start)

I am not able to understand how does this above macro works.
How does it above macro gets appropriate base address register in
configuration space?
 
Old 11-22-2010, 07:19 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

1. I'm sure you're probably familiar with this document:
http://tldp.org/LDP/tlk/dd/pci.html

Note in particular the "PCI Base Address" diagrams

2. Next, look at resource.c in your kernel source:

/usr/src/linux/kernel/resource.c =>
Code:
struct resource ioport_resource = {
        .name   = "PCI IO",
        .start  = 0x0000,
        .end    = IO_SPACE_LIMIT,
        .flags  = IORESOURCE_IO,
};

EXPORT_SYMBOL(ioport_resource);
...
3. This is a "Linux kernel thing", and not a "PCI thing".
Specifically,
a) The kernel has a "dev" pointer
b) "dev" has an array of "ioport_resources"
c) The macro you cited "knows" the values of start, end, etc based on other (source-configurable) definitions in the kernel.

'Hope that helps ... at least a little ...
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Base address for hardware pin and register..! cvr Linux - Hardware 1 07-22-2010 05:06 PM
Address Space Randomization on 2.6.28-15-generic ubuntu 9.04. Finding base address nullprocess Linux - Security 1 09-15-2009 12:56 AM
Address Space Randomization on 2.6.28-15-generic ubuntu 9.04. Finding base address nullprocess Linux - Kernel 1 09-14-2009 08:31 PM
Address Space Randomization on 2.6.28-15-generic ubuntu 9.04. Finding base address nullprocess Linux - Kernel 0 09-14-2009 10:45 AM
base address and port address Nodren Linux - Hardware 0 08-30-2004 02:54 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:35 PM.

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