I惴 writing an driver for a high performed A/D ISA-card under linux
kernel 2.0.33 (SuSE 5.2).
In order to record a 100 kB data stream at hock with a transfer rate of
800 kB / sec. I need shared memory support in my driver.
My driver is build as character device driver. The source code looks
like
========================================================================
#include <linux/fs.h>
#include <asm/system.h>
#include <asm/io.h>
#include <linux/errno.h>
#include <linux/major.h>
#include <asm/segment.h>
#include <linux/kernel.h>
#include <linux/signal.h>
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/malloc.h>
#include <asm/shmparam.h>
#include <linux/ipc.h>
#include <linux/shm.h>
#include <linux/version.h>
...
//-------------------------------------------------------------------
static int psam_open( struct inode *inode, struct file *filp)
{
PRINTK("psam: psam_open called\n");
if (filp->f_count > 1)
return -EBUSY;
if( (shmid = sys_shmget( (key_t)12345678, 1024, SHM_RND )) == -1 )
return 12345678; // printk("Can愒 create shared memory!\n");
MOD_INC_USE_COUNT;
return 0;
}
...
=====================================================================
The compiling process with command
gcc -O6 -Wall -c psam.c -D__LINUX__ -DLINUX -D__KERNEL__
runs good, but following command
insmod psam
gives me the message
psam: unresolved symbol sys_shmget
.
Need the compiler an additional parameter to bind
the asmlinkage definitions in <linux/shm.h> ?
asmlinkage int sys_shmget (key_t key, int size, int flag);
asmlinkage int sys_shmat (int shmid, char *shmaddr, int shmflg, ulong
*addr);
asmlinkage int sys_shmdt (char *shmaddr);
asmlinkage int sys_shmctl (int shmid, int cmd, struct shmid_ds
*buf);
Thanks for any info.
Jens.
In article <358797...@informatik.uni-leipzig.de>, Jens Jahny <ja...@informatik.uni-leipzig.de> writes:
|> Hallo,
|>
|> I惴 writing an driver for a high performed A/D ISA-card under linux
|> kernel 2.0.33 (SuSE 5.2).
|> In order to record a 100 kB data stream at hock with a transfer rate of
|> 800 kB / sec. I need shared memory support in my driver.
|>
|> My driver is build as character device driver. The source code looks
|> like
[...]
|> if( (shmid = sys_shmget( (key_t)12345678, 1024, SHM_RND )) == -1 )
|> return 12345678; // printk("Can愒 create shared memory!\n");
[...]
the symbol sys_shmget is not exported to modules.
Are you sure sys_shmget ist doing what you need? May be it is better to
allocate physical memory in the driver and to export it to
applications by mmap(). I strongly recommend to have a look into the
book by Rubini (Linux Device Driver Development), O'Reilly.
Roger
I strongly suggest you purchase the new "Linux Device Driver" book by
Alessandro Rubini - ISBN 1-56592-292-1. It has all the information you
probably need, with specific chapters on interfacing ISA and PCI cards
and memory techniques used. Additionally, comes with code and practice
modules to act as your developing guide.
Costs about $30 (DM60), and in my view well worth the money.
Grahame
I don't think you can create shared memory segments from within
a driver and access them from user space just like that. (Someone
correct me if I'm wrong). I guess you will have to read the data
into a kernel-space buffer and copy them to the application's
address space with memcopy_tofs().
I have written some extensions for the Linux kernel to support DMA
accesses into user-space, so, if your card supports DMA, you could
let the driver store the data directly to where you need it. However,
since you are using an ISA card, I suspect that it can only DMA within
the low 1 MB of memory, which my routines don't explicitly support
(they are intended mainly for PCI cards). Anyway, you can find
the stuff at our FTP site: ftp://ftp.sysgo.de/pub/Linux/ .
Hope this helps
Rob
----------------------------------------------------------------
Robert Kaiser email: rkaiser AT sysgo DOT de
SYSGO RTS GmbH
Mainz / Germany