blob: da7d400f8ad79fe2f90009748d4c76a24e601fa6 [file] [log] [blame]
Mayank Grover98c4c742019-04-25 17:21:37 +05301/* Copyright (c) 2010-2017,2019 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 Shah0f3c8ac2014-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
Mayank Grover98c4c742019-04-25 17:21:37 +053041#define RECOVERY_BOOT_RECOVERY_CMD "boot-recovery"
42#define RECOVERY_BOOT_FASTBOOT_CMD "boot-fastboot"
43
Maunik Shah0f3c8ac2014-03-02 17:47:58 +053044/* bootselect partition format structure */
45struct boot_selection_info {
46 uint32_t signature; // Contains value BOOTSELECT_SIGNATURE defined above
47 uint32_t version;
48 uint32_t boot_partition_selection; // Decodes which partitions to boot: 0-Windows,1-Android
49 uint32_t state_info; // Contains factory and format bit as definded above
50};
Shashank Mittal024c0332010-02-03 11:44:00 -080051
52/* Recovery Message */
53struct recovery_message {
54 char command[32];
55 char status[32];
56 char recovery[1024];
57};
58
59
60struct update_header {
61 unsigned char MAGIC[UPDATE_MAGIC_SIZE];
62
63 unsigned version;
64 unsigned size;
65
66 unsigned image_offset;
67 unsigned image_length;
68
69 unsigned bitmap_width;
70 unsigned bitmap_height;
71 unsigned bitmap_bpp;
72
73 unsigned busy_bitmap_offset;
74 unsigned busy_bitmap_length;
75
76 unsigned fail_bitmap_offset;
77 unsigned fail_bitmap_length;
78};
79
Pavel Nedevc728bb32013-04-05 16:58:05 +030080int write_misc(unsigned page_offset, void *buf, unsigned size);
Shashank Mittal024c0332010-02-03 11:44:00 -080081
82int get_recovery_message(struct recovery_message *out);
83int set_recovery_message(const struct recovery_message *in);
Mayank Grover98c4c742019-04-25 17:21:37 +053084int send_recovery_cmd(const char *command);
Shashank Mittal024c0332010-02-03 11:44:00 -080085int 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