libforensic1394  0.2.0
forensic1394.h
Go to the documentation of this file.
1 /*
2  This file is part of libforensic1394.
3  Copyright (C) 2010 Freddie Witherden <freddie@witherden.org>
4 
5  libforensic1394 is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as
7  published by the Free Software Foundation, either version 3 of the
8  License, or (at your option) any later version.
9 
10  libforensic1394 is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with libforensic1394. If not, see
17  <http://www.gnu.org/licenses/>.
18 */
19 
120 #ifndef _FORENSIC_1394_H
121 #define _FORENSIC_1394_H
122 
123 #ifdef __cplusplus
124 extern "C"
125 {
126 #endif
127 
128 #if defined(FORENSIC1394_DECL)
129  // No op
130 #elif defined(_MSC_VER)
131 # define FORENSIC1394_DECL __declspec(dllexport)
132 #elif (__GNUC__ >= 3)
133 # define FORENSIC1394_DECL __attribute__((visibility("default")))
134 #else
135 # define FORENSIC1394_DECL
136 #endif
137 
138 #include <stdlib.h>
139 #include <stdint.h>
140 
142 typedef struct _forensic1394_bus forensic1394_bus;
143 
145 typedef struct _forensic1394_dev forensic1394_dev;
146 
157 typedef struct _forensic1394_req
158 {
160  uint64_t addr;
161 
163  size_t len;
164 
166  void *buf;
168 
175 #define FORENSIC1394_CSR_SZ 256
176 
195  forensic1394_dev *dev);
196 
207 typedef enum
208 {
228 
238 
257 
292  int *ndev,
293  forensic1394_device_callback ondestroy);
294 
306 
318 FORENSIC1394_DECL void *
320 
331 
344 
354 
363 
389  uint64_t addr,
390  size_t len,
391  void *buf);
392 
415  forensic1394_req *req,
416  size_t nreq);
417 
438  uint64_t addr,
439  size_t len,
440  void *buf);
441 
456  const forensic1394_req *req,
457  size_t nreq);
458 
471  uint32_t *rom);
472 
482 FORENSIC1394_DECL uint16_t
484 
494 FORENSIC1394_DECL int64_t
496 
507 FORENSIC1394_DECL const char *
509 
520 
531 FORENSIC1394_DECL const char *
533 
544 
560 
572 FORENSIC1394_DECL void *
574 
585 
597 FORENSIC1394_DECL const char *
599 
600 #ifdef __cplusplus
601 }
602 #endif
603 
604 #endif // _FORENSIC_1394_H
FORENSIC1394_DECL int64_t forensic1394_get_device_guid(forensic1394_dev *dev)
Returns the GUID of the device.
FORENSIC1394_DECL forensic1394_result forensic1394_enable_sbp2(forensic1394_bus *bus)
Provides an SBP-2 unit directory; required for DMA to Windows systems.
FORENSIC1394_DECL uint16_t forensic1394_get_device_nodeid(forensic1394_dev *dev)
Returns the node ID of the device.
Bad transfer size (normally too large)
Definition: forensic1394.h:222
FORENSIC1394_DECL forensic1394_bus * forensic1394_alloc(void)
Allocates a new forensic1394 handle.
FORENSIC1394_DECL void forensic1394_destroy(forensic1394_bus *bus)
Destroys a bus handle.
FORENSIC1394_DECL void forensic1394_get_device_csr(forensic1394_dev *dev, uint32_t *rom)
Copies the configuration ROM for the device dev into rom.
forensic1394_result
Possible return status codes.
Definition: forensic1394.h:207
#define FORENSIC1394_DECL
Definition: forensic1394.h:135
FORENSIC1394_DECL const char * forensic1394_get_result_str(forensic1394_result r)
Converts a return status code to a string.
size_t len
Length of the buffer in bytes.
Definition: forensic1394.h:163
Sentinel; internal use only.
Definition: forensic1394.h:226
FORENSIC1394_DECL void * forensic1394_get_bus_user_data(forensic1394_bus *bus)
Fetches the user data for bus.
FORENSIC1394_DECL void * forensic1394_get_device_user_data(forensic1394_dev *dev)
Fetches the user data for the device dev.
FORENSIC1394_DECL int forensic1394_get_device_product_id(forensic1394_dev *dev)
Returns the product ID of the device, if any.
void * buf
Data buffer.
Definition: forensic1394.h:166
FORENSIC1394_DECL forensic1394_dev ** forensic1394_get_devices(forensic1394_bus *bus, int *ndev, forensic1394_device_callback ondestroy)
Gets the devices attached to the FireWire bus.
I/O Timeout.
Definition: forensic1394.h:224
FORENSIC1394_DECL forensic1394_result forensic1394_read_device(forensic1394_dev *dev, uint64_t addr, size_t len, void *buf)
Reads len bytes from dev starting at addr into buf.
FORENSIC1394_DECL const char * forensic1394_get_device_vendor_name(forensic1394_dev *dev)
Returns the vendor name of the device, if any.
FORENSIC1394_DECL const char * forensic1394_get_device_product_name(forensic1394_dev *dev)
Returns the product name of the device, if any.
void(* forensic1394_device_callback)(forensic1394_bus *bus, forensic1394_dev *dev)
Definition: forensic1394.h:194
FORENSIC1394_DECL int forensic1394_get_device_request_size(forensic1394_dev *dev)
Returns the maximum request size supported by the device.
struct _forensic1394_dev forensic1394_dev
An opaque device handle.
Definition: forensic1394.h:145
Device is busy.
Definition: forensic1394.h:218
FORENSIC1394_DECL forensic1394_result forensic1394_read_device_v(forensic1394_dev *dev, forensic1394_req *req, size_t nreq)
Reads each request specified in req from dev asynchronously.
FORENSIC1394_DECL void forensic1394_set_bus_user_data(forensic1394_bus *bus, void *u)
Sets the user data for the bus.
General, unspecified, error.
Definition: forensic1394.h:212
uint64_t addr
The address to read/write.
Definition: forensic1394.h:160
FORENSIC1394_DECL forensic1394_result forensic1394_open_device(forensic1394_dev *dev)
Opens the device dev for reading/writing.
FORENSIC1394_DECL forensic1394_result forensic1394_write_device(forensic1394_dev *dev, uint64_t addr, size_t len, void *buf)
Writes len bytes from buf to dev starting at addr.
Permissions related error.
Definition: forensic1394.h:216
FORENSIC1394_DECL int forensic1394_get_device_vendor_id(forensic1394_dev *dev)
Returns the vendor ID of the device, if any.
General I/O error.
Definition: forensic1394.h:220
A bus reset has occured.
Definition: forensic1394.h:214
FORENSIC1394_DECL forensic1394_result forensic1394_write_device_v(forensic1394_dev *dev, const forensic1394_req *req, size_t nreq)
Writes each request specified in req to dev asynchronously.
FORENSIC1394_DECL int forensic1394_is_device_open(forensic1394_dev *dev)
Checks if a device is open or not.
A request structure used for making batch read/write requests.
Definition: forensic1394.h:157
No errors encountered.
Definition: forensic1394.h:210
FORENSIC1394_DECL void forensic1394_close_device(forensic1394_dev *dev)
Closes the device dev.
struct _forensic1394_bus forensic1394_bus
An opaque bus handle.
Definition: forensic1394.h:142
FORENSIC1394_DECL void forensic1394_set_device_user_data(forensic1394_dev *dev, void *u)
Sets the user data for the device dev to u.