blob: 70ac9c770c75542cb37ac652889044b88307fe8c [file] [log] [blame]
Amaury Poulyd66c1672012-11-29 17:29:13 +01001/***************************************************************************
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,
Amaury Poulyfb43a132012-12-06 12:16:57 +010069 SAMSUNG_WRITE_ERROR = -4,
Amaury Poulyd66c1672012-11-29 17:29:13 +010070};
71
72typedef int (*samsung_read_t)(void *user, int offset, void *buffer, int size);
Amaury Poulyfb43a132012-12-06 12:16:57 +010073typedef int (*samsung_write_t)(void *user, int offset, void *buffer, int size);
Amaury Poulyd66c1672012-11-29 17:29:13 +010074typedef void (*samsung_printf_t)(void *user, bool error, const char *fmt, ...);
75
76struct samsung_firmware_t *samsung_read(samsung_read_t read,
77 samsung_printf_t printf, void *user, enum samsung_error_t *err);
Amaury Poulyfb43a132012-12-06 12:16:57 +010078enum samsung_error_t samsung_write(samsung_write_t write, samsung_printf_t printf,
79 void *user, struct samsung_firmware_t *fw);
Amaury Poulyd66c1672012-11-29 17:29:13 +010080void samsung_free(struct samsung_firmware_t *fw);
81
82#endif /* __SAMSUNG_H__ */