ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm hoping i've come to the right place and someone can help me here!
I'm doing some work for a client, they have upgraded the processor in one of their products due to redundancy issues. They were running linux with a custom application that uses a kernel module to gather data from the PCI port which then sticks the data in a shared memory space for a GUI app to pick up and display on the screen.
My job was to port this existing platform over to the new processor, I think its a AMD Geode... same processor family before but has double the RAM (256MB now).
Problem is, the shared memory doesn't work on the new processor. Everything else is exactly the same as before! I tried putting dummy data from the kernel module in the shared memory space, but the GUI application can only read 0's from the shared memory space.
its quite a complicated problem to explain, I can post code if need be and provide more information, but I was wondering if anyone would know why shared memory space could fail when the difference between the new and old processor is just bigger RAM.
I don't know enough about linux to even begin trying to fix it! Apologies if I've done a terrible job of explaining the problem! If anyone can even suggest something that would be great! The person who write the existing code isn't available so i'm trying to understand it! I'm not sure if you have to reserve a particular area of memory if you want to share it!
the GUI app uses mmap, which should return a pointer to the shared memory. The kernel module, I think uses kalloc or something (i havent got the code with me so that could be wrong). I dont see any absolute addresses being used.
The kernel module sort of saves itself in /dev . The GUI app then opens the kernel module as a file read operation. Not sure if that helps or not!
So it creates a character device or something similar? I don't believe that's actually shared memory since the module could easily generate data as it's accessed. Does the GUI read the same number of bytes as are written by the module? Can it read 0s even if nothing is written to the file first? Also, if mmap is used, why is read also used? I can't really help with the module, but please post a minimal main function that would replicate the problem were I to have the module running.
Kevin Barry
Yes I believe it is a character device! And yes it does read the same amount of bytes written by the module! The functionality is basically a oscilloscope. So the module writes data from the PCI (which is written to by an FPGA reading an ADC) into this 'shared memory' buffer and the GUI app reads it and draws it on the screen.
It may open the device as read and write...not just read.
Ill post the code, guess that will help alot!
Someone mentioned to me that the kernel has to reserve memory? I got told to look at menu.lst in /boot/grub... didn't help much though!
So this is the code that opens up the module, and then gets a pointer to the shared memory using mmap. struct sample is basically just a structure used to store data for 8 input channels which is stored in the shared memory.
This code is in the module. Not sure if the first bit with kmalloc_area is useful but i thought id post it anyway. allocator_allocate_dma is another module, not sure if its a standard module or not but I have the code for it.
Code:
kmalloc_area = (int *)__get_free_pages(GFP_KERNEL,1);
for (virt_addr=(unsigned long)kmalloc_area; virt_addr<(unsigned long)kmalloc_area+0x1000; virt_addr+=PAGE_SIZE)
{
// reserve all pages to make them remapable
mem_map_reserve(virt_to_page(virt_addr));
}
my_mem = allocator_allocate_dma (LEN, GFP_KERNEL);
if (!my_mem)
{
printk(KERN_WARNING "Cant allocate memory!\n");
}
printk ("my_mem = %lx\nremapping!\n", my_mem);
mem_ptr = ioremap(my_mem, LEN);
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.