blob: 204312b252db098d39018f0a90c43373f3b930de [file] [log] [blame]
Maunik Shah78a85e52014-03-02 17:47:58 +05301/* Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
Shashank Mittal024c0332010-02-03 11:44:00 -08002
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer in the documentation and/or other materials provided
11 * with the distribution.
Duy Truongf3ac7b32013-02-13 01:07:28 -080012 * * Neither the name of The Linux Foundation nor the names of its
Shashank Mittal024c0332010-02-03 11:44:00 -080013 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef _BOOTLOADER_RECOVERY_H
30#define _BOOTLOADER_RECOVERY_H
31
Maunik Shah78a85e52014-03-02 17:47:58 +053032#define UPDATE_MAGIC "MSM-RADIO-UPDATE"
33#define UPDATE_MAGIC_SIZE 16
34#define UPDATE_VERSION 0x00010000
35#define FFBM_MODE_BUF_SIZE 8
36#define BOOTSELECT_SIGNATURE ('B' | ('S' << 8) | ('e' << 16) | ('l' << 24))
37#define BOOTSELECT_VERSION 0x00010001
38#define BOOTSELECT_FORMAT (1 << 31)
39#define BOOTSELECT_FACTORY (1 << 30)
Shashank Mittal024c0332010-02-03 11:44:00 -080040
Maunik Shah78a85e52014-03-02 17:47:58 +053041/* bootselect partition format structure */
42struct boot_selection_info {
43 uint32_t signature; // Contains value BOOTSELECT_SIGNATURE defined above
44 uint32_t version;
45 uint32_t boot_partition_selection; // Decodes which partitions to boot: 0-Windows,1-Android
46 uint32_t state_info; // Contains factory and format bit as definded above
47};
Shashank Mittal024c0332010-02-03 11:44:00 -080048
49/* Recovery Message */
50struct recovery_message {
51 char command[32];
52 char status[32];
53 char recovery[1024];
54};
55
56
57struct update_header {
58 unsigned char MAGIC[UPDATE_MAGIC_SIZE];
59
60 unsigned version;
61 unsigned size;
62
63 unsigned image_offset;
64 unsigned image_length;
65
66 unsigned bitmap_width;
67 unsigned bitmap_height;
68 unsigned bitmap_bpp;
69
70 unsigned busy_bitmap_offset;
71 unsigned busy_bitmap_length;
72
73 unsigned fail_bitmap_offset;
74 unsigned fail_bitmap_length;
75};
76
Pavel Nedevc728bb32013-04-05 16:58:05 +030077int write_misc(unsigned page_offset, void *buf, unsigned size);
Shashank Mittal024c0332010-02-03 11:44:00 -080078
79int get_recovery_message(struct recovery_message *out);
80int set_recovery_message(const struct recovery_message *in);
81
82int read_update_header_for_bootloader(struct update_header *header);
83int update_firmware_image (struct update_header *header, char *name);
84
85int recovery_init (void);
Deepa Dinamani41fa8d62013-05-23 13:25:36 -070086/* This function will look for the ffbm cookie in the misc partition.
87 * Upon finding a valid cookie it will return 1 and place the cookie
88 * into ffbm.If it does not find a valid cookie it will return 0.If
89 * an error is hit it will return -1.If either of these return values
90 * is seen the data in ffbm should not be used and should be considered
91 * invalid.
92 */
93int get_ffbm(char *ffbm, unsigned size);
Pavel Nedeva1e62322013-04-05 15:21:36 +030094
Shashank Mittal024c0332010-02-03 11:44:00 -080095extern unsigned boot_into_recovery;
96
97#endif