Here's a snipplet from pcicard.h:#include <stdio.h> #include <sys/ioctl.h> #include <fcntl.h> #include "pcicard.h" int main(int argc, char **argv) { u8 val; int fd; if ((fd = open('/dev/pcicard', O_RDWR)) == -1) { perror("open"); exit(1); } val = 0x03; ioctl(fd, PCICARD_SET_REGISTER, &val); close(fd); exit(1); }
After converting with h2ph and moving the relevant lines into the Perl script itself, it looks as follows:#define PCIMAX_IOC_NUM 'O' #define PCICARD_SET_REGISTER _IOR(PCICARD_IOC_NUM, 1, u8 *) #define PCICARD_GET_REGISTER _IOW(PCICARD_IOC_NUM, 2, u8 *)
However, this does not work. The corresponding code in the kernel module is not being executed. Any hints what I'm missing here? Many thanks!#!/usr/bin/perl require 'sys/ioctl.ph'; require '_h2ph_pre.ph'; sub PCICARD_IOC_NUM () { ord('0'); } sub PCICARD_SET_REGISTER () { &_IOR( &PCICARD_IOC_NUM, 1, 'int' ); } sub PCICARD_GET_REGISTER () { &_IOW( &PCICARD_IOC_NUM, 2, 'int' ); } $value = 0x03; open(PCI, '+</dev/pcimax'); ioctl(PCI, &PCICARD_SET_REGISTER, \$value); close(PCI);
Retitled by davido per consideration vote.
In reply to Help using ioctl to write a PCI device by p-rex
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |