Yello,
I'm trying to write a kernel module for an embedded system that has a CPU with two cores, what I'm basically trying to do is allow a Linux program on CoreA to read buffers that are being written to by a bare metal encoder running on CoreB. The buffers and variables I need to be able to access have fixed memory locations in L3(SDRAM) and L2 Cache (Shared onchip SRAM), the larger buffers and variables will be read on the Linux side, some of the others will need to be able to change bytes.
Now my main question is where or not it's possible to get the kernel process to pass to the Linux process a pointer so the linux process can read the buffer directly rather then have to copy the data. I know that the kernel module can directly address memory but I don't if I can then pass that to the Linux process. So can someone point me in the right direction, thanks
The way I was assuming it could be done was by using ioctl to return a pointer to a variable in the kernel module that already points to the right area of memory area, something to the effect of the code below, but having never written a kernel module before, and none of the documentation talking about directly addressing memory I need my assumptions confirmed.
Kernel Module:
Code:
static unsigned char *streambuffer = (unsigned char*)0x02800000;
int encoder_icc_ioctl (struct inode *inode, struct file* filp, unsigned int cmd, unsigned long arg)
{
switch (cmd)
{
case (SOME_COMMAND):
{
return &streambuffer;
}
}
}
Linux Program:
Code:
unsigned char **streambufferpointer = ioctl(...);
The CPU and the uClinux kernel for it both use one address range for all 3 caches, which each cache appearing in different parts of that range, 0x02800000 is a direct pointer to the buffer stored in L3 cache. I know that works because we tested the output to a Proc file, its getting a pointer to that address to a Linux process that I'm not sure on, as I don't know how this process would handle the kernel and user address spaces.
If it can't be done then please say, I would rather not have to copy the buffers if possible, but if its unavoidable that's fine. Thanks for the help.