p-rex has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help using ioctl to write a PCI device
by tachyon (Chancellor) on Nov 01, 2004 at 23:13 UTC | |
by p-rex (Novice) on Nov 02, 2004 at 15:01 UTC | |
by tachyon (Chancellor) on Nov 02, 2004 at 22:53 UTC | |
by p-rex (Novice) on Nov 02, 2004 at 14:28 UTC | |
|
Re: Help using ioctl to write a PCI device
by Fletch (Bishop) on Nov 01, 2004 at 22:51 UTC |