yu.dong | c33b307 | 2024-08-21 23:14:49 -0700 | [diff] [blame^] | 1 | #!/usr/bin/perl |
| 2 | # |
| 3 | # Copyright Statement: |
| 4 | # -------------------- |
| 5 | # This software is protected by Copyright and the information contained |
| 6 | # herein is confidential. The software may not be copied and the information |
| 7 | # contained herein may not be used or disclosed except with the written |
| 8 | # permission of MediaTek Inc. (C) 2006 |
| 9 | # |
| 10 | # BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 11 | # THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") |
| 12 | # RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON |
| 13 | # AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, |
| 14 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF |
| 15 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. |
| 16 | # NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE |
| 17 | # SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR |
| 18 | # SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH |
| 19 | # THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO |
| 20 | # NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S |
| 21 | # SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. |
| 22 | # |
| 23 | # BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE |
| 24 | # LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, |
| 25 | # AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, |
| 26 | # OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO |
| 27 | # MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. |
| 28 | # |
| 29 | # THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE |
| 30 | # WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF |
| 31 | # LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND |
| 32 | # RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER |
| 33 | # THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC). |
| 34 | # |
| 35 | #***************************************************************************** |
| 36 | #* |
| 37 | #* Filename: |
| 38 | #* --------- |
| 39 | #* copro_info_gen.pl |
| 40 | #* |
| 41 | #* Project: |
| 42 | #* -------- |
| 43 | #* |
| 44 | #* |
| 45 | #* Description: |
| 46 | #* ------------ |
| 47 | #* This script is used to parse copro information |
| 48 | #* |
| 49 | #* |
| 50 | #* Author: |
| 51 | #* ------- |
| 52 | #* Carl Kao (mtk08237) |
| 53 | #* |
| 54 | #*------------------------------------------------------------------------------ |
| 55 | #* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 56 | #*============================================================================ |
| 57 | #****************************************************************************/ |
| 58 | #**************************************************************************** |
| 59 | # Included Modules |
| 60 | #**************************************************************************** |
| 61 | use strict; |
| 62 | BEGIN { push @INC , './tools/', './tools/MemoryUtility/' } # add additional library path |
| 63 | use CommonUtility; |
| 64 | use BasicMemInfoQuery; |
| 65 | use FileInfoParser; |
| 66 | use POSIX qw(floor ceil); |
| 67 | |
| 68 | #use L1coreInfo; |
| 69 | |
| 70 | #**************************************************************************** |
| 71 | # Constants |
| 72 | #**************************************************************************** |
| 73 | my $COPRO_INFO_VERNO = " v0.29"; |
| 74 | # v0.29 , 2016/08/01, Tero, Copro generation disabled |
| 75 | # v0.28 , 2015/06/23, Carl, Refine GetSharedMemorySize. It includes dsp tx/rx section now |
| 76 | # v0.27 , 2015/06/22, Carl, Change default l1core ROM, RAM size |
| 77 | # v0.26 , 2015/05/11, Carl, Correct output log |
| 78 | # v0.25 , 2015/04/15, Carl, Refine setting for (MCU RO, MDHW RW) DNC+NC, (MCU RW, MDHW RW) DNC+NC |
| 79 | # v0.24, 2015/04/09, Carl, Align the shared DNC base to 64KB for input section MCU-RO, HW-RW (EMI RMPU) |
| 80 | # v0.23 , 2015/03/27, Carl, set default value of L1CORE_DSP_TX_LENGTH, L1CORE_DSP_RX_LENGTH to 0 |
| 81 | # v0.22 , 2015/03/19, Carl, add L1CORE_DSP_TX_LENGTH, L1CORE_DSP_RX_LENGTH for dsp sections |
| 82 | # v0.21 , 2015/03/11, Carl, Increase default l1core ROM size to 16MB |
| 83 | # v0.20 , 2015/03/04, Carl, Increase default l1core RAM size to 48MB |
| 84 | # v0.19 , 2015/01/14, Carl, Memory Utility Refinement |
| 85 | # v0.18 , 2015/01/06, Carl, lds refinement: 1) auto adjust shared region size, 2) reserve pcore, l1core SWLA space |
| 86 | # v0.17 , 2014/12/22, Carl, Support L2SRAM section (in L1CORE) |
| 87 | # v0.16 , 2014/10/29, Carl, Increase l1core default size |
| 88 | # v0.15 , 2014/10/06, Carl, Reserve sig space for L1CORE_LV |
| 89 | # v0.14 , 2014/09/26, Carl, Support GFH + SIG (reserve space for L1CORE_RWZI) |
| 90 | # v0.13 , 2014/09/26, Carl, Support GFH + SIG (reserve space for L1CORE_LV) |
| 91 | # v0.12 , 2014/09/26, Carl, Support GFH + SIG |
| 92 | # v0.11 , 2014/09/11, Carl, Increase pcore ROM size for pcore only load |
| 93 | # v0.10 , 2014/09/11, mei, support memory dump |
| 94 | # v0.09 , 2014/09/05, Carl, reduce default shared memory size for PCORE ONLY project |
| 95 | # v0.08 , 2014/08/20, Carl, refine l1core dump region |
| 96 | # v0.07 , 2014/08/19, Carl, add l1core reset vector address |
| 97 | # v0.06 , 2014/07/31, Carl, add l1core dump region |
| 98 | # v0.05 , 2014/07/14, Carl, update the lasst section in l1ocre |
| 99 | # v0.04 , 2014/05/08, Carl, enlarge default size for build |
| 100 | # v0.03 , 2014/05/07, Carl, 2-phase linking |
| 101 | # v0.02 , 2014/03/31, Carl, Support to generate L1CORE input (reference:TK6280 pcore\tools\copro_info_gen.pl) |
| 102 | # v0.01 , 2014/03/03, BM, Initial revision |
| 103 | |
| 104 | my $debug_flag = "0"; |
| 105 | #**************************************************************************** |
| 106 | # Input |
| 107 | #**************************************************************************** |
| 108 | my $FORCE_GEN = $ARGV[0]; |
| 109 | my $COPRO_INFO_TEMP = $ARGV[1]; |
| 110 | my $COPRO_INFO_OUTPUT = $ARGV[1]; |
| 111 | my $themf = $ARGV[2]; |
| 112 | my $INFOMAKELOG = $ARGV[3]; |
| 113 | my $SINGLE_CORE = $ARGV[4]; |
| 114 | |
| 115 | |
| 116 | print "copro_info_gen input:\n$ARGV[0]\n$ARGV[1]\n$ARGV[2]\n$ARGV[3]\n$ARGV[4]\n\n"; |
| 117 | |
| 118 | #**************************************************************************** |
| 119 | # Global Variables |
| 120 | #**************************************************************************** |
| 121 | my $g_bFORCE = ($FORCE_GEN eq "TRUE") ? 1 : 0; |
| 122 | $g_bFORCE = ($debug_flag eq "1") ? 1 : $g_bFORCE; |
| 123 | my %g_COPRO_INFO; |
| 124 | my %g_MKFILE; |
| 125 | my %g_CmplOpt; |
| 126 | my %g_RelInfo; |
| 127 | my %g_PathInfo; |
| 128 | exit 0; |
| 129 | #**************************************************************************** |
| 130 | # >>> Main Flow |
| 131 | #**************************************************************************** |
| 132 | FileInfo::PreProcess($themf, \%g_MKFILE, $INFOMAKELOG, \%g_CmplOpt, \%g_RelInfo,1); |
| 133 | SetPathInfo($COPRO_INFO_TEMP, \%g_PathInfo); |
| 134 | |
| 135 | SetDefaultValue(\%g_COPRO_INFO); |
| 136 | |
| 137 | map {print "$_ => ".$g_COPRO_INFO{$_}. "(".CommonUtil::Dec2Hex($g_COPRO_INFO{$_}).")"."\n"; } sort keys %g_COPRO_INFO; |
| 138 | gen_COPRO_INFO_LOG(\%g_COPRO_INFO, $COPRO_INFO_OUTPUT); |
| 139 | |
| 140 | exit 0; |
| 141 | #**************************************************************************** |
| 142 | # Subroutines |
| 143 | #**************************************************************************** |
| 144 | sub NeedToGen |
| 145 | { |
| 146 | my ($bFORCE, $MAKE_FILE)=@_; |
| 147 | my $bNeed = 0; # no need to generate |
| 148 | print "[NeedToGen] FORCE=$bFORCE, SINGLE_CORE=". $SINGLE_CORE ." debug_flag=". $debug_flag ."\n"; |
| 149 | if( ($bFORCE and $SINGLE_CORE eq "FALSE" )or (($debug_flag eq "1") ? 1 : 0)) |
| 150 | { |
| 151 | #die for BasicMemInfo |
| 152 | coproinfo_die("$MAKE_FILE doesn't exist!\n") if(!-e $MAKE_FILE); |
| 153 | $bNeed = 1; |
| 154 | } |
| 155 | print $bNeed ? "=> Generate tmp file contents\n" : "=> NO NEED to generate tmp file contents\n"; |
| 156 | return $bNeed; |
| 157 | } |
| 158 | |
| 159 | sub SetPathInfo |
| 160 | { |
| 161 | my ($strInfoPath, $PathInfo_href) = @_; |
| 162 | my $strContent = CommonUtil::GetFileContent($strInfoPath); |
| 163 | print "Path Info:\n$strContent\n"; |
| 164 | CommonUtil::HashStringParser($strContent, $PathInfo_href); |
| 165 | } |
| 166 | sub GetPath |
| 167 | { |
| 168 | my ($strKeyword) = @_; #keyword is defined in codegen.mak's copro_info_gen |
| 169 | return $g_PathInfo{$strKeyword}; |
| 170 | } |
| 171 | sub gen_COPRO_INFO_LOG |
| 172 | { |
| 173 | my ($COPRO_INFO_href, $OUTPUT_PATH) = @_; |
| 174 | my $strCOPRO_INFO = CommonUtil::HashStringGenerator($COPRO_INFO_href); |
| 175 | CommonUtil::WriteFileContent($OUTPUT_PATH, $strCOPRO_INFO, 0); |
| 176 | } |
| 177 | |
| 178 | |
| 179 | ##################### |
| 180 | # FIX_ME, copro |
| 181 | ##################### |
| 182 | sub wait_for_reuse |
| 183 | #sub get_COPRO_INFO |
| 184 | { |
| 185 | coproinfo_die("not suppoet ARM7 !\n"); |
| 186 | |
| 187 | my ($MAKE_FILE, $IMAGELAYOUT, $MAP_PATH, $SYM_PATH, $COPRO_INFO_href) = @_; |
| 188 | print "Set COPRO INFO:\n"; |
| 189 | print "--------------------------------------------------------------\n"; |
| 190 | # my $nLoadViewSize = BasicMemInfo::CMD_GetLoadViewSize($MAKE_FILE, $IMAGELAYOUT, $MAP_PATH, $SYM_PATH, undef); |
| 191 | # $COPRO_INFO_href->{FileInfo::COPRO_LV_SIZE} = $nLoadViewSize; |
| 192 | # my $nTotalRamUsage = BasicMemInfo::CMD_GetPhysicalRAMUsage($MAKE_FILE, $IMAGELAYOUT, $MAP_PATH, $SYM_PATH, undef); |
| 193 | # $COPRO_INFO_href->{FileInfo::COPRO_TOTAL_USAGE} = $nTotalRamUsage; |
| 194 | } |
| 195 | |
| 196 | sub SetDefaultValue |
| 197 | { |
| 198 | my ($COPRO_INFO_href) = @_; |
| 199 | print "Set Default Value:\n"; |
| 200 | print "--------------------------------------------------------------\n"; |
| 201 | |
| 202 | $COPRO_INFO_href->{FileInfo::PCORE_LV_SIZE} = 0xE00000; # 14MB |
| 203 | |
| 204 | if ( &FileInfo::find("SINGLE_CORE_ONLY", "PCORE") ) |
| 205 | { |
| 206 | $COPRO_INFO_href->{FileInfo::PCORE_LV_SIZE} = 0x700000; |
| 207 | |
| 208 | } |
| 209 | else |
| 210 | { |
| 211 | $COPRO_INFO_href->{FileInfo::PCORE_LV_SIZE} = 0xE00000; # 14MB |
| 212 | } |
| 213 | |
| 214 | $COPRO_INFO_href->{FileInfo::SHARED_REGION_SIZE} = 0x0; # set it to zero for l1core to auto adjust size. watch out if you want to change it to non-zero value |
| 215 | |
| 216 | } |
| 217 | |
| 218 | sub coproinfo_die |
| 219 | { |
| 220 | my ($error_msg, $file, $line_no) = @_; |
| 221 | my $pack_name = undef; |
| 222 | if(!defined $file or !defined $line_no) |
| 223 | { |
| 224 | ($pack_name, $file, $line_no) = caller; |
| 225 | } |
| 226 | &CommonUtil::error_handler($error_msg, $file, $line_no, 'COPRO_INFO_GEN'); |
| 227 | } |