All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai] Test program not accessing RTDM driver
@ 2016-01-11 14:33 Heinick, J Michael
  2016-01-11 14:54 ` Philippe Gerum
  2016-01-11 14:55 ` Gilles Chanteperdrix
  0 siblings, 2 replies; 5+ messages in thread
From: Heinick, J Michael @ 2016-01-11 14:33 UTC (permalink / raw)
  To: xenomai


.........1.........2.........3.........4.........5.........6.........7....|

Currently, I have a RTDM driver that installs with insmod, creates the
node in /dev/rtdm, uninstalls with rmmod, and removes the node from
/dev/rtdm.  At this early stage this RTDM driver is only a skeleton that
should log a message with rtdm_printk whenever the open, close, read,
write, and ioctl handlers are called. So far I have been unable to get
any indication that any of the handlers I have written for the driver are
interacting with the small test program even though the program appears to
run without errors.

The ioctl call in the test program generates the following message in the
dmesg file:

[12503.672657] [Xenomai] tcgrtdmtest[3595] called regular ioctl() on /dev/rtdm/tcgrtdm

The example at http://git.xenomai.org/xenomai-jro.git/tree/demo/posix/cobalt/gpiopwm.c?h=410c
recently suggested by Jorge Ramirez Ortiz has been somewhat helpful, but
I still do not know what I am missing.  Are my rtdm_device and
rtdm_driver structures correct enough to get the handlers called, or is the
problem elsewhere?

Thanks for any help that you can provide.
Mike H.

Additional details on our situation are included below:

The code: vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
// ------------- tcgrtdmtest.c -----------
#include <xenomai/init.h>
#include <rtdm/rtdm.h>
#include <stdlib.h>
#include <errno.h>
#include <error.h>
#include <stdio.h>

int main()
  {
  int fd;
  unsigned int rply;
  rply = 987; // =0x3DB
  fd = open("/dev/rtdm/tcgrtdm",O_RDWR);
  perror("Open error: ");
  ioctl(fd,0x55,&rply);
  printf("reply = 0x%X\n",rply); // reply = 0xAB would be good
  close(fd);
  return 0;
  }


The makefile: vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
XENO_CONFIG := /usr/xenomai/bin/xeno-config
CFLAGS := $(shell $(XENO_CONFIG) --posix --cflags)
LDLAGS := $(shell $(XENO_CONFIG) --posix --ldflags)
CC := $(shell $(XENO_CONFIG) --cc)

default:
        $(CC) -o tcgrtdmtest tcgrtdmtest.C $(CFLAGS) $(LDFLAGS)

The test program make result: vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
$ make
gcc -o tcgrtdmtest tcgrtdmtest.C -I/usr/xenomai/include/cobalt -I/usr/xenomai/include -D_GNU_SOURCE -D_REENTRANT -D__COBALT__ -D__COBALT_WRAP__
$

Output from test program vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
(Note: The 987 (0x3DB) sent to the driver by the test ptogram should
be changed to 0xAB and returned by the driver in the ioctl call, but
that is not happening.)
Open error: : Success
reply = 0x3DB


The driver: vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
// ------------------- tcgbc635rt.c ---------------------------
#include <rtdm/rtdm.h>
#include <rtdm/driver.h>

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Michael Heinick");
MODULE_DESCRIPTION("RTDM Interface to BC635 TCG card");

int __init tcgrt_init(void);

void __exit tcgrt_exit(void);
static int tcgrtdmopen(struct rtdm_fd *fd, int oflags)
  {
  int status;
  printk(KERN_CRIT"TCG RTDM open:.\n");
  rtdm_printk(KERN_CRIT"TCG RTDM open:.\n");
  status = 0;
  return status;
  }

static void tcgrtdmclose(struct rtdm_fd *fd)
  {
  int status;
  printk("TCG RTDM close:.\n");
  rtdm_printk("TCG RTDM close:.\n");
  status =  0;
  return;
  }

static int tcgrtdmioctl(struct rtdm_fd *fd, unsigned int request,void __user *arg)
  {
  unsigned int rply;
  printk("TCG RTDM ioctl: 0x%X\n",request);
  if(!rtdm_rw_user_ok(fd,arg,sizeof(rply))) { return -EFAULT; }
  rtdm_copy_from_user(fd,&rply,arg,sizeof(rply));
  rtdm_printk("TCG RTDM ioctl: 0x%X arg = 0x%X\n",request,rply);
  rply = 0xAB; //Change rply to 0xAB for return to test application
  rtdm_copy_to_user(fd, arg, &rply, sizeof(rply));
  return request;
  }

static ssize_t tcgrtdmread(struct rtdm_fd *fd, void __user *buf, size_t size)
  {
  rtdm_printk("TCG RTDM read:.\n");
  size = 124;
  return size;
  }

static ssize_t tcgrtdmwrite(struct rtdm_fd *fd, const void __user *buf, size_t size)
  {
  rtdm_printk("TCG RTDM write:.\n");
  return size;
  }

static struct rtdm_driver driver = {
  .profile_info = RTDM_PROFILE_INFO(tcgrtdm,RTDM_CLASS_SERIAL,0,3),
  .device_flags = RTDM_NAMED_DEVICE | RTDM_EXCLUSIVE,
  .device_count = 1,
  .ops = {
    .open = tcgrtdmopen,
    .close = tcgrtdmclose,
    .read_nrt = tcgrtdmread,
    .write_nrt = tcgrtdmwrite,
    .ioctl_nrt = tcgrtdmioctl,
    },
  };
static struct rtdm_device device = {
  .driver = &driver,
  .label = "tcgrtdm"
  };

int __init tcgrt_init(void)
  {
  int status;
  rtdm_printk("TCG RTDM Driver Init.\n");
  status = rtdm_dev_register(&device);
  if(status == 0)
    {
    rtdm_printk("TCG RTDM Driver Registration succeeded.\n");
    }
  else
    {
    switch(status)
     {
      case -EINVAL:
        rtdm_printk("Registration: Invalid entries in device structure\n");
        break;
      case -EEXIST:
        rtdm_printk("Registration: Device name of Protocol ID already in use\n");
        break;
      case -ENOMEM:
        rtdm_printk("Registration: Memory allocation failed\n");
        break;
      default:
        rtdm_printk("Registration: Unknown error\n");
        break;
      } // End of status switch
    } // End of status not 0
  return status;
  }

void __exit tcgrt_exit(void)
  {
  rtdm_printk("Unregistration: Exiting TCG RTDM Driver\n");
  rtdm_dev_unregister(&device);
  }

#ifdef MODULE
module_init(tcgrt_init);
#endif
module_exit(tcgrt_exit);

The driver makefile: vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
XENO_CONFIG := /usr/xenomai/bin/xeno-config
$(eval ccflags-y = $(shell $(XENO_CONFIG) --rtdm --cflags))
obj-m += tcgbc635rt.o

default:
       $(MAKE) -C $(KDIR) M=$(PWD) tcgbc635rt.ko

The driver make result: vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
make -C /lib/modules/3.14.44-xeno02/build M=/home/guts/mike/tcg/rtdmdrvr tcgbc635rt.ko
make[1]: Entering directory `/home/guts/mike/xeno/linux-3.14.44'
  CC [M]  /home/guts/mike/tcg/rtdmdrvr/tcgbc635rt.o
  MODPOST 1 modules
  CC      /home/guts/mike/tcg/rtdmdrvr/tcgbc635rt.mod.o
  LD [M]  /home/guts/mike/tcg/rtdmdrvr/tcgbc635rt.ko
make[1]: Leaving directory `/home/guts/mike/xeno/linux-3.14.44'


Return from /usr/xenomai/bin/xeno-config --info vvvvvvvvvvvvvvvvvvvvvvvvvv
$ /usr/xenomai/bin/xeno-config --info
Xenomai version: Xenomai/cobalt v3.0.1
Linux htsi-linux 3.14.44-xeno02 #1 SMP PREEMPT Fri Nov 13 09:35:37 EST 2015 x86_64 x86_64 x86_64 GNU/Linux
Kernel parameters: BOOT_IMAGE=/vmlinuz-3.14.44-xeno02 root=UUID=ef5daf08-36a0-46b3-9ed4-4917b36301cf ro nomodeset quiet splash
I-pipe release #10 detected
Cobalt core 3.0.1 detected
Compiler: gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)
Build args: --with-core=cobalt --enable-smp --enable-pshared --host=i686-linux host_alias=i686-linux
$


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-01-12 16:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-11 14:33 [Xenomai] Test program not accessing RTDM driver Heinick, J Michael
2016-01-11 14:54 ` Philippe Gerum
2016-01-12 15:43   ` Heinick, J Michael
2016-01-12 16:24     ` Philippe Gerum
2016-01-11 14:55 ` Gilles Chanteperdrix

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.