Amaury Pouly | d66c167 | 2012-11-29 17:29:13 +0100 | [diff] [blame] | 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 | |
| 31 | struct 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 | |
| 42 | struct 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 | |
| 53 | struct 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 | |
| 63 | enum samsung_error_t |
| 64 | { |
| 65 | SAMSUNG_SUCCESS = 0, |
| 66 | SAMSUNG_READ_ERROR = -1, |
| 67 | SAMSUNG_FORMAT_ERROR = -2, |
| 68 | SAMSUNG_MD5_ERROR = -3, |
Amaury Pouly | fb43a13 | 2012-12-06 12:16:57 +0100 | [diff] [blame] | 69 | SAMSUNG_WRITE_ERROR = -4, |
Amaury Pouly | d66c167 | 2012-11-29 17:29:13 +0100 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | typedef int (*samsung_read_t)(void *user, int offset, void *buffer, int size); |
Amaury Pouly | fb43a13 | 2012-12-06 12:16:57 +0100 | [diff] [blame] | 73 | typedef int (*samsung_write_t)(void *user, int offset, void *buffer, int size); |
Amaury Pouly | d66c167 | 2012-11-29 17:29:13 +0100 | [diff] [blame] | 74 | typedef void (*samsung_printf_t)(void *user, bool error, const char *fmt, ...); |
| 75 | |
| 76 | struct samsung_firmware_t *samsung_read(samsung_read_t read, |
| 77 | samsung_printf_t printf, void *user, enum samsung_error_t *err); |
Amaury Pouly | fb43a13 | 2012-12-06 12:16:57 +0100 | [diff] [blame] | 78 | enum samsung_error_t samsung_write(samsung_write_t write, samsung_printf_t printf, |
| 79 | void *user, struct samsung_firmware_t *fw); |
Amaury Pouly | d66c167 | 2012-11-29 17:29:13 +0100 | [diff] [blame] | 80 | void samsung_free(struct samsung_firmware_t *fw); |
| 81 | |
| 82 | #endif /* __SAMSUNG_H__ */ |