[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: RFC: Access to device drivers with mmap()
|
From: |
Mohammad-Reza Nabipoor |
|
Subject: |
Re: RFC: Access to device drivers with mmap() |
|
Date: |
Mon, 1 Jan 2024 16:35:21 +0100 |
Hi Andreas.
On Mon, Jan 01, 2024 at 12:38:57PM +0100, Andreas Klinger wrote:
> Hi,
>
> I'm writing Linux device drivers in which there is a mmap() file operation for
> mapping the memory from the kernel driver to the userspace. These drivers have
> no read() or write() functions.
>
> I would like to investigate the content of this memory area with poke as it
> contains structured data (mostly picture images).
>
> What I've seen so far is that poke is always accessing an opened file with
> lseek(), read(), write() but never with mmap() what I would need in my case.
>
> Or did I miss something?
>
1. One option is using libpoke and introducing a new "Foreign Device Interface"
using
`pk_register_iod' function and by implementing the `struct pk_iod_if'. See
at the end of `libpoke.h'.
Then, you can run your Poke scripts on your program that is using libpoke.
The down-side is you don't benefit from `poke' CLI program. It'll be an
independent app.
2. The other option is to introduce a new IO space in libpoke. See
`libpoke/ios.c' file.
Here you can see the supported IO Space Devices:
```
enum
{
IOS_DEV_ZERO,
IOS_DEV_MEM,
IOS_DEV_STREAM,
IOS_DEV_NBD,
IOS_DEV_PROC,
IOS_DEV_SUB,
IOS_DEV_FILE, /* File must be last */
};
static const struct ios_dev_if *ios_dev_ifs[] =
{
[IOS_DEV_ZERO] = &ios_dev_zero,
[IOS_DEV_MEM] = &ios_dev_mem,
[IOS_DEV_STREAM] = &ios_dev_stream,
#ifdef HAVE_LIBNBD
[IOS_DEV_NBD] = &ios_dev_nbd,
#else
[IOS_DEV_NBD] = NULL,
#endif
#ifdef HAVE_PROC
[IOS_DEV_PROC] = &ios_dev_proc,
#else
[IOS_DEV_PROC] = NULL,
#endif
[IOS_DEV_SUB] = &ios_dev_sub,
[IOS_DEV_FILE] = &ios_dev_file, /* File must be last */
};
Then you can see implementation for each of them in the corresponding
`libpoke/ios-dev-$name.c' file.
> Would it be possible to introduce a new command (.mmap) for this purpose?
>
See `poke/pk-cmd-ios.c'.
> If yes, I would also participate in development.
>
You are very welcome!
You can also join us in IRC: #poke on libera.chat servers.
Regards,
Mohammad-Reza