rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | /* Copyright Statement: |
| 2 | * |
| 3 | * This software/firmware and related documentation ("MediaTek Software") are |
| 4 | * protected under relevant copyright laws. The information contained herein is |
| 5 | * confidential and proprietary to MediaTek Inc. and/or its licensors. Without |
| 6 | * the prior written permission of MediaTek inc. and/or its licensors, any |
| 7 | * reproduction, modification, use or disclosure of MediaTek Software, and |
| 8 | * information contained herein, in whole or in part, shall be strictly |
| 9 | * prohibited. |
| 10 | * |
| 11 | * MediaTek Inc. (C) 2016. All rights reserved. |
| 12 | * |
| 13 | * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 14 | * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 15 | * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER |
| 16 | * ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL |
| 17 | * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED |
| 18 | * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR |
| 19 | * NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH |
| 20 | * RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, |
| 21 | * INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES |
| 22 | * TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. |
| 23 | * RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO |
| 24 | * OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK |
| 25 | * SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE |
| 26 | * RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR |
| 27 | * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S |
| 28 | * ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE |
| 29 | * RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE |
| 30 | * MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE |
| 31 | * CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 32 | * |
| 33 | * The following software/firmware and/or related documentation ("MediaTek |
| 34 | * Software") have been modified by MediaTek Inc. All revisions are subject to |
| 35 | * any receiver's applicable license agreements with MediaTek Inc. |
| 36 | */ |
| 37 | |
| 38 | #ifndef DRAM_BUFFER_H |
| 39 | #define DRAM_BUFFER_H |
| 40 | |
| 41 | #include "partition.h" |
| 42 | |
| 43 | #define BMT_BUFFER_SIZE 0x10000 |
| 44 | #define PART_HDR_BUF_SIZE 512 |
| 45 | #define GPT_BUFFER_SIZE (0x4000) |
| 46 | #define STORAGE_BUFFER_SIZE 0x10000 |
| 47 | #define IMG_HDR_BUF_SIZE 512 |
| 48 | #define LOG_BUFFER_MAX_SIZE (0x10000) |
| 49 | #define DRAM_SEC_SECRO_BUFFER_LENGTH (0x3000) |
| 50 | #define DRAM_SEC_WORKING_BUFFER_LENGTH 0x2000 |
| 51 | #define DRAM_SEC_UTIL_BUFFER_LENGTH 0x1000 |
| 52 | #define DRAM_SEC_LIB_HEAP_LENGTH 0x4000 |
| 53 | #define DRAM_SEC_IMG_BUFFER_LENGTH 0x3000 |
| 54 | #define DRAM_SEC_CHUNK_BUFFER_LENGTH 0x100000 |
| 55 | #define CFG_DRAM_ADDR (0x00240000) |
| 56 | #define MAX_MAIN_SIZE (0x1000) |
| 57 | #define MAX_SPAR_SIZE (0x80) |
| 58 | #define BMT_DAT_BUFFER_SIZE (MAX_MAIN_SIZE + MAX_SPAR_SIZE) |
| 59 | #define PMT_DAT_BUFFER_SIZE (MAX_MAIN_SIZE + MAX_SPAR_SIZE) |
| 60 | #define PMT_READ_BUFFER_SIZE (MAX_MAIN_SIZE) |
| 61 | #define NAND_NFI_BUFFER_SIZE 0x1000 |
| 62 | #define PART_MAX_NUM 20 |
| 63 | |
| 64 | #if CFG_BYPASS_EMI |
| 65 | typedef struct { |
| 66 | u8 bmt_buf[0x1000]; |
| 67 | u8 bmt_dat_buf[BMT_DAT_BUFFER_SIZE]; |
| 68 | u8 nand_nfi_buf[0x1000]; |
| 69 | part_hdr_t part_hdr_buf[1]; |
| 70 | u32 crc32_table[256]; |
| 71 | u8 pgpt_header_buf[512]; |
| 72 | u8 sgpt_header_buf[512]; |
| 73 | u8 pgpt_entries_buf[GPT_BUFFER_SIZE]; |
| 74 | u8 sgpt_entries_buf[GPT_BUFFER_SIZE]; |
| 75 | unsigned char storage_buffer[16]; |
| 76 | u8 img_hdr_buf[IMG_HDR_BUF_SIZE]; |
| 77 | unsigned int part_num; |
| 78 | part_hdr_t part_info[2]; |
| 79 | part_t partition_info[2]; |
| 80 | #ifdef MTK_EMMC_SUPPORT |
| 81 | struct part_meta_info meta_info[1]; |
| 82 | #endif |
| 83 | u32 bootarg; |
| 84 | u8 log_dram_buf[0x1000]; |
| 85 | u8 sec_secro_buf[DRAM_SEC_SECRO_BUFFER_LENGTH]; |
| 86 | u8 sec_working_buf[DRAM_SEC_WORKING_BUFFER_LENGTH];/*This dram Buffer not used for security concern*/ |
| 87 | u8 sec_util_buf[DRAM_SEC_UTIL_BUFFER_LENGTH]; |
| 88 | u8 sec_lib_heap_buf[DRAM_SEC_LIB_HEAP_LENGTH]; |
| 89 | u8 sec_img_buf[DRAM_SEC_IMG_BUFFER_LENGTH]; /*This dram Buffer not used for security concern*/ |
| 90 | u8 sec_chunk_buf[0x4000]; |
| 91 | u32 *boottag; |
| 92 | } dram_buf_t; |
| 93 | #else |
| 94 | typedef struct { |
| 95 | /*bmt.c*/ |
| 96 | u8 bmt_buf[BMT_BUFFER_SIZE]; |
| 97 | u8 bmt_dat_buf[BMT_DAT_BUFFER_SIZE]; |
| 98 | /*nand.c*/ |
| 99 | u8 nand_nfi_buf[NAND_NFI_BUFFER_SIZE]; |
| 100 | |
| 101 | /*download.c*/ |
| 102 | part_hdr_t part_hdr_buf[PART_HDR_BUF_SIZE]; |
| 103 | /*efi.c*/ |
| 104 | u32 crc32_table[256]; |
| 105 | u8 pgpt_header_buf[512]; |
| 106 | u8 sgpt_header_buf[512]; |
| 107 | u8 pgpt_entries_buf[GPT_BUFFER_SIZE]; |
| 108 | u8 sgpt_entries_buf[GPT_BUFFER_SIZE]; |
| 109 | /*mmc_common_inter.c*/ |
| 110 | unsigned char storage_buffer[STORAGE_BUFFER_SIZE]; |
| 111 | /*partition.c*/ |
| 112 | u8 img_hdr_buf[IMG_HDR_BUF_SIZE]; |
| 113 | unsigned int part_num; |
| 114 | part_hdr_t part_info[PART_MAX_NUM]; |
| 115 | part_t partition_info[128]; |
| 116 | |
| 117 | #ifdef MTK_EMMC_SUPPORT |
| 118 | struct part_meta_info meta_info[128]; |
| 119 | #endif |
| 120 | u32 bootarg; |
| 121 | u8 log_dram_buf[LOG_BUFFER_MAX_SIZE]; |
| 122 | u8 sec_secro_buf[DRAM_SEC_SECRO_BUFFER_LENGTH]; |
| 123 | u8 sec_working_buf[DRAM_SEC_WORKING_BUFFER_LENGTH];/*This dram Buffer not used for security concern*/ |
| 124 | u8 sec_util_buf[DRAM_SEC_UTIL_BUFFER_LENGTH]; |
| 125 | u8 sec_lib_heap_buf[DRAM_SEC_LIB_HEAP_LENGTH]; |
| 126 | u8 sec_img_buf[DRAM_SEC_IMG_BUFFER_LENGTH]; /*This dram Buffer not used for security concern*/ |
| 127 | u8 sec_chunk_buf[DRAM_SEC_CHUNK_BUFFER_LENGTH]; |
| 128 | u32 *boottag; |
| 129 | } dram_buf_t; |
| 130 | #endif |
| 131 | |
| 132 | typedef struct { |
| 133 | u8 sram_sec_working_buf[DRAM_SEC_WORKING_BUFFER_LENGTH]; |
| 134 | u8 sram_sec_img_buf[DRAM_SEC_IMG_BUFFER_LENGTH]; |
| 135 | } sec_buf_t; |
| 136 | |
| 137 | void init_dram_buffer(); |
| 138 | u64 platform_memory_size(void); |
| 139 | dram_buf_t *g_dram_buf; |
| 140 | sec_buf_t g_sec_buf; |
| 141 | |
| 142 | #endif /*DRAM_BUFFER_H*/ |