rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [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 | #* check_modid.pl |
| 40 | #* |
| 41 | #* Project: |
| 42 | #* -------- |
| 43 | #* |
| 44 | #* |
| 45 | #* Description: |
| 46 | #* ------------ |
| 47 | #* This script is used to compare pcore/l1core module id |
| 48 | #* |
| 49 | #* |
| 50 | #* Author: |
| 51 | #* ------- |
| 52 | #* Carl Kao (mtk08237) |
| 53 | #* |
| 54 | #****************************************************************************/ |
| 55 | use strict; |
| 56 | use List::Util qw[min max]; |
| 57 | use Data::Dumper; |
| 58 | |
| 59 | ############################################ |
| 60 | ######### configurable variable ########### |
| 61 | ############################################ |
| 62 | |
| 63 | my $skip_pattern = "MOD_REQ_QUEUE|\_empty\_string|\_\_end"; |
| 64 | |
| 65 | my $need_debug=1; |
| 66 | #undef $need_debug; |
| 67 | |
| 68 | ############################################ |
| 69 | ############################################ |
| 70 | ############################################ |
| 71 | |
| 72 | |
| 73 | #**************************************************************************** |
| 74 | # Constants |
| 75 | #**************************************************************************** |
| 76 | my $CHECK_MODID_VERNO = " u0.04"; |
| 77 | # u0.04, 2014/12/05, Carl, add skip pattern "_empty_string" and "__end" and skip modid with value |
| 78 | # u0.03, 2014/10/15, Carl, exit 0 if no pcore/l1core enum file to avoid false alarm in bm_new |
| 79 | # u0.02, 2014/09/16, Carl, add skip pattern "MOD_REQ_QUEUE" |
| 80 | # u0.01, 2014/05/22, Carl, Init version, merge from U3G_TK6280_DEV |
| 81 | |
| 82 | my $pcore_enum_file = shift; |
| 83 | my $l1dsp_enum_file = shift; |
| 84 | my $output_file = shift; |
| 85 | |
| 86 | my %pcore_enum_id_to_name_hash; |
| 87 | my %pcore_enum_name_to_id_hash; |
| 88 | my %l1dsp_enum_id_to_name_hash; |
| 89 | my %l1dsp_enum_name_to_id_hash; |
| 90 | |
| 91 | my $max_pcore_enum_id=0; |
| 92 | my $min_pcore_enum_id=5000; |
| 93 | my $max_l1dsp_enum_id=0; |
| 94 | my $min_l1dsp_enum_id=5000; |
| 95 | |
| 96 | use constant MAX_ENUM => 8192; |
| 97 | |
| 98 | my $is_mod_id_sync=1; |
| 99 | |
| 100 | |
| 101 | $pcore_enum_file or die "Usage: $0 <pcore enum file> <l1dsp enum file> <output file>"; |
| 102 | $l1dsp_enum_file or die "Usage: $0 <pcore enum file> <l1dsp enum file> <output file>"; |
| 103 | $output_file or die "Usage: $0 <pcore enum file> <l1dsp enum file> <output file>"; |
| 104 | |
| 105 | if(!-e $pcore_enum_file) |
| 106 | { |
| 107 | print "pcore enumFile $pcore_enum_file dose not existed, please check build result.\n"; |
| 108 | exit 0; |
| 109 | } |
| 110 | if(!-e $l1dsp_enum_file) |
| 111 | { |
| 112 | print "l1core enumfile $l1dsp_enum_file dose not existed, please check build result.\n"; |
| 113 | exit 0; |
| 114 | } |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | open (OU, ">$output_file"); |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | open (PCORE_ENUM, "<$pcore_enum_file" || die "cannot open $pcore_enum_file"); |
| 125 | |
| 126 | while(my $line=<PCORE_ENUM>) |
| 127 | { |
| 128 | if ($line =~ m/^(MOD_\w+)\s+(\d+)/) |
| 129 | { |
| 130 | #&debug_print("$1 $2\n"); |
| 131 | |
| 132 | my $strModName = $1; |
| 133 | my $nModValue = $2; |
| 134 | |
| 135 | next if ($strModName =~ /$skip_pattern/); |
| 136 | next if ($nModValue > MAX_ENUM); |
| 137 | |
| 138 | $pcore_enum_name_to_id_hash {$strModName} = $nModValue; |
| 139 | $pcore_enum_id_to_name_hash {$nModValue} = $strModName; |
| 140 | $max_pcore_enum_id = &max($max_pcore_enum_id,$nModValue); |
| 141 | $min_pcore_enum_id = &min($min_pcore_enum_id,$nModValue); |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | |
| 146 | open (L1DSP_ENUM, "<$l1dsp_enum_file" || die "cannot open $l1dsp_enum_file"); |
| 147 | |
| 148 | while(my $line=<L1DSP_ENUM>) |
| 149 | { |
| 150 | if ($line =~ m/^(MOD_\w+)\s+(\d+)/) |
| 151 | { |
| 152 | #&debug_print("$1 $2\n"); |
| 153 | |
| 154 | my $strModName = $1; |
| 155 | my $nModValue = $2; |
| 156 | |
| 157 | next if ($strModName =~ /$skip_pattern/); |
| 158 | next if ($nModValue > MAX_ENUM); |
| 159 | |
| 160 | $l1dsp_enum_name_to_id_hash {$strModName} = $nModValue; |
| 161 | $l1dsp_enum_id_to_name_hash {$nModValue} = $strModName; |
| 162 | $max_l1dsp_enum_id = &max($max_l1dsp_enum_id,$nModValue); |
| 163 | $min_l1dsp_enum_id = &min($min_l1dsp_enum_id,$nModValue); |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | my $tmp_str = "id module id for pcore"; |
| 168 | output_print($tmp_str." " x (57-length($tmp_str))); |
| 169 | $tmp_str = "module id for l1dsp\n"; |
| 170 | output_print($tmp_str); |
| 171 | $tmp_str = "-" x 100; |
| 172 | $tmp_str .= "\n"; |
| 173 | output_print($tmp_str); |
| 174 | |
| 175 | my $pre_i = 0; |
| 176 | for(my $i=$min_pcore_enum_id; $i<=$max_l1dsp_enum_id; $i++) |
| 177 | { |
| 178 | next if ( !exists $pcore_enum_id_to_name_hash{$i} && |
| 179 | ! exists $l1dsp_enum_id_to_name_hash{$i} ); |
| 180 | |
| 181 | if($i-$pre_i>1){ |
| 182 | $tmp_str = "-" x 100; |
| 183 | $tmp_str .= "\n"; |
| 184 | output_print($tmp_str); |
| 185 | } |
| 186 | $pre_i = $i; |
| 187 | |
| 188 | if($i<10){ output_print($i." "); } |
| 189 | elsif($i<100){ output_print("$i "); } |
| 190 | elsif($i<1000){ output_print("$i "); } |
| 191 | else { output_print("$i "); } |
| 192 | |
| 193 | if(exists $pcore_enum_id_to_name_hash{$i}) |
| 194 | { |
| 195 | output_print($pcore_enum_id_to_name_hash{$i}); |
| 196 | output_print(" " x (50-length($pcore_enum_id_to_name_hash{$i}))); |
| 197 | } |
| 198 | else |
| 199 | { |
| 200 | output_print(" " x 50); |
| 201 | } |
| 202 | |
| 203 | if(exists $l1dsp_enum_id_to_name_hash{$i}) |
| 204 | { |
| 205 | output_print($l1dsp_enum_id_to_name_hash{$i}); |
| 206 | output_print(" " x (50-length($l1dsp_enum_id_to_name_hash{$i}))); |
| 207 | } |
| 208 | else |
| 209 | { |
| 210 | output_print(" " x 50); |
| 211 | } |
| 212 | |
| 213 | if( !exists $pcore_enum_id_to_name_hash{$i} && |
| 214 | $l1dsp_enum_id_to_name_hash{$i} =~ m/HISR/ ) |
| 215 | { |
| 216 | output_print( "\n"); |
| 217 | next; |
| 218 | } |
| 219 | |
| 220 | if( !exists $l1dsp_enum_id_to_name_hash{$i} && |
| 221 | $pcore_enum_id_to_name_hash{$i} =~ m/HISR/ ) |
| 222 | { |
| 223 | output_print("\n"); |
| 224 | next; |
| 225 | } |
| 226 | |
| 227 | if( $l1dsp_enum_id_to_name_hash{$i} =~ m/HISR/ && |
| 228 | $pcore_enum_id_to_name_hash{$i} =~ m/HISR/ ) |
| 229 | { |
| 230 | output_print("\n"); |
| 231 | next; |
| 232 | } |
| 233 | |
| 234 | if( $l1dsp_enum_id_to_name_hash{$i} =~ m/FOR_SYNC_MOD_ID/ || |
| 235 | $pcore_enum_id_to_name_hash{$i} =~ m/FOR_SYNC_MOD_ID/ ) |
| 236 | { |
| 237 | output_print("\n"); |
| 238 | next; |
| 239 | } |
| 240 | |
| 241 | if( $pcore_enum_id_to_name_hash{$i} ne $l1dsp_enum_id_to_name_hash{$i} ) |
| 242 | { |
| 243 | $is_mod_id_sync=0; |
| 244 | output_print("WARNING!!\n"); |
| 245 | next; |
| 246 | } |
| 247 | |
| 248 | output_print("\n"); |
| 249 | |
| 250 | } |
| 251 | |
| 252 | close OU; |
| 253 | |
| 254 | if(!$is_mod_id_sync) |
| 255 | { |
| 256 | print "Error: the module id of pcore/l1dsp are different\n"; |
| 257 | print "Error: please check $output_file to fix it\n"; |
| 258 | exit 1; |
| 259 | } |
| 260 | |
| 261 | exit 0; |
| 262 | |
| 263 | |
| 264 | |
| 265 | |
| 266 | sub debug_print |
| 267 | { |
| 268 | print @_ if defined $need_debug; |
| 269 | } |
| 270 | |
| 271 | sub output_print |
| 272 | { |
| 273 | print OU @_; |
| 274 | } |
| 275 | |
| 276 | |