LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 08-27-2012, 04:48 AM   #1
jackyding2679
LQ Newbie
 
Registered: Sep 2011
Location: China
Distribution: CentOS
Posts: 1

Rep: Reputation: Disabled
Question about access to pci configuration space, the macro PCI_CONF1_ADDRESS confuse me


I am learning the linux kernel code,about the part of pci, and I read the file /arch/x86/pci/Direct.c, some code confuse me:
Code:
/*
* Functions for accessing PCI base (first 256 bytes) and extended
* (4096 bytes per PCI function) configuration space with type 1
* accesses.
*/
#define PCI_CONF1_ADDRESS(bus, devfn, reg) \
(0x80000000 | ((reg & 0xF00) << 16) | (bus << 16) \
| (devfn << 8) | (reg & 0xFC))

static int pci_conf1_read(unsigned int seg, unsigned int bus,
          unsigned int devfn, int reg, int len, u32 *value)
{
unsigned long flags;

if ((bus > 255) || (devfn > 255) || (reg > 4095)) {
    *value = -1;
    return -EINVAL;
}

spin_lock_irqsave(&pci_config_lock, flags);

outl(PCI_CONF1_ADDRESS(bus, devfn, reg), 0xCF8);

switch (len) {
case 1:
    *value = inb(0xCFC + (reg & 3));
    break;
case 2:
    *value = inw(0xCFC + (reg & 2));
    break;
case 4:
    *value = inl(0xCFC);
    break;
}

spin_unlock_irqrestore(&pci_config_lock, flags);

return 0;
}
The kernel version is 2.6.18,so, the macro PCI_CONF1_ADDRESS confuse me. As you know, it can only access to the first 256-byte of the pci confiuration space when using the IO port CF8/CFC, if you want to access the space between 256~4095-byte, you must use ECAM (Enhanced Configuration Access Mechanism), but the annotation above says:
Quote:
extended (4096 bytes per PCI function) configuration space with type 1 accesses.
Does this mean that it can access all the 4096-byte of the pci configuration space when using IO port CF8/CFC? But why does the PCI LOCAL BUS SPECIFICATION never mention this?
Meanwhile,i also feel puzzled about the expression:
Quote:
((reg & 0xF00) << 16)
It use this way to generate a pci config address,I never saw this expression in any book or SPECIFICATION.
thank you so much.

Last edited by colucix; 08-28-2012 at 10:24 AM. Reason: to make my expression clearly. Moderator note: moved to Linux Kernel and sent back to Zero Reply List, waiting for bumping.
 
  


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
how does macro to get base address register in configuration space works jamesbon Programming 1 11-22-2010 07:19 PM
How do you MMAP PCI Configurations Space to User Space jbreaka4lyfe Linux - Kernel 0 03-03-2008 01:15 PM
PCI Driver (How to access info in config space) bramsey123 Programming 1 09-29-2007 03:36 PM
Gpio Twiddling In Embedded Linux? or How to access PCI memory space regs? jds-linux Programming 1 07-11-2004 02:17 AM
glibc configuration confuse taoweijia Linux - General 15 06-09-2004 10:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 11:19 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