"Wayne E. Van Loon Sr." wrote:
> 
> Hello rtl users.
> I am beginning a project where I would like to use a rtl process as both a rt 
>process and a driver for 4 ea. bt848 devices. I need 12 buffers of 172,800 bytes ea. 
>and each buffer needs to be DMA capable (consecutive physical addresses).  I could 
>live with the buffers being fragmented - meaning that each buffer might in turn be 
>composed of smaller buffers - but it would make more sense (to me) if each buffer was 
>the size that was really needed. I mention this because it is also my understanding 
>that the maximum memory that can be allocated at any one time using get_free_page () 
>is 128KB.
> 
> I wish to do all processing in a Linux process. So it would be real nice if I could 
>also access the buffers from my Linux process rather than having rtl (or a driver) 
>set up the bt848 DMA controllers and then have to copy the buffers to another set of 
>12 buffers in user-land. Sounds like a candidate for shared memory, except that it is 
>my understanding that memory allocated for shared memory is not physically 
>consecutive and therefore not DMA capable.
> 
> One way that I hear of to do this might be to use the mem = xxxx at boot time , 
>reserving the upper 2 MB of ram for my buffers and then hard code carve it up into 
>the buffers that I need. I don't have any idea if these buffers could somehow be 
>accessed from user-land or whether they would have to be copy_to_user()'d or similar.
> 
> Any suggestions? Good places to look and learn? Also, any corrections of my 
>(mis)understandings would be greatly appreciated.
> 

Hi Wayne,

Your final suggestion is the one I would use (it is less efficient than
vremap, but doesn't suffer framentation).  You can get at this memory
from the Linux kernel using ioremap, and from userspace using mmap.

To do this in lilo.conf, reserve some memory (run lilo afterwards)

append="mem=xxxm"   

where xxx is 2 Megs less than you have (yuk!!)

In user space:
----------------
void *map_shared_mem(int mem_os_mb)
{
    int mem_fd;
    void *ptr   = NULL;

    if(( mem_fd = open("/dev/mem", O_RDWR)) < 0)
        err_abort(errno,"Open /dev/mem");

    ptr =              (void *) mmap(0,
                                SHM_SIZE,
                                PROT_READ | PROT_WRITE, MAP_FILE |
MAP_SHARED,
                                mem_fd, mem_os_mb * 0x100000 );
    if( ptr == MAP_FAILED )
        err_abort(errno, "mmap shared memory");

    close(mem_fd);
    return ptr;
}


In kernel space:
----------------


#if LINUX_VERSION_CODE < 0x020100
#include <linux/mm.h>                   // vremap
#define ioremap vremap
#define iounmap vfree
#else
#include <asm/io.h>                     // ioremap
#endif

volatile void *ptr;
        
ptr = (void *)ioemap(mem_os * 0x100000, SHM_SIZE);


Regards, Stuart
-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/

Reply via email to