Reut Zysman | ff6bab9 | 2016-02-09 14:06:31 +0200 | [diff] [blame] | 1 | /* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved. |
| 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 | #ifndef MDTP_FS_H |
| 30 | #define MDTP_FS_H |
| 31 | |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 32 | #define MAX_IMAGES (40) |
| 33 | #define MDTP_HEADER_LEN (4096) |
| 34 | #define META_DATA_PARTITION_LEN (2048) |
| 35 | #define MAX_PARAMS (512) |
| 36 | #define MDTP_PARAM_UNSET_VALUE (111) |
| 37 | #define SUPPORTED_METADATA_VERSION (1) |
| 38 | |
Reut Zysman | ff6bab9 | 2016-02-09 14:06:31 +0200 | [diff] [blame] | 39 | /* |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 40 | MDTP image layout: |
| 41 | -The mdtp image file contains two layers that both include mdtp_img headers: |
| 42 | 1. The first header includes the image sets metadata. |
| 43 | 2. Once we decided which image set we would like to display, we read the metadata |
| 44 | of that specific image set (contains metadata of the actual images). |
Reut Zysman | ff6bab9 | 2016-02-09 14:06:31 +0200 | [diff] [blame] | 45 | -The mdtp_img header is a fixed length of 4096 Bytes. |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 46 | -The mdtp_img header is divided into 2 partitions: |
Reut Zysman | ff6bab9 | 2016-02-09 14:06:31 +0200 | [diff] [blame] | 47 | 1.MDTP parameters (eFuse, digit-space, etc..) |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 48 | 2.Images/image sets meta-data (offset, width, height) |
Reut Zysman | ff6bab9 | 2016-02-09 14:06:31 +0200 | [diff] [blame] | 49 | -Each partition size is 2048 Bytes. |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 50 | -Each parameter is 4 Bytes long, 512 params max. |
| 51 | -Each meta-data parameter (offset/width/height) is 4 Bytes long. |
Reut Zysman | ff6bab9 | 2016-02-09 14:06:31 +0200 | [diff] [blame] | 52 | */ |
| 53 | |
| 54 | |
| 55 | /* Standalone parameters */ |
| 56 | typedef struct mdtp_image_params { |
| 57 | uint32_t offset; |
| 58 | uint32_t width; |
| 59 | uint32_t height; |
| 60 | } mdtp_image_params_t; |
| 61 | |
| 62 | /* Image parameters */ |
| 63 | typedef struct mdtp_meta_data { |
| 64 | uint32_t params[MAX_PARAMS]; |
| 65 | mdtp_image_params_t image_params[MAX_IMAGES]; |
| 66 | } mdtp_meta_data_t; |
| 67 | |
| 68 | /*To make sure the header len is exactly MDTP_HEADER */ |
| 69 | typedef union mdtp_image { |
| 70 | mdtp_meta_data_t meta_data; |
| 71 | uint8_t header[MDTP_HEADER_LEN]; |
| 72 | } mdtp_image_t; |
| 73 | |
| 74 | |
| 75 | typedef enum{ACCEPTEDIT_TEXT = 0, ALERT_MESSAGE = 1, BTN_OK_OFF = 2, |
| 76 | BTN_OK_ON = 3, MAINTEXT_5SECONDS = 4, MAINTEXT_ENTERPIN = 5, |
| 77 | MAINTEXT_INCORRECTPIN = 6, PINTEXT = 7, |
| 78 | PIN_SELECTED_0 = 8, PIN_SELECTED_1 = 9, PIN_SELECTED_2 = 10, PIN_SELECTED_3 = 11, |
| 79 | PIN_SELECTED_4 = 12, PIN_SELECTED_5 = 13, PIN_SELECTED_6 = 14, |
| 80 | PIN_SELECTED_7 = 15, PIN_SELECTED_8 = 16, PIN_SELECTED_9 = 17, |
| 81 | PIN_UNSELECTED_0 = 18, PIN_UNSELECTED_1 = 19, PIN_UNSELECTED_2 = 20, |
| 82 | PIN_UNSELECTED_3 = 21, PIN_UNSELECTED_4 = 22, PIN_UNSELECTED_5 = 23, |
| 83 | PIN_UNSELECTED_6 = 24, PIN_UNSELECTED_7 = 25, |
| 84 | PIN_UNSELECTED_8 = 26, PIN_UNSELECTED_9 = 27} mdtp_image_id_t; |
| 85 | |
Reut Zysman | 3f3eccd | 2016-04-20 22:05:36 +0300 | [diff] [blame] | 86 | typedef enum {VIRTUAL_FUSE = 0, DIGIT_SPACE = 1, VERSION = 2, TYPE = 3, IMAGE_SETS_NUM = 4} mdtp_parameter_id_t; |
| 87 | |
| 88 | typedef enum {IMAGES = 1, IMAGE_SETS = 2} mdtp_metadata_type_t; |
Reut Zysman | ff6bab9 | 2016-02-09 14:06:31 +0200 | [diff] [blame] | 89 | |
| 90 | /*--------------------------------------------------------- |
| 91 | * External Functions |
| 92 | *-------------------------------------------------------*/ |
| 93 | |
| 94 | /** |
| 95 | * Returns an image offset |
| 96 | */ |
| 97 | uint32_t get_image_offset(mdtp_image_id_t img); |
| 98 | |
| 99 | /** |
| 100 | * Returns an image width |
| 101 | */ |
| 102 | uint32_t get_image_width(mdtp_image_id_t img); |
| 103 | |
| 104 | /** |
| 105 | * Returns an image height |
| 106 | */ |
| 107 | uint32_t get_image_height(mdtp_image_id_t img); |
| 108 | |
| 109 | /** |
| 110 | * returns a parameter value |
| 111 | */ |
| 112 | uint32_t mdtp_fs_get_param(mdtp_parameter_id_t param); |
| 113 | |
| 114 | /** |
| 115 | * Loads MDTP image meta data from EMMC |
| 116 | */ |
| 117 | int mdtp_fs_init(); |
| 118 | |
| 119 | #endif /* MDTP_FS_H */ |