From f3c9af36c29428caa872fa67f20c958d52a5fb21 Mon Sep 17 00:00:00 2001 From: "B.J. Buchalter" Date: Thu, 24 Mar 2011 03:14:27 -0400 Subject: [PATCH] Add raw1394_add_config_rom_descriptor() and raw1394_remove_config_rom_descriptor() API This adds support of the firewire-core (juju) ABI to add and remove config ROM directories or descriptors. The raw1394 ABI supports similar requests, but for now we leave the two functions unimplemented when running on top of raw1394. Signed-off-by: Benjamin Buchalter Signed-off-by: Stefan Richter (whitespace changes) --- src/dispatch.c | 34 ++++++++++++++++++++++++++++++++++ src/fw.c | 35 +++++++++++++++++++++++++++++++++++ src/fw.h | 7 +++++++ src/raw1394.h | 9 +++++++++ 4 files changed, 85 insertions(+) diff --git a/src/dispatch.c b/src/dispatch.c index 72a45a4..1cc8e6a 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -519,6 +519,40 @@ int raw1394_update_config_rom(raw1394handle_t handle, const quadlet_t new_rom, size, rom_version); } +int raw1394_add_config_rom_descriptor(raw1394handle_t handle, + const quadlet_t immediate_key, + const quadlet_t key, + const quadlet_t *new_rom_directory, + size_t size, + __u32 *out_token) +{ + if (!handle) { + errno = EINVAL; + return -1; + } + if (handle->is_fw) + return fw_add_config_rom_descriptor(handle->mode.fw, + immediate_key, key, new_rom_directory, size, out_token); + else { + errno = EINVAL; + return -1; + } +} + +int raw1394_remove_config_rom_descriptor(raw1394handle_t handle, __u32 token) +{ + if (!handle) { + errno = EINVAL; + return -1; + } + if (handle->is_fw) + return fw_remove_config_rom_descriptor(handle->mode.fw, token); + else { + errno = EINVAL; + return -1; + } +} + int raw1394_get_config_rom(raw1394handle_t handle, quadlet_t *buffer, size_t buffersize, size_t *rom_size, unsigned char *rom_version) { diff --git a/src/fw.c b/src/fw.c index 6fae12d..da275c5 100644 --- a/src/fw.c +++ b/src/fw.c @@ -1542,6 +1542,41 @@ fw_update_config_rom(fw_handle_t handle, const quadlet_t *new_rom, return -1; } +int +fw_add_config_rom_descriptor(fw_handle_t handle, + const quadlet_t immediate_key, + const quadlet_t key, + const quadlet_t *new_rom_directory, + size_t size, + __u32 *out_token) +{ + struct fw_cdev_add_descriptor request; + int retval; + + request.immediate = immediate_key; + request.key = key; + request.data = ptr_to_u64(new_rom_directory); + request.length = size; + request.handle = 0; + + retval = ioctl(handle->local_device->fd, FW_CDEV_IOC_ADD_DESCRIPTOR, + &request); + if (retval < 0) + return -1; + + *out_token = request.handle; + return 0; +} + +int +fw_remove_config_rom_descriptor(fw_handle_t handle, __u32 token) +{ + struct fw_cdev_remove_descriptor request = {token}; + + return ioctl(handle->local_device->fd, FW_CDEV_IOC_REMOVE_DESCRIPTOR, + &request); +} + int fw_get_config_rom(fw_handle_t handle, quadlet_t *buffer, size_t buffersize, size_t *rom_size, diff --git a/src/fw.h b/src/fw.h index c8481c2..e64b2f3 100644 --- a/src/fw.h +++ b/src/fw.h @@ -202,6 +202,13 @@ int fw_start_fcp_listen(fw_handle_t handle); int fw_stop_fcp_listen(fw_handle_t handle); int fw_update_config_rom(fw_handle_t handle, const quadlet_t *new_rom, size_t size, unsigned char rom_version); +int fw_add_config_rom_descriptor(fw_handle_t handle, + const quadlet_t immediate_key, + const quadlet_t key, + const quadlet_t *new_rom_directory, + size_t size, + __u32 *out_token); +int fw_remove_config_rom_descriptor(fw_handle_t handle, __u32 token); int fw_get_config_rom(fw_handle_t handle, quadlet_t *buffer, size_t buffersize, size_t *rom_size, unsigned char *rom_version); diff --git a/src/raw1394.h b/src/raw1394.h index 762276f..7239de3 100644 --- a/src/raw1394.h +++ b/src/raw1394.h @@ -1165,6 +1165,15 @@ const char *raw1394_get_libversion(void); int raw1394_update_config_rom(raw1394handle_t handle, const quadlet_t *new_rom, size_t size, unsigned char rom_version); +int raw1394_add_config_rom_descriptor(raw1394handle_t handle, + const quadlet_t immediate_key, + const quadlet_t key, + const quadlet_t *new_rom_directory, + size_t size, + u_int32_t *out_token); + +int raw1394_remove_config_rom_descriptor(raw1394handle_t handle, + u_int32_t token); /** * raw1394_get_config_rom - reads the current version of the configuration ROM of a host