From c4d75933cb2a8e3fcd396ea78b869a2f2c6b4234 Mon Sep 17 00:00:00 2001 From: abombe Date: Sun, 6 Feb 2000 15:10:14 +0000 Subject: [PATCH] Added lock transaction. git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@7 53a565d1-3bb7-0310-b661-cf11e63c67ab --- src/raw1394.h | 5 +++++ src/readwrite.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/src/raw1394.h b/src/raw1394.h index 9cf4c34..57dee74 100644 --- a/src/raw1394.h +++ b/src/raw1394.h @@ -123,6 +123,9 @@ int raw1394_start_read(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, size_t length, quadlet_t *buffer, unsigned long tag); int raw1394_start_write(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, size_t length, quadlet_t *data, unsigned long tag); +int raw1394_start_lock(struct raw1394_handle *handle, nodeid_t node, + nodeaddr_t addr, unsigned int extcode, quadlet_t data, + quadlet_t arg, unsigned long tag); /* * This does the complete transaction and will return when it's finished. It @@ -133,6 +136,8 @@ int raw1394_read(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, size_t length, quadlet_t *buffer); int raw1394_write(raw1394handle_t handle, nodeid_t node, nodeaddr_t addr, size_t length, quadlet_t *data); +int raw1394_lock(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr, + unsigned int extcode, quadlet_t data, quadlet_t arg); /* * Start and stop receiving a certain isochronous channel. You have to set an diff --git a/src/readwrite.c b/src/readwrite.c index 192b0a1..9e01d39 100644 --- a/src/readwrite.c +++ b/src/readwrite.c @@ -1,5 +1,6 @@ #include +#include #include "raw1394.h" #include "kernel-raw1394.h" @@ -44,6 +45,42 @@ int raw1394_start_write(struct raw1394_handle *handle, nodeid_t node, return (int)write(handle->fd, req, sizeof(*req)); } +int raw1394_start_lock(struct raw1394_handle *handle, nodeid_t node, + nodeaddr_t addr, unsigned int extcode, quadlet_t data, + quadlet_t arg, unsigned long tag) +{ + struct raw1394_request *req = &handle->req; + quadlet_t sendbuf[2]; + + if ((extcode > 7) || (extcode == 0)) { + errno = EINVAL; + return -1; + } + + CLEAR_REQ(req); + + req->type = RAW1394_REQ_LOCK; + req->generation = handle->generation; + req->tag = tag; + + req->address = ((u_int64_t)node << 48) | addr; + req->sendb = sendbuf; + + switch (extcode) { + case 3: /* EXTCODE_FETCH_ADD */ + case 4: /* EXTCODE_LITTLE_ADD */ + sendbuf[0] = data; + req->length = 4; + break; + default: + sendbuf[0] = arg; + sendbuf[1] = data; + req->length = 8; + break; + } + + return (int)write(handle->fd, req, sizeof(*req)); +} #define SYNCFUNC_VARS \ @@ -81,5 +118,16 @@ int raw1394_write(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr, SYNCFUNC_BODY; } +int raw1394_lock(struct raw1394_handle *handle, nodeid_t node, nodeaddr_t addr, + unsigned int extcode, quadlet_t data, quadlet_t arg) +{ + SYNCFUNC_VARS; + + err = raw1394_start_lock(handle, node, addr, extcode, data, arg, + (unsigned long)&rh); + + SYNCFUNC_BODY; +} + #undef SYNCFUNC_VARS #undef SYNCFUNC_BODY