1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)]
#![allow(
    clippy::approx_constant,
    clippy::type_complexity,
    clippy::unreadable_literal,
    clippy::upper_case_acronyms
)]
#![cfg_attr(feature = "dox", feature(doc_cfg))]

#[allow(unused_imports)]
use libc::{
    c_char, c_double, c_float, c_int, c_long, c_short, c_uchar, c_uint, c_ulong, c_ushort, c_void,
    intptr_t, size_t, ssize_t, uintptr_t, FILE,
};

#[allow(unused_imports)]
use glib::{gboolean, gconstpointer, gpointer, GType};

// Enums
pub type HinawaFwFcpError = c_int;
pub const HINAWA_FW_FCP_ERROR_TIMEOUT: HinawaFwFcpError = 0;
pub const HINAWA_FW_FCP_ERROR_LARGE_RESP: HinawaFwFcpError = 1;
pub const HINAWA_FW_FCP_ERROR_ABORTED: HinawaFwFcpError = 2;

pub type HinawaFwNodeError = c_int;
pub const HINAWA_FW_NODE_ERROR_DISCONNECTED: HinawaFwNodeError = 0;
pub const HINAWA_FW_NODE_ERROR_OPENED: HinawaFwNodeError = 1;
pub const HINAWA_FW_NODE_ERROR_NOT_OPENED: HinawaFwNodeError = 2;
pub const HINAWA_FW_NODE_ERROR_FAILED: HinawaFwNodeError = 3;

pub type HinawaFwRcode = c_int;
pub const HINAWA_FW_RCODE_COMPLETE: HinawaFwRcode = 0;
pub const HINAWA_FW_RCODE_CONFLICT_ERROR: HinawaFwRcode = 4;
pub const HINAWA_FW_RCODE_DATA_ERROR: HinawaFwRcode = 5;
pub const HINAWA_FW_RCODE_TYPE_ERROR: HinawaFwRcode = 6;
pub const HINAWA_FW_RCODE_ADDRESS_ERROR: HinawaFwRcode = 7;
pub const HINAWA_FW_RCODE_SEND_ERROR: HinawaFwRcode = 16;
pub const HINAWA_FW_RCODE_CANCELLED: HinawaFwRcode = 17;
pub const HINAWA_FW_RCODE_BUSY: HinawaFwRcode = 18;
pub const HINAWA_FW_RCODE_GENERATION: HinawaFwRcode = 19;
pub const HINAWA_FW_RCODE_NO_ACK: HinawaFwRcode = 20;
pub const HINAWA_FW_RCODE_INVALID: HinawaFwRcode = 21;

pub type HinawaFwReqError = c_int;
pub const HINAWA_FW_REQ_ERROR_CONFLICT_ERROR: HinawaFwReqError = 4;
pub const HINAWA_FW_REQ_ERROR_DATA_ERROR: HinawaFwReqError = 5;
pub const HINAWA_FW_REQ_ERROR_TYPE_ERROR: HinawaFwReqError = 6;
pub const HINAWA_FW_REQ_ERROR_ADDRESS_ERROR: HinawaFwReqError = 7;
pub const HINAWA_FW_REQ_ERROR_SEND_ERROR: HinawaFwReqError = 16;
pub const HINAWA_FW_REQ_ERROR_CANCELLED: HinawaFwReqError = 17;
pub const HINAWA_FW_REQ_ERROR_BUSY: HinawaFwReqError = 18;
pub const HINAWA_FW_REQ_ERROR_GENERATION: HinawaFwReqError = 19;
pub const HINAWA_FW_REQ_ERROR_NO_ACK: HinawaFwReqError = 20;
pub const HINAWA_FW_REQ_ERROR_INVALID: HinawaFwReqError = 21;

pub type HinawaFwRespError = c_int;
pub const HINAWA_FW_RESP_ERROR_FAILED: HinawaFwRespError = 0;
pub const HINAWA_FW_RESP_ERROR_RESERVED: HinawaFwRespError = 1;
pub const HINAWA_FW_RESP_ERROR_ADDR_SPACE_USED: HinawaFwRespError = 2;

pub type HinawaFwTcode = c_int;
pub const HINAWA_FW_TCODE_WRITE_QUADLET_REQUEST: HinawaFwTcode = 0;
pub const HINAWA_FW_TCODE_WRITE_BLOCK_REQUEST: HinawaFwTcode = 1;
pub const HINAWA_FW_TCODE_WRITE_RESPONSE: HinawaFwTcode = 2;
pub const HINAWA_FW_TCODE_READ_QUADLET_REQUEST: HinawaFwTcode = 4;
pub const HINAWA_FW_TCODE_READ_BLOCK_REQUEST: HinawaFwTcode = 5;
pub const HINAWA_FW_TCODE_READ_QUADLET_RESPONSE: HinawaFwTcode = 6;
pub const HINAWA_FW_TCODE_READ_BLOCK_RESPONSE: HinawaFwTcode = 7;
pub const HINAWA_FW_TCODE_CYCLE_START: HinawaFwTcode = 8;
pub const HINAWA_FW_TCODE_LOCK_REQUEST: HinawaFwTcode = 9;
pub const HINAWA_FW_TCODE_STREAM_DATA: HinawaFwTcode = 10;
pub const HINAWA_FW_TCODE_LOCK_RESPONSE: HinawaFwTcode = 11;
pub const HINAWA_FW_TCODE_LOCK_MASK_SWAP: HinawaFwTcode = 17;
pub const HINAWA_FW_TCODE_LOCK_COMPARE_SWAP: HinawaFwTcode = 18;
pub const HINAWA_FW_TCODE_LOCK_FETCH_ADD: HinawaFwTcode = 19;
pub const HINAWA_FW_TCODE_LOCK_LITTLE_ADD: HinawaFwTcode = 20;
pub const HINAWA_FW_TCODE_LOCK_BOUNDED_ADD: HinawaFwTcode = 21;
pub const HINAWA_FW_TCODE_LOCK_WRAP_ADD: HinawaFwTcode = 22;
pub const HINAWA_FW_TCODE_LOCK_VENDOR_DEPENDENT: HinawaFwTcode = 23;

// Records
#[repr(C)]
pub struct HinawaCycleTime {
    _data: [u8; 0],
    _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
}

impl ::std::fmt::Debug for HinawaCycleTime {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("HinawaCycleTime @ {:p}", self))
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct HinawaFwFcpClass {
    pub parent_class: HinawaFwRespClass,
    pub responded:
        Option<unsafe extern "C" fn(*mut HinawaFwFcp, c_uint, c_uint, *const u8, c_uint)>,
}

impl ::std::fmt::Debug for HinawaFwFcpClass {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("HinawaFwFcpClass @ {:p}", self))
            .field("parent_class", &self.parent_class)
            .field("responded", &self.responded)
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct HinawaFwNodeClass {
    pub parent_class: gobject::GObjectClass,
    pub bus_update: Option<unsafe extern "C" fn(*mut HinawaFwNode)>,
    pub disconnected: Option<unsafe extern "C" fn(*mut HinawaFwNode)>,
}

impl ::std::fmt::Debug for HinawaFwNodeClass {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("HinawaFwNodeClass @ {:p}", self))
            .field("parent_class", &self.parent_class)
            .field("bus_update", &self.bus_update)
            .field("disconnected", &self.disconnected)
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct HinawaFwReqClass {
    pub parent_class: gobject::GObjectClass,
    pub responded: Option<
        unsafe extern "C" fn(*mut HinawaFwReq, HinawaFwRcode, c_uint, c_uint, *const u8, c_uint),
    >,
}

impl ::std::fmt::Debug for HinawaFwReqClass {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("HinawaFwReqClass @ {:p}", self))
            .field("parent_class", &self.parent_class)
            .field("responded", &self.responded)
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct HinawaFwRespClass {
    pub parent_class: gobject::GObjectClass,
    pub requested: Option<
        unsafe extern "C" fn(
            *mut HinawaFwResp,
            HinawaFwTcode,
            u64,
            c_uint,
            c_uint,
            c_uint,
            c_uint,
            c_uint,
            *const u8,
            c_uint,
        ) -> HinawaFwRcode,
    >,
}

impl ::std::fmt::Debug for HinawaFwRespClass {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("HinawaFwRespClass @ {:p}", self))
            .field("parent_class", &self.parent_class)
            .field("requested", &self.requested)
            .finish()
    }
}

// Classes
#[derive(Copy, Clone)]
#[repr(C)]
pub struct HinawaFwFcp {
    pub parent_instance: HinawaFwResp,
}

impl ::std::fmt::Debug for HinawaFwFcp {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("HinawaFwFcp @ {:p}", self))
            .field("parent_instance", &self.parent_instance)
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct HinawaFwNode {
    pub parent_instance: gobject::GObject,
}

impl ::std::fmt::Debug for HinawaFwNode {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("HinawaFwNode @ {:p}", self))
            .field("parent_instance", &self.parent_instance)
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct HinawaFwReq {
    pub parent_instance: gobject::GObject,
}

impl ::std::fmt::Debug for HinawaFwReq {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("HinawaFwReq @ {:p}", self))
            .field("parent_instance", &self.parent_instance)
            .finish()
    }
}

#[derive(Copy, Clone)]
#[repr(C)]
pub struct HinawaFwResp {
    pub parent_instance: gobject::GObject,
}

impl ::std::fmt::Debug for HinawaFwResp {
    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
        f.debug_struct(&format!("HinawaFwResp @ {:p}", self))
            .field("parent_instance", &self.parent_instance)
            .finish()
    }
}

#[link(name = "hinawa")]
extern "C" {

    //=========================================================================
    // HinawaFwFcpError
    //=========================================================================
    pub fn hinawa_fw_fcp_error_get_type() -> GType;
    pub fn hinawa_fw_fcp_error_quark() -> glib::GQuark;

    //=========================================================================
    // HinawaFwNodeError
    //=========================================================================
    pub fn hinawa_fw_node_error_get_type() -> GType;
    pub fn hinawa_fw_node_error_quark() -> glib::GQuark;

    //=========================================================================
    // HinawaFwRcode
    //=========================================================================
    pub fn hinawa_fw_rcode_get_type() -> GType;

    //=========================================================================
    // HinawaFwReqError
    //=========================================================================
    pub fn hinawa_fw_req_error_get_type() -> GType;
    pub fn hinawa_fw_req_error_quark() -> glib::GQuark;

    //=========================================================================
    // HinawaFwRespError
    //=========================================================================
    pub fn hinawa_fw_resp_error_get_type() -> GType;
    pub fn hinawa_fw_resp_error_quark() -> glib::GQuark;

    //=========================================================================
    // HinawaFwTcode
    //=========================================================================
    pub fn hinawa_fw_tcode_get_type() -> GType;

    //=========================================================================
    // HinawaCycleTime
    //=========================================================================
    pub fn hinawa_cycle_time_get_type() -> GType;
    pub fn hinawa_cycle_time_new() -> *mut HinawaCycleTime;
    pub fn hinawa_cycle_time_compute_tstamp(
        self_: *const HinawaCycleTime,
        tstamp: c_uint,
        isoc_cycle: *mut [c_uint; 2],
    );
    pub fn hinawa_cycle_time_get_clock_id(self_: *const HinawaCycleTime, clock_id: *mut c_int);
    pub fn hinawa_cycle_time_get_fields(self_: *const HinawaCycleTime, fields: *mut [u16; 3]);
    pub fn hinawa_cycle_time_get_raw(self_: *const HinawaCycleTime, raw: *mut u32);
    pub fn hinawa_cycle_time_get_system_time(
        self_: *const HinawaCycleTime,
        tv_sec: *mut i64,
        tv_nsec: *mut i32,
    );
    pub fn hinawa_cycle_time_parse_tstamp(tstamp: c_uint, isoc_cycle: *mut [c_uint; 2]);

    //=========================================================================
    // HinawaFwFcp
    //=========================================================================
    pub fn hinawa_fw_fcp_get_type() -> GType;
    pub fn hinawa_fw_fcp_new() -> *mut HinawaFwFcp;
    pub fn hinawa_fw_fcp_avc_transaction(
        self_: *mut HinawaFwFcp,
        cmd: *const u8,
        cmd_size: size_t,
        resp: *mut *mut u8,
        resp_size: *mut size_t,
        timeout_ms: c_uint,
        error: *mut *mut glib::GError,
    ) -> gboolean;
    pub fn hinawa_fw_fcp_avc_transaction_with_tstamp(
        self_: *mut HinawaFwFcp,
        cmd: *const u8,
        cmd_size: size_t,
        resp: *mut *mut u8,
        resp_size: *mut size_t,
        tstamp: *mut [c_uint; 3],
        timeout_ms: c_uint,
        error: *mut *mut glib::GError,
    ) -> gboolean;
    pub fn hinawa_fw_fcp_bind(
        self_: *mut HinawaFwFcp,
        node: *mut HinawaFwNode,
        error: *mut *mut glib::GError,
    ) -> gboolean;
    pub fn hinawa_fw_fcp_command(
        self_: *mut HinawaFwFcp,
        cmd: *const u8,
        cmd_size: size_t,
        timeout_ms: c_uint,
        error: *mut *mut glib::GError,
    ) -> gboolean;
    pub fn hinawa_fw_fcp_command_with_tstamp(
        self_: *mut HinawaFwFcp,
        cmd: *const u8,
        cmd_size: size_t,
        tstamp: *mut [c_uint; 2],
        timeout_ms: c_uint,
        error: *mut *mut glib::GError,
    ) -> gboolean;
    pub fn hinawa_fw_fcp_unbind(self_: *mut HinawaFwFcp);

    //=========================================================================
    // HinawaFwNode
    //=========================================================================
    pub fn hinawa_fw_node_get_type() -> GType;
    pub fn hinawa_fw_node_new() -> *mut HinawaFwNode;
    pub fn hinawa_fw_node_create_source(
        self_: *mut HinawaFwNode,
        gsrc: *mut *mut glib::GSource,
        error: *mut *mut glib::GError,
    ) -> gboolean;
    pub fn hinawa_fw_node_get_config_rom(
        self_: *mut HinawaFwNode,
        image: *mut *const u8,
        length: *mut size_t,
        error: *mut *mut glib::GError,
    ) -> gboolean;
    pub fn hinawa_fw_node_open(
        self_: *mut HinawaFwNode,
        path: *const c_char,
        open_flag: c_int,
        error: *mut *mut glib::GError,
    ) -> gboolean;
    pub fn hinawa_fw_node_read_cycle_time(
        self_: *mut HinawaFwNode,
        clock_id: c_int,
        cycle_time: *mut *mut HinawaCycleTime,
        error: *mut *mut glib::GError,
    ) -> gboolean;

    //=========================================================================
    // HinawaFwReq
    //=========================================================================
    pub fn hinawa_fw_req_get_type() -> GType;
    pub fn hinawa_fw_req_new() -> *mut HinawaFwReq;
    pub fn hinawa_fw_req_request(
        self_: *mut HinawaFwReq,
        node: *mut HinawaFwNode,
        tcode: HinawaFwTcode,
        addr: u64,
        length: size_t,
        frame: *mut *mut u8,
        frame_size: *mut size_t,
        error: *mut *mut glib::GError,
    ) -> gboolean;
    pub fn hinawa_fw_req_transaction(
        self_: *mut HinawaFwReq,
        node: *mut HinawaFwNode,
        tcode: HinawaFwTcode,
        addr: u64,
        length: size_t,
        frame: *mut *mut u8,
        frame_size: *mut size_t,
        timeout_ms: c_uint,
        error: *mut *mut glib::GError,
    ) -> gboolean;
    pub fn hinawa_fw_req_transaction_with_tstamp(
        self_: *mut HinawaFwReq,
        node: *mut HinawaFwNode,
        tcode: HinawaFwTcode,
        addr: u64,
        length: size_t,
        frame: *mut *mut u8,
        frame_size: *mut size_t,
        tstamp: *mut [c_uint; 2],
        timeout_ms: c_uint,
        error: *mut *mut glib::GError,
    ) -> gboolean;

    //=========================================================================
    // HinawaFwResp
    //=========================================================================
    pub fn hinawa_fw_resp_get_type() -> GType;
    pub fn hinawa_fw_resp_new() -> *mut HinawaFwResp;
    pub fn hinawa_fw_resp_release(self_: *mut HinawaFwResp);
    pub fn hinawa_fw_resp_reserve(
        self_: *mut HinawaFwResp,
        node: *mut HinawaFwNode,
        addr: u64,
        width: c_uint,
        error: *mut *mut glib::GError,
    ) -> gboolean;
    pub fn hinawa_fw_resp_reserve_within_region(
        self_: *mut HinawaFwResp,
        node: *mut HinawaFwNode,
        region_start: u64,
        region_end: u64,
        width: c_uint,
        error: *mut *mut glib::GError,
    ) -> gboolean;
    pub fn hinawa_fw_resp_set_resp_frame(self_: *mut HinawaFwResp, frame: *mut u8, length: size_t);

}