summaryrefslogtreecommitdiff
path: root/utils/samsungtools/samsung.h
diff options
context:
space:
mode:
Diffstat (limited to 'utils/samsungtools/samsung.h')
-rw-r--r--utils/samsungtools/samsung.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/utils/samsungtools/samsung.h b/utils/samsungtools/samsung.h
new file mode 100644
index 0000000000..4336e02651
--- /dev/null
+++ b/utils/samsungtools/samsung.h
@@ -0,0 +1,78 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2012 Amaury Pouly
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef __SAMSUNG_H__
22#define __SAMSUNG_H__
23
24#include <stdint.h>
25#include <stdbool.h>
26
27/**
28 * Low-Level
29 */
30
31struct yp_header_t
32{
33 char signature[12];
34 uint32_t pad;
35 char version[8];
36 char region[4];
37 char extra[4];
38 char model[20];
39 uint32_t datasize;
40} __attribute__((packed));
41
42struct yp_md5_t
43{
44 uint8_t md5[16];
45} __attribute__((packed));
46
47#define YP_SIGNATURE "SAMSUNG YEPP"
48
49/**
50 * API
51 */
52
53struct samsung_firmware_t
54{
55 char version[8];
56 char region[4];
57 char extra[4];
58 char model[20];
59 void *data;
60 int data_size;
61};
62
63enum samsung_error_t
64{
65 SAMSUNG_SUCCESS = 0,
66 SAMSUNG_READ_ERROR = -1,
67 SAMSUNG_FORMAT_ERROR = -2,
68 SAMSUNG_MD5_ERROR = -3,
69};
70
71typedef int (*samsung_read_t)(void *user, int offset, void *buffer, int size);
72typedef void (*samsung_printf_t)(void *user, bool error, const char *fmt, ...);
73
74struct samsung_firmware_t *samsung_read(samsung_read_t read,
75 samsung_printf_t printf, void *user, enum samsung_error_t *err);
76void samsung_free(struct samsung_firmware_t *fw);
77
78#endif /* __SAMSUNG_H__ */