Reut Zysman | ff6bab9 | 2016-02-09 14:06:31 +0200 | [diff] [blame] | 1 | /* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 2 | * |
| 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 | #include <debug.h> |
| 30 | #include <dev/fbcon.h> |
| 31 | #include <target.h> |
| 32 | #include <mmc.h> |
| 33 | #include <partition_parser.h> |
| 34 | #include <stdlib.h> |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 35 | #include <string.h> |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 36 | #include <display_menu.h> |
| 37 | #include <qtimer.h> |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 38 | #include "mdtp.h" |
Reut Zysman | 561d81a | 2015-08-26 17:37:28 +0300 | [diff] [blame] | 39 | #include "mdtp_defs.h" |
Reut Zysman | ff6bab9 | 2016-02-09 14:06:31 +0200 | [diff] [blame] | 40 | #include "mdtp_fs.h" |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 41 | |
| 42 | // Image releative locations |
| 43 | #define ERROR_MESSAGE_RELATIVE_Y_LOCATION (0.18) |
| 44 | #define MAIN_TEXT_RELATIVE_Y_LOCATION (0.33) |
| 45 | #define PIN_RELATIVE_Y_LOCATION (0.47) |
| 46 | #define PIN_TEXT_RELATIVE_Y_LOCATION (0.57) |
| 47 | #define OK_BUTTON_RELATIVE_Y_LOCATION (0.75) |
| 48 | #define OK_TEXT_RELATIVE_Y_LOCATION (0.82) |
| 49 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 50 | #define MDTP_PRESSING_DELAY_MSEC (400) |
| 51 | #define MDTP_MAX_IMAGE_SIZE (1183000) //size in bytes, includes some extra bytes since we round up to block size in read |
| 52 | #define RGB888_BLACK (0x000000) |
| 53 | #define BITS_PER_BYTE (8) |
| 54 | |
| 55 | |
Amit Blay | 8e2731c | 2015-04-28 21:54:55 +0300 | [diff] [blame] | 56 | #define CENTER_IMAGE_ON_X_AXIS(image_width,screen_width) (((screen_width)-(image_width))/2) |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 57 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 58 | extern uint32_t target_volume_up(); |
| 59 | extern uint32_t target_volume_down(); |
Amit Blay | f43af75 | 2015-11-10 19:13:37 +0200 | [diff] [blame] | 60 | extern int msm_display_on(); |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 61 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 62 | struct mdtp_fbimage { |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 63 | uint32_t width; |
| 64 | uint32_t height; |
| 65 | uint8_t image[MDTP_MAX_IMAGE_SIZE]; |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 66 | }; |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 67 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 68 | /*---------------------------------------------------------------------------- |
| 69 | * Global Variables |
| 70 | * -------------------------------------------------------------------------*/ |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 71 | |
Amir Kotzer | 20716f1 | 2016-02-24 10:31:18 +0200 | [diff] [blame] | 72 | static uint32_t g_pin_frames_x_location[MDTP_PIN_LEN] = {0}; |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 73 | static uint32_t g_pin_frames_y_location = 0; |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 74 | static bool g_diplay_pin = false; |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 75 | |
| 76 | static bool g_initial_screen_displayed = false; |
| 77 | |
Rami Butstein | faecf7f | 2015-06-04 16:39:30 +0300 | [diff] [blame] | 78 | static struct mdtp_fbimage *g_mdtp_header = NULL; |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 79 | static struct fbcon_config *fb_config = NULL; |
| 80 | |
Reut Zysman | 561d81a | 2015-08-26 17:37:28 +0300 | [diff] [blame] | 81 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 82 | /*---------------------------------------------------------------------------- |
| 83 | * Local Functions |
| 84 | * -------------------------------------------------------------------------*/ |
| 85 | |
| 86 | /** |
Rami Butstein | faecf7f | 2015-06-04 16:39:30 +0300 | [diff] [blame] | 87 | * Allocate mdtp image |
| 88 | */ |
| 89 | static void alloc_mdtp_image() { |
| 90 | if (!g_mdtp_header) { |
| 91 | g_mdtp_header = (struct mdtp_fbimage *)malloc(sizeof(struct mdtp_fbimage)); |
| 92 | ASSERT(g_mdtp_header); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Free mdtp image |
| 98 | */ |
| 99 | void free_mdtp_image() { |
| 100 | if (g_mdtp_header) { |
| 101 | free(g_mdtp_header); |
| 102 | g_mdtp_header = NULL; |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | /** |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 107 | * Load images from EMMC |
| 108 | */ |
| 109 | static struct mdtp_fbimage* mdtp_read_mmc_image(uint32_t offset, uint32_t width, uint32_t height) |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 110 | { |
| 111 | int index = INVALID_PTN; |
| 112 | unsigned long long ptn = 0; |
Rami Butstein | faecf7f | 2015-06-04 16:39:30 +0300 | [diff] [blame] | 113 | struct mdtp_fbimage *logo = g_mdtp_header; |
Amit Blay | df42d2f | 2015-02-03 16:37:09 +0200 | [diff] [blame] | 114 | uint32_t block_size = mmc_get_device_blocksize(); |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 115 | |
| 116 | index = partition_get_index("mdtp"); |
| 117 | if (index == 0) { |
| 118 | dprintf(CRITICAL, "ERROR: mdtp Partition table not found\n"); |
| 119 | return NULL; |
| 120 | } |
| 121 | |
| 122 | ptn = partition_get_offset(index); |
| 123 | if (ptn == 0) { |
| 124 | dprintf(CRITICAL, "ERROR: mdtp Partition invalid\n"); |
| 125 | return NULL; |
| 126 | } |
| 127 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 128 | if (fb_config) |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 129 | { |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 130 | uint8_t *base = logo->image; |
Amit Blay | 8e2731c | 2015-04-28 21:54:55 +0300 | [diff] [blame] | 131 | unsigned bytes_per_bpp = ((fb_config->bpp) / BITS_PER_BYTE); |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 132 | |
Amit Blay | 8e2731c | 2015-04-28 21:54:55 +0300 | [diff] [blame] | 133 | if (mmc_read(ptn+offset, (void*)base, ROUNDUP(width*height*bytes_per_bpp, block_size))) { |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 134 | fbcon_clear(); |
| 135 | dprintf(CRITICAL, "ERROR: mdtp image read failed\n"); |
| 136 | return NULL; |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 137 | } |
Amit Blay | 4418fb4 | 2015-05-05 08:45:13 +0300 | [diff] [blame] | 138 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 139 | logo->width = width; |
| 140 | logo->height = height; |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | return logo; |
| 144 | } |
| 145 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 146 | /** |
| 147 | * flush fbcon display |
| 148 | * |
| 149 | * The function is duplicated from fbcon.c |
| 150 | */ |
| 151 | static void fbcon_flush(void) |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 152 | { |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 153 | if (fb_config->update_start) |
| 154 | fb_config->update_start(); |
| 155 | if (fb_config->update_done) |
| 156 | while (!fb_config->update_done()); |
| 157 | } |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 158 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 159 | /** |
| 160 | * Clear complete section on the screen. |
| 161 | * The section is of section_height, and is located from the y |
| 162 | * coordinate and down. |
| 163 | */ |
| 164 | static void fbcon_clear_section(uint32_t y, uint32_t section_height) |
| 165 | { |
| 166 | unsigned image_base; |
| 167 | unsigned bytes_per_bpp; |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 168 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 169 | if (fb_config) |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 170 | { |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 171 | image_base = (y *(fb_config->width)); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 172 | bytes_per_bpp = ((fb_config->bpp) / BITS_PER_BYTE); |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 173 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 174 | unsigned count = fb_config->width*section_height; |
| 175 | memset(fb_config->base + image_base*bytes_per_bpp, RGB888_BLACK, count*bytes_per_bpp); |
| 176 | |
| 177 | fbcon_flush(); |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 178 | } |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 179 | else |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 180 | { |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 181 | dprintf(CRITICAL,"ERROR: fbcon_config struct is NULL\n"); |
| 182 | display_error_msg(); /* This will never return */ |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 183 | } |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 184 | } |
| 185 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 186 | /** |
| 187 | * Put image at a specific (x,y) location on the screen. |
| 188 | * Duplicated from fbcon.c, with modifications to allow (x,y) location (instead of a centered image), |
| 189 | * and display bmp images properly (order of copying the lines to the screen was reversed) |
| 190 | */ |
| 191 | static void fbcon_putImage_in_location(struct mdtp_fbimage *fbimg, uint32_t x, uint32_t y) |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 192 | { |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 193 | unsigned i = 0; |
| 194 | unsigned bytes_per_bpp; |
| 195 | unsigned image_base; |
| 196 | unsigned width, pitch, height; |
| 197 | unsigned char *logo_base = NULL; |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 198 | |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 199 | if (!fb_config) { |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 200 | dprintf(CRITICAL,"ERROR: NULL configuration, image cannot be displayed\n"); |
| 201 | return; |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 202 | } |
| 203 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 204 | if(fbimg) { |
| 205 | width = pitch = fbimg->width; |
| 206 | height = fbimg->height; |
| 207 | logo_base = (unsigned char *)fbimg->image; |
| 208 | } |
| 209 | else { |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 210 | dprintf(CRITICAL,"ERROR: invalid image struct\n"); |
| 211 | return; |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 212 | } |
| 213 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 214 | bytes_per_bpp = ((fb_config->bpp) / BITS_PER_BYTE); |
| 215 | |
| 216 | #if DISPLAY_TYPE_MIPI |
| 217 | if (bytes_per_bpp == 3) |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 218 | { |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 219 | if (fbimg->width == fb_config->width && fbimg->height == fb_config->height) |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 220 | { |
Amit Blay | 8e2731c | 2015-04-28 21:54:55 +0300 | [diff] [blame] | 221 | dprintf(CRITICAL,"ERROR: full screen image, cannot be displayed\n"); |
| 222 | return; |
| 223 | } |
| 224 | |
| 225 | if (fbimg->width > fb_config->width || fbimg->height > fb_config->height || |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 226 | (x > (fb_config->width - fbimg->width)) || (y > (fb_config->height - fbimg->height))) |
Amit Blay | 8e2731c | 2015-04-28 21:54:55 +0300 | [diff] [blame] | 227 | { |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 228 | dprintf(CRITICAL,"ERROR: invalid image size, larger than the screen or exceeds its margins\n"); |
| 229 | return; |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 230 | } |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 231 | |
| 232 | image_base = ( (y *(fb_config->width)) + x); |
| 233 | for (i = 0; i < height; i++) { |
| 234 | memcpy (fb_config->base + ((image_base + (i * (fb_config->width))) * bytes_per_bpp), |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 235 | logo_base + ((height - 1 - i) * pitch * bytes_per_bpp), width * bytes_per_bpp); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 236 | } |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 237 | } |
Amit Blay | 8e2731c | 2015-04-28 21:54:55 +0300 | [diff] [blame] | 238 | else |
| 239 | { |
| 240 | dprintf(CRITICAL,"ERROR: invalid bpp value\n"); |
| 241 | display_error_msg(); /* This will never return */ |
| 242 | } |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 243 | |
Amit Blay | 4418fb4 | 2015-05-05 08:45:13 +0300 | [diff] [blame] | 244 | /* Flush the contents to memory before giving the data to dma */ |
| 245 | arch_clean_invalidate_cache_range((addr_t) fb_config->base, (fb_config->height * fb_config->width * bytes_per_bpp)); |
| 246 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 247 | fbcon_flush(); |
Amit Blay | f43af75 | 2015-11-10 19:13:37 +0200 | [diff] [blame] | 248 | msm_display_on(); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 249 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 250 | #endif |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 251 | } |
| 252 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 253 | /** |
| 254 | * Display main error message |
| 255 | */ |
| 256 | static int display_error_message() |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 257 | { |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 258 | struct mdtp_fbimage *fbimg; |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 259 | |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 260 | if (fb_config) |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 261 | { |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 262 | uint32_t x = CENTER_IMAGE_ON_X_AXIS(get_image_width(ALERT_MESSAGE),fb_config->width); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 263 | uint32_t y = ((fb_config->height)*ERROR_MESSAGE_RELATIVE_Y_LOCATION); |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 264 | fbimg = mdtp_read_mmc_image(get_image_offset(ALERT_MESSAGE),get_image_width(ALERT_MESSAGE), get_image_height(ALERT_MESSAGE)); |
| 265 | if (NULL == fbimg) |
| 266 | { |
| 267 | dprintf(CRITICAL,"ERROR: failed to read error image from mmc\n"); |
| 268 | return -1; |
| 269 | } |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 270 | |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 271 | fbcon_putImage_in_location(fbimg, x, y); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 272 | |
| 273 | return 0; |
| 274 | } |
| 275 | else |
| 276 | { |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 277 | dprintf(CRITICAL,"ERROR: fbcon_config struct is NULL\n"); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 278 | return -1; |
| 279 | } |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 280 | } |
| 281 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 282 | /** |
| 283 | * Read from mmc the image in the given offset, of the given width and height. |
| 284 | * Then, display the image on the screen in the given (x,y) location. |
| 285 | */ |
| 286 | static void display_image(uint32_t offset, uint32_t width, uint32_t height, uint32_t x, uint32_t y) |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 287 | { |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 288 | struct mdtp_fbimage *fbimg; |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 289 | |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 290 | if (fb_config) |
| 291 | { |
| 292 | fbimg = mdtp_read_mmc_image(offset, width, height); |
| 293 | if (NULL == fbimg) |
| 294 | { |
| 295 | dprintf(CRITICAL,"ERROR: failed to read image from mmc\n"); |
| 296 | display_error_msg(); /* This will never return */ |
| 297 | } |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 298 | |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 299 | fbcon_putImage_in_location(fbimg, x, y); |
| 300 | } |
| 301 | else |
| 302 | { |
| 303 | dprintf(CRITICAL,"ERROR: fbcon_config struct is NULL\n"); |
| 304 | display_error_msg(); /* This will never return */ |
| 305 | } |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 306 | } |
| 307 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 308 | /** |
| 309 | * Display initial delay message |
| 310 | */ |
| 311 | static void display_initial_delay() |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 312 | { |
Reut Zysman | ff6bab9 | 2016-02-09 14:06:31 +0200 | [diff] [blame] | 313 | uint32_t x = CENTER_IMAGE_ON_X_AXIS(get_image_width(MAINTEXT_5SECONDS),fb_config->width); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 314 | uint32_t y = (fb_config->height)*MAIN_TEXT_RELATIVE_Y_LOCATION; |
Reut Zysman | ff6bab9 | 2016-02-09 14:06:31 +0200 | [diff] [blame] | 315 | display_image(get_image_offset(MAINTEXT_5SECONDS), get_image_width(MAINTEXT_5SECONDS), get_image_height(MAINTEXT_5SECONDS), x, y); |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 316 | } |
| 317 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 318 | /** |
| 319 | * Display "enter PIN" message |
| 320 | */ |
| 321 | static void display_enter_pin() |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 322 | { |
Reut Zysman | ff6bab9 | 2016-02-09 14:06:31 +0200 | [diff] [blame] | 323 | uint32_t x = CENTER_IMAGE_ON_X_AXIS(get_image_width(MAINTEXT_ENTERPIN),fb_config->width); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 324 | uint32_t y = (fb_config->height)*MAIN_TEXT_RELATIVE_Y_LOCATION; |
Reut Zysman | ff6bab9 | 2016-02-09 14:06:31 +0200 | [diff] [blame] | 325 | display_image(get_image_offset(MAINTEXT_ENTERPIN), get_image_width(MAINTEXT_ENTERPIN), get_image_height(MAINTEXT_ENTERPIN), x, y); |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 326 | } |
| 327 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 328 | /** |
| 329 | * Display invalid PIN message |
| 330 | */ |
| 331 | static void display_invalid_pin() |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 332 | { |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 333 | uint32_t x = CENTER_IMAGE_ON_X_AXIS(get_image_width(MAINTEXT_INCORRECTPIN),fb_config->width); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 334 | uint32_t y = (fb_config->height)*MAIN_TEXT_RELATIVE_Y_LOCATION; |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 335 | |
Reut Zysman | ff6bab9 | 2016-02-09 14:06:31 +0200 | [diff] [blame] | 336 | display_image(get_image_offset(MAINTEXT_INCORRECTPIN), get_image_width(MAINTEXT_INCORRECTPIN), get_image_height(MAINTEXT_INCORRECTPIN), x, y); |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 337 | } |
| 338 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 339 | /** |
| 340 | * Clear digits instructions |
| 341 | */ |
| 342 | static void display_digits_instructions() |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 343 | { |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 344 | uint32_t x = CENTER_IMAGE_ON_X_AXIS(get_image_width(PINTEXT),fb_config->width); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 345 | uint32_t y = (fb_config->height)*PIN_TEXT_RELATIVE_Y_LOCATION; |
| 346 | |
Reut Zysman | ff6bab9 | 2016-02-09 14:06:31 +0200 | [diff] [blame] | 347 | display_image(get_image_offset(PINTEXT), get_image_width(PINTEXT), get_image_height(PINTEXT), x, y); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | /** |
| 351 | * Clear digits instructions |
| 352 | */ |
| 353 | static void clear_digits_instructions() |
| 354 | { |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 355 | uint32_t y = (fb_config->height)*PIN_TEXT_RELATIVE_Y_LOCATION; |
| 356 | fbcon_clear_section(y, get_image_height(PINTEXT)); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | /** |
| 360 | * Display a digit as un-selected. |
| 361 | */ |
| 362 | static void display_digit(uint32_t x, uint32_t y, uint32_t digit) |
| 363 | { |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 364 | if (g_diplay_pin == false) |
| 365 | return; |
| 366 | |
| 367 | display_image(get_image_offset(PIN_UNSELECTED_0 + digit), |
| 368 | get_image_width(PIN_UNSELECTED_0 + digit), get_image_height(PIN_UNSELECTED_0 + digit), x, y); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | /** |
| 372 | * Display a digit as selected. |
| 373 | */ |
| 374 | static void display_selected_digit(uint32_t x, uint32_t y, uint32_t digit) |
| 375 | { |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 376 | if (g_diplay_pin == false) |
| 377 | return; |
| 378 | |
Reut Zysman | ff6bab9 | 2016-02-09 14:06:31 +0200 | [diff] [blame] | 379 | display_image(get_image_offset(PIN_SELECTED_0 + digit), |
| 380 | get_image_width(PIN_SELECTED_0 + digit), |
| 381 | get_image_height(PIN_SELECTED_0 + digit), x, y); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 382 | } |
| 383 | |
| 384 | /** |
| 385 | * Display OK button as un-selected. |
| 386 | */ |
| 387 | static void display_ok_button() |
| 388 | { |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 389 | uint32_t ok_x = CENTER_IMAGE_ON_X_AXIS(get_image_width(BTN_OK_OFF),fb_config->width); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 390 | uint32_t ok_y = (fb_config->height)*OK_BUTTON_RELATIVE_Y_LOCATION; |
| 391 | |
Reut Zysman | ff6bab9 | 2016-02-09 14:06:31 +0200 | [diff] [blame] | 392 | display_image(get_image_offset(BTN_OK_OFF), get_image_width(BTN_OK_OFF),get_image_height(BTN_OK_OFF), ok_x, ok_y); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 393 | } |
| 394 | |
| 395 | /** |
| 396 | * Display OK button as selected. |
| 397 | */ |
| 398 | static void display_selected_ok_button() |
| 399 | { |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 400 | uint32_t ok_x = CENTER_IMAGE_ON_X_AXIS(get_image_width(BTN_OK_ON),fb_config->width); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 401 | uint32_t ok_y = (fb_config->height)*OK_BUTTON_RELATIVE_Y_LOCATION; |
| 402 | |
Reut Zysman | ff6bab9 | 2016-02-09 14:06:31 +0200 | [diff] [blame] | 403 | display_image(get_image_offset(BTN_OK_ON), get_image_width(BTN_OK_ON), get_image_height(BTN_OK_ON), ok_x, ok_y); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 404 | } |
| 405 | |
Reut Zysman | ff6bab9 | 2016-02-09 14:06:31 +0200 | [diff] [blame] | 406 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 407 | /** |
| 408 | * Display the instructions for the OK button. |
| 409 | */ |
| 410 | static void display_pin_instructions() |
| 411 | { |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 412 | uint32_t x = CENTER_IMAGE_ON_X_AXIS(get_image_width(ACCEPTEDIT_TEXT),fb_config->width); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 413 | uint32_t y = (fb_config->height)*OK_TEXT_RELATIVE_Y_LOCATION; |
| 414 | |
Reut Zysman | ff6bab9 | 2016-02-09 14:06:31 +0200 | [diff] [blame] | 415 | display_image(get_image_offset(ACCEPTEDIT_TEXT), get_image_width(ACCEPTEDIT_TEXT), get_image_height(ACCEPTEDIT_TEXT), x, y); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | /** |
| 419 | * Clear the instructions for the OK button. |
| 420 | */ |
| 421 | static void clear_pin_message() |
| 422 | { |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 423 | uint32_t y = (fb_config->height)*OK_TEXT_RELATIVE_Y_LOCATION; |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 424 | |
Reut Zysman | ff6bab9 | 2016-02-09 14:06:31 +0200 | [diff] [blame] | 425 | fbcon_clear_section(y,get_image_height(ACCEPTEDIT_TEXT)); |
Reut Zysman | 33512bc | 2015-08-09 19:17:09 +0300 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | /** |
| 429 | * Initialize data structures required for MDTP UI. |
| 430 | */ |
| 431 | static void init_mdtp_ui_data() |
| 432 | { |
| 433 | fb_config = fbcon_display(); |
| 434 | alloc_mdtp_image(); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 435 | } |
| 436 | |
| 437 | /** |
| 438 | * Display the basic layout of the screen (done only once). |
| 439 | */ |
| 440 | static void display_initial_screen(uint32_t pin_length) |
| 441 | { |
Rami Butstein | faecf7f | 2015-06-04 16:39:30 +0300 | [diff] [blame] | 442 | if (g_initial_screen_displayed == true) |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 443 | return; |
| 444 | |
Reut Zysman | 33512bc | 2015-08-09 19:17:09 +0300 | [diff] [blame] | 445 | init_mdtp_ui_data(); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 446 | |
Rami Butstein | faecf7f | 2015-06-04 16:39:30 +0300 | [diff] [blame] | 447 | if (fb_config) |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 448 | { |
| 449 | fbcon_clear(); |
| 450 | |
| 451 | if (display_error_message()) |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 452 | display_error_msg(); /* This will never return */ |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 453 | display_initial_delay(); |
| 454 | |
| 455 | mdelay(INITIAL_DELAY_MSECONDS); |
| 456 | |
| 457 | g_pin_frames_y_location = ((fb_config->height)*PIN_RELATIVE_Y_LOCATION); |
| 458 | |
Reut Zysman | ff6bab9 | 2016-02-09 14:06:31 +0200 | [diff] [blame] | 459 | uint32_t total_pin_length = pin_length*get_image_width(PIN_UNSELECTED_0) + mdtp_fs_get_param(DIGIT_SPACE)*(pin_length - 1); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 460 | |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 461 | if (fb_config->width > total_pin_length) |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 462 | { |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 463 | g_diplay_pin = true; |
| 464 | |
| 465 | uint32_t complete_pin_centered = (fb_config->width - total_pin_length)/2; |
| 466 | |
| 467 | for (uint32_t i=0; i<pin_length; i++) |
| 468 | { |
| 469 | g_pin_frames_x_location[i] = complete_pin_centered + i*(mdtp_fs_get_param(DIGIT_SPACE) + get_image_width(PIN_UNSELECTED_0)); |
| 470 | } |
| 471 | |
| 472 | for (uint32_t i=0; i<pin_length; i++) |
| 473 | { |
| 474 | display_digit(g_pin_frames_x_location[i], g_pin_frames_y_location, 0); |
| 475 | } |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 476 | } |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 477 | else |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 478 | { |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 479 | dprintf(CRITICAL,"ERROR: screen is not wide enough, PIN digits can't be displayed\n"); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 480 | } |
| 481 | |
| 482 | display_ok_button(); |
| 483 | |
| 484 | g_initial_screen_displayed = true; |
| 485 | } |
| 486 | else |
| 487 | { |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 488 | dprintf(CRITICAL,"ERROR: fbcon_config struct is NULL\n"); |
| 489 | display_error_msg(); /* This will never return */ |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 490 | } |
| 491 | } |
| 492 | |
| 493 | /** |
| 494 | * Display the recovery PIN screen and set received buffer |
| 495 | * with the PIN the user has entered. |
| 496 | * The entered PIN will be validated by the calling function. |
| 497 | */ |
| 498 | static void display_get_pin_interface(char *entered_pin, uint32_t pin_length) |
| 499 | { |
| 500 | uint32_t previous_position = 0, current_position = 0; |
| 501 | |
| 502 | display_initial_screen(pin_length); |
| 503 | display_enter_pin(); |
| 504 | |
| 505 | // Convert ascii to digits |
| 506 | for (uint32_t i=0; i<pin_length; i++) |
| 507 | { |
| 508 | entered_pin[i] -= '0'; |
| 509 | } |
| 510 | display_selected_digit(g_pin_frames_x_location[0], g_pin_frames_y_location, entered_pin[0]); |
| 511 | display_digits_instructions(); |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 512 | |
| 513 | while (1) |
| 514 | { |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 515 | if (target_volume_up()) |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 516 | { |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 517 | // current position is the OK button |
| 518 | if (current_position == pin_length) |
| 519 | { |
| 520 | // Convert digits to ascii and |
| 521 | // validate entered PIN in the calling function |
| 522 | for (uint32_t i=0; i<pin_length; i++) |
| 523 | { |
| 524 | entered_pin[i] += '0'; |
| 525 | } |
| 526 | return; |
| 527 | } |
| 528 | |
| 529 | // current position is a PIN slot |
| 530 | entered_pin[current_position] = (entered_pin[current_position]+1) % 10; |
| 531 | display_selected_digit(g_pin_frames_x_location[current_position], g_pin_frames_y_location, entered_pin[current_position]); |
| 532 | mdelay(MDTP_PRESSING_DELAY_MSEC); |
| 533 | } |
| 534 | if (target_volume_down()) |
| 535 | { |
| 536 | previous_position = current_position; |
| 537 | current_position = (current_position+1) % (pin_length+1); |
| 538 | |
| 539 | // previous position was the OK button |
| 540 | if (previous_position == pin_length) |
| 541 | { |
| 542 | clear_pin_message(); |
| 543 | display_ok_button(); |
| 544 | |
| 545 | display_digits_instructions(); |
| 546 | display_selected_digit(g_pin_frames_x_location[current_position], g_pin_frames_y_location, entered_pin[current_position]); |
| 547 | |
| 548 | } |
| 549 | |
| 550 | // current position is the OK button |
| 551 | else if (current_position == pin_length) |
| 552 | { |
| 553 | display_digit(g_pin_frames_x_location[previous_position], g_pin_frames_y_location, entered_pin[previous_position]); |
| 554 | clear_digits_instructions(); |
| 555 | |
| 556 | display_selected_ok_button(); |
| 557 | display_pin_instructions(); |
| 558 | } |
| 559 | |
| 560 | // both the previous and the current positions are PIN slots |
| 561 | else |
| 562 | { |
| 563 | display_digit(g_pin_frames_x_location[previous_position], g_pin_frames_y_location, entered_pin[previous_position]); |
| 564 | |
| 565 | display_selected_digit(g_pin_frames_x_location[current_position], g_pin_frames_y_location, entered_pin[current_position]); |
| 566 | } |
| 567 | |
| 568 | mdelay(MDTP_PRESSING_DELAY_MSEC); |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 569 | } |
| 570 | } |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 571 | } |
| 572 | |
| 573 | /*---------------------------------------------------------------------------- |
| 574 | * External Functions |
| 575 | * -------------------------------------------------------------------------*/ |
| 576 | |
| 577 | /** |
| 578 | * Display the recovery PIN screen and set received buffer |
| 579 | * with the PIN the user has entered. |
| 580 | */ |
| 581 | void get_pin_from_user(char *entered_pin, uint32_t pin_length) |
| 582 | { |
| 583 | display_get_pin_interface(entered_pin, pin_length); |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 584 | |
| 585 | return; |
| 586 | } |
| 587 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 588 | /** |
| 589 | * User has entered invalid PIN, display error message and |
| 590 | * allow the user to try again. |
| 591 | */ |
| 592 | void display_invalid_pin_msg() |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 593 | { |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 594 | clear_pin_message(); |
| 595 | display_ok_button(); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 596 | |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 597 | display_invalid_pin(); |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 598 | |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 599 | mdelay(INVALID_PIN_DELAY_MSECONDS); |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 600 | } |
| 601 | |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 602 | /** |
| 603 | * Display error message and stop boot process. |
| 604 | */ |
| 605 | void display_error_msg() |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 606 | { |
Reut Zysman | 33512bc | 2015-08-09 19:17:09 +0300 | [diff] [blame] | 607 | init_mdtp_ui_data(); |
Amit Blay | 8e2731c | 2015-04-28 21:54:55 +0300 | [diff] [blame] | 608 | |
| 609 | if (fb_config) |
| 610 | { |
| 611 | fbcon_clear(); |
| 612 | display_error_message(); // No point in checking the return value here |
| 613 | } |
Reut Zysman | 1841127 | 2015-02-09 13:47:27 +0200 | [diff] [blame] | 614 | |
| 615 | // Invalid state. Nothing to be done but contacting the OEM. |
| 616 | // Stop boot process. |
| 617 | dprintf(CRITICAL,"ERROR: blocking boot process\n"); |
Amit Blay | 8e2731c | 2015-04-28 21:54:55 +0300 | [diff] [blame] | 618 | for(;;); |
Amit Blay | 6281ebc | 2015-01-11 14:44:08 +0200 | [diff] [blame] | 619 | } |
| 620 | |
Reut Zysman | ff6bab9 | 2016-02-09 14:06:31 +0200 | [diff] [blame] | 621 | /** |
| 622 | * Display error message in case mdtp image is corrupted and stop boot process. |
| 623 | */ |
| 624 | void display_error_msg_mdtp() |
| 625 | { |
| 626 | int big_factor = 8; // Font size |
| 627 | char* str = "Device unable to boot"; |
| 628 | char* str2 = "\nError - mdtp image is corrupted\n"; |
| 629 | fbcon_clear(); |
| 630 | while(*str != 0) { |
| 631 | fbcon_putc_factor(*str++, FBCON_COMMON_MSG, big_factor); |
| 632 | } |
| 633 | fbcon_draw_line(FBCON_COMMON_MSG); |
| 634 | while(*str2 != 0) { |
| 635 | fbcon_putc_factor(*str2++, FBCON_COMMON_MSG, big_factor); |
| 636 | } |
| 637 | fbcon_draw_line(FBCON_COMMON_MSG); |
| 638 | |
| 639 | // Invalid state. Nothing to be done but contacting the OEM. |
| 640 | // Stop boot process. |
| 641 | dprintf(CRITICAL,"ERROR: blocking boot process - mdtp image corrupted\n"); |
| 642 | for(;;); |
| 643 | |
| 644 | } |
| 645 | |