[lkml]   [2000]   [Aug]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectPCI Memory Mapping

    First, please CC your emails to me, since I'm not subscribed.
    Secondly, I know C, but I'm not anywhere near what you'd call a kernel
    hacker. So dumb things down for me, but not _too_ much :)

    Also note that I use Linux 2.2.15, as much as I would want to use 2.4,
    I don't feel like it would be keen of me to switch to a development kernel
    until this release kernel's driver works.

    Anyway, What I'm doing is scanning the PCI bus, and finding the one
    or more cards that have 16mb of on-board memory. base_address[0] if you
    will. I AND that with PCI_BASE_ADDRESS_IO_MASK, and register a device
    major and minor for the device.

    A userland program will now attempt to mmap the device. It requests
    exactly 16mb. Everything seems ok until I try to read or write to this
    memory. It gives me a kernel complaint:

    do_wp_page: bogus page at address 4017400 (72000000)

    base_address[0] is 0xF2000008, and with the mask, F2000000. According to
    the device's documentation, both are acceptable (for what they are).

    I've also pasted in my entire mmap handler:
    (please excuse me if this email is a bit long)

    int device_mmap(struct file * filp, struct vm_area_struct * vma)
    int id = MINOR(filp->f_dentry->d_inode->i_rdev)-1;
    /* this id is supposed to be -1 */
    e4DevT *dev = &devTable[id];

    unsigned long off = vma->vm_offset;
    unsigned long physical=dev->ioaddr+off+PAGE_OFFSET;
    unsigned long vsize=vma->vm_end - vma->vm_start;
    unsigned long psize=dev->ioaddr - off;

    if (off & (PAGE_SIZE-1))
    printk("mmap: page unaligned\n");
    return -ENXIO;
    if (vsize > psize)
    printk("too high\n");
    return -EINVAL;
    if (remap_page_range(vma->vm_start, physical, vsize, vma->vm_page_prot))
    return 0;

    printk("mmap (remap_page_range) device #%d successful\n",id);
    /* this message is printed */

    return 0;

    Thanks for your assistance.

    P.S. There needs to be reference/documentation for all these functions,
    something easier to grep.

    -Charles <>

    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 13:58    [W:0.020 / U:4.084 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site