writing/finding pci bar0 - Linux

This is a discussion on writing/finding pci bar0 - Linux ; i'm struggling to learn/understand pci direct access from user space. i have a test system, system board parallel port is disabled, and a pci parallel port card is installed. using lspci i can see base_address_0 as 0xfc98. i've written some ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: writing/finding pci bar0

  1. writing/finding pci bar0

    i'm struggling to learn/understand pci direct access from user space.
    i have a test system, system board parallel port is disabled, and
    a pci parallel port card is installed. using lspci i can see
    base_address_0 as 0xfc98. i've written some code to wiggle bits
    on that card by writing to 0xfc98. using setpci i can change
    BAR0 address to 0x378. however, the card only responds for a
    few minutes. if i rewrite base_address_0 back to card a few
    times, it will come back for awhile. what am i doing wrong
    here? can you not manually change the base address in this
    manner?
    when i look a the output of lspci -bvx, the value stored at
    offset 0x10 is one higher than the actual base address. why
    is this?


  2. Re: writing/finding pci bar0

    gobo20@lycos.com wrote:

    >i'm struggling to learn/understand pci direct access from user space.
    >i have a test system, system board parallel port is disabled, and
    >a pci parallel port card is installed. using lspci i can see
    >base_address_0 as 0xfc98. i've written some code to wiggle bits
    >on that card by writing to 0xfc98. using setpci i can change
    >BAR0 address to 0x378. however, the card only responds for a
    >few minutes. if i rewrite base_address_0 back to card a few
    >times, it will come back for awhile. what am i doing wrong
    >here? can you not manually change the base address in this
    >manner?


    No. The BAR addresses are assigned by the BIOS at boot time, and possibly
    modified later by the Linux kernel.

    >when i look a the output of lspci -bvx, the value stored at
    >offset 0x10 is one higher than the actual base address. why
    >is this?


    The low-order bit of the BAR registers say whether the address is in memory
    space (0) or I/O port space (1). Parallel ports use I/O ports. That's why
    you're able to tickle it from user mode (using outpb, right?). If it was a
    memory address, you'd need to use a kernel driver.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.

  3. Re: writing/finding pci bar0

    Tim Roberts wrote:
    > The low-order bit of the BAR registers say whether the address is in memory
    > space (0) or I/O port space (1). Parallel ports use I/O ports. That's why
    > you're able to tickle it from user mode (using outpb, right?). If it was a
    > memory address, you'd need to use a kernel driver.


    If the device uses memory rather than I/O space, you can open /dev/mem
    and mmap it.

    GH


  4. Re: writing/finding pci bar0

    Tim Roberts wrote:

    >
    > No. The BAR addresses are assigned by the BIOS at boot time, and possibly
    > modified later by the Linux kernel.


    i understand the bios sets the five base addr's initially. but if the
    kernel can change
    them, why can't i (using setpci for example)?

    >
    > >when i look a the output of lspci -bvx, the value stored at
    > >offset 0x10 is one higher than the actual base address. why
    > >is this?

    >
    > The low-order bit of the BAR registers say whether the address is in memory
    > space (0) or I/O port space (1). Parallel ports use I/O ports. That's why
    > you're able to tickle it from user mode (using outpb, right?). If it was a
    > memory address, you'd need to use a kernel driver.


    interesting. after all the digging i've done, i did not come across
    that little
    detail. writing to the ports with outb.


    > --
    > Tim Roberts, timr@probo.com
    > Providenza & Boekelheide, Inc.



  5. Re: writing/finding pci bar0

    gobo20@lycos.com wrote:
    >
    >Tim Roberts wrote:
    >
    >> No. The BAR addresses are assigned by the BIOS at boot time, and possibly
    >> modified later by the Linux kernel.

    >
    >i understand the bios sets the five base addr's initially. but if the
    >kernel can change them, why can't i (using setpci for example)?


    Because when YOU change them, the kernel isn't told about it, so it's
    tables are no longer correct.

    Plus, you don't have enough information to know whether the I/O port you
    want is already assigned to something else.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.

  6. Re: writing/finding pci bar0

    Tim Roberts wrote:

    > gobo20@lycos.com wrote:
    >>
    >>Tim Roberts wrote:
    >>
    >>> No. The BAR addresses are assigned by the BIOS at boot time, and
    >>> possibly modified later by the Linux kernel.

    >>
    >>i understand the bios sets the five base addr's initially. but if the
    >>kernel can change them, why can't i (using setpci for example)?

    >
    > Because when YOU change them, the kernel isn't told about it, so it's
    > tables are no longer correct.
    >
    > Plus, you don't have enough information to know whether the I/O port you
    > want is already assigned to something else.


    Thank you Tim for expressing clearly what i had partially figured out but
    could not express, i just knew it would be really, really bad idea.

    --
    JosephKK
    Gegen dummheit kampfen die Gotter Selbst, vergebens.**
    --Schiller

+ Reply to Thread