Date: Mon, 9 Oct 2006 14:31:12 -0400 From: Mikhail Teterin <mi+kde@aldan.algebra.com> To: freebsd@gm.nunu.org, ikob@koganei.wide.ad.jp Cc: firewire@freebsd.org Subject: libraw1394 port for FreeBSD? Message-ID: <200610091431.12698@aldan>
next in thread | raw e-mail | index | archive | help
--Boundary-00=_wVpKF5iDZ2oZDyt Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello! You are the authors of FreeBSD's firewire code, which appears to present an API different, from what Linux programs expect. Could we have a compatibility layer, which would provide such Linuxish API, so that it would be easier to port applications written and maintained on Linux? I'm attaching the skeleton of the devel/libraw1394 port. As you can see, libraw1394 comes with its own version of ieee1394-ioctl.h (which the port simply removes for now). The IOCTLs defined in it -- like RAW1394_IOC_ISO_XMIT_INIT and RAW1394_IOC_ISO_SHUTDOWN -- need to be provided by something in FreeBSD's /usr/include. Alternatively, the libraw1394's src/iso.c needs to be patched (or rewritten) using FreeBSD's firewire APIs. Would you be able to offer help/suggestions on either of the two approaches? The attached (incomplete) port makes the rest of the library compile cleanly, but I have no hope for being able to fix the iso.c myself... Thank you very much for your time. Respectfully, -mi --Boundary-00=_wVpKF5iDZ2oZDyt Content-Type: text/x-diff; charset="us-ascii"; name="libraw1394.shar" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="libraw1394.shar" # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # libraw1394 # libraw1394/Makefile # libraw1394/distinfo # libraw1394/files # libraw1394/files/patch-types # libraw1394/files/patch-eventloop # libraw1394/files/patch-errors # libraw1394/files/patch-iso # echo c - libraw1394 mkdir -p libraw1394 > /dev/null 2>&1 echo x - libraw1394/Makefile sed 's/^X//' >libraw1394/Makefile << 'END-of-libraw1394/Makefile' XPORTNAME= libraw1394 XPORTVERSION= 1.2.1 XMASTER_SITES= http://www.linux1394.org/dl/ XCATEGORIES= devel multimedia X XCOMMENT= Linux' API for direct access to the IEEE 1394 bus X XGNU_CONFIGURE= yes X Xpost-patch: X ${MV} ${WRKSRC}/src/ieee1394-ioctl.h ${WRKSRC}/src/ieee1394-ioctl.h.org X ${ECHO_MSG} '/* Meow-meow */' > ${WRKSRC}/src/ieee1394-ioctl.h X X.include <bsd.port.mk> END-of-libraw1394/Makefile echo x - libraw1394/distinfo sed 's/^X//' >libraw1394/distinfo << 'END-of-libraw1394/distinfo' XMD5 (libraw1394-1.2.1.tar.gz) = e6210ff05b7f4ec0401ad3d11f493e1a XSHA256 (libraw1394-1.2.1.tar.gz) = 13381fb2ea63e6ee428d49c7f6679755a2c331f82afc19522794d11943bcab52 XSIZE (libraw1394-1.2.1.tar.gz) = 382992 END-of-libraw1394/distinfo echo c - libraw1394/files mkdir -p libraw1394/files > /dev/null 2>&1 echo x - libraw1394/files/patch-types sed 's/^X//' >libraw1394/files/patch-types << 'END-of-libraw1394/files/patch-types' X--- src/kernel-raw1394.h Fri Nov 5 19:26:44 2004 X+++ src/kernel-raw1394.h Mon Oct 9 13:40:37 2006 X@@ -73,43 +73,43 @@ X #define RAW1394_NOTIFY_ON 1 X X-#include <asm/types.h> X+#include <sys/types.h> X X struct raw1394_request { X- __u32 type; X- __s32 error; X- __u32 misc; X+ uint32_t type; X+ int32_t error; X+ uint32_t misc; X X- __u32 generation; X- __u32 length; X+ uint32_t generation; X+ uint32_t length; X X- __u64 address; X+ uint64_t address; X X- __u64 tag; X+ uint64_t tag; X X- __u64 sendb; X- __u64 recvb; X+ uint64_t sendb; X+ uint64_t recvb; X }; X X struct raw1394_khost_list { X- __u32 nodes; X- __u8 name[32]; X+ uint32_t nodes; X+ uint8_t name[32]; X }; X X typedef struct arm_request { X- __u16 destination_nodeid; X- __u16 source_nodeid; X- __u64 destination_offset; X- __u8 tlabel; X- __u8 tcode; X- __u8 extended_transaction_code; X- __u32 generation; X- __u16 buffer_length; X- __u8 *buffer; X+ uint16_t destination_nodeid; X+ uint16_t source_nodeid; X+ uint64_t destination_offset; X+ uint8_t tlabel; X+ uint8_t tcode; X+ uint8_t extended_transaction_code; X+ uint32_t generation; X+ uint16_t buffer_length; X+ uint8_t *buffer; X } *arm_request_t; X X typedef struct arm_response { X- __s32 response_code; X- __u16 buffer_length; X- __u8 *buffer; X+ int32_t response_code; X+ uint16_t buffer_length; X+ uint8_t *buffer; X } *arm_response_t; X X@@ -125,15 +125,15 @@ X /* must be identical to hpsb_iso_packet_info in iso.h! */ X struct raw1394_iso_packet_info { X- __u32 offset; X- __u16 len; X- __u16 cycle; /* recv only */ X- __u8 channel; /* recv only */ X- __u8 tag; X- __u8 sy; X+ uint32_t offset; X+ uint16_t len; X+ uint16_t cycle; /* recv only */ X+ uint8_t channel; /* recv only */ X+ uint8_t tag; X+ uint8_t sy; X }; X X /* argument for RAW1394_ISO_RECV/XMIT_PACKETS ioctls */ X struct raw1394_iso_packets { X- __u32 n_packets; X+ uint32_t n_packets; X struct raw1394_iso_packet_info *infos; X }; X@@ -141,20 +141,20 @@ X struct raw1394_iso_config { X /* size of packet data buffer, in bytes (will be rounded up to PAGE_SIZE) */ X- __u32 data_buf_size; X+ uint32_t data_buf_size; X X /* # of packets to buffer */ X- __u32 buf_packets; X+ uint32_t buf_packets; X X /* iso channel (set to -1 for multi-channel recv) */ X- __s32 channel; X+ int32_t channel; X X /* xmit only - iso transmission speed */ X- __u8 speed; X+ uint8_t speed; X X /* The mode of the dma when receiving iso data. Must be supported by chip */ X- __u8 dma_mode; X+ uint8_t dma_mode; X X /* max. latency of buffer, in packets (-1 if you don't care) */ X- __s32 irq_interval; X+ int32_t irq_interval; X }; X X@@ -166,14 +166,14 @@ X /* number of packets waiting to be filled with data (ISO transmission) X or containing data received (ISO reception) */ X- __u32 n_packets; X+ uint32_t n_packets; X X /* approximate number of packets dropped due to overflow or X underflow of the packet buffer (a value of zero guarantees X that no packets have been dropped) */ X- __u32 overflows; X+ uint32_t overflows; X X /* cycle number at which next packet will be transmitted; X -1 if not known */ X- __s16 xmit_cycle; X+ int16_t xmit_cycle; X }; X X--- src/raw1394_private.h Wed Feb 16 10:49:49 2005 X+++ src/raw1394_private.h Mon Oct 9 13:44:29 2006 X@@ -57,11 +57,6 @@ X #define CLEAR_REQ(reqp) memset((reqp), 0, sizeof(struct raw1394_request)) X X-#if SIZEOF_VOID_P == 4 X-#define int2ptr(x) ((void *)(__u32)x) X-#define ptr2int(x) ((__u64)(__u32)x) X-#else X-#define int2ptr(x) ((void *)x) X-#define ptr2int(x) ((__u64)x) X-#endif X+#define int2ptr(x) ((void *)(uintptr_t)x) X+#define ptr2int(x) ((uintptr_t)x) X X #endif /* _RAW1394_PRIVATE_H */ X--- src/readwrite.c Wed Nov 10 18:39:00 2004 X+++ src/readwrite.c Mon Oct 9 14:01:28 2006 X@@ -44,5 +44,5 @@ X req.tag = tag; X X- req.address = ((__u64)node << 48) | addr; X+ req.address = ((uint64_t)node << 48) | addr; X req.length = length; X req.recvb = ptr2int(buffer); X@@ -64,5 +64,5 @@ X req.tag = tag; X X- req.address = ((__u64)node << 48) | addr; X+ req.address = ((uint64_t)node << 48) | addr; X req.length = length; X req.sendb = ptr2int(data); X@@ -90,5 +90,5 @@ X req.tag = tag; X X- req.address = ((__u64)node << 48) | addr; X+ req.address = ((uint64_t)node << 48) | addr; X req.sendb = ptr2int(sendbuf); X req.recvb = ptr2int(result); X@@ -128,5 +128,5 @@ X req.tag = tag; X X- req.address = ((__u64)node << 48) | addr; X+ req.address = ((uint64_t)node << 48) | addr; X req.sendb = ptr2int(sendbuf); X req.recvb = ptr2int(result); X@@ -163,5 +163,5 @@ X req.tag = rawtag; X X- req.address = ((__u64)channel << 48) | speed; X+ req.address = ((uint64_t)channel << 48) | speed; X req.misc = (tag << 16) | sy; X req.length = length; X@@ -185,5 +185,5 @@ X req.tag = rawtag; X X- req.address = ((__u64)channel << 48) | speed; X+ req.address = ((uint64_t)channel << 48) | speed; X req.misc = (tag << 16) | sy; X req.length = length; END-of-libraw1394/files/patch-types echo x - libraw1394/files/patch-eventloop sed 's/^X//' >libraw1394/files/patch-eventloop << 'END-of-libraw1394/files/patch-eventloop' X--- src/eventloop.c Sat Apr 8 22:29:54 2006 X+++ src/eventloop.c Mon Oct 9 13:54:59 2006 X@@ -21,5 +21,4 @@ X #include <config.h> X #include <unistd.h> X-#include <byteswap.h> X X #include "raw1394.h" END-of-libraw1394/files/patch-eventloop echo x - libraw1394/files/patch-errors sed 's/^X//' >libraw1394/files/patch-errors << 'END-of-libraw1394/files/patch-errors' X--- src/errors.c Wed Nov 10 18:53:05 2004 X+++ src/errors.c Mon Oct 9 14:00:19 2006 X@@ -39,5 +39,9 @@ X 0xdead, X 0xdead, X+#ifdef EREMOTEIO X EREMOTEIO, /* ack_data_error */ X+#else X+ EIO, X+#endif X EPERM, /* ack_type_error */ X 0xdead /* invalid ack code */ X@@ -49,5 +53,9 @@ X 0xdead, X EAGAIN, /* rcode_conflict_error */ X+#ifdef EREMOTEIO X EREMOTEIO, /* rcode_data_error */ X+#else X+ EIO, X+#endif X EPERM, /* rcode_type_error */ X EINVAL, /* rcode_address_error */ END-of-libraw1394/files/patch-errors echo x - libraw1394/files/patch-iso sed 's/^X//' >libraw1394/files/patch-iso << 'END-of-libraw1394/files/patch-iso' X--- src/iso.c Sat Apr 8 22:02:31 2006 X+++ src/iso.c Mon Oct 9 14:17:43 2006 X@@ -17,5 +17,5 @@ X #include <sys/ioctl.h> X #include <sys/mman.h> X-#include <malloc.h> X+#include <stdlib.h> X X #include "raw1394.h" END-of-libraw1394/files/patch-iso exit --Boundary-00=_wVpKF5iDZ2oZDyt--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200610091431.12698>