summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar abombe 1999-12-02 23:07:38 +0000
committerGravatar abombe 1999-12-02 23:07:38 +0000
commit0f5ef10baaba0890f7e9bed6545e0614b65e7884 (patch)
tree115fc38dea3113e5937f33fba540764e0802c80b /src
Initial revision
git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@1 53a565d1-3bb7-0310-b661-cf11e63c67ab
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am20
-rw-r--r--src/csr.h23
-rw-r--r--src/eventloop.c81
-rw-r--r--src/kernel-raw1394.h102
-rw-r--r--src/main.c179
-rw-r--r--src/raw1394.h132
-rw-r--r--src/raw1394_private.h23
-rw-r--r--src/readwrite.c96
-rw-r--r--src/testlibraw.c119
9 files changed, 775 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..4905126
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,20 @@
+
+# the libraw1394 itself
+
+lib_LTLIBRARIES = libraw1394.la
+
+libraw1394_la_LDFLAGS = -version-info 0:0:0
+
+libraw1394_la_SOURCES = \
+ main.c \
+ eventloop.c \
+ readwrite.c \
+ kernel-raw1394.h \
+ raw1394_private.h
+
+# headers to be installed
+pkginclude_HEADERS = raw1394.h csr.h
+
+# testlibraw
+noinst_PROGRAMS = testlibraw
+testlibraw_LDADD = libraw1394.la
diff --git a/src/csr.h b/src/csr.h
new file mode 100644
index 0000000..13f7c13
--- /dev/null
+++ b/src/csr.h
@@ -0,0 +1,23 @@
+
+#define CSR_REGISTER_BASE 0xfffff0000000ULL
+
+/* register offsets relative to CSR_REGISTER_BASE */
+#define CSR_STATE_CLEAR 0x0
+#define CSR_STATE_SET 0x4
+#define CSR_NODE_IDS 0x8
+#define CSR_RESET_START 0xc
+#define CSR_SPLIT_TIMEOUT_HI 0x18
+#define CSR_SPLIT_TIMEOUT_LO 0x1c
+#define CSR_CYCLE_TIME 0x200
+#define CSR_BUS_TIME 0x204
+#define CSR_BUSY_TIMEOUT 0x210
+#define CSR_BUS_MANAGER_ID 0x21c
+#define CSR_BANDWIDTH_AVAILABLE 0x220
+#define CSR_CHANNELS_AVAILABLE_HI 0x224
+#define CSR_CHANNELS_AVAILABLE_LO 0x228
+#define CSR_CONFIG_ROM 0x400
+#define CSR_CONFIG_ROM_END 0x800
+#define CSR_TOPOLOGY_MAP 0x1000
+#define CSR_TOPOLOGY_MAP_END 0x1400
+#define CSR_SPEED_MAP 0x2000
+#define CSR_SPEED_MAP_END 0x3000
diff --git a/src/eventloop.c b/src/eventloop.c
new file mode 100644
index 0000000..32b053c
--- /dev/null
+++ b/src/eventloop.c
@@ -0,0 +1,81 @@
+
+#include <unistd.h>
+
+#include "raw1394.h"
+#include "kernel-raw1394.h"
+#include "raw1394_private.h"
+
+
+int raw1394_loop_iterate(struct raw1394_handle *handle)
+{
+ struct raw1394_request *req = &handle->req;
+ int retval = 0;
+
+ if (read(handle->fd, req, sizeof(*req)) < 0) {
+ return -1;
+ }
+
+ switch (req->type) {
+ case RAW1394_REQ_BUS_RESET:
+ handle->generation = req->generation;
+ handle->num_of_nodes = req->misc & 0xffff;
+ handle->local_id = req->misc >> 16;
+
+ if (handle->bus_reset_handler) {
+ retval = handle->bus_reset_handler(handle);
+ }
+ break;
+
+ case RAW1394_REQ_ISO_RECEIVE:
+ if (handle->iso_handler) {
+ retval = handle->iso_handler(handle,
+ (handle->buffer[0] >> 8)
+ & 0x3f, req->length,
+ handle->buffer);
+ }
+ break;
+
+ default:
+ if (handle->tag_handler) {
+ retval = handle->tag_handler(handle, req->tag,
+ req->error);
+ }
+ break;
+ }
+
+ return retval;
+}
+
+
+bus_reset_handler_t raw1394_set_bus_reset_handler(struct raw1394_handle *handle,
+ bus_reset_handler_t new)
+{
+ bus_reset_handler_t old;
+
+ old = handle->bus_reset_handler;
+ handle->bus_reset_handler = new;
+
+ return old;
+}
+
+tag_handler_t raw1394_set_tag_handler(struct raw1394_handle *handle,
+ tag_handler_t new)
+{
+ tag_handler_t old;
+
+ old = handle->tag_handler;
+ handle->tag_handler = new;
+
+ return old;
+}
+
+iso_handler_t raw1394_set_iso_handler(struct raw1394_handle *handle,
+ iso_handler_t new)
+{
+ iso_handler_t old;
+
+ old = handle->iso_handler;
+ handle->iso_handler = new;
+
+ return old;
+}
diff --git a/src/kernel-raw1394.h b/src/kernel-raw1394.h
new file mode 100644
index 0000000..fe8ea72
--- /dev/null
+++ b/src/kernel-raw1394.h
@@ -0,0 +1,102 @@
+
+#ifndef IEEE1394_RAW1394_H
+#define IEEE1394_RAW1394_H
+
+#define RAW1394_DEVICE_MAJOR 171
+#define RAW1394_DEVICE_NAME "raw1394"
+
+#define RAW1394_KERNELAPI_VERSION 1
+
+/* state: opened */
+#define RAW1394_REQ_INITIALIZE 1
+
+/* state: initialized */
+#define RAW1394_REQ_LIST_CARDS 2
+#define RAW1394_REQ_SET_CARD 3
+
+/* state: connected */
+#define RAW1394_REQ_ASYNC_READ 100
+#define RAW1394_REQ_ASYNC_WRITE 101
+#define RAW1394_REQ_LOCK 102
+#define RAW1394_REQ_LOCK64 103
+
+#define RAW1394_REQ_ISO_LISTEN 200
+
+/* kernel to user */
+#define RAW1394_REQ_BUS_RESET 10000
+#define RAW1394_REQ_ISO_RECEIVE 10001
+
+/* error codes */
+#define RAW1394_ERROR_NONE 0
+#define RAW1394_ERROR_COMPAT (-1001)
+#define RAW1394_ERROR_STATE_ORDER (-1002)
+#define RAW1394_ERROR_GENERATION (-1003)
+#define RAW1394_ERROR_INVALID_ARG (-1004)
+#define RAW1394_ERROR_MEMFAULT (-1005)
+#define RAW1394_ERROR_ALREADY (-1006)
+
+#define RAW1394_ERROR_EXCESSIVE (-1020)
+#define RAW1394_ERROR_UNTIDY_LEN (-1021)
+
+#define RAW1394_ERROR_SEND_ERROR (-1100)
+#define RAW1394_ERROR_ABORTED (-1101)
+#define RAW1394_ERROR_TIMEOUT (-1102)
+
+
+struct raw1394_request {
+ int type;
+ int error;
+ int misc;
+
+ unsigned int generation;
+ octlet_t address;
+
+ unsigned long tag;
+
+ size_t length;
+ quadlet_t *sendb;
+ quadlet_t *recvb;
+};
+
+struct raw1394_khost_list {
+ int nodes;
+ char name[32];
+};
+
+#ifdef __KERNEL__
+
+struct file_info {
+ struct list_head list;
+
+ enum { opened, initialized, connected } state;
+
+ struct hpsb_host *host;
+
+ struct list_head req_pending;
+ struct list_head req_complete;
+ struct semaphore complete_sem;
+ spinlock_t reqlists_lock;
+ wait_queue_head_t poll_wait_complete;
+
+ u64 listen_channels;
+};
+
+struct pending_request {
+ struct list_head list;
+ struct file_info *file_info;
+ struct hpsb_packet *packet;
+ struct tq_struct tq;
+ quadlet_t *data;
+ int free_data;
+ struct raw1394_request req;
+};
+
+struct host_info {
+ struct list_head list;
+ struct hpsb_host *host;
+ struct list_head file_info_list;
+};
+
+#endif /* __KERNEL__ */
+
+#endif /* IEEE1394_RAW1394_H */
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..7cc8fe1
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,179 @@
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+
+#include "raw1394.h"
+#include "kernel-raw1394.h"
+#include "raw1394_private.h"
+
+
+static int bus_reset_default(struct raw1394_handle *handle)
+{
+ return 0;
+}
+
+static int tag_handler_default(struct raw1394_handle *handle, unsigned long tag,
+ int error)
+{
+ struct raw1394_reqhandle *rh;
+
+ if (tag) {
+ rh = (struct raw1394_reqhandle *)tag;
+ return rh->callback(handle, rh->data, error);
+ } else {
+ return -1;
+ }
+}
+
+static int iso_handler_default(struct raw1394_handle *handle, int channel,
+ size_t length, quadlet_t *data)
+{
+ return 0;
+}
+
+
+static unsigned int init_rawdevice(struct raw1394_handle *h)
+{
+ struct raw1394_request *req = &h->req;
+
+ CLEAR_REQ(req);
+ req->type = RAW1394_REQ_INITIALIZE;
+ req->misc = RAW1394_KERNELAPI_VERSION;
+
+ if (write(h->fd, req, sizeof(*req)) < 0) return -1;
+ if (read(h->fd, req, sizeof(*req)) < 0) return -1;
+ if (req->error) {
+ errno = 0;
+ return -1;
+ }
+
+ return req->generation;
+}
+
+
+struct raw1394_handle *raw1394_get_handle(void)
+{
+ struct raw1394_handle *handle;
+
+ handle = malloc(sizeof(struct raw1394_handle));
+ if (!handle) {
+ errno = ENOMEM;
+ return NULL;
+ }
+
+ handle->fd = open("/dev/raw1394", O_RDWR);
+ if (handle->fd < 0) {
+ free(handle);
+ return NULL;
+ }
+
+ handle->generation = init_rawdevice(handle);
+ if (handle->generation < 0) {
+ close(handle->fd);
+ free(handle);
+ return NULL;
+ }
+
+ handle->bus_reset_handler = bus_reset_default;
+ handle->tag_handler = tag_handler_default;
+ handle->iso_handler = iso_handler_default;
+ return handle;
+}
+
+void raw1394_destroy_handle(struct raw1394_handle *handle)
+{
+ if (handle) {
+ close(handle->fd);
+ free(handle);
+ }
+}
+
+int raw1394_get_fd(struct raw1394_handle *handle)
+{
+ return handle->fd;
+}
+
+unsigned int raw1394_get_generation(struct raw1394_handle *handle)
+{
+ return handle->generation;
+}
+
+int raw1394_get_nodecount(struct raw1394_handle *handle)
+{
+ return handle->num_of_nodes;
+}
+
+nodeid_t raw1394_get_local_id(struct raw1394_handle *handle)
+{
+ return handle->local_id;
+}
+
+
+int raw1394_get_port_info(struct raw1394_handle *handle,
+ struct raw1394_portinfo *pinf, int maxports)
+{
+ int num;
+ struct raw1394_request *req = &handle->req;
+ struct raw1394_khost_list *khl;
+
+ CLEAR_REQ(req);
+ req->type = RAW1394_REQ_LIST_CARDS;
+ req->generation = handle->generation;
+ req->recvb = handle->buffer;
+ req->length = HBUF_SIZE;
+
+ while (1) {
+ if (write(handle->fd, req, sizeof(*req)) < 0) return -1;
+ if (read(handle->fd, req, sizeof(*req)) < 0) return -1;
+
+ if (!req->error) break;
+
+ if (req->error == RAW1394_ERROR_GENERATION) {
+ handle->generation = req->generation;
+ continue;
+ }
+
+ return -1;
+ }
+
+ for (num = req->misc, khl = (struct raw1394_khost_list *)handle->buffer;
+ num && maxports; num--, maxports--, pinf++, khl++) {
+ pinf->nodes = khl->nodes;
+ strcpy(pinf->name, khl->name);
+ }
+
+ return req->misc;
+}
+
+int raw1394_set_port(struct raw1394_handle *handle, int port)
+{
+ struct raw1394_request *req = &handle->req;
+
+ CLEAR_REQ(req);
+
+ req->type = RAW1394_REQ_SET_CARD;
+ req->generation = handle->generation;
+ req->misc = port;
+
+ if (write(handle->fd, req, sizeof(*req)) < 0) return -1;
+ if (read(handle->fd, req, sizeof(*req)) < 0) return -1;
+
+ switch (req->error) {
+ case RAW1394_ERROR_GENERATION:
+ handle->generation = req->generation;
+ errno = ESTALE;
+ return -1;
+ case RAW1394_ERROR_INVALID_ARG:
+ errno = EINVAL;
+ return -1;
+ case RAW1394_ERROR_NONE:
+ handle->num_of_nodes = req->misc & 0xffff;
+ handle->local_id = req->misc >> 16;
+ return 0;
+ default:
+ errno = 0;
+ return -1;
+ }
+}
diff --git a/src/raw1394.h b/src/raw1394.h
new file mode 100644
index 0000000..de9dcb7
--- /dev/null
+++ b/src/raw1394.h
@@ -0,0 +1,132 @@
+
+#ifndef _LIBRAW1394_RAW1394_H
+#define _LIBRAW1394_RAW1394_H
+
+#include <sys/types.h>
+typedef u_int32_t quadlet_t;
+typedef u_int64_t octlet_t;
+typedef u_int64_t nodeaddr_t;
+typedef u_int16_t nodeid_t;
+
+
+typedef struct raw1394_handle *raw1394handle_t;
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Required as initialization. One handle can control one port, it is possible
+ * to use multiple handles. raw1394_get_handle returns NULL for failure,
+ * raw1394_destroy_handle accepts NULL. If raw1394_get_handle returns NULL and
+ * errno is 0, this version of libraw1394 is incompatible with the kernel.
+ */
+raw1394handle_t raw1394_get_handle(void);
+void raw1394_destroy_handle(raw1394handle_t handle);
+
+/*
+ * Get the fd of this handle to select()/poll() on it. Don't try to mess around
+ * with it any other way. Valid only after the handle got attached to a port.
+ */
+int raw1394_get_fd(raw1394handle_t handle);
+
+unsigned int raw1394_get_generation(raw1394handle_t handle);
+nodeid_t raw1394_get_local_id(raw1394handle_t handle);
+
+/* Get number of nodes on bus. */
+int raw1394_get_nodecount(raw1394handle_t handle);
+
+/*
+ * Returns number of available ports (port == one IEEE 1394 card or onboard
+ * chip). A maximum number of maxport raw1394_portinfos will be filled out at
+ * *pinf, zero is valid if you're only interested in the number of ports (which
+ * is returned).
+ */
+struct raw1394_portinfo {
+ int nodes;
+ char name[32];
+};
+
+int raw1394_get_port_info(raw1394handle_t handle, struct raw1394_portinfo *pinf,
+ int maxports);
+
+/*
+ * Attach handle to port (counted from zero). Returns zero for success or -1
+ * for failure. If in the case of failure errno is set to ESTALE the generation
+ * number has changed and you should reget the port info.
+ */
+int raw1394_set_port(raw1394handle_t handle, int port);
+
+
+/*
+ * Get one new message through handle and process it. See below for handler
+ * registering functions. This function will return -1 for an error or the
+ * return value of the handler which got executed. Default handlers always
+ * return zero.
+ */
+int raw1394_loop_iterate(raw1394handle_t handle);
+
+/*
+ * Set the handler that will be called when a bus reset message is encountered.
+ * The default action is to do nothing. Returns old handler.
+ */
+typedef int (*bus_reset_handler_t)(raw1394handle_t);
+bus_reset_handler_t raw1394_set_bus_reset_handler(raw1394handle_t handle,
+ bus_reset_handler_t new);
+
+/*
+ * Set the handler that will be called when an async read/write/lock returns.
+ * The default action is to call the callback in the raw1394_reqhandle pointed
+ * to by tag. Returns old handler.
+ */
+typedef int (*tag_handler_t)(raw1394handle_t, unsigned long tag, int errcode);
+tag_handler_t raw1394_set_tag_handler(raw1394handle_t handle,
+ tag_handler_t new);
+
+/*
+ * Set the handler that will be called when an iso packet arrives (data points
+ * to the iso packet header). The default action is to do nothing. Returns old
+ * handler.
+ *
+ * Iso receive is not implemented yet.
+ */
+typedef int (*iso_handler_t)(raw1394handle_t, int channel, size_t length,
+ quadlet_t *data);
+iso_handler_t raw1394_set_iso_handler(raw1394handle_t handle,
+ iso_handler_t new);
+
+
+/*
+ * This is the general request handle. It is used by the default tag handler
+ * when a request completes, it calls the callback and passes it the data
+ * pointer and the error code of the request.
+ */
+typedef int (*req_callback_t)(raw1394handle_t, void *data, int errcode);
+struct raw1394_reqhandle {
+ req_callback_t callback;
+ void *data;
+};
+
+/*
+ * Passes custom tag. Use pointer to raw1394_reqhandle if you use the standard
+ * tag handler.
+ */
+int raw1394_start_read(struct raw1394_handle *handle, nodeid_t node,
+ nodeaddr_t addr, size_t length, quadlet_t *buffer,
+ unsigned long tag);
+
+/*
+ * This does the complete transaction and will return when it's finished. It
+ * will call raw1394_loop_iterate() as often as necessary, return values of
+ * handlers called will be lost.
+ */
+int raw1394_read(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr,
+ size_t length, quadlet_t *buffer);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LIBRAW1394_RAW1394_H */
diff --git a/src/raw1394_private.h b/src/raw1394_private.h
new file mode 100644
index 0000000..06c2746
--- /dev/null
+++ b/src/raw1394_private.h
@@ -0,0 +1,23 @@
+
+#ifndef _RAW1394_PRIVATE_H
+#define _RAW1394_PRIVATE_H
+
+struct raw1394_handle {
+ int fd;
+ unsigned int generation;
+
+ nodeid_t local_id;
+ int num_of_nodes;
+
+ bus_reset_handler_t bus_reset_handler;
+ tag_handler_t tag_handler;
+ iso_handler_t iso_handler;
+
+ struct raw1394_request req;
+ quadlet_t buffer[2048];
+};
+
+#define HBUF_SIZE 8192
+#define CLEAR_REQ(reqp) memset((reqp), 0, sizeof(struct raw1394_request))
+
+#endif /* _RAW1394_PRIVATE_H */
diff --git a/src/readwrite.c b/src/readwrite.c
new file mode 100644
index 0000000..37e9f71
--- /dev/null
+++ b/src/readwrite.c
@@ -0,0 +1,96 @@
+
+#include <unistd.h>
+
+#include "raw1394.h"
+#include "kernel-raw1394.h"
+#include "raw1394_private.h"
+
+
+struct sync_cb_data {
+ int done;
+ int errcode;
+};
+
+static int sync_cb(struct raw1394_handle *unused,
+ struct sync_cb_data *data, int error)
+{
+ data->errcode = error;
+ data->done = 1;
+ return 0;
+}
+
+
+int raw1394_start_read(struct raw1394_handle *handle, nodeid_t node,
+ nodeaddr_t addr, size_t length, quadlet_t *buffer,
+ unsigned long tag)
+{
+ struct raw1394_request *req = &handle->req;
+
+ CLEAR_REQ(req);
+
+ req->type = RAW1394_REQ_ASYNC_READ;
+ req->generation = handle->generation;
+ req->tag = tag;
+
+ req->address = ((u_int64_t)node << 48) | addr;
+ req->length = length;
+ req->recvb = buffer;
+
+ return (int)write(handle->fd, req, sizeof(*req));
+}
+
+int raw1394_start_write(struct raw1394_handle *handle, nodeid_t node,
+ nodeaddr_t addr, size_t length, quadlet_t *data,
+ unsigned long tag)
+{
+ struct raw1394_request *req = &handle->req;
+
+ CLEAR_REQ(req);
+
+ req->type = RAW1394_REQ_ASYNC_WRITE;
+ req->generation = handle->generation;
+ req->tag = tag;
+
+ req->address = ((u_int64_t)node << 48) | addr;
+ req->length = length;
+ req->sendb = data;
+
+ return (int)write(handle->fd, req, sizeof(*req));
+}
+
+
+
+#define SYNCFUNC_VARS \
+ struct sync_cb_data sd = { 0, 0 }; \
+ struct raw1394_reqhandle rh = { (req_callback_t)sync_cb, &sd }; \
+ int err
+
+#define SYNCFUNC_BODY \
+ if (err < 0) return err; \
+ while (!sd.done) raw1394_loop_iterate(handle); \
+ return sd.errcode
+
+int raw1394_read(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr,
+ size_t length, quadlet_t *buffer)
+{
+ SYNCFUNC_VARS;
+
+ err = raw1394_start_read(handle, node, addr, length, buffer,
+ (unsigned long)&rh);
+
+ SYNCFUNC_BODY;
+}
+
+int raw1394_write(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr,
+ size_t length, quadlet_t *data)
+{
+ SYNCFUNC_VARS;
+
+ err = raw1394_start_write(handle, node, addr, length, data,
+ (unsigned long)&rh);
+
+ SYNCFUNC_BODY;
+}
+
+#undef SYNCFUNC_VARS
+#undef SYNCFUNC_BODY
diff --git a/src/testlibraw.c b/src/testlibraw.c
new file mode 100644
index 0000000..59f0ada
--- /dev/null
+++ b/src/testlibraw.c
@@ -0,0 +1,119 @@
+
+#include <stdio.h>
+#include <errno.h>
+
+#include "raw1394.h"
+#include "csr.h"
+
+
+#define TESTADDR (CSR_REGISTER_BASE + CSR_CYCLE_TIME)
+
+const char not_compatible[] = "\
+This libraw1394 does not work with your version of Linux. You need a different
+version that matches your kernel (see kernel help text for the raw1394 option to
+find out which is the correct version).\n";
+
+const char not_loaded[] = "\
+This probably means that you don't have raw1394 support in the kernel or that
+you haven't loaded the raw1394 module.\n";
+
+
+quadlet_t buffer;
+
+int my_tag_handler(struct raw1394_handle *handle, unsigned long tag, int error)
+{
+ if (error < 0) {
+ printf("completed with error %d\n", error);
+ } else {
+ printf("completed with 0x%08x, value 0x%08x\n", error, buffer);
+ }
+
+ return 0;
+}
+
+
+
+int main(int argc, char **argv)
+{
+ raw1394handle_t handle;
+ int i, numcards;
+ struct raw1394_portinfo pinf[16];
+
+ tag_handler_t std_handler;
+ int retval;
+
+
+ handle = raw1394_get_handle();
+
+ if (!handle) {
+ if (!errno) {
+ printf(not_compatible);
+ } else {
+ perror("couldn't get handle");
+ printf(not_loaded);
+ }
+ exit(1);
+ }
+
+ printf("successfully got handle\n");
+ printf("current generation number: %d\n", raw1394_get_generation(handle));
+
+ numcards = raw1394_get_port_info(handle, pinf, 16);
+ if (numcards < 0) {
+ perror("couldn't get card info");
+ exit(1);
+ } else {
+ printf("%d card(s) found\n", numcards);
+ }
+
+ if (!numcards) {
+ exit(0);
+ }
+
+ for (i = 0; i < numcards; i++) {
+ printf(" nodes on bus: %2d, card name: %s\n", pinf[i].nodes,
+ pinf[i].name);
+ }
+
+ if (raw1394_set_port(handle, 0) < 0) {
+ perror("couldn't set port");
+ exit(1);
+ }
+
+ printf("using first card found: %d nodes on bus, local ID is %d\n",
+ raw1394_get_nodecount(handle),
+ raw1394_get_local_id(handle) & 0x3f);
+
+ printf("\ndoing transactions with custom tag handler\n");
+ std_handler = raw1394_set_tag_handler(handle, my_tag_handler);
+ for (i = 0; i < pinf[0].nodes; i++) {
+ printf("trying to send read request to node %d... ", i);
+ fflush(stdout);
+ buffer = 0;
+
+ if (raw1394_start_read(handle, 0xffc0 | i, TESTADDR, 4,
+ &buffer, 0) < 0) {
+ perror("failed");
+ continue;
+ }
+ raw1394_loop_iterate(handle);
+ }
+
+ printf("\nusing standard tag handler and synchronous calls\n");
+ raw1394_set_tag_handler(handle, std_handler);
+ for (i = 0; i < pinf[0].nodes; i++) {
+ printf("trying to read from node %d... ", i);
+ fflush(stdout);
+ buffer = 0;
+
+ retval = raw1394_read(handle, 0xffc0 | i, TESTADDR, 4, &buffer);
+ if (retval < 0) {
+ printf("failed with error %d\n", retval);
+ } else {
+ printf("completed with 0x%08x, value 0x%08x\n", retval,
+ buffer);
+ }
+ }
+
+ exit(0);
+}