| 1 |
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* |
| 3 |
* qmi-firmware-update -- Command line tool to update firmware in QMI devices |
| 4 |
* |
| 5 |
* This program is free software: you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation, either version 2 of the License, or |
| 8 |
* (at your option) any later version. |
| 9 |
* |
| 10 |
* This program 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 General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
* |
| 18 |
* Copyright (C) 2016 Bjørn Mork <[email protected]> |
| 19 |
* Copyright (C) 2016 Zodiac Inflight Innovations |
| 20 |
* Copyright (C) 2016-2017 Aleksander Morgado <[email protected]> |
| 21 |
*/ |
| 22 |
|
| 23 |
#ifndef QFU_QDL_MESSAGE_H |
| 24 |
#define QFU_QDL_MESSAGE_H |
| 25 |
|
| 26 |
#include <glib-object.h> |
| 27 |
#include <gio/gio.h> |
| 28 |
|
| 29 |
#include "qfu-image.h" |
| 30 |
|
| 31 |
G_BEGIN_DECLS |
| 32 |
|
| 33 |
/* Maximum QDL header size (i.e. without payload) */ |
| 34 |
#define QFU_QDL_MESSAGE_MAX_HEADER_SIZE 50 |
| 35 |
|
| 36 |
/* Maximum QDL message size (header and payload) */ |
| 37 |
#define QFU_QDL_MESSAGE_MAX_SIZE (QFU_QDL_MESSAGE_MAX_HEADER_SIZE + QFU_IMAGE_CHUNK_SIZE) |
| 38 |
|
| 39 |
/* from GobiAPI_1.0.40/Core/QDLEnum.h and |
| 40 |
* GobiAPI_1.0.40/Core/QDLBuffers.h with additional details from USB |
| 41 |
* snooping |
| 42 |
*/ |
| 43 |
typedef enum { |
| 44 |
QFU_QDL_CMD_HELLO_REQ = 0x01, |
| 45 |
QFU_QDL_CMD_HELLO_RSP = 0x02, |
| 46 |
QFU_QDL_CMD_ERROR = 0x0d, |
| 47 |
QFU_QDL_CMD_OPEN_UNFRAMED_REQ = 0x25, |
| 48 |
QFU_QDL_CMD_OPEN_UNFRAMED_RSP = 0x26, |
| 49 |
QFU_QDL_CMD_WRITE_UNFRAMED_REQ = 0x27, |
| 50 |
QFU_QDL_CMD_WRITE_UNFRAMED_RSP = 0x28, |
| 51 |
QFU_QDL_CMD_CLOSE_UNFRAMED_REQ = 0x29, |
| 52 |
QFU_QDL_CMD_CLOSE_UNFRAMED_RSP = 0x2a, |
| 53 |
QFU_QDL_CMD_DOWNLOAD_REQ = 0x2b, |
| 54 |
QFU_QDL_CMD_RESET_REQ = 0x2d, |
| 55 |
QFU_QDL_CMD_GET_IMAGE_PREF_REQ = 0x2e, |
| 56 |
QFU_QDL_CMD_GET_IMAGE_PREF_RSP = 0x2f, |
| 57 |
} QfuQdlCmd; |
| 58 |
|
| 59 |
/* Request builders */ |
| 60 |
|
| 61 |
gsize qfu_qdl_request_hello_build (guint8 *buffer, |
| 62 |
gsize buffer_len, |
| 63 |
guint8 minver, |
| 64 |
guint8 maxver); |
| 65 |
gssize qfu_qdl_request_ufopen_build (guint8 *buffer, |
| 66 |
gsize buffer_len, |
| 67 |
QfuImage *image, |
| 68 |
GCancellable *cancellable, |
| 69 |
GError **error); |
| 70 |
gssize qfu_qdl_request_ufwrite_build (guint8 *buffer, |
| 71 |
gsize buffer_len, |
| 72 |
QfuImage *image, |
| 73 |
guint16 sequence, |
| 74 |
GCancellable *cancellable, |
| 75 |
GError **error); |
| 76 |
gsize qfu_qdl_request_ufclose_build (guint8 *buffer, |
| 77 |
gsize buffer_len); |
| 78 |
gsize qfu_qdl_request_reset_build (guint8 *buffer, |
| 79 |
gsize buffer_len); |
| 80 |
|
| 81 |
/* Response parsers */ |
| 82 |
|
| 83 |
gboolean qfu_qdl_response_hello_parse (const guint8 *buffer, |
| 84 |
gsize buffer_len, |
| 85 |
GError **error); |
| 86 |
gboolean qfu_qdl_response_error_parse (const guint8 *buffer, |
| 87 |
gsize buffer_len, |
| 88 |
GError **error); |
| 89 |
gboolean qfu_qdl_response_ufopen_parse (const guint8 *buffer, |
| 90 |
gsize buffer_len, |
| 91 |
GError **error); |
| 92 |
gboolean qfu_qdl_response_ufwrite_parse (const guint8 *buffer, |
| 93 |
gsize buffer_len, |
| 94 |
guint16 *sequence, |
| 95 |
GError **error); |
| 96 |
gboolean qfu_qdl_response_ufclose_parse (const guint8 *buffer, |
| 97 |
gsize buffer_len, |
| 98 |
GError **error); |
| 99 |
|
| 100 |
G_END_DECLS |
| 101 |
|
| 102 |
#endif /* QFU_QDL_MESSAGE_H */ |