blob: c4305fcb331740eb79a8671cc79238989a11334a [file] [log] [blame]
Glenn Stroz99291c22016-07-18 11:27:37 -07001/* Copyright (c) 2014,2016 The Linux Foundation. All rights reserved.
Sundarajan Srinivasan34bbe072014-03-21 17:27:16 -07002
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.
12 * * Neither the name of The Linux Foundation. nor the names of its
13 * 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 __BOOT_DEVICE_H
30#define __BOOT_DEVICE_H
31
32#include <sys/types.h>
Unnati Gandhif37b3622014-11-18 18:02:45 +053033#include <platform.h>
Sundarajan Srinivasan34bbe072014-03-21 17:27:16 -070034
Channagoud Kadabic42ea322014-10-10 12:26:54 -070035#if USE_MDM_BOOT_CFG
36#define BOOT_DEVICE_MASK(val) ((val & 0x1E) >> 1)
37#else
Unnati Gandhif37b3622014-11-18 18:02:45 +053038#define BOOT_DEVICE_MASK(val) boot_device_mask(val)
Channagoud Kadabic42ea322014-10-10 12:26:54 -070039#endif
Sundarajan Srinivasan34bbe072014-03-21 17:27:16 -070040
41/* Boot device */
Channagoud Kadabic42ea322014-10-10 12:26:54 -070042#if USE_MDM_BOOT_CFG
Sundarajan Srinivasan34bbe072014-03-21 17:27:16 -070043enum boot_device
44{
Channagoud Kadabic42ea322014-10-10 12:26:54 -070045 BOOT_DEFAULT=0, /* NAND */
46 BOOT_EMMC=3,
47};
48#else
49enum boot_device
50{
51 BOOT_DEFAULT=0, /* EMMC */
Sundarajan Srinivasan34bbe072014-03-21 17:27:16 -070052 BOOT_EMMC=2,
53 BOOT_UFS=4,
Glenn Stroz99291c22016-07-18 11:27:37 -070054 BOOT_SD_ELSE_UFS=5,
Sundarajan Srinivasan34bbe072014-03-21 17:27:16 -070055};
Channagoud Kadabic42ea322014-10-10 12:26:54 -070056#endif
Sundarajan Srinivasan34bbe072014-03-21 17:27:16 -070057
Monika Singh5e170362018-03-14 00:48:36 +053058#define MAX_NUMBER_OF_LOADED_IMAGES 32
59#ifndef MAX_GPT_NAME_SIZE
60#define MAX_GPT_NAME_SIZE 72
61#endif
62
63typedef struct {
64 char *name;
65 void *image_buffer;
66 uint32_t imgsize;
67} imagedata;
68
69typedef struct bootinfo {
70 int multi_slot_boot;
71 bool bootinto_recovery;
72 bool bootreason_alarm;
73 char pname[MAX_GPT_NAME_SIZE];
74 char bootable_slot[MAX_GPT_NAME_SIZE];
75 imagedata images[MAX_NUMBER_OF_LOADED_IMAGES];
76 uint32_t num_loaded_images;
77 uint32_t boot_state;
78 char *vbcmdline;
79 uint32_t vbcmdline_len;
80 uint32_t vbcmdline_filled_len;
81 void *vb_data;
82} bootinfo;
83
Jiten Patel2cb89192018-08-22 12:51:47 +053084typedef enum {
85 IMG_BOOT = 0,
86 IMG_DTBO,
87 IMG_VBMETA,
88 IMG_RECOVERY,
89 IMG_MAX
90} img_type;
91
Monika Singh5e170362018-03-14 00:48:36 +053092int getimage(const bootinfo *Info, void **image_buffer, uint32_t *imgsize,
93 char *imgname);
94
Sundarajan Srinivasan34bbe072014-03-21 17:27:16 -070095void platform_read_boot_config();
96uint32_t platform_get_boot_dev();
97uint32_t platform_boot_dev_isemmc();
98void platform_boot_dev_cmdline(char *buf);
Monika Singh5e170362018-03-14 00:48:36 +053099int get_boot_image_info(void **image_buffer, uint32_t *imgsize,char *imgname);
Veera Sundaram Sankaran00181512014-12-09 11:23:39 -0800100
101void *target_mmc_device();
Sundarajan Srinivasan34bbe072014-03-21 17:27:16 -0700102#endif