<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Need to access PCIe memory space directly from user space - LS1088ARDB-PB in Other NXP Products</title>
    <link>https://community.nxp.com/t5/Other-NXP-Products/Need-to-access-PCIe-memory-space-directly-from-user-space/m-p/1299428#M11405</link>
    <description>&lt;DIV&gt;UIO system can allow user to access bar memory from user space, please refer to&amp;nbsp;&lt;A href="https://www.kernel.org/doc/html/v4.14/driver-api/uio-howto.html" target="_blank"&gt;https://www.kernel.org/doc/html/v4.14/driver-api/uio-howto.html&lt;/A&gt;.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV id="writing-userspace-driver-using-uio-pci-generic" class="section"&gt;
&lt;H3&gt;Writing userspace driver using uio_pci_generic&lt;/H3&gt;
&lt;P&gt;Userspace driver can use pci sysfs interface, or the libpci library that wraps it, to talk to the device and to re-enable interrupts by writing to the command register.&lt;/P&gt;
&lt;/DIV&gt;
&lt;DIV id="example-code-using-uio-pci-generic" class="section"&gt;
&lt;H3&gt;Example code using uio_pci_generic&lt;/H3&gt;
&lt;P&gt;Here is some sample userspace driver code using uio_pci_generic:&lt;/P&gt;
&lt;DIV class="highlight-none"&gt;
&lt;DIV class="highlight"&gt;
&lt;PRE&gt;#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;unistd.h&amp;gt;
#include &amp;lt;sys/types.h&amp;gt;
#include &amp;lt;sys/stat.h&amp;gt;
#include &amp;lt;fcntl.h&amp;gt;
#include &amp;lt;errno.h&amp;gt;

int main()
{
    int uiofd;
    int configfd;
    int err;
    int i;
    unsigned icount;
    unsigned char command_high;

    uiofd = open("/dev/uio0", O_RDONLY);
    if (uiofd &amp;lt; 0) {
        perror("uio open:");
        return errno;
    }
    configfd = open("/sys/class/uio/uio0/device/config", O_RDWR);
    if (configfd &amp;lt; 0) {
        perror("config open:");
        return errno;
    }

    /* Read and cache command value */
    err = pread(configfd, &amp;amp;command_high, 1, 5);
    if (err != 1) {
        perror("command config read:");
        return errno;
    }
    command_high &amp;amp;= ~0x4;

    for(i = 0;; ++i) {
        /* Print out a message, for debugging. */
        if (i == 0)
            fprintf(stderr, "Started uio test driver.\n");
        else
            fprintf(stderr, "Interrupts: %d\n", icount);

        /****************************************/
        /* Here we got an interrupt from the
           device. Do something to it. */
        /****************************************/

        /* Re-enable interrupts. */
        err = pwrite(configfd, &amp;amp;command_high, 1, 5);
        if (err != 1) {
            perror("config write:");
            break;
        }

        /* Wait for next interrupt. */
        err = read(uiofd, &amp;amp;icount, 4);
        if (err != 4) {
            perror("uio read:");
            break;
        }

    }
    return errno;
}&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Tue, 29 Jun 2021 05:53:05 GMT</pubDate>
    <dc:creator>yipingwang</dc:creator>
    <dc:date>2021-06-29T05:53:05Z</dc:date>
    <item>
      <title>Need to access PCIe memory space directly from user space - LS1088ARDB-PB</title>
      <link>https://community.nxp.com/t5/Other-NXP-Products/Need-to-access-PCIe-memory-space-directly-from-user-space/m-p/1295449#M11336</link>
      <description>&lt;P&gt;I am using LS1088ARDB-PB Hardware and I ported NXP LSDK 2012 main (GNU/LINUX 5.4.47 aarch64) software. I have connected one PCIe based board externally to the LS1088ARDB-PB PCIe 1 port. I can see the external connected PCIe board details by giving command of "lspci -v" in the user space.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to understand how to access direct memory spaces of Base Address Register (BAR) memory address space from user space?&lt;/P&gt;&lt;P&gt;Please suggest if I need to enable to get an access or any code available to Write/Read memory mapped BAR address space?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards&lt;/P&gt;&lt;P&gt;Suresh&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 13:10:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Other-NXP-Products/Need-to-access-PCIe-memory-space-directly-from-user-space/m-p/1295449#M11336</guid>
      <dc:creator>gsuresh_12</dc:creator>
      <dc:date>2021-06-21T13:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: Need to access PCIe memory space directly from user space - LS1088ARDB-PB</title>
      <link>https://community.nxp.com/t5/Other-NXP-Products/Need-to-access-PCIe-memory-space-directly-from-user-space/m-p/1299428#M11405</link>
      <description>&lt;DIV&gt;UIO system can allow user to access bar memory from user space, please refer to&amp;nbsp;&lt;A href="https://www.kernel.org/doc/html/v4.14/driver-api/uio-howto.html" target="_blank"&gt;https://www.kernel.org/doc/html/v4.14/driver-api/uio-howto.html&lt;/A&gt;.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV id="writing-userspace-driver-using-uio-pci-generic" class="section"&gt;
&lt;H3&gt;Writing userspace driver using uio_pci_generic&lt;/H3&gt;
&lt;P&gt;Userspace driver can use pci sysfs interface, or the libpci library that wraps it, to talk to the device and to re-enable interrupts by writing to the command register.&lt;/P&gt;
&lt;/DIV&gt;
&lt;DIV id="example-code-using-uio-pci-generic" class="section"&gt;
&lt;H3&gt;Example code using uio_pci_generic&lt;/H3&gt;
&lt;P&gt;Here is some sample userspace driver code using uio_pci_generic:&lt;/P&gt;
&lt;DIV class="highlight-none"&gt;
&lt;DIV class="highlight"&gt;
&lt;PRE&gt;#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;unistd.h&amp;gt;
#include &amp;lt;sys/types.h&amp;gt;
#include &amp;lt;sys/stat.h&amp;gt;
#include &amp;lt;fcntl.h&amp;gt;
#include &amp;lt;errno.h&amp;gt;

int main()
{
    int uiofd;
    int configfd;
    int err;
    int i;
    unsigned icount;
    unsigned char command_high;

    uiofd = open("/dev/uio0", O_RDONLY);
    if (uiofd &amp;lt; 0) {
        perror("uio open:");
        return errno;
    }
    configfd = open("/sys/class/uio/uio0/device/config", O_RDWR);
    if (configfd &amp;lt; 0) {
        perror("config open:");
        return errno;
    }

    /* Read and cache command value */
    err = pread(configfd, &amp;amp;command_high, 1, 5);
    if (err != 1) {
        perror("command config read:");
        return errno;
    }
    command_high &amp;amp;= ~0x4;

    for(i = 0;; ++i) {
        /* Print out a message, for debugging. */
        if (i == 0)
            fprintf(stderr, "Started uio test driver.\n");
        else
            fprintf(stderr, "Interrupts: %d\n", icount);

        /****************************************/
        /* Here we got an interrupt from the
           device. Do something to it. */
        /****************************************/

        /* Re-enable interrupts. */
        err = pwrite(configfd, &amp;amp;command_high, 1, 5);
        if (err != 1) {
            perror("config write:");
            break;
        }

        /* Wait for next interrupt. */
        err = read(uiofd, &amp;amp;icount, 4);
        if (err != 4) {
            perror("uio read:");
            break;
        }

    }
    return errno;
}&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 29 Jun 2021 05:53:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Other-NXP-Products/Need-to-access-PCIe-memory-space-directly-from-user-space/m-p/1299428#M11405</guid>
      <dc:creator>yipingwang</dc:creator>
      <dc:date>2021-06-29T05:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: Need to access PCIe memory space directly from user space - LS1088ARDB-PB</title>
      <link>https://community.nxp.com/t5/Other-NXP-Products/Need-to-access-PCIe-memory-space-directly-from-user-space/m-p/1299623#M11413</link>
      <description>&lt;P&gt;Thank you for your reply, I will try this code and will let you know the behavior.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Suresh&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jun 2021 10:23:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Other-NXP-Products/Need-to-access-PCIe-memory-space-directly-from-user-space/m-p/1299623#M11413</guid>
      <dc:creator>gsuresh_12</dc:creator>
      <dc:date>2021-06-29T10:23:48Z</dc:date>
    </item>
  </channel>
</rss>

