"Dean W. Anneser" wrote: > Though somewhat off-topic, I am trying to port our simulation/control/data_acq >system to RTLinux. > Key to the success of this endeavor, is the capability of having one process able to >read/write > into the process space of another. In the example provided I can both mmap() and >read()/write() > /proc on our current platform. On Linux 2.4.1 (RH7.1) however, neither worked. > > A couple of years ago, when I first tried this with RH5.2 (I don't remember the >Linux version) > I remember seeing a similar (if not identical) disclaimer to what's in the current >proc(5) > manpage. The last sentence gave me hope the capability I was seeking was to be >implemented > imminently. > > mem This is not the same as the mem (1:1) device, despite the fact that it has >the > same device numbers. The /dev/mem device is the physical memory before any > address translation is done, but the mem file here is the memory of the >process > that accesses it. This cannot be mmap(2)'ed currently, and will not be >until a > general mmap(2) is added to the kernel. (This might have happened by the >time > you read this.) > > Either Linux can in some form support this and I'm doing something wrong (and the >documentation > is out-of-date); or it is currently not yet possible through /proc. > > Thank you for taking the time to read this note. Any help or pointers would be very >much > appreciated (I hope someone else has crossed this bridge before me). Ok. I think I can see the problem. The interface to mmab has changed since RTLinux 2.0 (I think this was used with RedHat 5.2). It have been made a lot easy to use. I RTLinux 3.0 you shold use rtl_mmap module insted. I have posted a small exampel with this mail. The docomentation for the mmap module is put in drivers/mmap in the rtlinux kernel sourch.
/* * init module *--------------- * har til opgave at oprette f?aelles datalager * blot en test af mbuff. * * Anders Gnistrup * email [EMAIL PROTECTED] * 4/7-01 *-----------------*/ #include <rtl.h> #include <mbuff.h> #include <rtl_printf.h> #include "rt2linux.h" void *memory; int init_module(void) { rt2lMem *mem_ptr; memory = mbuff_alloc(MEM_NAME, sizeof(rt2lMem)); if(memory!=NULL) { rtl_printf("did alloc mem\n"); mem_ptr = memory; mem_ptr->devnr[0].ref = 10; } else rtl_printf("did not alloc at addres %p\n",memory); return 0; } void cleanup_module(void) { rt2lMem *mem_ptr; if(memory!=NULL) { mem_ptr = memory; rtl_printf("got name and ref %d\n", mem_ptr->devnr[0].ref); mbuff_free(MEM_NAME,memory); } }
/* * load from commen arear * just a test * -------------------------*/ #include <unistd.h> #include <stdio.h> #include <rtlinux/mbuff.h> #include "rt2linux.h" void *memory; int main(void) { rt2lMem *mem_ptr; memory = mbuff_alloc(MEM_NAME,sizeof(rt2lMem)); if(memory!=NULL) { printf("succes in alloc mem\n"); mem_ptr = memory; printf("ref %d\n",mem_ptr->devnr[0].ref); mem_ptr->devnr[0].ref = 20; printf("ref %d\n",mem_ptr->devnr[0].ref); mem_ptr->devnr[0].newData = 1; mem_ptr->run = 1; sleep(1); printf("ref %d\n",mem_ptr->devnr[0].newData); mbuff_free(MEM_NAME,memory); } else { printf("error alloc\n"); } return 0; }
/* * faelles datastruktur mellem rt-linux og linux. * data i header filen definere opbygning af data * det faelles lager modul, samt navnet pa modulet *-----------------------------------------------*/ #define MEM_NAME "rt2lMem" #define MOTOR_RIGHT "motor_right" #define MOTOR_LEFT "motor_left" #define DIST_CENCOR "dist cencor" #define LINE_CENCOR "linecencor" typedef struct device_ { int newData; /* new data is ready */ int ref; /* ref to de unit */ int error; /* message to userspace if error */ char name[20]; /* name of the device */ } device; #define NUMOFDEVICE 4 typedef struct rt2lMem_ { device devnr[4]; /* 4 devices */ int run; /* regulate devices */ } rt2lMem;