On 27.05.20 14:32, [email protected] wrote:
> From: Nikhil Devshatwar <[email protected]>
> 
> Number of peers available on a platform is different.
> Do not hard code the target peer_id used for interrupt.
> Parse this from the command line argument.
> 
> This de-couples the dependency between number of peers.
> ivshmem-demo can be run to communicate with desired target

No command line, please. We can do (<ID> + 1) % <Maximum Peers> as
target. All that is accessible via the register interface. But then all
demos should be updated, ie. also the bare-metal version.

Jan

> 
> Signed-off-by: Nikhil Devshatwar <[email protected]>
> ---
>  tools/ivshmem-demo.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/ivshmem-demo.c b/tools/ivshmem-demo.c
> index 163653e1..98d24111 100644
> --- a/tools/ivshmem-demo.c
> +++ b/tools/ivshmem-demo.c
> @@ -91,10 +91,11 @@ int main(int argc, char *argv[])
>  
>       pgsize = getpagesize();
>  
> -     if (argc < 2)
> -             path = strdup("/dev/uio0");
> -     else
> -             path = strdup(argv[1]);
> +     if (argc !=  3)
> +             error(1, EINVAL, "Usage: ivshmem-demo </dev/uioX> <peer_id>");
> +     path = strdup(argv[1]);
> +     target = atoi(argv[2]);
> +
>       fds[0].fd = open(path, O_RDWR);
>       if (fds[0].fd < 0)
>               error(1, errno, "open(%s)", path);
> @@ -113,6 +114,8 @@ int main(int argc, char *argv[])
>  
>       id = mmio_read32(&regs->id);
>       printf("ID = %d\n", id);
> +     if (target >= regs->max_peers || target == id)
> +             error(1, EINVAL, "invalid peer number");
>  
>       offset += pgsize;
>       size = uio_read_mem_size(path, 1);
> @@ -180,7 +183,6 @@ int main(int argc, char *argv[])
>                               error(1, errno, "read(sigfd)");
>  
>                       int_no = has_msix ? (id + 1) : 0;
> -                     target = (id + 1) % 3;
>                       printf("\nSending interrupt %d to peer %d\n",
>                              int_no, target);
>                       mmio_write32(&regs->doorbell, int_no | (target << 16));
> 

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jailhouse-dev/98bf4c5b-9812-d2d4-8da0-c887b44277b9%40siemens.com.

Reply via email to