| 1 |
#ifndef XTALK_BASE_H |
| 2 |
#define XTALK_BASE_H |
| 3 |
/* |
| 4 |
* Written by Oron Peled <[email protected]> |
| 5 |
* Copyright (C) 2009, Xorcom |
| 6 |
* |
| 7 |
* All rights reserved. |
| 8 |
* |
| 9 |
* This program is free software; you can redistribute it and/or modify |
| 10 |
* it under the terms of the GNU General Public License as published by |
| 11 |
* the Free Software Foundation; either version 2 of the License, or |
| 12 |
* (at your option) any later version. |
| 13 |
* |
| 14 |
* This program is distributed in the hope that it will be useful, |
| 15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 |
* GNU General Public License for more details. |
| 18 |
* |
| 19 |
* You should have received a copy of the GNU General Public License |
| 20 |
* along with this program; if not, write to the Free Software |
| 21 |
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 22 |
* |
| 23 |
*/ |
| 24 |
|
| 25 |
#include <stdint.h> |
| 26 |
#include <stdlib.h> |
| 27 |
#include <xtalk/proto.h> |
| 28 |
#include <xtalk/firmware_defs.h> |
| 29 |
|
| 30 |
#ifdef __cplusplus |
| 31 |
extern "C" |
| 32 |
{ |
| 33 |
#endif /* __cplusplus */ |
| 34 |
|
| 35 |
/* |
| 36 |
* Base XTALK device. A pointer to this struct |
| 37 |
* should be included in the struct representing |
| 38 |
* the dialect. |
| 39 |
*/ |
| 40 |
struct xtalk_base { |
| 41 |
void *transport_priv; /* e.g: struct xusb */ |
| 42 |
struct xtalk_ops ops; |
| 43 |
struct xtalk_protocol xproto; |
| 44 |
xtalk_cmd_callback_t callbacks[MAX_OPS]; |
| 45 |
uint8_t xtalk_proto_version; |
| 46 |
uint8_t status; |
| 47 |
size_t packet_size; |
| 48 |
uint16_t tx_sequenceno; |
| 49 |
int default_timeout; /* in millies */ |
| 50 |
}; |
| 51 |
|
| 52 |
int xtalk_set_protocol(struct xtalk_base *xtalk_base, |
| 53 |
const struct xtalk_protocol *xproto_base, |
| 54 |
const struct xtalk_protocol *xproto); |
| 55 |
const struct xtalk_command_desc *get_command_desc( |
| 56 |
const struct xtalk_protocol *xproto, uint8_t op); |
| 57 |
int send_command(struct xtalk_base *xtalk_base, |
| 58 |
struct xtalk_command *cmd, uint16_t *tx_seq); |
| 59 |
int recv_command(struct xtalk_base *xtalk_base, |
| 60 |
struct xtalk_command **reply_ref); |
| 61 |
|
| 62 |
/* |
| 63 |
* These are low-level interfaces that receive/send arbitrary buffers |
| 64 |
* Be carefull, as that allow to send illegal Xtalk packets |
| 65 |
*/ |
| 66 |
int send_buffer(struct xtalk_base *xtalk_base, const char *buf, int len); |
| 67 |
int recv_buffer(struct xtalk_base *xtalk_base, char *buf, int len); |
| 68 |
|
| 69 |
#ifdef __cplusplus |
| 70 |
} |
| 71 |
#endif /* __cplusplus */ |
| 72 |
|
| 73 |
#endif /* XTALK_BASE_H */ |